From: "Roland " <>
Newsgroups: comp.soft-sys.matlab
Subject: Re: ode, tan, singularity?
Date: Sat, 10 Mar 2012 09:49:12 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 19
Message-ID: <jjf82o$g3m$>
References: <jjbbul$r7c$> <jjbupc$m25$> <jjch18$ens$> <jjdopn$ptc$>
Reply-To: "Roland " <>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: 1331372952 16502 (10 Mar 2012 09:49:12 GMT)
NNTP-Posting-Date: Sat, 10 Mar 2012 09:49:12 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1293762
Xref: comp.soft-sys.matlab:760535

"Roger Stafford" wrote in message <jjdopn$ptc$>...
> "Roland " <> wrote in message <jjch18$ens$>...
> > .........
> > I am not shure if i understood correctly your suggestion. should i split up the function, one part for 
> > beta < pi /2 
> > and one for 
> > beta > pi/2?
> - - - - - - - -
>   When (b2-b1)/(z2-z1) < 0, as is the case with your equations, the trajectory followed by a solution to those differential equations assumes an infinite dz/du slope at beta = pi/2 and u cannot continue to increase.  The natural path for the trajectory to follow from there on would be along a vertical mirror image of the path with u now decreasing and z continuing to decrease as it finally asymptotically approaches the beta = pi level with u approaching minus infinity.  However with ode45 committed to advancing u, this is not possible, so my recommendation is to set ode45 to stop right at beta = pi/2.  As you have it set up, ode45 cannot continue from there without "hanging up" and producing nonsense.
>   A similar situation holds for the entire family of trajectories with all the various possible initial conditions.  Whenever beta is equal to pi/2 or differs from that by a multiple of pi - that is, whenever tan(beta) is infinite - the trajectories will necessarily reverse the direction of u as they cross the corresponding horizontal line.  If (b2-b1)/(z2-z1) > 0 these trajectories are reversed in the u direction with asymptotes occurring as u approaches plus infinity.
> Roger Stafford


Roger, thanks for the explanation of whats going wrong in my code. I solved the problem by solving for du/dz instead of dz/du, which makes everything much easier.