MathGroup Archive 2012

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: calculation error in series

  • To: mathgroup at smc.vnet.net
  • Subject: [mg125646] Re: calculation error in series
  • From: Bob Hanlon <hanlonr357 at gmail.com>
  • Date: Sun, 25 Mar 2012 00:15:41 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <201203240702.CAA04167@smc.vnet.net>

expr = Sum[1/2^(n + 1)
   Sum[(-1)^k  Binomial[n, k] E^(-k/2) Cos[a k],
    {k, 0, n}], {n, 0, Infinity}]

(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)))

Note that the internal algorithms produce a representation that
includes I. Numerical evaluation with this representation can produce
a complex artifact.

expr /. a -> 14.134725141734695

0.7305593181773564 -
   5.551115123125783*^-17*I

The simplest approach is just to use Chop to eliminate the artifact

% // Chop

0.7305593181773564

Alternatively,

expr // ExpToTrig // FullSimplify

(E + Sqrt[E]*Cos[a])/(1 + E +
      2*Sqrt[E]*Cos[a])

% /. a -> 14.134725141734695

0.7305593181773565


Bob Hanlon


On Sat, Mar 24, 2012 at 3:02 AM, Maurice Coderre
<mauricecoderre 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?
>



  • Prev by Date: Re: OpenCL OpenCLFractalRender3D invalid binary error
  • Next by Date: Convert string to number
  • Previous by thread: calculation error in series
  • Next by thread: Re: calculation error in series