Skip to main content
5-Regular Member
December 25, 2024
Solved

Curve fitting - Creep Coefficient - While loops - Mathcad 13

  • December 25, 2024
  • 1 reply
  • 3435 views

 

I am looking for an implementation of a program for curve fitting. I have already achieved a good approximation using the genfit function.

MB_12486492_0-1735166010787.png

 

Currently, I am trying to improve the fit further by using a routine with while loops that iteratively adjusts the three variables to achieve a better approximation.

MB_12486492_1-1735166044188.png

 

However, when I start the loop, it runs indefinitely and fails to find a solution. Could anyone help me resolve this issue?

 

Best answer by Werner_E

Ah, I had overlooked that you wrote MC13 in the topic.

Find attached the file saved in MC13 format.

 

Comparing the three fitting functions it shows (especially in the log-lin plot) that neither provides a good fit for x-values below 100.

Werner_E_0-1735216887260.png

For higher values of x, minimize and minerr returned a much better fit compared to genfit.

 

1 reply

25-Diamond I
December 26, 2024

You have to make ajpha1 an additional argument of functions Phi3P and also Delta as otherwise always the same function Phi3P is used, not considering the change in alpha1.

BTW, are you sure that it should read "< 0.0005" in the while condition and not "> 0.005" ?!!

I don't think that you can improve genfits alpha value with your method, which is also very inefficient concerning run time. You should rely on the built-in algorithms an may consider using minimize or a solve block with minerr instead of genfit.

Werner_E_4-1735191296307.png

 

You may test and also plot the cumulated absolute error values

Werner_E_5-1735191366224.png

 

 

Using this test function you may also use "minimize" to get the best value. It differs a liitle bit from the value derived by genfit and according to the test function its a little bit better.

Werner_E_3-1735191005945.png

 

But this is only a near to optimal value considering that beta and gamma are constant.

Your fit needs you to jiggle around with all three values at the same time, though.

So why not set up the test function dependent on all three and again use minimize:

Werner_E_6-1735192802345.png

The result is clearly much better than what genfit could come up with.

 

While we are at it, we can also try a solve block with minimize

Werner_E_8-1735192917825.png

The fit now is even (very slightly) better!

 

 

 

 

 

 

5-Regular Member
December 26, 2024

 

Thank you for the quick response and detailed explanation, Mr. Werner_E.

 

Although your explanation of the algorithm is clear, I would like to access your Mathcad file. However, it seems your version is newer than mine ( I am using Mathcad 13.0 ). Could you please save the file in this version for me?

 

Werner_E25-Diamond IAnswer
25-Diamond I
December 26, 2024

Ah, I had overlooked that you wrote MC13 in the topic.

Find attached the file saved in MC13 format.

 

Comparing the three fitting functions it shows (especially in the log-lin plot) that neither provides a good fit for x-values below 100.

Werner_E_0-1735216887260.png

For higher values of x, minimize and minerr returned a much better fit compared to genfit.