我试图象征性地求解具有复数的多项式及其与SymPy的共轭。我想我已经走了很长的路,但solve
并没有给我任何解决方案,尽管多项式是可以解决的。
from sympy import *
# set up symbols
a, b = symbols("a b", real=True)
t = a+I*b
T = functions.conjugate(t)
# set up 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 to solve symbolically...
solve([re(poly), im(poly)], a, b)
# Output: []
# Solving numerically works, but only finds one solution...
nsolve((re(poly), im(poly)), (a, b), (0, 0))
# Output: matrix(
# [['-137.962596090596'],
# ['52.6296963395752']])
# verify with two 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
有什么想法吗?
答案 0 :(得分:3)
一个问题可能是您的系数包含浮点数。这通常不适用于符号软件。
使用f = 10000 *简化(re(poly))和g = 10000 *简化(im(poly))并编辑结果给出具有整数系数的多项式。 CAS(我的情况下是岩浆)然后可以产生f和g的理想的三角形表示,其作为多项式给出
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
告诉我们存在5种解决方案。第二个多项式的数值解是
174.10461010682254746847015187264557067610513554291323564643772
+ 63.402741884833821878468926640811609033267039765104756747285816*i
174.104610106822547468470151872645570676105135542913235646437738
- 63.402741884833821878468926640811609033267039765104756747285804*i
258.006564009101655109715962546854008929462784282347754971379392
+ 272.334426347869856080204881056671278679761260094680345276069337*i
258.006564009101655109715962546854008929462784282347754971379382
- 272.334426347869856080204881056671278679761260094680345276069359*i
52.62969633957523864698147679803879873180829265956656342643376
产生了一个真正的解决方案。同情的数字结果是正确和完整的。