Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X
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 .
Solved! Go to Solution.
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?
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.
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.
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.
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?
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.
Vladimir,
did you see Rich's response above? "It's a bug..."
Luc