       Re: Integration or Evaluation Bug

• To: mathgroup at smc.vnet.net
• Subject: [mg69378] Re: Integration or Evaluation Bug
• From: p-valko at tamu.edu
• Date: Sat, 9 Sep 2006 03:27:00 -0400 (EDT)
• References: <edqq3j\$srp\$1@smc.vnet.net>

```> Assuming[t > 1/1000, Integrate[Exp[-w] Cos[w t] / (w^2+1),{w,0,1000}]]
> Plotted as a function of t, this is incorrectly growth instead of decay.

You are certainly right that something is fishy (in Integrate). Let me
tell you how I usually work around such complicated bugs and still get
the right symbolic answer. I call this "the Catalan trick".
I put an exact number instead of the parameter t, but only temporarily,
while Integrate[] is doing its duty. In most of my cases the parameter
should be between 0 and 1 so I use Catalan, and in your case it works
too, because it is bigger than 1/1000.  After the job and some
simplifications are done, I replace back the original parameter. (This
might be the general idea behind the Refine[] function too, but I like
to do it myself.)  So in your case:

f1[t_] = FullSimplify[ComplexExpand[Integrate[Exp[-w]Cos[Catalan
w]/(w^2 + 1), {w, 0, 1000}]]] /. Catalan -> t;

The result is
(E^(-I - t)*(E^(2*t)*(2*(1 + E^(2*I))*Pi - I*(-ExpIntegralEi[I - t] +
ExpIntegralEi[(-1 - 1000*I)*(-I + t)] +
E^(2*I)*(ExpIntegralEi[-I - t] -
ExpIntegralEi[(-1 + 1000*I)*(I + t)]))) -
I*(E^(2*I)*(ExpIntegralEi[-I + t] - ExpIntegralEi[(1 - 1000*I)*(-I +
t)]) -
ExpIntegralEi[I + t] + ExpIntegralEi[(1 + 1000*I)*(I + t)])))/4

and it is the the correct symbolic answer to your problem.  It decays
like a charm.

In:
t0=89+5/100;
N[f1[t0],20]//Chop
NIntegrate[Exp[-w]Cos[t0
w]/(w^2+1),{w,0,1000},WorkingPrecision\[Rule150, AccuracyGoal \[Rule]
20]

Out:
0.000126184671187050862020
0.00012618467118705086

I hope this trick helps.

Best Regards,
Peter

Chris H. Fleming wrote:
> I have found what is either a bug in integration or evaluation of
> exponential integrals and boiled it down to this simple example
>
> NIntegrate[Exp[-w] Cos[w t] / (w^2+1),{w,0,1000}]
>
> Plotted as a function of t, this is correctly oscillatory decay
>
> Assuming[t > 1/1000, Integrate[Exp[-w] Cos[w t] / (w^2+1),{w,0,1000}]]
>
> Plotted as a function of t, this is incorrectly growth instead of
> decay.
>
> The analytic answer has all terms like Exp[stuff t] Ei[-stuff t]
> If stuff was real, that would decay like 1/(stuff t)
>
> So I don't know if it's an integration bug or a bug in Ei evaluation

```

• Prev by Date: Re: Simplify UnitStep expressions
• Next by Date: Re: Re: RE: Re: Dot Product in Cylindrical Coordinates
• Previous by thread: Integration or Evaluation Bug
• Next by thread: Exporting text to (or in) vector graphics as "sentences"?