Re: Re: Bug ??????
- To: mathgroup at smc.vnet.net
- Subject: [mg105385] Re: [mg105346] Re: Bug ??????
- From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
- Date: Mon, 30 Nov 2009 06:12:30 -0500 (EST)
- References: <200911291008.FAA16112@smc.vnet.net>
On 29 Nov 2009, at 19:08, Bill Rowe wrote: > On 11/28/09 at 1:07 AM, wkfkh056 at yahoo.co.jp (ynb) wrote: > >> F[x_]:=34880228747203264624081936 - 464212176939061350196344960*x^2 >> + 4201844995162976506469882880*x^4 - >> 36736184611200699915890392480*x^6 + >> 245136733977616412716801297320*x^8 - >> 1144143594851571569661248433072*x^10 + >> 3682862525053500791559515638600*x^12 - >> 8693355704402316431096075720520*x^14 + >> 16394872503384952006491292949865*x^16 - >> 26387316917169915527289585290460*x^18 + ... > > <rest of definition snipped> > >> (* Bug ?; F[Sqrt[Sqrt + 3^(1/3)] + 1/Sqrt[3^(1/3) + 5^(1/5)]] >> //N >> =3.828176627860558*^38<---Bug ? *) > >> (* =0? *) > > This is not a bug. It is inherent when converting things to > machine precision. > > Your definition of F is an alternating sum of large powers of x. > The function N converts each subterm to machine precision then > computes the sum. Loss of precision is inevitable when such a > large dynamic range exists in the terms to be summed as is the > case here. > > Note, this is not a Mathematica issue. Rather it is inherent to > floating point arithmetic used on any computer system. > > To get a simple numerical answer to this problem, there are > several possible approaches. The simplest I can think of would > be either > > > =46[Sqrt[Sqrt + 3^(1/3)] + 1/Sqrt[3^(1/3) + = 5^(1/5)]]//Simplify//N > > or > > N[F[Sqrt[Sqrt + 3^(1/3)] + 1/Sqrt[3^(1/3) + 5^(1/5)]], 100] > > Note neither of these as written above is guaranteed to work. > Usage of Simplify will work *if* the structure of the terms to > be added result in cancellations giving a much simpler prior to > be converted to machine precision. > > The second approach will work if the second argument to N is > made sufficiently large. > > It should work equally well even if the second argument is small. This = is the whole point of significance arithmetic. Compare the answers: In:= N[F[Sqrt[Sqrt + 3^(1/3)] + 1/Sqrt[3^(1/3) + 5^(1/5)]], 3] Out= 1.83*10^10 In:= N[F[Sqrt[Sqrt + 3^(1/3)] + 1/Sqrt[3^(1/3) + 5^(1/5)]], 30] Out= 1.83396597760000000000000000000*10^10 Both of these "work" equally well with respect to the specified accuracy. Andrzej Kozlowski
- Re: Bug ??????
- From: Bill Rowe <firstname.lastname@example.org>
- Re: Bug ??????