A problem with Maple Polynomial Curve Fitting

536 Views Asked by At

I've been encountering a problem while trying to use the method of least squares to fit a quadratic polynomial. Below is the question

1) Use the method of least squares to fit a quadratic polynomial (y=a$_{0}$+a$_{1}x$+$a_{2}$x$^{2}$) to the given data. Here is the data (-1.1,-2.1),(-.3,-.9),(.9,.1),(1.6,1.1),(2.3,1.8). I had no problem getting it to fit a linear model by using Maple's "Curve Fitting" package. However when I go to try and get it to fit a quadratic polynomial it keeps giving me an error that reads

"Error, (in CurveFitting:-LeastSquares) curve to fit is not linear in the parameters"

My code is as follows

LeastSquares([[-1.1, -2.1], [-.3, -.9], [.9, .1], [1.6, 1.1], [2.3, 1.8]], v, curve = av^2+bv+c)

I'm very confused as to why this keeps occuring. I tried looking it up on the maple website for help and followed their example and everything worked out fine. I'm curious as to why mine is not working out. As always any help is always appreciated.

1

There are 1 best solutions below

0
On BEST ANSWER

Your difficulty is because you forgot the multiplication sign between a and v^2, and between b and `v.

Note that variable names in Maple are not restricted to a single character. They can be names of several characters.

As you have it, Maple is seeing variables named av and bv. And your model is not linear in the parameters in that case, since it contains (av)^2 which is the square of the parameter av.

So use a*v^2+b*v+c instead as your model expression for the curve option.