Get Help

Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Community
- :
- PTC Mathcad
- :
- PTC Mathcad
- :
- Iteration Sequence and difference in results Prime...

Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

02-19-2019
08:44 PM

02-19-2019
08:44 PM

Iteration Sequence and difference in results Prime and MAthcad

I am running the same function in Prime and Mathcad but get different results. See attached

Labels:

7 REPLIES 7

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

02-19-2019
11:22 PM

02-19-2019
11:22 PM

Re: Iteration Sequence and difference in results Prime and MAthcad

@albertschepers wrote:

I am running the same function in Prime and Mathcad but get different results. See attached

No, you are not running any functions at all!

All I see is a misuse of ranges.

You may have noted that the results of your "calculations" is NOT a vector and that you can't assign it to a variable and use it for later calculations.

A range is sort of an implicit loop and the order those loops for i and j are executed obviously has changed in Prime. But the results are the same anyway, of course.

If you use those ranges in a correct way, you get the very same results in Prime and in real Mathcad:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

02-20-2019
08:25 AM

02-20-2019
08:25 AM

Re: Iteration Sequence and difference in results Prime and MAthcad

Thank you for the prompt response. Also thank you for the reminder that these are called range variables. Attached is my final work sheet with the final formula creating a vector based on the two rang variables. Please note that the range variables are used correctly. Also the final formula has the same results in both Prime and Mathcad.

At issue is the intermediate results between Prime and Mathcad. You will notice the use of the range variables is complex to determine the desired final vector values and I would have assumed that Prime and Mathcad would determine the intermediate results, the derivation of formulas for the range variables, similarly. They don't. Prime's results are wrong, or at least not useful in developing the final formula.

Please note I attempted to attach a screen shot but it failed, the error message is there are two many characters. Perhaps there is another way of inserting a screenshot than clipping and pasting.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

02-20-2019
09:13 AM

02-20-2019
09:13 AM

Re: Iteration Sequence and difference in results Prime and MAthcad

Can you explain what you determine to be 'intermediate results'

and why you think they are wrong (in Prime)?

Luc

You cannot copy & paste pictures in this forum. You have to save your screenshot (or other picture) in a file (.png gives the sharpest pictures) and insert them with the 'Photos' button just above the edit pad.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

02-20-2019
10:46 AM

02-20-2019
10:46 AM

Re: Iteration Sequence and difference in results Prime and MAthcad

if you look at the first posted files you will see a difference in the results for the range variable formulas I am working on. I try these and build on them until I get the results I need. Once complete I simplify the formulas to make them as elegant as possible.

What happens is Prime and Mathcad throw different results due to the order in which range variables are used or iterated on, see Werner's screen shot in his last post, it is very clear what is happening. My screen shot shows the final form as well as the intermediate. The subscript for the node vector has several terms in it each of which I tested before combining. It is this testing of the intermediate terms that is done differently in Prime and Mathcad (see Werner's posted image).

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

02-20-2019
12:47 PM

02-20-2019
12:47 PM

Re: Iteration Sequence and difference in results Prime and MAthcad

What you call "testing" and "intermediate results" is simply wrong usage of ranges.

The "results" you get are useless for any calculations anyway and you should by all means avoid doing so.

Ranges should be used only in three situations:

1) Provide a range for plotting

2) in a for-loop inside a program

3) to index vectors and variables.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

02-20-2019
09:33 AM

02-20-2019
09:33 AM

Re: Iteration Sequence and difference in results Prime and MAthcad

Ah, I guess I see what bothers you:

You CANNOT depend on the order of execution of simultaneously used range variables.

Since addition is commutative, Mathcad may choose to start evaluation of any expression from left to right, or from right to left or any other order. And you must not be surprised if it differs from (sub-)version to (sub-)version of Mathcad and/or Prime, even from equation to equation on the same sheet!

Success!

Luc

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

02-20-2019
09:44 AM

02-20-2019
09:44 AM

Re: Iteration Sequence and difference in results Prime and MAthcad

You got it!

One more point of interest, once I have the correct formulation I use the symbolic solver to simplify the formula (I should have posted it before). When I do the formula is reduced to something that is quite elegant and works.

Now to see if I can prepare similar formulas for the coordinates of each node.

Thank you for your assistance.