Re: NDSolve and MaxStepSize
- To: mathgroup@smc.vnet.net
- Subject: [mg11724] Re: [mg11671] NDSolve and MaxStepSize
- From: David Withoff <withoff@wolfram.com>
- Date: Thu, 26 Mar 1998 03:08:52 -0500
> 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.
Here are two possible answers to that question:
1) Find a similar example in which Matlab fails. It should be very easy
to do that. This will demonstrate that such behavior is a
characteristic of all numerical algorithms, rather than a problem with
Mathematica.
2) Change the default MaxStepSize or MaxRelativeStepSize options in
NDSolve. Most people are unsurprised when, say, numerical integration
fails for an integrand with a sufficiently sharp feature. You could
take a poll of the people in your "matlab engineering environment" and
find out how sharp a feature needs to be before they are no longer
disappointed when the algorithm steps over that feature. Then set
MaxStepSize and/or MaxRelativeStepSize to those values.
Dave Withoff
Wolfram Research