Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Can't get Mathematica to evaluate correctly a difficult expression

  • To: mathgroup at smc.vnet.net
  • Subject: [mg111558] Re: Can't get Mathematica to evaluate correctly a difficult expression
  • From: Bill Rowe <readnews at sbcglobal.net>
  • Date: Thu, 5 Aug 2010 06:59:51 -0400 (EDT)

On 8/4/10 at 5:51 AM, damien.wyart at free.fr (Damien Wyart) wrote:

>I am using Mathematica 7.0.2 and playing a bit with an expression
>analyzed in the following paper:
>http://www.loria.fr/~zimmerma/papers/cise.pdf

>I tried many constructions with N and SetPrecision and can't get
>Mathematica to output the correct result (I am not very experienced
>with Mathematica). Here is the expression :

>173746*Sin[10^22]+94228*Log[17.1]-78487*Exp[0.42]

>The correct result should be -1.341818958*10^-12 but even forcing
>each term with N and a very large number, I am still not getting
>this value at all.

Actually, the "correct" result for this expression will vary
with different CPUs, different platforms etc. Without being very
specific about hardware and operating system, there is no
assurance whatever you will get the specific value you are expecting.

The problem is due to round off and loss of precision when using
machine precision numbers.

with

In[1]:= $Version

Out[1]= 7.0 for Mac OS X x86 (64-bit) (February 19, 2009)

I get

In[2]:= 173746*Sin[10^22] + 94228*Log[17.1] - 78487*Exp[0.42]

Out[2]= 2.91038*10^-11

I can get the result you are expecting by telling Mathematica to
use exact arithmetic until the final result is converted to a
floating point number. The following result should be repeatable
on all platforms running Mathematica version 7.0.1.

In[3]:= N[
  173746*Sin[10^22] + 94228*Log[171/10] - 78487*Exp[42/100], 16]

Out[3]= -1.341818957829620*10^-12



  • Prev by Date: DiracComb and Fouriertransform
  • Next by Date: Re: automatically include automatic numbering in a cell style
  • Previous by thread: Can't get Mathematica to evaluate correctly a difficult expression
  • Next by thread: Re: Relationship between vertices and indices with GraphDistanceMatrix