Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

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

Search the Archive

Re: //N bug, but WHY?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg58645] Re: [mg58634] //N bug, but WHY?
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Tue, 12 Jul 2005 05:21:30 -0400 (EDT)
  • Reply-to: hanlonr at cox.net
  • Sender: owner-wri-mathgroup at wolfram.com

expr=Cosh[(43*Pi)/Sqrt[2]]+(1-Cosh[
          43*Sqrt[2]*Pi])*Csch[43*Sqrt[2]*Pi]*Sinh[(43*Pi)/Sqrt[2]];

You are trying to take the difference of two very large numbers. Precision is 
an issue

term1=expr[[1]]

Cosh[(43*Pi)/Sqrt[2]]

term2=expr[[2]]

(1 - Cosh[43*Sqrt[2]*Pi])*Csch[43*Sqrt[2]*Pi]*Sinh[(43*Pi)/Sqrt[2]]

term1//N

1.526301024376754*^41

term2//N

-1.5263010243767541*^41

%+%%

-1.9342813113834067*^25

expr//N

-1.9342813113834067*^25

Using explicit precision will eliminate the problem

N[expr,20]

6.55178751785434401405005796823578794`20.*^-42

However, if you simplify, there is only one small term

FullSimplify[expr]

Sech[(43*Pi)/Sqrt[2]]

%//N

6.5517875178544*^-42


Bob Hanlon

> 
> From: "symbio" <symbio at has.com>
To: mathgroup at smc.vnet.net
> Date: 2005/07/11 Mon AM 04:19:20 EDT
> Subject: [mg58645] [mg58634] //N bug, but WHY?
> 
> 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: //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?