Ask Your Question

# Discriminant of multivariate polynomials with complex coefficients

I would like to compute the discriminant of some polynomial in two variables, x and z, the discriminant should be computed with respect to x. I am able to do so in certain cases, but not when the coefficients are complex numbers written in a certain way. For example, this works:

R.<z> = QQ[]
S.<x> = R[]
p = x**2 - z**2
p.discriminant()


gives:

4*z^2


But when I try to use a complex coefficient, discriminant fails because the expression is regarded as a symbolic expression, instead of a polynomial

q = x**2 - z**2 * I
q.discriminant()

AttributeError: 'sage.symbolic.expression.Expression' object has no attribute 'discriminant'


Curiously, if I use instead

q = x**2 - z**2 * 1j
q.discriminant()


this gives the correct answer. Now for particular reasons I really need to deal with 'I' as the complex unit, and cannot use 'j'. What's wrong with 'I'?

edit retag close merge delete

## 1 Answer

Sort by » oldest newest most voted

One solution

sage: K.<I> = QuadraticField(-1)
sage: R.<z> = K[]
sage: S.<x> = R[]
sage: q = x**2 - z**2 * I
sage: q.discriminant()
4*I*z^2


The default I in Sage is (for now) a symbolic expression.

more

## Comments

Thanks! Especially for explaining what is the issue with 'I'. Also nice simple solution

On further inspection, while this definitely works, it seems that sticking to 'I' does have some drawback apparently. For instance, computing the discriminant of a slightly more complicated polynomial like

-108*x**27*z**26 - 540*I*x**15*z**15 + 540*I*x**15*z**13 - x**3*z**4 + 2*x**3*z**2 - x**3


is much slower than computing the same discriminant with

-108*x**27*z**26 - 540*1j*x**15*z**15 + 540*1j*x**15*z**13 - x**3*z**4 + 2*x**3*z**2 - x**3


So it seems that I should really find a way of converting I to 1j, in the end. Any trick for this?

If you only want some approximate value of the discriminant, you can also do

sage: I = CC(0,1)
sage: R.<z> = CC[]
sage: S.<x> = R[]


Might be faster than what I proposed.

Indeed, it is. It seems that CC(0,1) = 1.000000 I, still employs 'I'. So why is it so much faster? I guess previously sage was trying to solve exactly, since coefficients were integers, while now the rational coefficient triggers approximate solution? Thanks again!

No no. CC does not use the symbolic I it is just a matter of notation. If you want to know "where" your object lives you can use the magic .parent() method

sage: I.parent()
Symbolic Ring
sage: I = CC(0,1)
sage: R.<z> = CC[]
sage: p = I*z
sage: p.parent()
Univariate Polynomial Ring in z over Complex Field with 53 bits of precision


## Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

## Stats

Asked: 2015-12-22 20:31:47 +0200

Seen: 938 times

Last updated: Dec 22 '15
{"ft_lang_label":"__label__en","ft_lang_prob":0.87908816,"math_prob":0.76268643,"size":915,"snap":"2021-21-2021-25","text_gpt3_token_len":238,"char_repetition_ratio":0.1481888,"word_repetition_ratio":0.027027028,"special_character_ratio":0.2546448,"punctuation_ratio":0.13186814,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9827512,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-06-24T19:25:38Z\",\"WARC-Record-ID\":\"<urn:uuid:ec116d02-0862-4f98-a299-bda1aa17ab8d>\",\"Content-Length\":\"63507\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:bdbbc0aa-d10f-4ec4-8408-75a8e707de03>\",\"WARC-Concurrent-To\":\"<urn:uuid:fe953a97-057d-4969-b76c-f9bf31e8bd4d>\",\"WARC-IP-Address\":\"194.254.163.53\",\"WARC-Target-URI\":\"https://ask.sagemath.org/question/31761/discriminant-of-multivariate-polynomials-with-complex-coefficients/\",\"WARC-Payload-Digest\":\"sha1:X7GGBSIAPWWMRXRTAOD4WTTINPYUQ6HS\",\"WARC-Block-Digest\":\"sha1:XN5WJQQ6RCBDFZX7PX7UTHFLFDOX3WH5\",\"WARC-Identified-Payload-Type\":\"application/xhtml+xml\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-25/CC-MAIN-2021-25_segments_1623488556482.89_warc_CC-MAIN-20210624171713-20210624201713-00355.warc.gz\"}"}