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

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

stupid mistakes whith Huge numbers

ptc-5222288
1-Newbie

stupid mistakes whith Huge numbers

See proof please:

http://img42.imageshack.us/img42/1897/e9kg.png

As you can see , Graph must be as y=0 (after cancellation). But I've got 2 different graphs and both of them are not a line y=0. Why???

5 REPLIES 5
Werner_E
25-Diamond I
(To:ptc-5222288)

testfirstname testlastname wrote:

See proof please:

http://img42.imageshack.us/img42/1897/e9kg.png

Proof what?

"testxxxxname", what did you expect? You are using numerical math and therefore should be prepared for numerical round off errors.

See attached that the error is just in the range of 10^-14 % - pretty good, I think.

See also two different ways to deal with the "problem", while the most obvious would be to cancel beforehand (I let Mathcads symbolics do the work) or apply some scaling.

test(2).png

But Mathcad can operate with much more numbers ( up to 10^307 http://img707.imageshack.us/img707/7990/w6je.png ). So how to control accuracy? And how I know , that Mathcad suddenly generates mistakes? Calculations not always is so simple , that can be simplify to y=0 or checked by calculator (using calculator to check Mathcad is stupid).

How digits after decimal comma Mathcad takes to calculations? 17 ? Why not 307 ? How to control it?

Werner_E
25-Diamond I
(To:ptc-5222288)

testfirstname testlastname wrote:

no wish to change the display name?

But Mathcad can operate with much more numbers ( up to 10^307

Thats right (even more than 10^307, precisely 10^1024-1=1.797*10^308, its just Mathcads error message which mentions the 10^307), but that does not mean you will get a307 digit precision with your calculations. The range of numbers we can deal with does not say anything about the accuracy - it depends on how the overall bits are distributed on mantissa and exponent. More bits for mantissa - more accuracy but smaller magnitudes. But no matter how many bits you will reserve - calculations with "computer numbers" will be inaccurate.

So how to control accuracy? And how I know , that Mathcad suddenly generates mistakes?

You can't. You don't. Thats bad but if it would be that easy any program could correct its errors and produce 100% accurate results which is not possible. You as a user have to be aware of those effects and you may countersteer in some cases, like scaling down (or up) your numbers, etc.

In MC sometimes using the symbolic eval help, but its not applicable in any situation. Its hard to say when you will run into numerical errors (unless you follow the fatalistic way and accept it will happen anytime and anywhere). If you change the 1.1 to 1.2 in the following example you will get a difference of perfect 0.

numerr1.png

The mathematical theory of numerical errors/numerical analysis is not an easy one and is closely related to the effect that the use of (inaccurate and usually truncated) measured data may have on the overall accuracy of a calculation. Sure not a trivial task to provide ranges the "real" (whatever that may be) result would be in with a certain probability, etc.

Numerical errors occur for different reasons, a finite set of numbers used with a finite precision, truncation errors (a sine is calculated by an infinite series expansion - it had to be truncated for obvious reasons), digitalisation errors (1.1 has just two digits in base 10, but an infinite number of digits in base 2 - its representation has to be truncated, unless you use something like BCD arithmetic).

Because the numbers used in computer arithmetic are so different (discrete, finite, ...) from the real numbers we usually think of, some simple mathematical laws we are used to do not apply. E.g. the commutative law of summation. As you can see in the example below, the order of the summands matters and influences (slightly in this case) the result.

numerr2.png

Sometimes people would come up with clever algorithms to overcome some single undesirable effects (e.g. Kahan summation algorithm), but in general you can be sure that computer arithmetic is not accurate and 100% precise - this applies to your clever pocket calculator, too 😉

How digits after decimal comma Mathcad takes to calculations? 17 ? Why not 307 ? How to control it?

You can set the result to DISPLAY up to 17 digits, which does not affect calculation precison. Why not 307 - guess because it would not make much sense to display that many (in most cases probably random) digits. Just because you see 100 decimal places does not mean the third one is still corect. Its always funny (and sad) to see students writing down all ten or twelve digits from their calculator display after calculations with measured data with a precison of just two decimal places. Thats some kind of lack of understanding, too.

If you really need to see more digits use symbolic eval (just up to 250, I think).

pi.png

For small numbers you additionally can set the zero threshold from the default 15 up to 307. This will show you a result different from zero sometimes where you otherwise would just see 0. But there is no way to control the precision of calculation - Mathcads numeric will calculate the same in every case.

Thats a big difference to symbolic evaluation. If you use the keyword "float", the precison you indicate affects the whole calculation. Thats quite dangerous and therefor its usually adviseable not to use "float" in symbolic evals at all.

You may search the net for "numerical errors" "numerical anlysis", etc. for further reading.

Mass of Ariane rocket to Mass of Earth is 1.3002008032128516*10^-19 so it's even less then error 10^-14 . So I don't think that error 10^-14 is pretty good. As I see Mathcad is inapplicable for space calculations.

Second, I think it's that stepped graph in my first attachment is very bad . If error - graph would be smooth curve , errors will compensate each other. But because of stepped appearance of errors , they are absolutely uncontrolled

Werner_E
25-Diamond I
(To:ptc-5222288)

testfirstname testlastname wrote:

Mass of Ariane rocket to Mass of Earth is 1.3002008032128516*10^-19

Do you think it makes much sense from an engineering point of view to specify that many decimal places? Which of all those digits would be the last you really could rely on? What accuracy do you expect from the mass of earth or the mass of Ariane (which you seem to specify with about 777 tons) you used in that calculation. Just because a calculator gives you twnty significant digits on the display this does not mean that the third one is stil valid. That depends on the input data and the sort of calculations being done.

BTW, the 10^-14 was the error in % and if thats accaptable for your calculation or not is of course your decision. And if you have a better tool for your needs, by any means, use it!

But IMHO 10^-14% off is a good value for a numeric calculation. Mathcad, BTW, would have no problems at all calculating the ratio Ariane/Earth, but sure would not be able to resolve the simple difference of the two. (diff:=m.earth-m.ariane m.earth-diff will be zero, not m.ariane).

I am not sure but I guess that some experts may disagree with your statment of Mathcad being inapplicabe for "space calculation", whatever calcs you may have in mind by this expression.

And at the end a tool is only as good as its user. And a user of any number crunching software should have some knowledge about numerical errors/analysis, should be aware of them and should know how to circumvent the negative effects of them if necessary.

Mostly not pure "space calculations" but maybe you are interested in the way Mathcad is used at the NASA: http://ntrs.nasa.gov/ search for "Mathcad".

Announcements

Top Tags