Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #4181
| From | Andrew Moylan <amoylan@wolfram.com> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: Integrating Interpolating function |
| Date | 2011-08-03 23:57 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <j1cn9v$gms$1@smc.vnet.net> (permalink) |
Depending on your application, it might also be convenient to better to get the integral out of NDSolve itself.
Compare:
In[13]:= s =
y /. First[
NDSolve[{y'[x] == y[x] Cos[x + y[x]], y[0] == 1}, y, {x, 0, 30}]];
NIntegrate[t*s[t], {t, 0, 30}]
Out[14]= 46.9655
And:
In[15]:= f[30] /.
First[NDSolve[{f'[x] == x y[x], f[0] == 0,
y'[x] == y[x] Cos[x + y[x]], y[0] == 1}, {f, y}, {x, 0, 30}]]
Out[15]= 46.9655
----- Original Message -----
> From: "Oliver Ruebenkoenig" <ruebenko@wolfram.com>
> To: mathgroup@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[0] == 1}, y, {x, 0, 30}]
> NIntegrate[t*s[t], {t, 0, 30}]
>
> does what you are looking for.
>
> Hth,
> Oliver
>
>
Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread
Re: Integrating Interpolating function Andrew Moylan <amoylan@wolfram.com> - 2011-08-03 23:57 +0000
csiph-web