# LINEST Function

> Calculate the slope and intercept of the best-fitting straight line with LINEST in TX Sheet Control: const, stats, regression statistics and spilled arrays.

- **Product:** TX Sheet Control
- **Section:** Documentation
- **Kind:** Function
- **Path:** TX Sheet Control > API Reference > Formula Functions > LINEST Function
- **245 words**
- **Web URL:** https://docs.textcontrol.com/tx-sheet-control/reference/formula-functions/linest/
- **LLMs URL:** https://docs.textcontrol.com/tx-sheet-control/reference/formula-functions/linest/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-sheet-control/reference/formula-functions/linest/llms-full.txt

---

Return the statistics of the straight line that best fits the data, by the least squares method. `known_y` holds the dependent values and `known_x` the independent ones (1, 2, 3 and so on when omitted). `const` TRUE or omitted calculates the intercept and FALSE sets it to 0, and `stats` TRUE adds rows of regression statistics, such as the standard errors and R². The result is an array that spills, with the slope first and the intercept second.

### Syntax

```text
LINEST(known_y, known_x, const, stats)
```

Category: Statistics. Minimum arguments: 1. Maximum arguments: 4.

Available for supported offline calculation.

### Examples

```text
=LINEST({2;4;6},{1;2;3})
```

The formula returns the slope 2 and the intercept 0 in two cells of a row, because the values 2, 4 and 6 lie on the line y = 2x.

Cell and range examples require appropriate input values in the referenced cells. Handle invalid arguments, formula errors and array and spill constraints.

### See Also

- [Formulas](https://docs.textcontrol.com/tx-sheet-control/spreadsheets/formulas/llms-full.txt)
- [Custom Functions and Formula Data](https://docs.textcontrol.com/tx-sheet-control/spreadsheets/custom-functions/llms-full.txt)

---

## Nearby

- **Previous:** [LET Function](https://docs.textcontrol.com/tx-sheet-control/reference/formula-functions/let/llms-full.txt)
- **Next:** [LN Function](https://docs.textcontrol.com/tx-sheet-control/reference/formula-functions/ln/llms-full.txt)
