Complex argument of an algebraic number

asked 2012-11-02 06:42:21 -0500

MvG gravatar image

This question is closely related to that question here. Basically I'd like to know whether there is a way to compute an accurate symbolic expression for the argument of an algebraic number.

That argument will in general not be an algebraic number itself, which seems to cause a lot of headache along the way. The following all fail, sometimes in rather spectacular backtracing ways:

sage: z = QQbar(3 + 2*I)
sage: z.arg()
AttributeError: 'AlgebraicNumber' object has no attribute 'arg'
sage: atan2(imag(z), real(z))
TypeError: Illegal initializer for algebraic number
sage: atan2(SR(imag(z)), SR(real(z)))
TypeError: Illegal initializer for algebraic number
sage: atan2(AA(imag(z)), AA(real(z)))
TypeError: Illegal initializer for algebraic number

I know a few cases which will work.

sage: atan2(QQ(imag(z)), QQ(real(z)))
arctan(2/3)

This however will break if the real or imaginary part were to contain any square roots.

sage: CC(z).arg()
0.588002603547568

This will give me a numeric approximation. I know I can get that approximation to arbitrary precision, but it's still not exact.

I have the impression that atan2 attempts to turn its result into an algebraic number, which will fail horribly. I would expect that result to contain an unevaluated call to atan2 instead, for the cases where the argument is not an algebraic number. Can this be done?

edit retag flag offensive close merge delete

Comments

What do you want to do with these numbers?

vdelecroix gravatar imagevdelecroix ( 2016-01-04 20:05:49 -0500 )edit

I honestly don't remember what I had in mind when I posted this question. I guess I worked around it somehow, or tried a completely different approach.

MvG gravatar imageMvG ( 2016-05-26 18:25:45 -0500 )edit