       Re: Re: Evaluating integral with varying upper limit?

Carl Woll wrote:

>AES wrote:
>
>
>
>>Given a function  f[x]  which happens to be rather messy and not
>>analytically integrable, I want to evaluate the function
>>
>>  g[y_] := NIntegrate[f[x], {x, ymin, y} ]
>>
>>with ymin fixed and  ymin < y < Infinity.
>>
>>I suppose that FunctionInterpolate is the way to go here (???).
>>
>>But, are there tricks to tell FunctionInterpolate what I know in
>>advance, namely that f[x] is everywhere positive, and decreases toward
>>zero rapidly enough at large x that g[y] will approach a finite limiting
>>value as y -> Infinity? (which value I'd like to have FI obtain with
>>moderate accuracy -- meaning 3 or 4 significant digits, not 10 or 20)
>>
>>Thanks . . .
>>
>>
>>
>>
>I would recommend using NDSolve to invert the NIntegrate operation,
>although handling the range ymin<y<Infinity is problematic. For example:
>
>In:=
>f[x_]:=BesselJ[2,x]Exp[-x]
>In:=
>g[y_]:=NIntegrate[f[x],{x,1,y}]
>
>Then, using NDSolve we have:
>
>In:=
>NDSolve[{h'[x] == f[x], h == 0}, h, {x, 1, 100}]
>Out=
>{{h -> InterpolatingFunction[{{1., 100.}}, <>]}}
>
>A few checks:
>
>g
>h /. %5[]
>0.102135
>0.102135
>
>g
>h /. %5[]
>0.102141
>0.102141
>
>
>g[Infinity]
>0.102141
>
>If you really need an InterpolationFunction whose range is ymin to
>Infinity, then you can try transforming variables, like y->1/y, but
>getting NDSolve to handle the point at Infinity (or 0 in transformed
>coordinates) becomes difficult.
>
>Carl Woll
>Wolfram Research
>
>
A colleague of mine suggested using y->Tan[y] as a transformation
function instead of y->1/y, and this works much better for my example:

f[x_]:=BesselJ[2,x]Exp[-x]
g[y_]:=NIntegrate[f[x],{x,1,y}]

nds = NDSolve[{1/Tan'[z] ht'[z] == f[ Tan[z] ], ht[ArcTan] ==0}, ht,
{z, ArcTan, Pi/2} ][]

With[{ht = ht /. nds},
h[x_] := ht[ ArcTan[x] ]
]

and some checks:

g
h
0.0859172
0.0859172

g[Infinity]
h[Infinity]
0.102141
0.102141

Carl Woll
Wolfram Research

• Prev by Date: RE: Plotting multi-column data
• Next by Date: Re: Efficiency of repeatedly appending to a List
• Previous by thread: Re: Evaluating integral with varying upper limit?
• Next by thread: Re: Evaluating integral with varying upper limit?