The linest(...) spreadsheet function is often used for finding a “trend line” ...
but it is capable of doing much more than that. I wrote up a web page discussing
the details. http://www.av8n.com/physics/linear-least-squares.htm
*) It can find the coefficients of the best-fit quadratic.
An example of this is given in section 3.
*) It can also handle higher-order polynomials.
*) It can find the coefficients of the best-fit Fourier series.
An example of this is given in section 5.
*) More generally, it can fit to an arbitrary linear combination of basis
functions, using whatever basis functions you choose.
It must be emphasized that the fitted function is a linear combination
of the basis functions, but the basis functions do not need to be
linear functions of X.
I mention it in this forum because anybody who wants to do physics needs
to be proficient with least-squares fitting. Fitting a straight trend-line
is the first baby step, and the non-straight examples discussed here are
the next step.
There is a whole lot more to the story, but these are some useful initial
steps in the right direction.
Also note that for many students, the barrier to using a spreadsheet is much
lower than the barrier to using an imperative computer language such as C++.
=======
The same web document http://www.av8n.com/physics/linear-least-squares.htm
contains a digression that discusses "array constants" and also the
get.formula(...) function, both of which are useful and IMHO not as
widely known as they should be.