MathGroup Archive 2005

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

Search the Archive

Re: //N bug, but WHY?

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:

N[[FullSimplify[Cosh[(43*Pi)/Sqrt[2]] +
     (1 - Cosh[43*Sqrt[2]*Pi])*Csch[43*Sqrt[2]*Pi]*


No problem here.


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


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?