Re: calculation error in series
- To: mathgroup at smc.vnet.net
- Subject: [mg125706] Re: calculation error in series
- From: Bob Hanlon <hanlonr357 at gmail.com>
- Date: Thu, 29 Mar 2012 03:03:27 -0500 (EST)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- References: <201203280958.EAA11087@smc.vnet.net>
Close the sum before using the values for w1 or w2 and the results are what you expect. equ1 = 1/2^(n + 1); equ2 = (-1)^k*Binomial[n, k]/E^(k/2); w1 = 14.134725141734695; w2 = Rationalize[w1, 0]; equ3 = Sum[equ1*equ2*Cos[a*k], {n, 0, Infinity}, {k, 0, n}] (Sqrt[E] + 2*E^(1 + I*a) + E^(1/2 + 2*I*a))/ (2*(1 + E^(1/2 + I*a))* (Sqrt[E] + E^(I*a))) equ4 = equ3 // ExpToTrig // FullSimplify (E + Sqrt[E]*Cos[a])/ (1 + E + 2*Sqrt[E]*Cos[a]) {equ3, equ4} /. a -> w1 // Chop {0.730559, 0.730559} {equ3, equ4} /. a -> w2 // N // Chop {0.730559, 0.730559} Bob Hanlon On Wed, Mar 28, 2012 at 5:58 AM, Dana DeLouis <dana01 at me.com> wrote: >> ... Is it the result of an accumulated imprecision ... > > Hi. Just for fun, here's an opposite view, where we think we have precise input. > I've never understood the algorithm, but it appears that if the input has a large numerator or denominator, then this situation appears to change the algorithm. > Here are 2 examples. > > You had 2 sum functions, so just to be different, I'll use one. > First, we adjust your posted equations: > > equ1=Divide[1,Power[2,(n+1)]]; > equ2=(Power[-1,k](Binomial[n,k]E^(-(k/2)))); > > Sum[equ1*equ2,{n,0,Infinity},{k,0,n}] > > Sqrt[E]/(1+Sqrt[E]) > > The above checks with what you have. > > Here are 2 numbers, that are considered (almost) equal. > > w1=14.134725141734695; > w2=Rationalize[w1,0]; > > w1==w2 > True > > One might think w2 would produce the more accurate answer. However, the algorithm gives different answers. > > Sum[equ1*equ2*Cos[w1*k],{n,0,Infinity},{k,0,n}] //Chop > 0.730559 > > Sum[equ1*equ2*Cos[w2*k],{n,0,Infinity},{k,0,n}] //N > 0.36528 +0.221225 I > > Here are 2 numbers that are as close together as possible. > Yet, they give different answers. > > w1=(2/3)-$MachineEpsilon; > w2=Rationalize[w1,0]; > > w1==w2 > True > > Sum[equ1*equ2*Cos[w1*k],{n,0,Infinity},{k,0,n}] //Chop > 0.636162 > > Sum[equ1*equ2*Cos[w2*k],{n,0,Infinity},{k,0,n}] //N//Chop > 0.318081 +0.0807899 I > > = = = = = = = = = = = = > I just find it interesting > HTH :>) > Dana DeLouis > Mac & Math 8 > = = = = = = = = = = = = > > > On Mar 24, 3:04 am, Maurice Coderre <mauricecode... at gmail.com> wrote: >> In[52]:= \!\( >> \*UnderoverscriptBox[\(\[Sum]\), \(n = 0\), \(\[Infinity]\)]\( >> FractionBox[\(1\), >> SuperscriptBox[\(2\), \((n + 1)\)]] \( >> \*UnderoverscriptBox[\(\[Sum]\), \(k = 0\), \(n\)]\(( >> SuperscriptBox[\((\(-1\))\), \(k\)] \((\(( >> \*FractionBox[\(n!\), \(\(\((n - k)\)!\) \(k!\)\)])\) >> \*SuperscriptBox[\(E\), \(- >> \*FractionBox[\(k\), \(2\)]\)]\ )\) Cos[14.134725141734695 k])\)\)\) >> \) >> >> Out[52]= 0.730559318177 + 5.55111512313*10^-17 I >> >> In[53]:= \!\( >> \*UnderoverscriptBox[\(\[Sum]\), \(n = 0\), \(\[Infinity]\)]\( >> FractionBox[\(1\), >> SuperscriptBox[\(2\), \((n + 1)\)]] \( >> \*UnderoverscriptBox[\(\[Sum]\), \(k = 0\), \(n\)]\(( >> SuperscriptBox[\((\(-1\))\), \(k\)] \((\(( >> \*FractionBox[\(n!\), \(\(\((n - k)\)!\) \(k!\)\)])\) >> \*SuperscriptBox[\(E\), \(- >> \*FractionBox[\(k\), \(2\)]\)]\ )\))\)\)\)\) >> >> Out[53]= Sqrt[E]/(1 + Sqrt[E]) >> >> Why does the insertion of a purely real trigonometric function in a >> purely real infinit series, as shown above, give a complex result? Is >> it the result of an accumulated imprecision in the numerical >> evaluation?
- References:
- Re: calculation error in series
- From: Dana DeLouis <dana01@me.com>
- Re: calculation error in series