Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2002

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

Search the Archive

Re: Step Info from NDSolve

  • To: mathgroup at
  • Subject: [mg33648] Re: Step Info from NDSolve
  • From: "Allan Hayes" <hay at>
  • Date: Thu, 4 Apr 2002 19:40:14 -0500 (EST)
  • References: <a8g34f$b2p$>
  • Sender: owner-wri-mathgroup at

"Brian Higgins" <bghiggins at> wrote in message
news:a8g34f$b2p$1 at
> Hi Mathgroup,
>  Is there anyway to get step information (number of steps, step size)
> from NDSolve during the actual integration


The following trick is generally applicable:

If a print out of progress is sufficient,

    h[(x_)?NumberQ, fx_, rhs_] := (Print[{x, fx}]; rhs)

    NDSolve[{f'[x] == h[x, f[x], 2*f[x]],  f[0] == 1}, f, {x,0, 1}]

If you want data to work on then

    g[(x_)?NumberQ, fx_, rhs_] :=  (points = Append[points, {x, fx}]; rhs)

    points = {};
    NDSolve[{f'[x] == g[x, f[x], 2*f[x]],  f[0] == 1}, f, {x, 0, 1}]


Allan Hayes
Mathematica Training and Consulting
Leicester UK
hay at
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565

  • Prev by Date: Unexpected brainmalfunction [was: Unexpected result with RSolve?]
  • Next by Date: RE: Unexpected result with RSolve?
  • Previous by thread: Step Info from NDSolve
  • Next by thread: Re: Step Info from NDSolve