python - Finding all roots of a complex polynomial with SymPy -
i'm trying symbolically solve polynomial complex numbers , conjugates sympy. think i've come long way, solve
not give me solutions although polynomial solveable.
from sympy import * # set symbols a, b = symbols("a b", real=true) t = a+i*b t = functions.conjugate(t) # set polynomial a1=0.005+i*0.0009 a2=0.9+i*-0.9 a3=0.4+i*0.5 a4=8+i*-80 a5=284+i*-1.5 a6=27100+i*-11500 poly=t**2 * t * a1 + t * t * a2 + t**2 * a3 + t * a4 + t * a5 + a6 # trying solve symbolically... solve([re(poly), im(poly)], a, b) # output: [] # solving numerically works, finds 1 solution... nsolve((re(poly), im(poly)), (a, b), (0, 0)) # output: matrix( # [['-137.962596090596'], # ['52.6296963395752']]) # verify 2 solutions obtained in maxima poly.subs({a:-137.9625935162095, b:52.6296992481203}).n() # output: 0.000540354631040322 + 0.00054727003909351*i poly.subs({a:-332.6474382554614+i*-185.9848818313149, b:258.0065640091016+i*-272.3344263478699}).n() # output: -6.55448222470652e-12 - 1.41238056784605e-12*i
any ideas?
one problem coefficients contain floating point numbers. not work symbolic software.
using f=10000*simplify(re(poly)) , g=10000*simplify(im(poly)) , editing results gives polynomials integer coefficients. cas (magma in case) can produce triangular representation of ideal of f , g, given polynomials
a - 2483798807340123709959247/13545514719183259347425004828125*b^4 + 66732206412048596386372283/541820588767330373897000193125*b^3 - 3849759933277117021785191063/86691294202772859823520030900*b^2 + 9245906471290310401430681453/1733825884055457196470400618*b - 31414499425567273751868164900/866912942027728598235200309, b^5 - 189465979625/206648369*b^4 + 330827538698125/826593476*b^3 - 17645868534640625/206648369*b^2 + 1724106750659765625/206648369*b - 52548859891484375000/206648369
which tells 5 solutions exist. numerical solutions second polynomial
174.10461010682254746847015187264557067610513554291323564643772 + 63.402741884833821878468926640811609033267039765104756747285816*i 174.104610106822547468470151872645570676105135542913235646437738 - 63.402741884833821878468926640811609033267039765104756747285804*i 258.006564009101655109715962546854008929462784282347754971379392 + 272.334426347869856080204881056671278679761260094680345276069337*i 258.006564009101655109715962546854008929462784282347754971379382 - 272.334426347869856080204881056671278679761260094680345276069359*i 52.62969633957523864698147679803879873180829265956656342643376
resulting in 1 real solution. numerical result of sympy correct , complete.
Comments
Post a Comment