Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Symbolic Math BUG with ATAN2 function
Date: Tue, 22 Dec 2009 09:31:05 +0000 (UTC)
Organization: The Magical Forest
Lines: 55
Message-ID: <hgq3kp$ktf$1@fred.mathworks.com>
References: <eee66e0.-1@webx.raydaftYaTP> <cg0vvl$q91$1@fred.mathworks.com> <hgp0a4$ojt$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1261474265 21423 172.30.248.37 (22 Dec 2009 09:31:05 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 22 Dec 2009 09:31:05 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 99682
Xref: news.mathworks.com comp.soft-sys.matlab:594272

"Felipe Nievinski" <fgnievinski@gmail.com> wrote in message <hgp0a4$ojt$1@fred.mathworks.com>...
> moler@mathworks.com (Cleve Moler) wrote in message <cg0vvl$q91$1@fred.mathworks.com>...
> > In article <eee66e0.-1@webx.raydaftYaTP>,
> > sofa saib <sofa_2004au@yahoo.com.au> wrote:
> > >If I use the following code
> > >
> > >syms x
> > >y=1/(1+i*x)
> > >r=abs(y)
> > >ezplot( y )
> > >
> > >This works great to plot the magnitude of
> > >the complex number y
> > >
> > >But if I want to plot the Angle of the
> > >complex number
> > >The following error results
> > >-----------------------------------------
> > >>> by=angle( y )
> > >??? Function 'atan2' is not defined for values of class 'sym'.
> > >
> > >Error in ==> atan2 at 15
> > >  [varargout{1:nargout}] = builtin('atan2', varargin{:});
> > >
> > >Error in ==> angle at 15
> > >p = atan2(imag(h), real(h));
> > >------------------------------------------
> > >
> > >Seems like the ATAN2 function will not work
> > >with symbolic math and yet the abs function dies.
> > >This makes complex symbolic maths rather
> > >useless with matlab ????
> > >
> > >Any help would be appreciated ?
> > >Is this a bug ???
> > >
> > >thanks
> > >sofa_2004au@yahoo.com.au
> > 
> > Hi --
> > 
> > The ATAN2 function is only defined for real arguments, even in MATLAB
> > itself.  Since its definition involves the signs of its two arguments,
> > it doesn't make sense for complex arguments.  It isn't a bug.
> > 
> What about expressing the symbolic atan2 via the tangent half-angle formula:
>     P = 2 * atan( (sqrt(X.^2 + Y.^2) - X) ./ Y );
> (See <http://en.wikipedia.org/wiki/Atan2>)
> -F.



Seems to me atan2 doesn't really mean anything in the symbolic context, since x and y aren't defined numerically.  (The purpose of atan2 is to put the resulting angle in the correct quadrant.)  How about the old standby:  phi = atan(imag(y)/real(y))?  MATLAB is good, but it won't do your homework *for* you!  

Star Strider