MathGroup Archive 1996

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

Search the Archive

Re: solving differential equations

  • To: mathgroup at smc.vnet.net
  • Subject: [mg3517] Re: [mg3484] solving differential equations
  • From: jpk at apex.mpe.FTA-Berlin.de (Jens-Peer Kuska)
  • Date: Wed, 20 Mar 1996 02:49:35 -0500
  • Sender: owner-wri-mathgroup at wolfram.com

> 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.

> Thanks,
> Steve Wilkinson
> 
> 
Hi Steve,

here is the solution for F[x]=Sin[x]

sol=
 NDSolve[
   {y[0]==0,
    y'[t]== If[ z=Sin[t]; Abs[z]>$MachineEpsilon, 
            (* then *)
               z/Abs[z],
            (*else *)
               1
              ]},
   y[t],{t,0,4Pi}
  ];            


{{y[t] -> 
 
    InterpolatingFunction[{0., 
 
       12.5664}, <>][t]}}


Plot[Evaluate[
   y[t] /. Flatten[sol]],{t,0,4Pi}]

Hope that helps
Jens

==== [MESSAGE SEPARATOR] ====


  • Prev by Date: Re: drawing realizations from a joint PDF
  • Next by Date: Re: Turning image in GraphicsArray 90 degrees
  • Previous by thread: solving differential equations
  • Next by thread: Re: solving differential equations