subtract a list of interpolating functions from another
- To: mathgroup at smc.vnet.net
- Subject: [mg48545] subtract a list of interpolating functions from another
- From: sean_incali at yahoo.com (sean kim)
- Date: Fri, 4 Jun 2004 04:51:04 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
still stepwise ode accuracy related question, but... consider two lists of three interpolating functions. like below. k1 = 1/10; k2 = 1/20; a0[t_] := 0.5 /; t < 0 ; a0[t_] := 0.5 /; 0 <= t <=20 ; a0[t_] := 0.5 /; 20 <= t <=60 ; a0[t_] := 0.5 /; 60 <= t <=400; a = 0.5; ndsolstep = 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, 0, 20, 60, 400, 400}, Method -> ExplicitRungeKutta][[1]] ndsol = NDSolve[{ b'[t] == -k2 b[t] y[t], x'[t] == -k1 a x[t] + k2 b[t] y[t], y'[t] == k1 a x[t] - k2 b[t] y[t], b[0] == 1, x[0] == 1, y[0] == 0}, {b, x, y}, {t, 0, 400}][[1]] will give two lists of {b -> InterpolatingFunction[{{0., 400.}}, <>], x -> InterpolatingFunction[{{0., 400.}}, <>], y -> InterpolatingFunction[{{0., 400.}}, <>]} one from normal system and another from stepwise defined( which has Rob Knapp's fix in it) they should be same if not very close. I thought maybe I would take a value of interpolating function at time poiints and subtract to see the differences. (to check how close they are) ndsol[[1, 1]][0] - ndsolstep[[1, 1]][0] Out[307]= 0 but all the time points i have chosen came back 0. (I chose the discontinous time points 0, 20, 60, 400 ) i was gonna say that two different approaches(stepwise defined and smooth) yielded exactly the same values , but I wasn't sure. how would you guys do this? thank you all very much in advance sean