[Date Index]
[Thread Index]
[Author Index]
Re: Problem with discontinuity in NDSolve[]
*To*: mathgroup at smc.vnet.net
*Subject*: [mg4404] Re: Problem with discontinuity in NDSolve[]
*From*: rubin at msu.edu (Paul A. Rubin)
*Date*: Fri, 19 Jul 1996 03:46:47 -0400
*Organization*: Michigan State University
*Sender*: owner-wri-mathgroup at wolfram.com
In article <4qqnms$49m at dragonfly.wolfram.com>,
a_kowald at chemie.fu-berlin.de (Axel Kowald) wrote:
->Hi everybody,
->
->I have a problem with NDSolve if my equation contains a discontinuity.
->If I try
->
->NDSolve[{y'[t] == 10 - y[t] * If[y[t]-15 <= 0, 0, 1],
-> y[0] == 0}, y, {t,0,20}]
->
->I always get the error: Maximum number of steps reached.
->The solution should be a linear increase until y = 15 followed by an
->exponential decay until a steady state is reached by y = 10
->
->
->Funny enough if I try
->
->NDSolve[{y'[t] == 10 - y[t] * If[t-15 <= 0, 0, 1],
-> y[0] == 0}, y, {t,0,20}]
->
->
->causing the discontinuity to be at t = 15 instead of y = 15 NDSolve has
no
->problems at all. (But of course this is not what I want.)
->
->
->ANY SOLUTIONS ??? ANY IDEAS ???
->
->
->
->Many thanks
->
->
-> Axel Kowald
->
->
->P.S. I'm using Mma 2.2 on a Mac with 7.5.3 and 24 MB RAM
I tried this in Mma 2.2.2/Windows, and got the same thing. I'm not sure
what Mma is using to solve the ODE, but I suspected at first that it was
just jamming at the point where the derivative of y[t] is undefined
(t=1.5). The difference between your first and second versions is that in
the second version, since it knows t exactly, the error in estimating y'[t]
is proportional to the error in estimating y[t], whereas in the first
method small errors in y[t] produce relatively enormous errors in y'[t]
(which essentially flip-flops between 10 and approximately -5).
I still think that's part of the problem, but there may be something about
how Mma does its function evaluations at work. I tried replacing your If[]
factor with Max[ 0, Min[ 1, (y[t] - 15)/eps ] ], where eps was given a
small positive value (.0001) beforehand. This was an attempt to smooth the
transition from 0 to 1 in the If[]. NDSolve produced no diagnostics, but
the solution it gave rose linearly from t=0, y=0 to t=1.5, y=15, and then
leveled out as a constant function (y=15 for t>1.5), which is utterly
wrong!
Paul
**************************************************************************
* Paul A. Rubin Phone: (517) 432-3509 *
* Department of Management Fax: (517) 432-1111 *
* Eli Broad Graduate School of Management Net: RUBIN at MSU.EDU *
* Michigan State University *
* East Lansing, MI 48824-1122 (USA) *
**************************************************************************
Mathematicians are like Frenchmen: whenever you say something to them,
they translate it into their own language, and at once it is something
entirely different. J. W. v. GOETHE
==== [MESSAGE SEPARATOR] ====
Prev by Date:
**Re: c code generation**
Next by Date:
**Re: surface plots from irregularly spaced data (scatter) points**
Previous by thread:
**Problem with discontinuity in NDSolve[]**
Next by thread:
**Re: Problem with discontinuity in NDSolve[]**
| |