MathGroup Archive 2006

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

Search the Archive

Re: NDSolve

  • To: mathgroup at smc.vnet.net
  • Subject: [mg65712] Re: NDSolve
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
  • Date: Sun, 16 Apr 2006 01:45:18 -0400 (EDT)
  • Organization: The Open University, Milton Keynes, UK
  • References: <e1nnch$lnr$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Subbu wrote:
> Hi,
> 
> I have a question regarding usage of solution given by NDSolve function
> 
> Suppose We have solved one ODE with NDSolve, it will give the solution
> as interpolating function. Suppose I am solving a ODE for solution of y
> as a function of x, I will get solution like
> {y -> InterpolatingFunction[{{0., 1.}}, <>]}.
> 
> Now I can get the values of y at any x using y[x]/.sol/.x->0.5
> 
> But Suppose I want to evaluate the y' [x](Derivative of y) how can we
> get it that from the solution of NDSolve 
> 
> Thank you
> 
Hi,

Just use the prime symbol to get the value of the derivative at a given 
point. For example,

In[1]:=
eqns = {Derivative[1][y][x] == y[x] + Sin[x],
     y[0] == 2};

In[2]:=
sol = NDSolve[eqns, y, {x, 0, 1}]

Out[2]=
{{y -> InterpolatingFunction[]}}

In[3]:=
y[x] /. sol /. x -> 0.5

Out[3]=
{3.4432988011900783}

In[4]:=
Derivative[1][y][x] /. sol /. x -> 0.5

Out[4]=
{3.9227506080049612}

In[5]:=
Plot[{y[x] /. sol, Derivative[1][y][x] /. sol},
    {x, 0, 1}, PlotStyle -> {Blue, Red}];

Best regards,
Jean-Marc


  • Prev by Date: Fitting a complex Function with FindMinimum
  • Next by Date: Re: List Operations
  • Previous by thread: Re: NDSolve
  • Next by thread: Re: NDSolve