If you want to find a more general polynomial y=a0xn + … + an which best fits a set of data points, you can use the polynomial_regression command. Given a set of points, either as a list of x-coordinates followed by a list of y-coordinates, or simply by a list of points, as well as a power n, the polynomial_regression command will return the list [an,…,a0] of coefficients of the polynomial. For example, if you enter
or
you will get
so the best fit polynomial will be y = (−5/6)x3 + (17/2)x2 − (56/3)x + 12.
To plot the curve, you can use the command polynomial_regression_plot; if you enter
you will get