MathGroup Archive 2005

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

Search the Archive

Re: //N bug, but WHY?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg58644] Re: [mg58634] //N bug, but WHY?
  • From: Andrzej Kozlowski <akozlowski at gmail.com>
  • Date: Tue, 12 Jul 2005 05:21:29 -0400 (EDT)
  • References: <200507110819.EAA22908@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Actually, however strange it may seem, there is no bug involved here  
at all. You are using machine precision arithemtic and it is quite  
normal for machine precision arithemtic to give quite different  
answers two algebraically equivalent expressions if one (or both) is  
"ill conditioned".  It is quite often the case that one form of an  
expression is "ill conditioned" and machine precision will give you  
an answer that is way off while another form is "well conditioned"  
and you will get a pretty good answer even with machine precision.

You can see quite clearly how this happens here. Just evaluate the  
same expression but using bignum arithmetic with reasonable precision:

In[1]:=
N[[FullSimplify[Cosh[(43*Pi)/Sqrt[2]] +
     (1 - Cosh[43*Sqrt[2]*Pi])*Csch[43*Sqrt[2]*Pi]*
      Sinh[(43*Pi)/Sqrt[2]]]],50]

Out[1]=
6.5517875178543440140500579682357879451030334737036144280\
42203561`50.*^-42

No problem here.

Now

In[2]:=
N[Cosh[(43*Pi)/Sqrt[2]] + (1 - Cosh[43*Sqrt[2]*Pi])*
     Csch[43*Sqrt[2]*Pi]*Sinh[(43*Pi)/Sqrt[2]], 50]


Internal precision limit
$MaxExtraPrecision =`50.  reached while evaluating
....

Out[2]=
6.551787517854344014050058`14.31640268976547*^-42

The answers are very close but the message tells you that the second  
expression is ill conditioned and even high precision aritmetic is  
having problems with it. Thus there is no bug here at all, it is just  
one of the "facts of life" one has to live with.

Andrzej Kozlowski

Chiba, JAPAN




On 11 Jul 2005, at 17:19, symbio wrote:

> Evaluating (using //N) two exact same expressions, gives wrong  
> answer unless
> fullsimplify is used first, I spent 2 days on a problem thinking my  
> answer
> was wrong, but turned out Mathematica 5 was giving me buggy answers, I
> debugged it to this point, but WHY in the world is this happening?   
> Please
> help!!!
>
> cut and paste below to see the test case:
>
> In[243]:=
> \!\(\(Cosh[\(43\ \[Pi]\)\/\@2] + \((1 - Cosh[43\ \@2\ \[Pi]])\)\ Csch[
>             43\ \@2\ \[Pi]]\ Sinh[\(43\ \[Pi]\)\/\@2] //  
> FullSimplify\) //
>     N\[IndentingNewLine]
>   Cosh[\(43\ \[Pi]\)\/\@2] + \((1 - Cosh[43\ \@2\ \[Pi]])\)\ Csch[
>           43\ \@2\ \[Pi]]\ Sinh[\(43\ \[Pi]\)\/\@2] // N\)
> Out[243]=
> \!\(6.551787517854307`*^-42\)
> Out[244]=
> \!\(\(-1.9342813113834067`*^25\)\)
>
>
>
> thanks,
>
>


  • Prev by Date: Re: superscripts
  • Next by Date: Fw: Re: Set of strings reducing problem
  • Previous by thread: //N bug, but WHY?
  • Next by thread: Re: //N bug, but WHY?