Re: Specify Step Size in NDSolve

*To*: mathgroup at smc.vnet.net*Subject*: [mg44678] Re: Specify Step Size in NDSolve*From*: "Curt Fischer" <crf3 at po.cwru.edu>*Date*: Thu, 20 Nov 2003 03:16:43 -0500 (EST)*References*: <bpffca$lt1$1@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

"Andrea" <andrea.knorr at engr.uconn.edu> wrote in message news:bpffca$lt1$1 at smc.vnet.net... > I posted the following message Friday the 14th of November, but have > not yet seen it, so I apologize if you see this twice. > > I am using NDSolve, and have run into an error with the step size it > is using. I get errors at very small times. Mathematica will > continue beyond this time point, but results are very inaccurate. I think the reason NDSolve was failing was that your equations were highly stiff, given the value of T that you are using! You might have tried specifying an implicit method such as BDF or ImplicitRungeKutta. (That might not have solve the problem either, though--I'm not sure what the default method for NDSolve is. Maybe it is smart already tried those.) > soln=NDSolve[{ > y'[t]== k v[t] T -delta y[t], > v'[t]== n delta y[t]-c v[t], > y[0]==7016819, v[0]== 2220151}, > {y,v},{t,0,1500}, MaxSteps->{10^5}]; But these equations are linear and a symbolic solution is available! These are the inputs from a Mathematica session in which I solved your equations analytically with DSolve and plugged in the value of the parameters you wanted (output deleted to save space). In[1]:= T = 343824133; In[3]:= soln = DSolve[{ y'[t] == k v[t] T - delta y[t], v'[t] == n delta y[t] - c v[t], y[0] == 7016819, v[0] == 2220151}, {y[t], v[t]}, {t}] In[5]:= {y[t], v[t]} /. soln[[1]] /. {k -> 0.0297, delta -> 4.51, n -> 46.38, c -> 6.145}