MathGroup Archive 1996

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

Search the Archive

Re: solving differential equations

  • To: mathgroup at
  • Subject: [mg3544] Re: solving differential equations
  • From: Robert Knapp <rknapp>
  • Date: Thu, 21 Mar 1996 01:10:25 -0500
  • Organization: Wolfram Research, Inc.
  • Sender: owner-wri-mathgroup at

Steven Wilkinson wrote:
> Mathgroup,
> I have a system of ODE I wish to solve numerically of the form X'[t] =
> F(X[t])/|F(X[t])| for a given function
>         F : plane -> plane
> and given intial conditions. NDSolve works well on this except where the
> system is ill-behaved, in particular, where F = 0. I can replace this
> system with another one that has equivalent solutions and is usually
> well-behaved where F = 0. However, I don't want to make the replacement
> unless I have to, and only near where F = 0. (I wish to construct a command
> that gives the solution for an inputted function F.)
> Is there any way possible to do this with NDSolve? In other words, as it
> steps along have it check the value of F. If its magnitude ever gets too
> close to 0, have it use the other system.
> If that is not possible, does anyone have a solver package that I could
> modify to do the above?
> Thanks,
> Steve Wilkinson
> Dept of Math & CS
> Northern Kentucky University
> wilkinson at

The easiest thing to do is to redefine the function so that you change
to the equivalent solution only when F is near zero.   Below is a very
simple example of how you can do this.

NDSolve[{x'[t] == t/Sin[t],x[0] == -1},x,{t,0,1}]
   Indeterminate expression 0. 1. ComplexInfinity
   Differential equation does not evaluate to a number
     at t = 0..

{{x -> InterpolatingFunction[{0., 0.}, <>]}}


Out[2]=  (* find an approximation near the removeable singularity *)
    t        4
1 + -- + O[t]

In[3]:=  (* define the function, so that the approximation is used 
             near the removable singularity.  100 $MachineEpsilon was
             an arbitrary choice, but I checked it with a plot to
             see that it matched the approximation well *)  

f[t_] := If[Abs[Sin[t]] < 100 $MachineEpsilon,

NDSolve[{x'[t] == f[t],x[0] == 1},x,{t,-1,1}]

{{x -> InterpolatingFunction[{-1., 1.}, <>]}}

Note that you case is slightly different since your right hand side has
the function with singularity depending on the dependent variable.  You
can still use a similar definition and use f[x[t]] instead of just f[t].

Rob Knapp
Wolfram Research, Inc.


  • Prev by Date: ListContourPlot: AxesLabels? (Q)
  • Next by Date: Re: Re: More on functions & derivatives:Correction
  • Previous by thread: Re: solving differential equations
  • Next by thread: ArcTan[x,y] - corrected address