       Re: Integrating Interpolating function

• To: mathgroup at smc.vnet.net
• Subject: [mg120700] Re: Integrating Interpolating function
• From: Andrew Moylan <amoylan at wolfram.com>
• Date: Wed, 3 Aug 2011 19:56:26 -0400 (EDT)
• Delivered-to: l-mathgroup@mail-archive0.wolfram.com

```Depending on your application, it might also be convenient to better to get the integral out of NDSolve itself.

Compare:

In:= s =
y /. First[
NDSolve[{y'[x] == y[x] Cos[x + y[x]], y == 1}, y, {x, 0, 30}]];
NIntegrate[t*s[t], {t, 0, 30}]

Out= 46.9655

And:

In:= f /.
First[NDSolve[{f'[x] == x y[x], f == 0,
y'[x] == y[x] Cos[x + y[x]], y == 1}, {f, y}, {x, 0, 30}]]

Out= 46.9655

----- Original Message -----
> From: "Oliver Ruebenkoenig" <ruebenko at wolfram.com>
> To: mathgroup at smc.vnet.net
> Sent: Thursday, August 4, 2011 9:20:37 AM
> Subject: Re: Integrating Interpolating function
>
> On Wed, 3 Aug 2011, math_new wrote:
>
> > Hi,
> >
> > I solve a system of differential equations using NDSolve up to time
> > t_end. which gives me something like
> >
> > sol = {f->InterpolatingFunction}
> >
> > Now I want to do an integral like that
> >
> > Integrate[t*f[t],{t,0,tend}]
> >
> > but it won't be computed. What am I doing wrong?
> >
> > Cheers
> >
> >
>
> Hi
>
> s = NDSolve[{y'[x] == y[x] Cos[x + y[x]], y == 1}, y, {x, 0, 30}]
> NIntegrate[t*s[t], {t, 0, 30}]
>
> does what you are looking for.
>
> Hth,
> Oliver
>
>

```

• Prev by Date: Re: Integrating Interpolating function
• Next by Date: Re: Integrating Interpolating function
• Previous by thread: Re: Integrating Interpolating function
• Next by thread: Preventing Users From Seeing the Contents of Certain Cells in CDF Files