Re: Evaluating integral with varying upper limit?

*To*: mathgroup at smc.vnet.net*Subject*: [mg71193] Re: Evaluating integral with varying upper limit?*From*: "Andrew Moylan" <andrew.j.moylan at gmail.com>*Date*: Fri, 10 Nov 2006 06:37:51 -0500 (EST)*References*: <200611060752.CAA08598@smc.vnet.net><eiupn1$fjr$1@smc.vnet.net>

[Chris Chiasson has provided an answer to my question about the best ways to make available code, notebooks, and packages to users of this list: see http://groups-beta.google.com/group/comp.soft-sys.math.mathematica/msg/379ef0c6f644fbaa.] On Nov 9, 7:43 pm, "Andrew Moylan" <andrew.j.moy... at gmail.com> wrote: > Hi all, > > This is a problem I encounter frequently; I'm surprised it doesn't have > a simple solution in terms of built-in Mathematica functions. The > general problem, for me, is, given some initial value problem {y'(x) == > y(y(x), x), y(0) == y0} (with y possibly multi-dimensional), give the > FUNCTION y. That is, give a function which, when called, will call > NDSolve over the appropriate interval (but probably no further, unless > the interval is very small), and return the result, while remembering > the results of all previous calls to NDSolve to avoid any unnecessary > recomputation. > > I have a written a package called AutoNDSolveInitialValueProblem which > performs this task. I frequently use it to solve exactly the problem > given above, namely, to make an efficient version of f[y_] := > NIntegrate[bla[x], {x, 0, y}]. Let me know if you'd be interested in > this package. > > In another thread I recently asked: what's the right way to submit > packages or general Mathematica notebooks to this newsgroup. If anyone > reading this thread knows the answer I'd be grateful. > > Cheers, > Andrew > > On Nov 8, 10:32 pm, Carl Woll <c... at wolfram.com> 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

**References**:**Evaluating integral with varying upper limit?***From:*AES <siegman@stanford.edu>