Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X
Newbie question...if I have a matrix of data values as shown below, how can I get Mathcad to solve for the actual polynomial (or exponential) expression ?
Or stated another way...can Mathcad provide the actual polynomial formula that would produce the graphed curve below based on the data provided.
I am using MathCad V9.0.
Solved! Go to Solution.
I tried the site suggested by DJf (I knew the site as ZunZun from former times) and it was indeed able to find the best fit so far
I added it to my sheet
With free eyes you hardly can spot a difference to the best so far.
Main difference seems to be at the front values
Probably the data is not exactly fulfilling a polynomial or exponential equation, so would rather use a fitting function.
Look up expfit, polyfit or genfit in the help pages.
If you need more help, come back again, attach your worksheet and state which version of Prime you are using.
From the pic it doesn't seem to me that a polynomial or an exponential would be a good fit - but you are the one who should know what process the data stems from and what kind of function can be expected.
BTW, from the spreadsheet screenshot it looks like you had chosen the wrong plot type in Excel as the x values are shown equidistant which they actually aren't.
My guess is:
with
So use genfit.
Success!
Luc
Thanks Luc...
Are you able to share any more of the details of your approach ? Apologies, but I'm new to the curve fitting functions in the Mathcad.
I will begin by looking at the genfit details in the help section as Werner suggested.
Can I assume that genfit produce these...
How did you arrive at this formula...
@TC_0928 wrote:
...
How did you arrive at this formula...
...
As Luc wrote - he guessed based on his experience that this type of function might give a good fit (and it looks like it actually does).
Still missing your worksheet with the data.
Understood...thanks Werner.
My intention is to try and have Mathcad derive a polynomial formula based on my set of data.
If I'm understanding the feedback so far, it would seem I have to use one of the curve fit functions to derive the coefficients. Which specific curve fit function to use and the next steps beyond that I am unsure of.
I defined a function which calculates the root of the sum of squared errors so that I have a measure of the quality of the fit (the lower the value, the better the fit).
Exponential and polynomial fits do not provide good approximations
Logistic power was quite better
but MMF proved to give the best fit so far
Its even slightly better compared to what Luc had suggested
But when I added that additional parameter (exponent of x) in Luc's suggestion as described above, I got the best fit of all of them (so far)
Why do you write that you are looking for a polynomial fit but then you tried an exponential fit in your sheet??
Where do the data stem from and what's the reason for looking for a fitting function?
In the attached sheet I added a plot where you can compare your data against two of the six mentioned fit function which you can chose via a combo box. You also can set the order of the polynomial here by changing the global assignment for n.
As an example here the comparison of a fifth order polynomial with the last mentioned fit function:
Increasing the order of the polynomial does not really help. You may chose a 12th order polynomial which would run exactly through all your 13 data points and therefore has an SQE value of fantastic zero, but I bet that nonetheless you would not be happy with this fit:
EDIT: Just found a bug in Prime. Changing the order of the polynomial does not always refresh the plot. A manual recalc (F5/F9) of the sheet is necessary so the change also shows in the plot.
EDIT2: You may also use the built-in "corr()" function as a measure of quality - the closer to 1, the better.
Hi,
Often overlooked are splines as a means of fitting data with a smooth curve. Is not what you asked for but it works.
Cheers
Terry
🙂
Surprise!! 😄
But then - EVERY interpolation would yield a perfect correlation of 1, no matter if its a spline interpolation or a simple linear interpolation.
If an interpolation is appropriate as opposed to a functional fit depends on the needs.
In fact we don't know what the thread starter intends to do and why he asked for "how can I get Mathcad to solve for the actual polynomial (or exponential) expression ?"
findcurves.com is the best site I've found for finding a representative equation.
@DJF wrote:
findcurves.com is the best site I've found for finding a representative equation.
And which function type for the best fit this site comes up using the data provided here?
Attached is my cheat sheet for a least squares fit for a polynomial. I apologize-- it's messy, You can pick the order of polynomial you want to fit and see how well it looks. Runs in Prime 4 Express and higher.
I tried the site suggested by DJf (I knew the site as ZunZun from former times) and it was indeed able to find the best fit so far
I added it to my sheet
With free eyes you hardly can spot a difference to the best so far.
Main difference seems to be at the front values
Thanks for the help Werner...much appreciated !!