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

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

SOLVED
Bedrock

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

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

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

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

Simply return a vector with both value of interest:

Unbenannt.PNG

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

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.

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

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

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

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

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

 

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.

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


@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

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

Yes, indeed... Too many zeroes.

 

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

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

In Mathcad 15 with the trace function:

bis.png

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

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