Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1995
*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 1995

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

Search the Archive

Re: Help required on differential equation

  • To: mathgroup at christensen.cybernetics.net
  • Subject: [mg1815] Re: Help required on differential equation
  • From: rknapp (Robert Knapp)
  • Date: Thu, 17 Aug 1995 00:03:23 -0400
  • Organization: The Santa Fe Institute

In article <DDDr09.AzA at wri.com> Dr Brian Hunton tel 270502 <hunton at news.ox.ac.uk> writes:

...
> 
> Please help! I have a differential equation that I solve numerically with
> Mathematica. This gives me my interpolating function f[x] which I can happily
> plot. Now I want to plot f''[x] over the same range, but I'm having all sorts
> of bother. Can anyone help? I'd be very grateful...
> 
...
> 

In principle this should cause no problem.  For example, if I define sol by

In[1]:=
sol = NDSolve[{y'[x] == y[x],y[0] == 1},y,{x,0,1}]
Out[1]=
{{y -> InterpolatingFunction[{0., 1.}, <>]}}

then 

Plot[Evaluate[y[x] /. sol[[1]]],{x,0,1}]

and 

Plot[Evaluate[y''[x] /. sol[[1]]],{x,0,1}]

work equally well (and give basically the same plot in this case).
Note the Evaluate, however.  In the first one, the plot can be done,
but will take a little longer without the Evaluate.  For the second
derivative, the plot will take MUCH longer without the Evaluate.  This
is because, since Plot has the attributew HoldAll, y'' is evaluated
for each numerical value plotted, and it takes a significant amout of
time to compute the derivative of an InterpolatingFunction object.

If you prefer not to need to remember to put an Evaluate in your Plot
commands, an equally effective alternative is to compute in advance.
FOr sol as defined above, I could produce the smae plots by:

f = sol[[1,1,2]];

Plot[f[x],{x,0,1}];

fpp = f'';

Plot[fpp[x],{x,0,1}];



Rob Knapp
WRI


  • Prev by Date: Problem with ComplexExpand[Abs[]]
  • Next by Date: Re: Applying FindRoot to Interpolating Functions
  • Previous by thread: Help required on differential equation
  • Next by thread: Re: Help required on differential equation