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

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

Mathcad provides incorrect solution

jfluckey
1-Newbie

Mathcad provides incorrect solution

Mathcad is adding a very small number to my results. There is no explaination for it. I am using Mathcad 14.

I have attached both the Mathcad file and a PDF (in case you are not running v14).

If you don't feel like downloading the attachments, this is the jist of what is happening:

Why would Mathcad add in that 10^(-14)? The problem is I want to do something similar to the following: . My equations don't work with imaginary numbers!

I tried increasing the Worksheet Options to 1e-020 for both TOL and CTOL and neither corrected the problem. What is happening?!??!?!

32 REPLIES 32
RichardJ
19-Tanzanite
(To:jfluckey)

I don't know if this will negatively affect me anywhere else, but it fixes this problem.

I doubt it. The option is there because sometimes an exact comparison is needed, but that's not ever likely to be the case in engineering problems. I'm not sure that I have ever needed to turn it on.

I guess it was said before, but all I see is the effect of rounding and conversion as is to expect when dealing with computer floating point arithmetic. There is no simple way to avoid it and assuming the everthing within a distance of 10^-16 IS an integer would be even worse.

Computer numbers are finite and the usual rules for real numbers do not apply - not even the commutative law is valid here. What you demand is basically infinite precision which is not possible in computer FP arithmetic.

There are specialist programs around which, e.g. store every number they deal with as a fraction of integers (theoretically of infinite length, but of course limited by available memory). Those programs also have to care to avoid conversion errors which stem from Dec to Bin and to Dez again by storing those numbers in a special format (BCD or whatever). And then those programs have to implement every simple and not so simple arithmetic, beginning with basic addition up to any functions implemented to work with those special format numbers. All these would heavily slow down any iteration routine or whaterver you do, so I'd never expect that kind of feature from a numeric calculation program like Mathcad.

That in contrary to symbolc Math - her I am disappointed about Mathcads/MuPads only 250 decimals limit. But then - its an all purpose program and given that, thas not bad at all.

So - no - I in no way can be pushed to call the effect you show being an error. In my opinion every engineer has to know his tools and how to use them the right way. Doing a series of calculations with a couble of numbers (unit conversion, divisions, multiple storing, etc.) and then hoping that the outcome is still an exact integer just because it should be, is too much demanding. While I can understand your disappointment to some degree - asking if that calculated number is exactly 7 is more kind of an inproper or inappropriate use of a tool IMHO.

I am sure you know how to deal with the problem (not asking for exact equality but if its in a small eps neighbourhood, or rounding the number to 12 decimals if you are sure you won't need more precision,...) but you simply feel it should not be necessary to deal with that "problem" yourself.

Mathacds developers have implemented a switch for useres like you which may solve your problem, at least itd does in your example sheet: Goto Menu - Tools/Worksheet Options/Calculation tab and uncheck "Use exact equality for comparisons and truncation". This won't make your vector element an integer, but the if-statement will yield "integer" if set that way.

RichardJ
19-Tanzanite
(To:jfluckey)

Fortunately, the writers of Mathcad were aware of the limits of numerical computing.

index.png

Top Tags