### 7.2.7 Power regression: power_regression power_regression_plot

To find the graph y=bxm which best fits a set of data points, you can use the power_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, the power_regression command will find the values of m and b which give the best fit curve. For example, if you enter

power_regression([[1,1],[2,4],[3,9],[4,16]])

or

power_regression([1,2,3,4],[1,4,9,16])

you will get

2.0, 1.0

so the best fit (in this case, exact fit) power curve will be y = 1.0 x2.

To plot the curve, you can use the command power_regression_plot; if you enter

power_regression_plot([1,2,3,4],[1,4,9,16])

you will get

which plots the graph, and has the equation and R2 value above the graph. Note that in this case the R2 value is 1, indicating that the data points fall directly on the curve.