You need to add I
as an algebraic extension:
In [2]: factor(x**2 + 1, extension=[I])
Out[2]: (x - ⅈ)⋅(x + ⅈ)
Pergunta
I can't figure out how to factor an polynomial expression to its complex roots.
>>> from sympy import *
>>> s = symbol('s')
>>> factor(s**2+1)
2
s + 1
Solução
You need to add I
as an algebraic extension:
In [2]: factor(x**2 + 1, extension=[I])
Out[2]: (x - ⅈ)⋅(x + ⅈ)