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

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

Bug in Mathcad 15 not in Prime and in my head

ValeryOchkov
24-Ruby IV

Bug in Mathcad 15 not in Prime and in my head

I could not solve a simple problem (the radius of the ball) by the method of scientific poking (see please Trial and error).

I decided that one bug got into my head. But I decided not to give up and converted the file into Mathcad Prime 4 (see please attachs). The bug was not in my head, but in Mathcad 15. What is this bug?

Mathcad 15Mathcad 15Mathcad Prime 4Mathcad Prime 4

 

ACCEPTED SOLUTION

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

While I agree with the better programming style suggested by Werner, the behaviour in Mathcad 11 is similar to that in Prime:

LM_20180210_Mc15bug.png

My guess its due to the (fortunate) lack of Static Unit Checking.

 

Success!

Luc

 

View solution in original post

5 REPLIES 5

I won't call it a bug as "return" is not a legit way to end a loop ("break" is the command you'll have to use for it).

Bild.png   or   Bild2.png

EDIT: Thinking about it again it seems that an additional cause for your attempt failing is because of the unit you use (here is one of the few point where Prime has an advantage).

You can make it work using one of the unit tricks you like so much and use so often:

Bild4.png

 

Nonetheless I think that its better programming style to use "break" and not "return" to cancel a loop and also it would be better just for clearness to use r.1 for the random radius rather than r, which is also the name of the program.

LucMeekes
23-Emerald III
(To:ValeryOchkov)

While I agree with the better programming style suggested by Werner, the behaviour in Mathcad 11 is similar to that in Prime:

LM_20180210_Mc15bug.png

My guess its due to the (fortunate) lack of Static Unit Checking.

 

Success!

Luc

 

Werner_E
25-Diamond I
(To:LucMeekes)


My guess its due to the (fortunate) lack of Static Unit Checking.


Yes, its sure a problem with the unit used and SUC seems to be first choice in the search for a culprit.

I just wonder why the break/return combination works OK then. It may not be a bug, but sure an inconsistent behavior. And the error message does not indicate that it could be a unit problem.

Needless to say that your sheet fails in MC15, too.

 

EDIT: I think I got it!

Mathcad does not realize/check that the while loop is never left other then by breaking out with return. So there may be the case that the loop is terminated in a regular way and then we need a return result with compatible units compared to the return statement in the loop. A simple 0 at the end does the job as in MC15 0 is compatible with any unit (on contrary to Prime).

So the problem its sure caused by SUC and the error message is, as so often in Mathcad, misleading/meaningless.

Bild.png

Yes


wrote:

My guess its due to the (fortunate) lack of Static Unit Checking.


Yes, its sure a problem with the unit used and SUC


Yes! r and V must have same dimension. In Mathcad 15 not Prime!

rV-MC-15-OK.png

 

> Yes! r and V must have same dimension. In Mathcad 15 not Prime!

No! Thats not the cause of the error in MC15.

Look at my EDITED answer above - the cause is that you need to provide a unit-compatible return value also for the fictive case that the loop will end regularily. The units of V have nothing to do with that.

Announcements

Top Tags