Re: calculation error in series
- To: mathgroup at smc.vnet.net
- Subject: [mg125648] Re: calculation error in series
- From: Peter Pein <petsie at dordos.net>
- Date: Sun, 25 Mar 2012 00:16:23 -0500 (EST)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- References: <jkjrlc$435$1@smc.vnet.net>
Am 24.03.2012 08:04, schrieb Maurice Coderre: > 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? > Hi Maurice, one can not expect exact results from inexact input. You can get rid of the floatingpoint-noise by applying Chop to the result or - preferably - by calculating the sum for an exact constant and replacing the approximate value later: In[3]:= Sum[(1/2^(n + 1))* Sum[(-1)^k*(n!/E^(k/2))*Cos[c*k]/ ((n - k)!*k!), {k, 0, n}], {n, 0, Infinity}]//ExpToTrig//FullSimplify Out[3]= (E+Sqrt[E] Cos[c])/(1+E+2 Sqrt[E] Cos[c]) In[4]:= %/.c->14.134725141734695 Out[4]= 0.730559 Peter P.S.: please use "Copy as Plain Text" (Shift-Strg-C) to copy/paste parts of your notebooks. Thanks