       Re: //N bug, but WHY?

• To: mathgroup at smc.vnet.net
• Subject: [mg58649] Re: //N bug, but WHY?
• From: Peter Pein <petsie at dordos.net>
• Date: Tue, 12 Jul 2005 05:21:33 -0400 (EDT)
• References: <data3n\$mec\$1@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```symbio schrieb:
> 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:=
> \!\(\(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=
> \!\(6.551787517854307`*^-42\)
> Out=
> \!\(\(-1.9342813113834067`*^25\)\)
>
>
>
> thanks,
>
The simplified expression is Sech[(43*Pi)/Sqrt], wich is - with
respect to numeric evaluation - completely different from
Cosh[(43*Pi)/Sqrt] + (1 - Cosh[43*Sqrt*Pi]) * Csch[43*Sqrt*Pi]
* Sinh[(43*Pi)/Sqrt]], where rounding errors occur, which are "blown
up" by the large numbers (Exp[43*Pi/Sqrt] is about 3*10^41). You
can't expect a correct result using 16-digit numerics. Try instead:

Block[{\$MaxExtraPrecision = 86},
N[Cosh[(43*Pi)/Sqrt] + (1 -
Cosh[43*Sqrt*Pi])*Csch[43*Sqrt*Pi]*Sinh[(43*Pi)/Sqrt],
\$MachinePrecision]]

this will give you:

6.551787517854344014050058*10^-42

--
Peter Pein
Berlin
http://people.freenet.de/Peter_Berlin/

```

• Prev by Date: Re: //N bug, but WHY?
• Next by Date: Re: //N bug, but WHY?
• Previous by thread: Re: //N bug, but WHY?
• Next by thread: Re: //N bug, but WHY?