MathGroup Archive 2000

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

Search the Archive

InterpolatingFunction in NDSolve


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