[SciPy-user] strange behaviour of angle(z)
David M. Cooke
cookedm at physics.mcmaster.ca
Thu Jul 6 12:03:37 EDT 2006
On Thu, 06 Jul 2006 13:49:02 +0200
Nils Wagner <nwagner at iam.uni-stuttgart.de> wrote:
> Nils Wagner wrote:
> > Hi all,
> >
> > I am surprised by the behaviour of angle(z)
> > I didn't expect negative return values.
> >
> >
> > >>> angle(1.0+0j)
> > 0.0
> > >>> angle(0.0+1j)
> > 1.5707963267948966
> > >>> angle(-1.0+0j)
> > 3.1415926535897931
> >
> > but
> >
> > >>> angle(0.0-1j)
> > -1.5707963267948966
> >
> > instead of
> >
> > 3*pi/2
> >
> > Is there any reason for negative return values ?
convention? (-pi,pi] instead of [0,2*pi). They're equivalent. Although
admittedly changing from one to the other is a bit of a pain.
(Hmm, and the range is actually [-float(pi), float(pi)], where float(pi) is
the floating-point approximation to pi -- a closed interval.)
> > SciPy-user mailing list
> > SciPy-user at scipy.org
> > http://projects.scipy.org/mailman/listinfo/scipy-user
> >
> Just now I discovered that Matlab has a function phase.
>
> PHASE computes the phase of a complex vector
> PHI=phase(G)
> G is a complex-valued row vector and PHI is returned as its phase (in
> radians),
> with an effort made to keep it c o n t i n u e s over the \pi-borders.
>
> Is there such a function in scipy ? If not it would be a nice enhancement.
*scratches head* How does it keep it continuous over \pi-borders? (Well, I
suppose [0,2*pi) is continuous across pi, but it's still discontinuous across
0 and 2*pi.)
--
|>|\/|<
/--------------------------------------------------------------------------\
|David M. Cooke http://arbutus.physics.mcmaster.ca/dmc/
|cookedm at physics.mcmaster.ca
More information about the SciPy-User
mailing list