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

Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X

Question on how to count the number of iterations for an Mathcad equation

tubar
12-Amethyst

Question on how to count the number of iterations for an Mathcad equation

What command or operation i have to do in order to find the number of iterations performed for solving an Mathcad equation like f(x):=e^x-x       that has in the final the solution 0.5671?

 

I need to find the number of iterations in order to evaluate the efficiency of the solving method.

 

I searched a lot for this aspect and I'm surprised that nobody had this question until now.

1 ACCEPTED SOLUTION

Accepted Solutions
tubar
12-Amethyst
(To:tubar)

Thank you again. Now, the problem is solved for me.

 

In Mathcad Prime the Debugging function was not possible like for Mathcad 15 View> Toolbars> Debug     resulting Trace Window.

 

In fact the best version of Mathcad remains for me Mathcad 13 where the displayed equations weren't limited at the  length.   Today, especially in Symbolic Tool , when results a very long equation it will not be displayed unfortunately. However, it is another subject.

 

I attached the updated files from your suggestions. Maybe will benefit others in the future.

 

 

 

View solution in original post

9 REPLIES 9
Werner_E
24-Ruby V
(To:tubar)

Simply return a vector with both value of interest:

Unbenannt.PNG

tubar
12-Amethyst
(To:Werner_E)

Thank you very much! It worked for both versions, Mathcad 15 and Mathcad Prime too.

 

 

Also, a history of the iterations it is possible to be presented?  For example, in Mathcad 15 exists a function Trace(x) that permits the view of the succesive values of the root x in a Trace Window.

 

However, in Mathcad Prime I cannot find the history of values of x in a Trace Window. I dont know why.

Werner_E
24-Ruby V
(To:tubar)

Prime is clearly inferior to Mathcad in many ways and is missing a lot of functionality compared to Mathcad.

The trace function simply is not implemented in Prime.

To return the history you'd like to see you could store all x-values in a vector and return that vector instead of the last calculated value.

Unbenannt.PNG

tubar
12-Amethyst
(To:tubar)

Thank you again. Now, the problem is solved for me.

 

In Mathcad Prime the Debugging function was not possible like for Mathcad 15 View> Toolbars> Debug     resulting Trace Window.

 

In fact the best version of Mathcad remains for me Mathcad 13 where the displayed equations weren't limited at the  length.   Today, especially in Symbolic Tool , when results a very long equation it will not be displayed unfortunately. However, it is another subject.

 

I attached the updated files from your suggestions. Maybe will benefit others in the future.

 

 

 

tubar
12-Amethyst
(To:tubar)

 

I found a strange difference between Mathcad 15 and Prime: Mathcad 15 solved the equation with 13 iterations while Mathcad Prime solved the equation with 19 iterations.

Werner_E
24-Ruby V
(To:tubar)


@tubar wrote:

 

I found a strange difference between Mathcad 15 and Prime: Mathcad 15 solved the equation with 13 iterations while Mathcad Prime solved the equation with 19 iterations.


Nothing strange - you get the same number of iterations if you use the same tolerance value for "tol".

You have different values in your two sheets.

 

BTW, as you now return the vector of x-values you can get rid of returning the value of i - you can determine the number of iterations by counting the number of values in the result vector:

Unbenannt.PNG

tubar
12-Amethyst
(To:Werner_E)

Yes, indeed... Too many zeroes.

 

Now I will extend the algorithms for Chords, Secant and Newton-Raphson methods.

In Mathcad 15 with the trace function:

bis.png

tubar
12-Amethyst
(To:ValeryOchkov)

Thank you. Indeed, the debugging functions are available in Mathcad 15 but Mathcad Prime missed this functionality.

Top Tags