cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

Is there any way to determine how many iterations Mathcad performed in a Minerr Nonlinear-Regression: Levenberg-Marquardt curvefit?

ptc-6698304
1-Visitor

Is there any way to determine how many iterations Mathcad performed in a Minerr Nonlinear-Regression: Levenberg-Marquardt curvefit?

I am trying to check if my Minerr solution to a nonlinear-regression, Levenberg-Marquardt curvefit of a circle to data points worked correctly. I did not get an error message, so I think the iterations converged. But I cannot check simply by the error at each data point, because, obviously, it is a minimization problem, so one expects to get error at each data point - it is a best curvefit problem. I set the TOL and CTOL convergence-error values to 1e-010, and I still got no error message. So I think it converged, but I want to make sure. If I could confirm that a non-trivial number of iterations was performed, then I could be somewhat reassured. But if it stopped after, say, 2 iterations, then I would guess that something got misinterpreted by Mathcad, perhaps in the required vectorization.

9 REPLIES 9

You may be able to use the trace feature. See here for an example.

http://communities.ptc.com/message/164648#164648

Thanks. I will try this. I didn't know that one could make a compose program after a boolean equals. I'll let you know how it came out.

Dave Rosenbaum wrote:

Thanks. I will try this. I didn't know that one could make a compose program after a boolean equals. I'll let you know how it came out.

Yes it's not a very well documented feature.

Yes, please let us know how you get on.

Mike Armstrong wrote:

You may be able to use the trace feature. See here for an example.

http://communities.ptc.com/message/164648#164648

... with animation http://communities.ptc.com/videos/1460

or http://communities.ptc.com/videos/1472

Valery Ochkov wrote:

Mike Armstrong wrote:

You may be able to use the trace feature. See here for an example.

http://communities.ptc.com/message/164648#164648

... with animation http://communities.ptc.com/videos/1460

or http://communities.ptc.com/videos/1472

Very clever Valery, I do recall seeing this before.

Please provide a worksheet if you require further help.

Werner_E
25-Diamond I
(To:ptc-6698304)

You may have a look at the built in variable ERR to get a measurement about the quality of the fit. Or you calculate your own sum of squared errors (SSE).

Wouldn't a plot of the raw data and the fitted function give you a quick idea of if the iteration succeeded?

There are two ways I can think of to get information how many iterations Mathcad's built-in numeric iteration algorithms have done.

Both would require that you turn one of the expressions used into a function which is defined before the solve block. The function would return the usual result but before it does so it would...

1) [does not work in Prime] ... call trace("xxx"). If you toggle degug you can then see how many times the line xxx is shown in the debug window. With some more work you may even be able to implement a counter so you don't have to count yourself.

2) ... use any of Mathcads WRITE commands (e.g. WRITEPRN resp. ADDPRN) to write a line to a file on disk. This slows down execution considerably. You may also implement a counter - read in the content of the file, incerement and write.

I just finished the ERR calculation, and confirmed that ERR was returning the square-root of the sum of the residuals (radial deviations from the circle) at each data point. I think the circle curvefit is working. I just want to be sure that Mathcad is actually doing what I intended it to do. I don't know why the forum searcher didn't return the above thread when I searched on: "maximum iterations".

Dave Rosenbaum wrote:

I don't know why the forum searcher didn't return the above thread when I searched on: "maximum iterations".

Don't worry, I only managed to find it because I contributed in the thread I directed you to.

Announcements

Top Tags