       Re: definite integral

• To: mathgroup at smc.vnet.net
• Subject: [mg49361] Re: definite integral
• From: "Curt Fischer" <crf3 at po.cwru.edu>
• Date: Fri, 16 Jul 2004 06:06:41 -0400 (EDT)
• References: <cd5ooi$b37$1@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

Hi Josh:

You need to use Evaluate[] inside your NIntegrate command.  For an trivial
example (which has the advantage of being able to be checked symbolically)
see below:

In:=
sol=NDSolve[{y==1,v==0,y'[t]==v[t],v'[t]==-1},{y[t],v[t]},{t,0,1}]

Out=
{{y[t]\[Rule]

InterpolatingFunction[{{0.,1.}},<>][t],v[t]\[Rule]InterpolatingFunction[\
{{0.,1.}},<>][t]}}

In:=
Plot[Evaluate[y[t]/.sol],{t,0,1}]

Out=
?Graphics?

In:=
NIntegrate[Evaluate[y[t]/.sol],{t,0,1}]

Out=
{0.833333}

Here's how you can check that this answer is correct (at least in this
simple case):

In:=
check=DSolve[{y==1,v==0,y'[t]==v[t],v'[t]==-1},{y[t],v[t]},t][]

Out=
\!$${y[t] \[Rule] 1\/2\ \((2 - t\^2)$$, v[t] \[Rule] $$-t$$}\)

In:=
Integrate[y[t]/.check,{t,0,1}]

Out=
\!$$5\/6$$

Josh wrote:
> from the solution of a system of 2 differential equations
>
> sol=NDSolve[{v'[t]==10^3*i[t],
> y'[t]== etc...
>
> I get the solution y[t] for t \in [0,1], and I can plot it with the
> command:
>
> Plot[Evaluate[y[t]/.sol],{t,0,0.5}, PlotRange->{-2,2}]
>
> but I have also to compute the definite integral of y[t], between 0
> and
> 0.1, how can I do?
>
> Thanks, Josh.

• Prev by Date: Re: importing image and getting numbers from the gray intensity
• Next by Date: Re: ArcCos[x] with x > 1
• Previous by thread: Re: definite integral
• Next by thread: Tr vs Total