Re: please help on ODE under condition
- To: mathgroup at smc.vnet.net
- Subject: [mg42942] Re: [mg42931] please help on ODE under condition
- From: Selwyn Hollis <selwynh at earthlink.net>
- Date: Tue, 5 Aug 2003 02:04:56 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Try using the (undocumented) StoppingTest option in NDSolve to stop when x(t)>d. Then restart with the desired initial values. Something like this: x0 = 1; y0 = 1; tt[0] = 0; d = 2; Do[ soln[k][t_] = {x[t], y[t]} /. First[ NDSolve[{x'[t] == x[t] + y[t], y'[t] == 1 - x[t], x[tt[k - 1]] == x0, y[tt[k - 1]] == y0}, {x[t], y[t]}, {t, tt[k - 1], tt[k - 1] + 10}, StoppingTest -> x[t] > d]]; tt[k] = soln[k][t][[1,0,1,1,2]]; {x0, y0} = soln[k][tt[k]]*{0.5, 1}, {k, 5}] << "Graphics`Graphics`" DisplayTogether[Table[Plot[Evaluate[soln[k][t]], {t, tt[k - 1], tt[k]}], {k, 5}]] Neat problem! ----- Selwyn Hollis http://www.math.armstrong.edu/faculty/hollis On Monday, August 4, 2003, at 12:45 AM, sabrina wrote: > Hello, all: > I am trying to solve a set of differential eqns . There is one problem > that > I don't know how to solve now. Let 's say I have x'(t)= ax(t)-by(t), > y'(t)=c-x(t), when x(t) >d ( say a constant), x will be half of current > value, but the odes still valid. How can I write the code the get the > conditon? Thanks > > Sabrina > > >