Re: Parametric Numerical Integral

• To: mathgroup at smc.vnet.net
• Subject: [mg63133] Re: Parametric Numerical Integral
• From: Peter Pein <petsie at dordos.net>
• Date: Thu, 15 Dec 2005 03:06:42 -0500 (EST)
• References: <dnopgm\$2hb\$1@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Nikola Letic schrieb:
> Hello,
> I have the following problem:
> I define a parametric integral as follows:
> int[p_]:=NIntegrate[If[t == 0, 0,1/(E^((1/2)*(-2 +
> 1/t)^2)*(Sqrt[2*Pi]*t))],{t, -p, p}, MaxRecursion -> 50,WorkingPrecision ->
> 50]
>
> it works fine for numerical values of p such as int[10], but when I try
> something like this:
>
> << NumericalMath`NLimit`
>
> NLimit[int[p], p -> Infinity]
>
> it ends up with error messages:
>
> NIntegrate::nlim: t = 1.00000 p is not a valid limit of integration.
>
> Now I tought that NLimit should also deal only with numerical values, but I
> was wrong. Seems that the way I defined this function above has serious
> limitations in its further usage.
>
> Does any of you Mathematica Gurus know an easy workaround for this?
>
>
> Nikola Letic
>
>

Hi Nikola,

define int[] for numeric arguments only:

Needs["NumericalMath`NLimit`"];
f[t_] := 1/(E^((1/2)*(-2 + 1/t)^2)*(Sqrt[2*Pi]*t));
int[p_?NumericQ] := NIntegrate[f[t], {t, -p, 0, p}, WorkingPrecision -> 50,
MaxRecursion -> 50]

The range {t, -p, 0, p} is a simple way to tell NIntegrate not to evaluate the
function for t==0.

NLimit[int[p], p -> Infinity]
--> 0.639988

If you are just interested in a number, stop reading here.

I construct an expression, which combines the negative and the positive
arguments of f and do a change of variables:

expr = Simplify[(f[t] + f[-t])*Dt[t] /. t -> 1/u /. Dt[u] -> 1]
--> -((-1 + E^(4*u))/(E^((1/2)*(2 + u)^2)*(Sqrt[2*Pi]*u)))

val = Integrate[-expr, {u, 0, Infinity}]
--> (Sqrt[Pi/2]*(I + Erfi[Sqrt[2]]))/E^2

Please, don't ask _me_ where _Mathematica_ found the I (most propably it's the
"i" in "Theorem of Residues"). But the real part happens to be seemingly correct:

N[Re[val], 20]
0.63998807456540892568

Peter

```

• Prev by Date: Re: Re: Remote Mathematica kernels and SSH password
• Next by Date: Re: Mathematica Programmer vs. Programming in Mathematica
• Previous by thread: Re: Parametric Numerical Integral
• Next by thread: Timing differences