Re: Simple question or how Mathematica getting on my nerves.
- To: mathgroup at smc.vnet.net
- Subject: [mg45862] Re: Simple question or how Mathematica getting on my nerves.
- From: drbob at bigfoot.com (Bobby R. Treat)
- Date: Tue, 27 Jan 2004 04:51:32 -0500 (EST)
- References: <butdvt$9se$1@smc.vnet.net> <bv006g$jc9$1@smc.vnet.net> <bv2f57$2r$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Surely someone will come up with a better example, but here are several computations of the identical (in theory) expression. Change k, and you'll see various behaviors. The first element of the output list is accurate to as many places as shown. The others are wrong to varying degrees. I didn't use Sum, because it adds in a smart order; I wanted to control things. (try setting addTable=Sum) The really curious thing is that the third and fourth results should be identical (I think) but they aren't! Also, using Attributes[addTable] = {HoldAll} changes several answers. add[x_List] := (For[sum = 0; i = 1, i <= Length[x], i++, sum += x[[i]]]; N[sum]) Attributes[addTable] = {}; addTable[x__] := add[Table[x]] first = 20; last = 40; k = 20; a = 20/9; InputForm[ N[{addTable[a^(-n) - (a + 10^(-k))^(-n), {n, first, last}], addTable[N[a^(-n)] - N[(a + 10^(-k))^(-n)], {n, first, last}], add[Table[ N[a^(n - first - last)] - N[(a + 10^(-k))^ (n - first - last)], {n, first, last}]], addTable[ N[a^(n - first - last)] - N[(a + 10^(-k))^ (n - first - last)], {n, first, last}], addTable[N[a^(-n)], {n, first, last}] - addTable[N[(a + 10^(-k))^ (-n)], {n, first, last}], addTable[ N[a^(-n)] - N[(a + 10^(-k))^ (n - first - last)], {n, first, last}]}]] {1.9748897304222703*^-26, 0., 9.137784495123884*^-24, 0., 0., -1.3234889800848443*^-23} Bobby Harold.Noffke at wpafb.af.mil (Harold Noffke) wrote in message news:<bv2f57$2r$1 at smc.vnet.net>... > Bob: > > In your reply to George you wrote ... > > > Although NIntegrate works without explicitly increasing the precision. > > So the precision is impacted by the sequencing of the calculations. > > > > NIntegrate[k[f], {f, 0.6214, 0.5242}] > > > > -0.139838 > > Can you explain what you meant by "sequencing of the calculations"? I > calculated the integral shown above after restarting Mathematica, and > I obtained the answer shown above. > > Regards, > Harold