Skip to main content
24-Ruby III
December 1, 2015
Solved

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

  • December 1, 2015
  • 3 replies
  • 4835 views

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 .

Best answer by 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?

3 replies

19-Tanzanite
December 1, 2015

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.

RichardJ19-TanzaniteAnswer
19-Tanzanite
December 1, 2015

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?

VladimirN24-Ruby IIIAuthor
24-Ruby III
December 3, 2015

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.

24-Ruby IV
December 1, 2015

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

19-Tanzanite
December 1, 2015

There is no symbolic math in the worksheet though.

23-Emerald IV
December 1, 2015

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?

19-Tanzanite
December 1, 2015

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