       analytic integration of InterpolatingFunction compositions

• To: mathgroup at smc.vnet.net
• Subject: [mg74046] analytic integration of InterpolatingFunction compositions
• From: "Roman" <rschmied at gmail.com>
• Date: Wed, 7 Mar 2007 03:15:14 -0500 (EST)

```Hello all:

When I have a simple InterpolatingFunction[] object from an NDSolve[]
call, I know I can analytically integrate this by using Integrate[].
However, what I want to do is analytically integrate compositions of
such InterpolatingFunction[] objects, which Integrate[] cannot handle.
For example, let

f = y /. First[NDSolve[{y'[x] == x*y[x]^2, y == 1}, y, {x, 0,
1}]]

Now I want to integrate f[x]^2:

NIntegrate[f[x]^2, {x, 0, 1}]

works fine. But this being an interpolating function, it seems to me
that one could get a much faster and more accurate result by analytic
integration. Unfortunately,

Integrate[f[x]^2, {x, 0, 1}]

does not compute.

In principle one could extract the interpolation grid from f[x] and
set up an analytic integration "by hand", using
NumericalMath`ListIntegrate`, but this quickly becomes nasty,
especially if you integrate products of different
InterpolatingFunction objects like

NIntegrate[f[x]*g[x], {x, 0, 1}]

which are both results of NDSolve[] and thus may be using different
grid points.

Does anyone have any suggestions on how to do these integrals
properly? Or how to coax NIntegrate[] into realizing that it should
use a grid which matches those of the various InterpolatingFunction
objects in its argument?

Cheers!
Roman.

```

• Prev by Date: Re: logical/set theoretic programming
• Next by Date: Re: beginner plot function with parameter
• Previous by thread: Re: "Transparency" with respect to differentiation
• Next by thread: Re: analytic integration of InterpolatingFunction compositions