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

Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X

Different results of the calculations in MC11/MC15 (not a symbolic calculations)

VladimirN
24-Ruby II

Different results of the calculations in MC11/MC15 (not a symbolic calculations)

The original document was created in a Mathcad 2001 version. Symbolic calculations in the document do not have. Why the different results of calculations in Mathcad 11 and Mathcad 15 ( M040)? But it is strange that the results in Mathcad 11 and in Mathcad Prime 3.1 are the same .

1 ACCEPTED SOLUTION

Accepted Solutions
RichardJ
19-Tanzanite
(To:RichardJ)

It's a bug in MC15 (I'm using M030, so it's not specific to M040). The program that calculates Ap is run for each value of the range variable J. Each of these runs should be independent of any previous run, but in MC15 they are not. Specifically, A is not reinitialized. For J=1 that doesn't matter because there are more rows than there were for J=0. But J=2 and J=3 have fewer rows than J=1, and the extra rows in A are left tacked onto the end. It can be fixed by explicitly initializing A to 0 before the for loop:

Note that I also got rid of the first for loop. I'm not sure what that was supposed to do, but if it was supposed to initialize i to some value it's a terrible way to do it. It would only do that if it is assumed that the loop will run even though there is nothing in the loop that assigns any value to any variable. That's a bad assumption, because any half way decent optimization will recognize that, and remove the loop. I'm a little surprised it even initialized i to 0. If i does need to be initialized to a value other than 0 then it needs to be done in a reliable way.

Edit: The bug also exists in MC13. I don't have MC12 installed, but I assume it was introduced when Mathsoft rewrote the compute engine for MC12. Or maybe it was a new "feature". Plenty of "features" that many users considered to be bugs were introduced in MC12! As to why it works in Prime, who knows. Was it deliberately fixed, but left unfixed in MC15, or was it accidentally fixed?

View solution in original post

11 REPLIES 11
RichardJ
19-Tanzanite
(To:VladimirN)

The short answer is that MC11 and Prime are correct, whereas MC15 is wrong. I haven't had time (yet) to figure out exactly why MC15 is wrong though. I think it's something to do with the use of the range variable J in the program that creates Ap.

RichardJ
19-Tanzanite
(To:RichardJ)

It's a bug in MC15 (I'm using M030, so it's not specific to M040). The program that calculates Ap is run for each value of the range variable J. Each of these runs should be independent of any previous run, but in MC15 they are not. Specifically, A is not reinitialized. For J=1 that doesn't matter because there are more rows than there were for J=0. But J=2 and J=3 have fewer rows than J=1, and the extra rows in A are left tacked onto the end. It can be fixed by explicitly initializing A to 0 before the for loop:

Note that I also got rid of the first for loop. I'm not sure what that was supposed to do, but if it was supposed to initialize i to some value it's a terrible way to do it. It would only do that if it is assumed that the loop will run even though there is nothing in the loop that assigns any value to any variable. That's a bad assumption, because any half way decent optimization will recognize that, and remove the loop. I'm a little surprised it even initialized i to 0. If i does need to be initialized to a value other than 0 then it needs to be done in a reliable way.

Edit: The bug also exists in MC13. I don't have MC12 installed, but I assume it was introduced when Mathsoft rewrote the compute engine for MC12. Or maybe it was a new "feature". Plenty of "features" that many users considered to be bugs were introduced in MC12! As to why it works in Prime, who knows. Was it deliberately fixed, but left unfixed in MC15, or was it accidentally fixed?

Richard,

Well, seemingly, that earlier anybody didn't face this problem. I for the first time see such bug. Your transformed program block works well. But nevertheless, for some reason this bug was corrected in Prime version.

Thank you.

RichardJ
19-Tanzanite
(To:VladimirN)

I also don't recall seeing this bug before, but the worksheet is constructed in an unusual way. There are two basic ways of iterating through a variable: use a range variable, or use a program. IMO, range variables are obsolete for almost all purposes, and are a legacy from when Mathcad did not have programming (version 5 and earlier, I think). I very rarely use them for anything other than filling vectors and setting the range of graphs, and I advise people to do the same. This worksheet "passes" a program with for loops to a range variable iterator, and that is very uncommon. I would have iterated though J using an outer loop in the program, and then it would be clear that A needed to be reinitialized each time.

This document was not created by me. I wanted to understand why different versions of Mathcad produce different calculation results. I also do not use ranged variables in my calculations (with the exception of the range values for creating plots).

Mathcad 11 and 15 (Prime) have different symbolic engine - from Maple and from MuPAD.

There is no symbolic math in the worksheet though.

LucMeekes
23-Emerald III
(To:VladimirN)

Mathcad 15 (M040) is reported to have some bug(s).

I tried M030 on the Example_MC11.mcd file and get a 'pure virtual function call' error at the evaluation of/around 'J=' (first page).

Too big dataset for M15?

RichardJ
19-Tanzanite
(To:LucMeekes)

It worked fine for me (other than the bug described above, of course).

I tested it on both version MC15 F000 (Win7 x64) and MC15 M040 (Win7 x86) and got the same result but without any error/splash screen.

LucMeekes
23-Emerald III
(To:VladimirN)

Vladimir,

did you see Rich's response above? "It's a bug..."

Luc

Top Tags