Re: A simple error
- To: mathgroup at smc.vnet.net
 - Subject: [mg102173] Re: [mg102140] A simple error
 - From: Bob Hanlon <hanlonr at cox.net>
 - Date: Fri, 31 Jul 2009 05:56:59 -0400 (EDT)
 - Reply-to: hanlonr at cox.net
 
If you want exact results you need to use exact numbers rather than machine precision numbers. Use Rationalize
TEP12 = 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);
Total[Rationalize[{TEP12, MTEP12}, 0]] // Simplify
272200
Alternatively, use Chop
TEP12 + MTEP12 // Simplify // Chop
272200.
Bob Hanlon
---- Youness Eaidgah <y.eaidgah at gmail.com> wrote: 
=============
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