MathGroup Archive 1998

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

Search the Archive

Re: NDSolve and MaxStepSize



In article <6f1ksj$f7d@smc.vnet.net>,
  lang@einev.ch (Fred Lang) wrote:
>
> Dear MathGroup users,
>
> I have found the following naive behavior of NDSolve:
>
> In[1] = tmin = 0 ; t0 = 0.2 ; t1 = 0.5 ; tmax = 1 ;
>
> In[2] = f[t_] = Which[ t < t0 , 0.0 , t <= t1 , 0.5 , t <= tmax , 0  ] ;
>
> (* f(t) is a step function * )
>
> In[3] = solution =
>
>         NDSolve[ { v'[t] == f[t] , v[0] == 0 } , v[t] , {t,tmin,tmax} ,
>
>              , MaxSteps -> 5000 ] ;
>
> In[4] = vsol[t_] = v[t] /. solution ;
>
> vsol(t) is the null function! NDSolve has choosen a maximal step !
>
> To receive the right answer I have to put  MaxStepSize -> 0.01 :
>
> In[5] = solution =
>
>         NDSolve[ { v'[t] == f[t] , v[0] == 0 } , v[t] , {t,tmin,tmax} ,
>
>                 MaxStepSize -> 0.01 , MaxSteps -> 5000 ] ;
>
> In[6] = vsol[t_] = v[t] /. solution ;
>
> How can I convince my matlab engineering environment to use mathematica
> with such a naive behavior?
>
> See you later.
>
> Fred Lang.
>
>

I think Fred, you will convince them, if they are engineers. What is the
MaxStepSize good for, if not for such a type of function? Playing
around with your example I even could do better (or worse?) than you:
Try this. On my pc (pentium pro, Win95), it produces something like an
exponential curve. If you want to know what is happening here, have a
look on FullForm[solution[[1,1,2]]].

f[t_] = Which[ t <= .002 , 0.0 , t < 1 , 0.5 , t ==1 , .00001 ];
solution =
  NDSolve[ { v'[t] == f[t] , v[0] == 0 } , v[t] , {t,tmin,tmax} ,
    MaxSteps -> 5000 ] ;
vsol[t_] = v[t] /. solution [[1]];
Plot[vsol[t],{t,0,1}]

Jurgen

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading



  • Prev by Date: Re: Data Extraction from List {{x1,y1}..{xn,yn}}where ##<x<##
  • Next by Date: RE: Re: odd behavior of NDSolve
  • Prev by thread: Re: NDSolve and MaxStepSize
  • Next by thread: Interpolation function objects