2

我试图用符号解决一个复数的多项式及其与 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

有任何想法吗?

4

1 回答 1

3

一个问题可能是您的系数包含浮点数。这通常不适用于符号软件。

使用 f=10000*simplify(re(poly)) 和 g=10000*simplify(im(poly)) 并编辑结果给出具有整数系数的多项式。CAS(在我的例子中是 Magma)然后可以产生 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

产生了一个真正的解决方案。sympy的数值结果是正确和完整的。

于 2013-12-12T14:02:40.620 回答