×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Perform a Least Squares Curve Fit
2

Perform a Least Squares Curve Fit

Perform a Least Squares Curve Fit

(OP)
Hi, everyone,

I am trying to find a program to perform a least squares curve fit with a ten coefficient equation.

z=c1+c2*(x)+c3*(y)+c4*(x^2)+c5*(x*y)+c6(y^2)+c7*(x^3)+c8(x^2*y)+c9(x*y^2)+c10*(y^3)

Does anyone know where I could find the program?

Thanks in advance.

RE: Perform a Least Squares Curve Fit

My starting point would be Excel.  Set up your data in a table.  Make a starting guess at your ten coefficients, placing them in ten adjacent cells on the spreadsheet.  Add the resulting z-prediction in another column in your table.  In yet another column place the square of the difference between the z-actual and the z-prediction.  At the bottom of that column put the sum of all the squared "errors".

Now use the Solver which comes as a standard part of Excel.  (You may need to activate its add-in first.)  You want to minimise the sum of the squared errors by varying your ten coefficients.  Your answer is then one click away, since your problem is (presumably) an unconstrained one.

Two caveats.  Firstly I have never used the Solver with as many as ten variables, so I cannot vouch for it here.  Secondly, you need your starting guess to be reasonably close to the final answer.

HTH

RE: Perform a Least Squares Curve Fit

wzal, how many data points do you have? I'd certainly do it in Excel.

Cheers

Greg Locock

RE: Perform a Least Squares Curve Fit

I suppose that you would like to fit some property z=f(x,y)in form of a polynomial of a third degree including mixed terms.Use Excel and write z's in the first column, x's in the second, y's in the third. Now form the fourth column where you write the result of x^2, in the fifth the result of y^2,then x^3 in the next and so on until you have all combinations of x's and y's, each in its own column.
Now make make linear fit and select the non-zero range of all columns but the first one as independent variables and let Excel calculate the coefficients.
Try first with a simple case with z=Ax+By+Cxy to see the idea.
m777182

RE: Perform a Least Squares Curve Fit

I do a lot of this sort of thing and I do it exactly the way m777182 recommended.

I have tried dedicated programs, and never found anything that matches a spreadsheet - I use Excel and Quattro Pro.  A useful advantage of doing it in a spreadsheet is that you can link a graph to the results and immediately see how good your curve is.

RE: Perform a Least Squares Curve Fit

I have written a program in basic which takes a set of coordinte pairs and produces an equation/graph of best fitting curve. It is on an old set of IBM punch cards.

RE: Perform a Least Squares Curve Fit

WZAL, WHERE IS YOUR EQUATION APPLIED? ALSO,CAN IT BE SIMPLIFIED SO THAT A 2D REGRESSION ANALYSIS CAN BE USED?

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources