Re: A simple error

• To: mathgroup at smc.vnet.net
• Subject: [mg102158] Re: A simple error
• From: Alois Steindl <alois.steindl at jet2web.cc>
• Date: Fri, 31 Jul 2009 05:53:47 -0400 (EDT)
• References: <h4rpen\$l85\$1@smc.vnet.net>

```Youness Eaidgah schrieb:
> Dear all,
> I have faced a awkward situation in Mathematica. I want to sum the following
> simple equations:
>
> DTEP12 = 0.11 (80000 - 12000 P + 800000 (1 - R)) +   0.11 (40000 - 12000 P +
> 1000000 (1 - R)) + 0.28 (-12000 P + 1200000 (1 - R))
> MTEP12 = 0.11 (-130000 + 12000 (-35 + P) + 800000 R) + 0.11 (-130000 + 12000
> (-35 + P) + 1000000 R) + 0.28 (-130000 + 12000 (-35 + P) + 1200000 R)
>
> Obviously, the result of the DTEP12+MTEP12 is : 272200
>
> However, when I use the following commands
>
> Simplify[DTEP12+ MTEP12]   or FullSimplify[DTEP12+MTEP12]
>
> Mathematica returns: 272200.+ 0. P + 5.82077*10^-11 R. I am suprised where
> the last term comes form (5.82077*10^-11 R)! It is a really really small
> value, however, it is still an error. it creates some inconveniences later
> in my calculations. I would appreciate if you could help me out.
> Thank you,
> Youness
>
>
Hello,
question like yours are asked here almost daily:
As soon as you use floating point numbers, rounding errors happen.
In your example you could replace 0.11 by 11/100+eps1 and 0.28 by
28/100+eps2.
You should definitively learn about the calculation with floating point