# Complex argument of an algebraic number 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 close merge delete

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.

Sort by » oldest newest most voted

Well...

sage: z=QQbar(3+2*i);z
2*I + 3
sage: arg(z)
arctan(0.6666666666666667?)


Note the "?" printed at the end of the decimal approximation. That means that this number is "exact", in the sense that this "quantity" represents an algorithm able to approximate the underlying complex to any precision. At least, that's what Sage says :

sage: arg(z).is_exact()
True


Note that, while there exists a radical expression for z (the original 3+2*i), there cannot be one for arctan(z)`, unless this one happens to be _known_ to be rational, in which case it can be coerced to be rational and a radical expression can be searched. As far as Sage can say, this is not the case...

more
{"ft_lang_label":"__label__en","ft_lang_prob":0.9183272,"math_prob":0.9285263,"size":1589,"snap":"2022-27-2022-33","text_gpt3_token_len":380,"char_repetition_ratio":0.13375394,"word_repetition_ratio":0.032786883,"special_character_ratio":0.2315922,"punctuation_ratio":0.12258065,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9763396,"pos_list":[0,1,2],"im_url_duplicate_count":[null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-08-10T08:30:34Z\",\"WARC-Record-ID\":\"<urn:uuid:b35753b9-2423-4fa2-8447-82edc5225cc9>\",\"Content-Length\":\"59840\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:833df773-cb83-4957-ad51-e13721da898c>\",\"WARC-Concurrent-To\":\"<urn:uuid:e5acdcdb-36e2-4a03-88bd-0ff09403cbba>\",\"WARC-IP-Address\":\"194.254.163.53\",\"WARC-Target-URI\":\"https://ask.sagemath.org/question/9497/complex-argument-of-an-algebraic-number/\",\"WARC-Payload-Digest\":\"sha1:O4RQROM3XWOUQUPJ5QUB6TI2GZQZZIHT\",\"WARC-Block-Digest\":\"sha1:P4YEFGR2LDU4ND2PQDKIXM4EICUU7HO6\",\"WARC-Identified-Payload-Type\":\"application/xhtml+xml\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-33/CC-MAIN-2022-33_segments_1659882571150.88_warc_CC-MAIN-20220810070501-20220810100501-00523.warc.gz\"}"}