[Date Index]
[Thread Index]
[Author Index]
Re: Can't get Mathematica to evaluate correctly a
*To*: mathgroup at smc.vnet.net
*Subject*: [mg111618] Re: Can't get Mathematica to evaluate correctly a
*From*: Bill Rowe <readnews at sbcglobal.net>
*Date*: Sat, 7 Aug 2010 06:22:04 -0400 (EDT)
On 8/6/10 at 6:56 AM, toniivas at gmail.com (Toni Ivas) wrote:
>Still something is strange with Mathematica 7.0 as my output shows:
<results/code snipped>
>After first evaluating without forcing with N[*,prec] Mathematica
>gives wrong answer
You are missing the point. The fact you get a result like
In[13]:= 173746*Sin[10^22] + 94228*Log[17.1] - 78487*Exp[0.42]
Out[13]= 2.91038*10^-11
has essentially nothing to do with Mathematica. This type of
result will occur in *any* software capable of doing the same
computation. The result is a direct consequence of using
floating point arithmetic. The exact value you get depends on
details of the FPU hardware you are using.
This is a wrong answer with respect to the true mathematical
answer using infinite precision numbers. But it is not wrong
answer with respect to floating point arithmetic. It is inherent
to the way floating point arithmetic works on any computer.
All three of the terms in the sum have values on the order of
10^5. You are looking for an answer on the order of 10^-12. You
simply cannot achieve the accuracy you are asking for in any
valid computation when you start with numbers with only 16 digit
precision. And in Mathematica, whenever you explicitly type a
decimal point in a number without explicitly specifying the
precision of that number you will be using machine precision
numbers that have approximately 16 digit precision. The
advantage of machine precision arithmetic is it is all done in
hardware and is the fastest possible computation
A result like:
In[14]:= N[
173746*Sin[10^22] + 94228*Log[171/10] - 78487*Exp[42/100], 16]
Out[14]= -1.341818957829620*10^-12
has a lot to do with Mathematica. This result takes advantage of
Mathematica's ability to do arbitrary precision arithmetic
something many other computational software packages cannot
easily do.
Mathematica gives you a choice. You can choose speed an accept
whatever accuracy is possible using your hardware. Or you can
sacrifice speed and choose whatever accuracy you want. It is up
to you to choose wisely.
Prev by Date:
**Re: A new graphic user interface**
Next by Date:
**Re: assuming certain properties about variables**
Previous by thread:
**Re: Can't get Mathematica to evaluate correctly a**
Next by thread:
**Re: Can't get Mathematica to evaluate correctly a difficult**
| |