MathGroup Archive 2000

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

Search the Archive

InterpolatingFunction in NDSolve

  • To: mathgroup at
  • Subject: [mg21640] InterpolatingFunction in NDSolve
  • From: eborzova at
  • Date: Tue, 18 Jan 2000 02:35:23 -0500 (EST)
  • Sender: owner-wri-mathgroup at

Hi everybody.
My question could be simple, but I just can't
figure it out. I need to use InterpolatingFunction
inside yet another function (Derivs) that is rhs
for NDSolve (please refer to the code below). The
problem is that if my rhs "Derivs" has some sort
of conditional logic (e.g. "If"), then it stops
working (see a comment with Return[sss[x]]).

Any help/hints/feedback are greatly appreciated!

solution = NDSolve[{Derivative[1][y][x]==-10*y
[x], y[0] == 1},
                    y,{x, 0, 0.5}]

sss = (y[x] /. solution[[1]])[[0]];

(* interpolating function seems to be ok: can
Plot it *)
Plot[sss[t], {t, 0, 0.5}];

Derivs[y_, x_] := Block[{},

     (* uncomment below to make it work *)

     (* Return[sss[x]]; *)

     If[x < 0.25, Return[sss[x]], Return[-sss



sol2 = NDSolve[{Derivative[1][y][x] == Derivs[y,
x], y[0] == 0},
                y,{x, 0, 0.5}]

Plot[Evaluate[y[x] /. sol2], {x, 0, 0.5}];

Sent via
Before you buy.

  • Prev by Date: Exact Kolmogorov Test Distribution; Computing Times
  • Next by Date: Re: entering an equation
  • Previous by thread: Exact Kolmogorov Test Distribution; Computing Times
  • Next by thread: Re: InterpolatingFunction in NDSolve