Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2007
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: analytic integration of InterpolatingFunction compositions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg74087] Re: analytic integration of InterpolatingFunction compositions
  • From: dh <dh at metrohm.ch>
  • Date: Fri, 9 Mar 2007 02:03:14 -0500 (EST)
  • References: <eslsu8$q6c$1@smc.vnet.net>


Hi Roman,

As I saw that you did not get any better answer, you may try 

re-interpolation: e.g. to integrate f^2: Choose some points to evaluate 

f, calculate f^2 at this points, calculate a new interpolation function 

and integrate. E.g.:

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

dat=Table[{x,f[x]^2},{x,0,1,0.1}];

f2=Interpolation[dat];

Integrate[f2[x],{x,0,1}]

Daniel



Roman wrote:

> 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[0] == 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: Precision available with NIntegrate {Method -> Oscillatory}
  • Next by Date: Re: "Transparency" with respect to differentiation
  • Previous by thread: Re: analytic integration of InterpolatingFunction compositions
  • Next by thread: Integrate