checking accuracy with stepwise ode.

• To: mathgroup at smc.vnet.net
• Subject: [mg48436] checking accuracy with stepwise ode.
• From: sean_incali at yahoo.com (sean kim)
• Date: Sat, 29 May 2004 03:07:01 -0400 (EDT)
• Sender: owner-wri-mathgroup at wolfram.com

```actually I figured it out, I hate it when I answer my own question
after posting it. I didn't define the functions with [t_]. that's why
the NDSOlve complained.

If i use the code below, it works fine, but How do I know the results
are accurate? Does NDSolve do soemthing different with the stepwise
functions that it doesn;t do with the normal functions?   how do I
check my results?  how do I know the answer that i got is correct? I
ask because the plot looks kinda funky.

sean

k1 = 1/10; k2 = 1/20;
a0[t_] := 0 /; t < 0 ;
a0[t_] := 1/10 /; 0 <= t <= 200 ;
a0[t_] := 0 /; 200 <= t <= 600 ;
a0[t_] := 1/10 /; 600 <= t<= 2000;

ndsolution = NDSolve[{b'[t] == -k2 b[t] y[t], x'[t] == -k1 a0[t]  x[t]
+ k2 b[t] y[t], y'[t] == k1 a0[t]  x[t] - k2 b[t] y[t], b[0] == 1,
x[0] == 1, y[0] == 0}, {b, x, y}, {t, 0, 2000}][[1]] ;

Plot[Evaluate[{a0[t], b[t], x[t], y[t]} /. ndsolution], {t, 0, 2000},
PlotStyle -> {
{AbsoluteThickness[2], RGBColor[0, 0, 0]},
{AbsoluteThickness[2], RGBColor[.7, 0, 0]},
{AbsoluteThickness[2],RGBColor[0, .7, 0]},
{AbsoluteThickness[2], RGBColor[0, 0, .7]}},
PlotRange -> All, Axes -> False, Frame -> True,
PlotLabel -> StyleForm[A StyleForm[" B", FontColor -> RGBColor[.7, 0,
0]] StyleForm[" X", FontColor -> RGBColor[0, .7, 0]]StyleForm["Y",
FontColor -> RGBColor[0, 0, .7]],
FontFamily -> "Helvetica", FontSize -> 12, FontWeight -> "Bold"]];

```

• Prev by Date: Re: NSolve freezes on two polynomial equations
• Next by Date: Re: stepwise ode. why does this fail?
• Previous by thread: Extract substrings using metacharacters
• Next by thread: Re: matrix operations