### 7.2.5 Exponential regression: exponential_regression exponential_regression_plot

A set of points might be expected to lie on an exponential curve y=b ax. 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 exponential_regression command will find the values of a and b which give the best fit exponential. For example, if you enter

evalf(exponential_regression([[1,1],[2,4],[3,9],[4,16]]))

or

evalf(exponential_regression([1,2,3,4],[1,4,9,16]))

(where the evalf is used to get a numeric approximation to an exact expression) you will get

2.49146187923,0.5

so the best fit exponential curve will be y = 0.5*(2.49146187923)x.

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

exponential_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.