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

Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X

Question for StuartBruff with comparison between Maple and Mathcad calculation method

FDS
12-Amethyst
12-Amethyst

Question for StuartBruff with comparison between Maple and Mathcad calculation method

Dear Stuart or other power user,

You mentioned that beside of mathcad you also experiment with maple. As I stick to real mathcad I would like to have a plan B for the moment my mathcad no longer works. So I am transferring some of my mathcad sheets into maple as exercise.

In the attached worksheets I believe that I did exactly the same in both programs but the end result is 10 units lower in maple than in mathcad. I have tried to find the reason for days but was not able to pinpoint the issue. Would you be so kind to throw an eye on it? As the maple file could not be uploaded I provided it as a txt file

I already want to express my gratitude in advance for your help.

Filip

ACCEPTED SOLUTION

Accepted Solutions
LucMeekes
23-Emerald III
(To:FDS)

@FDS I think I've found the culprit.

In Maple your differential equation is:

LucMeekes_2-1639226853001.png

resulting in:

LucMeekes_3-1639226888897.png

In Mathcad you've implemented:

LucMeekes_4-1639226945141.png

Resulting in:

LucMeekes_5-1639226969147.png

That's  a small jump for an exponent...

 

Success!
Luc

 

View solution in original post

20 REPLIES 20
LucMeekes
23-Emerald III
(To:FDS)

Misschien helpt het (nog meer) om beide berekeningen als .PDF aan te hangen. Het valt me op dat de structuur van beide sheets nogal verschillend is, dat maakt het vergelijken lastig. De Mathcad sheet file heeft een referentie naar O2 dissociatie.xmcdz, die zit er niet bij. Tenslotte: als je de bestanden in een .ZIP file stopt, kun je ze wel aanhangen.

 

Succes!
Luc

 Luc,

 

In de bijlage vindt u het bestand voor de 11e versie van het programma.

 

