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

  • To: mathgroup at smc.vnet.net
  • Subject: [mg111579] Re: Can't get Mathematica to evaluate correctly a
  • From: Toni Ivas <toniivas at gmail.com>
  • Date: Fri, 6 Aug 2010 06:56:30 -0400 (EDT)

Dear Bill and Damien

Still something is strange with Mathematica 7.0 as my output shows:

In[50]:== $Version

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

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

Out[54]== 2.91038*10^-11

In[55]:== N[173746*Sin[10^22] + 94228*Log[17.1] - 78487*Exp[0.42], 20]

Out[55]== 2.91038*10^-11

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

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

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

Out[57]== -1.3418189578296195497*10^-12

After first evaluating without forcing with N[*,prec] Mathematica
gives wrong answer
but then on trying to evaluate expression with precision 20 it gives
same answer,
and finally trying with 16 (maybe MachinePrecision) it gives correct
answer, all subsequent
evaluation with higher precision give correct answer :)

Best,
Toni

On Thu, Aug 5, 2010 at 12:59 PM, Bill Rowe <readnews at sbcglobal.net> wrote:
> 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: Re: automatically include automatic numbering in a
  • Next by Date: Re: AxesLabel parallel to 3D axes?
  • Previous by thread: Re: Can't get Mathematica to evaluate correctly a
  • Next by thread: Re: Can't get Mathematica to evaluate correctly a