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:= N[[FullSimplify[Cosh[(43*Pi)/Sqrt] + (1 - Cosh[43*Sqrt*Pi])*Csch[43*Sqrt*Pi]* Sinh[(43*Pi)/Sqrt]]],50] Out= 6.5517875178543440140500579682357879451030334737036144280\ 42203561`50.*^-42 No problem here. Now In:= N[Cosh[(43*Pi)/Sqrt] + (1 - Cosh[43*Sqrt*Pi])* Csch[43*Sqrt*Pi]*Sinh[(43*Pi)/Sqrt], 50] Internal precision limit $MaxExtraPrecision =`50. reached while evaluating .... Out= 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:= > \!\(\(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, > >
- //N bug, but WHY?
- From: "symbio" <firstname.lastname@example.org>
- //N bug, but WHY?