0

When using Mathematica, the following expression is given:

In[429]:= 100*(1 - 0.002)^5*(1 - 0.005)*(1 - 0.006)*3.5
Out[430]= 342.7127137548418

I tried using N[], SetPrecision[] etc.. and couldn't get the real value which is 342.712713754841762864 according to the website.

How do I prevent Mathematica from rounding the result?

prgDevelop
  • 1,557
  • 2
  • 15
  • 26
  • You could use `N[100*(1 - 2/1000)^5*(1 - 5/1000)*(1 - 6/1000)*35/10, 30]`, or provide the input with greater precision. – b.gatessucks Nov 09 '13 at 13:08
  • But why does Mathematica round my result as soon as I'm using float values? I still want to be able to use decimal values AND get a precise result. How do I provide input with a greater precision? Because SetPrecision doesn't seem to do the trick. – prgDevelop Nov 09 '13 at 13:13
  • I mean, the website seems to handle my expression very well. Why won't Mathematica do the same? – prgDevelop Nov 09 '13 at 13:18
  • this is well addressed in the last question you asked..http://stackoverflow.com/questions/19864033/python-decimal-decimal-precision-doesnt-match-wolfram-alphas/19876715#19876715 – agentp Nov 09 '13 at 14:10

2 Answers2

1

Idk, whether you have already found the answer but you can just FullForm of your expression. I am really in shock that it is so difficult in my case compute accurately 4852.95 + 14000.

0

You can, but shouldn't.

If you want extra precision on your results, you can enter 123.456`digits of precision on all of your decimal numbers to set the precision of them and their results. This would turn your original expression into something such as 100*(1 - 0.002`25)^5*(1 - 0.005`25)*(1 - 0.006`25)*3.5`25, which gives the expected result of 342.7127137548417628640000. Note however, that Mathematica mainly works well with explicit rational numbers, such as 1/200, for getting exact results. However, beyond the precision, I have seen no other problems inherent in floating-point values.

Community
  • 1
  • 1
LegionMammal978
  • 680
  • 8
  • 15