Read in some x-y data and then find a least-squares fit to the data as a linear combination of given functions, or as a nonlinear function.
Read in arrays x
and y
from
xyL.dat and find the best 5th degree polynomial fit
read xyL.dat x y
scalar\fit a0 a1 a2 a3 a4 a5
fit y = a0+a1*x+a1*x^2+a2*x^3+a3*x^4+a4*x^5
Read in arrays x
and y
from xyN.dat
and find the best fit to y(x) = a0*exp(a1*x)*sin(a2*x+a3)
read xyN.dat x y
scalar\fit a0 a1 a2 a3
a0 = 5
a1 = -.5
a2 = 1.5
a3 = .5
fit y = a0*exp(a1*x)*sin(a2*x+a3)