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

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

Prime 6.0 - Ceil and Floor function error

Alvaro_95
7-Bedrock

Prime 6.0 - Ceil and Floor function error

Hello everyone,

 

I am experiencing the same rounding error from previous versions in Mathcad Prime 6.0. Have an explanation?  Or, where can I report effectively this error?

 

Thanks!

 

clipboard_image_0.png

1 ACCEPTED SOLUTION

Accepted Solutions

The solution is simple.

Check "Approximate Equality" ("Calculation" ribbon, "Calculation Options") and you should get the correct result:

clipboard_image_0.png

clipboard_image_0.png

View solution in original post

15 REPLIES 15


@Alvaro_95 wrote:

Hello everyone,

 

I am experiencing the same rounding error from previous versions in Mathcad Prime 6.0. Have an explanation?  Or, where can I report effectively this error?


Effectively? Nowhere! Don't forget - we are dealing with PTC and they have proven their ... "efficiency" in program development and bug fixing quite effective if you look at the way they "develop" Prime.

If you really go through the hassle of reporting this effect you can open a support case, but only if you have paid them and are under maintenance. The lack of a channel in which everybody can report bugs already tells the whole story about PTCs interest in making their software more bug-free.

 

BTW, AFAIR this bug has already been reported here in the forum a few times (its also present in real Mathcad, so its rather old)  and also shows up without using units:

clipboard_image_0.png

 

 

Thank you Werner. I will try to report via support contact.
And yes, it will be useful to have a label "report" just as "tips" or "ideas" in the community.


@Alvaro_95 wrote:
Thank you Werner. I will try to report via support contact.
And yes, it will be useful to have a label "report" just as "tips" or "ideas" in the community.

This label would only make sense, if relevant PTC-staff would scan a subforum like this on a regular basis and act accordingly. I guess this never will happen. Good luck with your support case.

 

BTW, in MC15 we can set the number of decimal places to 17 and that way we can see whats happening. This at least partially explains the effect - internal round-off errors - possibly due to conversion from decimal in IEEE binary format. The effect also shows if we set the result to 15 decimal numbers. If we do that in Prime (15 is the max possible here), we are not shown that round-off error but obviously its there as we still have the bug in "floor" etc.

clipboard_image_0.png

LucMeekes
23-Emerald III
(To:Werner_E)

Mathcad 11 gives:

clipboard_image_0.png

Luc


@LucMeekes wrote:

Mathcad 11 gives:

 

With 17 decimal places?

Thats interesting. I know that MC11 has the better symbolics (with Maple) but was not aware that pure numeric functions also were implemented in a better way and wonder why this changed in later versions.

Basically there is nothing which could be done against the round-off errors themselves as this is a natural conversion effect (0,1 in binary is periodic and has to be cut off somewhere) and a limitation of the IEEE format used to save numbers in numeric mode.

But functions like "Floor" could be written in way so they are aware of this effect and could internally do some clever rounding to avoid it. At least in cases like the one shown here. I guess no matter how clever the function is implemented, it would always be possible to find examples where some error shows up, but it would not be examples with numbers that simple as 2.9 and 0.1.

Here are some more even simpler examples of round-offs. Again in MC15 set to 17 decimal places.

 

LucMeekes
23-Emerald III
(To:Werner_E)

Hmm, it appears that I cannot request 17 decimal places. 15 is the maximum.

But the examples with the (lowecase) floor() functions do show a difference with what you've shown.

Note that the result of the floor() function must be an integer by definition.if the result of 2.9/0.1 would be just below 29, its floor would be 28, not 29.

This:

clipboard_image_0.png

shows that the quotients are spot-on. Or is there something that I'm missing?

 

Luc

So it looks like MC11 does correct in every respect.

Guess the "improvements" made on the way from MC11 to MC15 were larger than I thought.

 

So you cant demand 17 decimals places but just 15 like we can in Prime.

clipboard_image_0.png

 

Hi,

 

It is not really a bug, but a matter of internal precision representation of 0.07 / 0.01 being greater than 7.0000000000000000.

Capture.JPG

Cheers


@terryhendicott wrote:

Hi,

 

It is not really a bug, but a matter of internal precision representation

Guess thats exactly what I wrote above when I mentioned the round-off errors due to conversion from decimal to binary and back (in conjunction with the IEEE format used for internal storage).

The bug is not the lack of precision but the fact, that functions like "Floor" should nonetheless give the correct results with the values shown.

I agree its not a bug as in both versions, real Mathcad and Prime, we have the options to turn off "exact" comparison (as shown in my other answers) and that way get the correct results.

It gets even more crazy!

I open the MC11 file which Luc had attached and opened it with MC15.

As you can see in the screen shot - all calculations are correct now!

Even if I retype from scratch one of the expressions which formerly gave a wrong result, the result now is correct!!

When I open an new sheet and copy the region with the correct result from Luc's sheet to the new one, I get the wrong result again.

My test expression was floor(2.9/0.1) which gives 29 in Luc's sheet and 28 in a sheet created with MC15.

I also saved Luc's sheet with MC15 in xmcdz format and then reloaded it, but the results still are correct!

 

EDIT: Found it!! Silly me - I really should have thought on that from the very beginning!

In real Mathcad one can influence the calculation behavior and in Lucs Sheet in the Worksheet Options the option "Use exact equality for comparison and truncation" was unchecked, while in my sheet this by default was checked.

Unchecking this options makes sense, I guess.

clipboard_image_0.png

 

 

LucMeekes
23-Emerald III
(To:Werner_E)

Mathcad 11 gives me these options:

clipboard_image_0.png

The setting that comes closest to Mathcad 15's "Use exact equality for comparison and truncation"  is the last box: "Use exact equality foor boolean comparisons"

Of course I've tried it. There's no difference in any of the results. Checked or unchecked, I get:

clipboard_image_1.png

I've saved the file now with the box checked. Please check how it translates to Mathcad 15..

 

Luc

Here is what I see when I open your new sheet.

The box is still checked and some results of course are wrong. Unchecking the box talks Mathcad into delivering correct results.

clipboard_image_0.png

The solution is simple.

Check "Approximate Equality" ("Calculation" ribbon, "Calculation Options") and you should get the correct result:

clipboard_image_0.png

clipboard_image_0.png

Very helpful! Thank you Werner. This at least hide the precision error from Mathcad.

tselvan
4-Participant
(To:Alvaro_95)

 
Top Tags