P.S. Vergeet trouwens niet dat u de site kunt gebruiken - "SMath Studio in the Cloud" (https://en.smath.com/cloud/ ) om voorbeelden van bestanden in het formaat ".xmcd": https://en.smath.com/cloud/sheet/e7pLXZ3AKV

StuartBruff
23-Emerald III
(To:FDS)


@FDS wrote:

You mentioned that beside of mathcad you also experiment with maple. As I stick to real mathcad I would like to have a plan B for the moment my mathcad no longer works. So I am transferring some of my mathcad sheets into maple as exercise.

In the attached worksheets I believe that I did exactly the same in both programs but the end result is 10 units lower in maple than in mathcad. I have tried to find the reason for days but was not able to pinpoint the issue. Would you be so kind to throw an eye on it? As the maple file could not be uploaded I provided it as a txt file


 

Unfortunately, I'm not much of a power user as I don't have either Mathcad 15 or a Mathcad Prime subscription.

 

Could you please provide a pdf (or MS Word) copy of your worksheet?  (I can't remember whether M15 has a direct print-to-pdf save option or whether it needs to be done via the Print dialog;  I think there is an RTF option somewhere, as well )

 

However, depending upon what timescale you are looking at, Mathcad Prime seems to be heading towards parity with M15 in a few releases' time.  Sticking with Prime might yet be an option for you.  What features in Real Mathcad (or TOS) do you need/use that Mathcad Prime (TNG)

 

https://community.ptc.com/t5/PTC-Mathcad/PTC-Mathcad-Prime-Roadmap-2021-update/m-p/738684

 

Stuart

 

I've tried @LucMeekes's file viewer but it has a problem with part of the xmcdz file.

 

2021 12 08 a.png

 


 

Star Trek references ...

 

TOS - The Original (Mathcad) Series

TNM - The New (Mathcad) Generation

 

Kind of apt, as the "crew" isn't the same and has a different mindset, plus the Enterprises (Mathcads) are superficially similar but, again, different in many ways.

 Stuart,

 

Please find in the attachment PDF file to preview the contents of this worksheet and the file for Mathcad Prime version.

 

P.S. By the way, don't forget that you can use the site -  "SMath Studio in the Cloud" (https://en.smath.com/cloud/ ) to preview files in the format - ".xmcd": https://en.smath.com/cloud/sheet/e7pLXZ3AKV 

StuartBruff
23-Emerald III
(To:VladimirN)


@VladimirN wrote:

 Stuart,

 

Please find in the attachment PDF file to preview the contents of this worksheet and the file for Mathcad Prime version.


I've compared the Mathcad Prime worksheet to the Maple workbook and, as Luc has pointed out, there are some differences.   I've corrected what I can at the moment and the figures seems to agree up until the rkfixed evaluation.   At that point, other things were calling for my attention and I haven't had time to implement an rkfixed function (I managed linterp).

 

Stuart

LucMeekes
23-Emerald III
(To:StuartBruff)

There's an rkfixed in my Prime Express toolbox, https://community.ptc.com/t5/PTC-Mathcad/Prime-Express-A-joke/m-p/604216

It's recursive, so it will happily accept 20 steps, but if you go above that you get a warning, and advice.

I 'm hoping to use fold() to speed it up.

 

Success!
Luc

StuartBruff
23-Emerald III
(To:LucMeekes)

I knew you'd get there before me, Luc!  Well done.  😊

 


@LucMeekes wrote:

There's an rkfixed in my Prime Express toolbox, https://community.ptc.com/t5/PTC-Mathcad/Prime-Express-A-joke/m-p/604216


Ah, as the results looked like a straightforward, smooth curve, I dashed off a quick rk4 integrator.   Seems to do a good enough job, but I need to do a bit more digging to determine if the numerical differences are due to my rkfixed having an rk4 integrator vs the intrinsic rkfixed's rk45, or due to my having incorrectly converted a unit (unit_free caught me out initially).

 

2021 12 10 c.png

 


It's recursive, so it will happily accept 20 steps, but if you go above that you get a warning, and advice.

Fortunately, the simplicity of the rk4 seems to cope with up the recursion limit.

 

2021 12 10 d.png

 


I 'm hoping to use fold() to speed it up.

Yes, I was thinking along the same lines.  It might be possible for an integrator that uses a fixed number of steps, by pre-creating the independent variable vector (or just a 1..n list) and letting fold iterate over that.

 

Stuart

 

 

StuartBruff
23-Emerald III
(To:StuartBruff)


@StuartBruff wrote:

@LucMeekes wrote:

There's an rkfixed in my Prime Express toolbox, https://community.ptc.com/t5/PTC-Mathcad/Prime-Express-A-joke/m-p/604216

I 'm hoping to use fold() to speed it up.

Yes, I was thinking along the same lines.  It might be possible for an integrator that uses a fixed number of steps, by pre-creating the independent variable vector (or just a 1..n list) and letting fold iterate over that.


It is, indeed, seemingly possible to use fold to get round Mathcad's recursion depth limit.

 

2021 13 10 a.png

 

2021 13 10 b.png

 

Like a lot of things, the solution is "obvious" once you've found it.  But its implementation is messy and cumbersome, even by my standards. 😕

 

There are probably better ways to do it, but I just can't seem to find another, more elegant, way around fold needing a dyadic-only function.   

 

I'll have to see if I can improve the function before releasing it into the wild.   

 

Stuart

LucMeekes
23-Emerald III
(To:FDS)

Thanks to @VladimirN I'm able to look at the Mathcad file in more detail.

I find already one difference, near the top:

In Mathcad you define Hct := Chb*3, which results in Hct=0.303.

In Maple you define Hct := 0.301.

 

I guess, the results are different because the input is different.

 

Further, you appear to be using units in Maple consistently. You fail to use (the same) units in Mathcad.

 

Success!
Luc

 

FDS
12-Amethyst
12-Amethyst
(To:LucMeekes)

First of all thank you Luc, Stuart and Vladimir for your swift response and help.

Luc you have a keen eye I did not spot that difference. However, changing it does not substantially change the final result. I have attached for your convenience the MC15 file as a MC11 file and also the mw file in a zip (7-zip). The file referring to the dissociation I have removed as it is not really needed for my question. I also reordered the MC sheet to have the order moer or less the same as the maple sheet. Only the water vapour part is different due to the fact that maple can calculate this directly. Graag maak ik van de gelegenheid ook gebruik om U te bedanken voor de vele waardevolle informatie die ik over de jaren kreeg via Uw antwoorden in de collaboratory.

Stuart, my main reason for not pursuing Prime is that it works with subscription. Once I go in retirement I most likely do not want to spend that money each year for a program I will use at that time for personal pleasure. With Maple I can buy a perpetual license at an acceptable price once retired.

I really hope someone can pinpoint the difference as it really gives me a headache 🙂

Filip

 

VladimirN
24-Ruby II
(To:FDS)

In any case, you will be able to use Mathcad Prime Express version without a subscription.

LucMeekes
23-Emerald III
(To:FDS)

Filip,

 

Thanks for your kind words.

"However, changing it does not substantially change the final result." I did not expect it would make a big difference, but there was a possibility of course: small input changes CAN make big output differences. My intention was to indicate that there is least one difference, and there may be more. As the sheets didn't line up enough, I stopped there.

Now that you've lined the Mcd file up with the maple file, if I find time I'll check further.

 

Succes!
Luc

StuartBruff
23-Emerald III
(To:FDS)

Stuart, my main reason for not pursuing Prime is that it works with subscription. Once I go in retirement I most likely do not want to spend that money each year for a program I will use at that time for personal pleasure. With Maple I can buy a perpetual license at an acceptable price once retired.

I have already made that point on these forums.   I have perpetual licences for both Mathematica and Maple Flow for less than the price of an annual subscription to Mathcad Prime.   If I were still a MATLAB user, I could have a pretty good deal there, too, as a home user.   

 

Much though I like the simplicity and (relative) ease of the Mathcad interface, I just can't justify spending that amount of money on a product that doesn't yet meet the capabilities of its predecessor, let alone the features I was requesting going back to M11.

 

I understand PTC's rationale for their pricing policy and I'm sure the appropriate people have crunched the numbers and psychology to justify their subscription model.   All I will note is that Mr Maple and Mr Wolfram are getting my money and PTC are not.

 

I really hope someone can pinpoint the difference as it really gives me a headache 🙂

I'll try to have a look later. 

 

Luc will probably beat me to it, though.  😀

 

Stuart

VladimirN
24-Ruby II
(To:FDS)

I had an old card somewhere comparing Maple and Mathcad. Write to me in private so that I can add it to my list.

LucMeekes
23-Emerald III
(To:FDS)

Filip,

 

Here are more differences:

Mathcad: Barometerdruk:=765.8 torr

Maple:     Pbaro:=765 mmHg

That's 0.1 % relative difference (much more than the 0.000015% difference between torr and mmHg there is according to Wikipedia).

 

Mathcad:  Pb=328.095               Results in Tcor_waterdamp=36.7 torr

Maple       PbaroCor=327.725    Results in Ps(Tb)=36.7219 mmHg

Why not define the same formula in Mathcad as you have in Maple:

LucMeekes_0-1639088655169.png

Then

LucMeekes_1-1639089039228.png

 

A larger difference occurs with S, or Sv...

You define a function for it in Maple and use it twice; one time with (uncorrected) PO2 and P50 values, then with PvO2.c and P50.vc.

In Mathcad you write two explicit expressions, one using PvO2 and P50v, the other using (the same, uncorrected) PvO2 and (the corrected) P50vc. The difference in results becomes 0.778 for Maple, 0.873 for Mathcad...

 

My conclusion now: There's more than one reason why you get different results from your Maple sheet as compared to your Mathcad sheet. I'll leave it here.

And I guess Richard was right...

 

Success!
Luc

 

FDS
12-Amethyst
12-Amethyst
(To:LucMeekes)

Dear Luc, My sincere apologies for wasting your time. I made a massive mistake by converting an older version to MC11, reason for which you found all these differences. I have now attached the correct one which I checked for all intermediate values and they seem to be the same. Nevertheless, the difference calculated after the ODE remains. I hardly dear to ask you but would you be willing to check one again?

By the way what did you mean by the sentence "I guess Richard was right"? 

StuartBruff
23-Emerald III
(To:FDS)


@FDS wrote:

Dear Luc, My sincere apologies for wasting your time. I made a massive mistake by converting an older version to MC11, reason for which you found all these differences. I have now attached the correct one which I checked for all intermediate values and they seem to be the same.


 

Hi Filip,

 

SMath Studio does not accept .mcd files (just .xmcd).  What are the differences between the new M11 worksheet you've uploaded and the Prime 3.1 worksheet you uploaded previously?   (Also, are there any differences between the "new" Maple workbook and the previous one?).

 

I had difficulties with my iMac yesterday and ended up having to uninstall/reinstall Maple.   I've now got Maple up and running and thought the best way to proceed was to rearrange the Prime 3 worksheet to more closely resemble the Maple workbook.

 

I've attached a pdf copy of the Maple 2021.2 evaluation of your penultimate worksheet.

 

Stuart

 

Now and again, I like to check things that I think I know and am usually surprised to find out that what I thought wasn't either quite correct or even true.  I also occasionally remember to check if everyone's singing from the same hymn sheet.

 

2021 12 10 a.png

LucMeekes
23-Emerald III
(To:FDS)

Hi Filip,

 

See Stuarts post from yesterday 12:44:

"Luc will probably beat me to it, though. "

 

I'll try to have a look later.

Luc

LucMeekes
23-Emerald III
(To:FDS)

@FDS I think I've found the culprit.

In Maple your differential equation is:

LucMeekes_2-1639226853001.png

resulting in:

LucMeekes_3-1639226888897.png

In Mathcad you've implemented:

LucMeekes_4-1639226945141.png

Resulting in:

LucMeekes_5-1639226969147.png

That's  a small jump for an exponent...

 

Success!
Luc

 

FDS
12-Amethyst
12-Amethyst
(To:LucMeekes)

Dear Luc and Stuart, thank you both for your extensive help. Luc, I am always amazed how you can find these differences! I went several times over my worksheet and overlooked it every time. Have a nice weekend!

Announcements

Top Tags