[Date Index]
[Thread Index]
[Author Index]
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[3]:=
>f[x_]:=BesselJ[2,x]Exp[-x]
>In[4]:=
>g[y_]:=NIntegrate[f[x],{x,1,y}]
>
>Then, using NDSolve we have:
>
>In[5]:=
>NDSolve[{h'[x] == f[x], h[1] == 0}, h, {x, 1, 100}]
>Out[5]=
>{{h -> InterpolatingFunction[{{1., 100.}}, <>]}}
>
>A few checks:
>
>g[10]
>h[10] /. %5[[1]]
>0.102135
>0.102135
>
>g[100]
>h[100] /. %5[[1]]
>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[1]] ==0}, ht,
{z, ArcTan[1], Pi/2} ][[1]]
With[{ht = ht /. nds},
h[x_] := ht[ ArcTan[x] ]
]
and some checks:
g[3]
h[3]
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?**
| |