Check if polynomial has complex coefficients

39 views
Skip to first unread message

Risubh Jain

unread,
Jan 19, 2020, 5:24:54 AM1/19/20
to sympy
What is the correct way of checking if a polynomial has complex coefficients?

Oscar Benjamin

unread,
Jan 19, 2020, 5:57:00 AM1/19/20
to sympy
What do you mean by complex coefficients?

I can think of several meanings:

1. You want to know if any of the coefficients has non-zero imaginary part.
2. You want to know that all of the coefficients represent complex
numbers and not something else like matrices.
3. You want to know that the coefficients are concrete numbers like
1+I rather than symbols like Symbol('x', complex=True)

Also when you say polynomial do you mean a `Poly` or an `Expr` that is
polynomial in some symbol?

Show a bit of code that gives an example of what you would like to be
able to do.

--
Oscar

On Sun, 19 Jan 2020 at 10:24, Risubh Jain <risubhj...@gmail.com> wrote:
>
> What is the correct way of checking if a polynomial has complex coefficients?
>
> --
> You received this message because you are subscribed to the Google Groups "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sympy+un...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/d5424af8-9fcd-4a4e-bed9-8d3ab611c86f%40googlegroups.com.

Risubh Jain

unread,
Jan 19, 2020, 6:22:16 AM1/19/20
to sympy
I wanted a way to check if Poly(x + I, x, I, domain='ZZ') has complex coefficients. Sorry for the incomplete question.
As @jksuom suggested on gitter , I in poly.gens works fine for my use case. 

On Sunday, January 19, 2020 at 4:27:00 PM UTC+5:30, Oscar wrote:
What do you mean by complex coefficients?

I can think of several meanings:

1. You want to know if any of the coefficients has non-zero imaginary part.
2. You want to know that all of the coefficients represent complex
numbers and not something else like matrices.
3. You want to know that the coefficients are concrete numbers like
1+I rather than symbols like Symbol('x', complex=True)

Also when you say polynomial do you mean a `Poly` or an `Expr` that is
polynomial in some symbol?

Show a bit of code that gives an example of what you would like to be
able to do.

--
Oscar

On Sun, 19 Jan 2020 at 10:24, Risubh Jain <risubhj...@gmail.com> wrote:
>
> What is the correct way of checking if a polynomial has complex coefficients?
>
> --
> You received this message because you are subscribed to the Google Groups "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sy...@googlegroups.com.

S.Y. Lee

unread,
Jan 31, 2020, 6:25:18 AM1/31/20
to sympy
I'm not sure why it's treated as an polynomial over integers generated by `I, x` rather than a polynomial over complexes generated by `x`, but surely there can be some limited supports for this.

Aaron Meurer

unread,
Jan 31, 2020, 12:20:35 PM1/31/20
to sympy
If you specify the generators explicitly like Poly(x + I, x) it
chooses the domain EX. You have to manually do domain=ZZ[I] to get the
complex domain. I think ideally it would use the extension domain
automatically, but support for such things is still limited.

Aaron Meurer
> --
> You received this message because you are subscribed to the Google Groups "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sympy+un...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/5bd66930-28dd-40a8-bc83-bf0b5e942f8e%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages