Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2004
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

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

Search the Archive

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[1]:=
sol=NDSolve[{y[0]==1,v[0]==0,y'[t]==v[t],v'[t]==-1},{y[t],v[t]},{t,0,1}]

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

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

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

Out[2]=
?Graphics?

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

Out[3]=
{0.833333}


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


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

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

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

Out[5]=
\!\(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