MathGroup Archive 2000

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

Search the Archive

InterpolatingFunction in NDSolve

  • To: mathgroup at smc.vnet.net
  • Subject: [mg21640] InterpolatingFunction in NDSolve
  • From: eborzova at my-deja.com
  • Date: Tue, 18 Jan 2000 02:35:23 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

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!

          Thanks.
                  Elena.
Clear[sss];
Clear[solution];
Clear[sol2];
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
[x]]];

     Print["Ooops!!!!"];

     Abort[];
];

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 Deja.com http://www.deja.com/
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