在Sympy矩阵中找到复数的实部

时间:2018-10-15 11:59:41

标签: python sympy

我有一个从MyMat.eigenvals().keys()的{​​{1}}获得的矩阵(这是4D jacobian矩阵的特征值):

sympy

我只想参与其中,所以我尝试使用egV = [5728761814608399/400000000000000 + sqrt(116481370240190604554434649577057/100000000000000000000000000000 - 2*(704966930593670936740277648541223935870775995019826163729310179922474354087956414591800649953/8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 + sqrt(4176563721214961521026417694955136953714825217199604642869248664796023172422674692165308442655306961942463737618615469818663523407583102219569144299457956960070280847076949520807345)*I/50000000000000000000000000000000000000000000000000000000000000000000000000000000000000)**(1/3) - 542870217167939624258689632311630767295785372177/(20000000000000000000000000000000000000000000*sqrt(116481370240190604554434649577057/200000000000000000000000000000 + 84525541314107370029729686916824478617779085658015330937307969/(20000000000000000000000000000000000000000000000000000000000*(704966930593670936740277648541223935870775995019826163729310179922474354087956414591800649953/8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 + sqrt(4176563721214961521026417694955136953714825217199604642869248664796023172422674692165308442655306961942463737618615469818663523407583102219569144299457956960070280847076949520807345)*I/50000000000000000000000000000000000000000000000000000000000000000000000000000000000000)**(1/3)) + 2*(704966930593670936740277648541223935870775995019826163729310179922474354087956414591800649953/8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 + sqrt(4176563721214961521026417694955136953714825217199604642869248664796023172422674692165308442655306961942463737618615469818663523407583102219569144299457956960070280847076949520807345)*I/50000000000000000000000000000000000000000000000000000000000000000000000000000000000000)**(1/3))) - 84525541314107370029729686916824478617779085658015330937307969/(20000000000000000000000000000000000000000000000000000000000*(704966930593670936740277648541223935870775995019826163729310179922474354087956414591800649953/8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 + sqrt(4176563721214961521026417694955136953714825217199604642869248664796023172422674692165308442655306961942463737618615469818663523407583102219569144299457956960070280847076949520807345)*I/50000000000000000000000000000000000000000000000000000000000000000000000000000000000000)**(1/3)))/2 - sqrt(116481370240190604554434649577057/200000000000000000000000000000 + 84525541314107370029729686916824478617779085658015330937307969/(20000000000000000000000000000000000000000000000000000000000*(704966930593670936740277648541223935870775995019826163729310179922474354087956414591800649953/8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 + sqrt(4176563721214961521026417694955136953714825217199604642869248664796023172422674692165308442655306961942463737618615469818663523407583102219569144299457956960070280847076949520807345)*I/50000000000000000000000000000000000000000000000000000000000000000000000000000000000000)**(1/3)) + 2*(704966930593670936740277648541223935870775995019826163729310179922474354087956414591800649953/8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 + sqrt(4176563721214961521026417694955136953714825217199604642869248664796023172422674692165308442655306961942463737618615469818663523407583102219569144299457956960070280847076949520807345)*I/50000000000000000000000000000000000000000000000000000000000000000000000000000000000000)**(1/3))/2, 5728761814608399/400000000000000 + sqrt(116481370240190604554434649577057/100000000000000000000000000000 - 2*(704966930593670936740277648541223935870775995019826163729310179922474354087956414591800649953/8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 + sqrt(4176563721214961521026417694955136953714825217199604642869248664796023172422674692165308442655306961942463737618615469818663523407583102219569144299457956960070280847076949520807345)*I/50000000000000000000000000000000000000000000000000000000000000000000000000000000000000)**(1/3) + 542870217167939624258689632311630767295785372177/(20000000000000000000000000000000000000000000*sqrt(116481370240190604554434649577057/200000000000000000000000000000 + 84525541314107370029729686916824478617779085658015330937307969/(20000000000000000000000000000000000000000000000000000000000*(704966930593670936740277648541223935870775995019826163729310179922474354087956414591800649953/8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 + sqrt(4176563721214961521026417694955136953714825217199604642869248664796023172422674692165308442655306961942463737618615469818663523407583102219569144299457956960070280847076949520807345)*I/50000000000000000000000000000000000000000000000000000000000000000000000000000000000000)**(1/3)) + 2*(704966930593670936740277648541223935870775995019826163729310179922474354087956414591800649953/8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 + sqrt(4176563721214961521026417694955136953714825217199604642869248664796023172422674692165308442655306961942463737618615469818663523407583102219569144299457956960070280847076949520807345)*I/50000000000000000000000000000000000000000000000000000000000000000000000000000000000000)**(1/3))) - 84525541314107370029729686916824478617779085658015330937307969/(20000000000000000000000000000000000000000000000000000000000*(704966930593670936740277648541223935870775995019826163729310179922474354087956414591800649953/8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 + sqrt(4176563721214961521026417694955136953714825217199604642869248664796023172422674692165308442655306961942463737618615469818663523407583102219569144299457956960070280847076949520807345)*I/50000000000000000000000000000000000000000000000000000000000000000000000000000000000000)**(1/3)))/2 + sqrt(116481370240190604554434649577057/200000000000000000000000000000 + 84525541314107370029729686916824478617779085658015330937307969/(20000000000000000000000000000000000000000000000000000000000*(704966930593670936740277648541223935870775995019826163729310179922474354087956414591800649953/8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 + sqrt(4176563721214961521026417694955136953714825217199604642869248664796023172422674692165308442655306961942463737618615469818663523407583102219569144299457956960070280847076949520807345)*I/50000000000000000000000000000000000000000000000000000000000000000000000000000000000000)**(1/3)) + 2*(704966930593670936740277648541223935870775995019826163729310179922474354087956414591800649953/8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 + sqrt(4176563721214961521026417694955136953714825217199604642869248664796023172422674692165308442655306961942463737618615469818663523407583102219569144299457956960070280847076949520807345)*I/50000000000000000000000000000000000000000000000000000000000000000000000000000000000000)**(1/3))/2, 5728761814608399/400000000000000 - sqrt(116481370240190604554434649577057/200000000000000000000000000000 + 84525541314107370029729686916824478617779085658015330937307969/(20000000000000000000000000000000000000000000000000000000000*(704966930593670936740277648541223935870775995019826163729310179922474354087956414591800649953/8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 + sqrt(4176563721214961521026417694955136953714825217199604642869248664796023172422674692165308442655306961942463737618615469818663523407583102219569144299457956960070280847076949520807345)*I/50000000000000000000000000000000000000000000000000000000000000000000000000000000000000)**(1/3)) + 2*(704966930593670936740277648541223935870775995019826163729310179922474354087956414591800649953/8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 + sqrt(4176563721214961521026417694955136953714825217199604642869248664796023172422674692165308442655306961942463737618615469818663523407583102219569144299457956960070280847076949520807345)*I/50000000000000000000000000000000000000000000000000000000000000000000000000000000000000)**(1/3))/2 - sqrt(116481370240190604554434649577057/100000000000000000000000000000 - 2*(704966930593670936740277648541223935870775995019826163729310179922474354087956414591800649953/8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 + sqrt(4176563721214961521026417694955136953714825217199604642869248664796023172422674692165308442655306961942463737618615469818663523407583102219569144299457956960070280847076949520807345)*I/50000000000000000000000000000000000000000000000000000000000000000000000000000000000000)**(1/3) - 542870217167939624258689632311630767295785372177/(20000000000000000000000000000000000000000000*sqrt(116481370240190604554434649577057/200000000000000000000000000000 + 84525541314107370029729686916824478617779085658015330937307969/(20000000000000000000000000000000000000000000000000000000000*(704966930593670936740277648541223935870775995019826163729310179922474354087956414591800649953/8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 + sqrt(4176563721214961521026417694955136953714825217199604642869248664796023172422674692165308442655306961942463737618615469818663523407583102219569144299457956960070280847076949520807345)*I/50000000000000000000000000000000000000000000000000000000000000000000000000000000000000)**(1/3)) + 2*(704966930593670936740277648541223935870775995019826163729310179922474354087956414591800649953/8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 + sqrt(4176563721214961521026417694955136953714825217199604642869248664796023172422674692165308442655306961942463737618615469818663523407583102219569144299457956960070280847076949520807345)*I/50000000000000000000000000000000000000000000000000000000000000000000000000000000000000)**(1/3))) - 84525541314107370029729686916824478617779085658015330937307969/(20000000000000000000000000000000000000000000000000000000000*(704966930593670936740277648541223935870775995019826163729310179922474354087956414591800649953/8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 + sqrt(4176563721214961521026417694955136953714825217199604642869248664796023172422674692165308442655306961942463737618615469818663523407583102219569144299457956960070280847076949520807345)*I/50000000000000000000000000000000000000000000000000000000000000000000000000000000000000)**(1/3)))/2, 5728761814608399/400000000000000 - sqrt(116481370240190604554434649577057/100000000000000000000000000000 - 2*(704966930593670936740277648541223935870775995019826163729310179922474354087956414591800649953/8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 + sqrt(4176563721214961521026417694955136953714825217199604642869248664796023172422674692165308442655306961942463737618615469818663523407583102219569144299457956960070280847076949520807345)*I/50000000000000000000000000000000000000000000000000000000000000000000000000000000000000)**(1/3) + 542870217167939624258689632311630767295785372177/(20000000000000000000000000000000000000000000*sqrt(116481370240190604554434649577057/200000000000000000000000000000 + 84525541314107370029729686916824478617779085658015330937307969/(20000000000000000000000000000000000000000000000000000000000*(704966930593670936740277648541223935870775995019826163729310179922474354087956414591800649953/8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 + sqrt(4176563721214961521026417694955136953714825217199604642869248664796023172422674692165308442655306961942463737618615469818663523407583102219569144299457956960070280847076949520807345)*I/50000000000000000000000000000000000000000000000000000000000000000000000000000000000000)**(1/3)) + 2*(704966930593670936740277648541223935870775995019826163729310179922474354087956414591800649953/8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 + sqrt(4176563721214961521026417694955136953714825217199604642869248664796023172422674692165308442655306961942463737618615469818663523407583102219569144299457956960070280847076949520807345)*I/50000000000000000000000000000000000000000000000000000000000000000000000000000000000000)**(1/3))) - 84525541314107370029729686916824478617779085658015330937307969/(20000000000000000000000000000000000000000000000000000000000*(704966930593670936740277648541223935870775995019826163729310179922474354087956414591800649953/8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 + sqrt(4176563721214961521026417694955136953714825217199604642869248664796023172422674692165308442655306961942463737618615469818663523407583102219569144299457956960070280847076949520807345)*I/50000000000000000000000000000000000000000000000000000000000000000000000000000000000000)**(1/3)))/2 + sqrt(116481370240190604554434649577057/200000000000000000000000000000 + 84525541314107370029729686916824478617779085658015330937307969/(20000000000000000000000000000000000000000000000000000000000*(704966930593670936740277648541223935870775995019826163729310179922474354087956414591800649953/8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 + sqrt(4176563721214961521026417694955136953714825217199604642869248664796023172422674692165308442655306961942463737618615469818663523407583102219569144299457956960070280847076949520807345)*I/50000000000000000000000000000000000000000000000000000000000000000000000000000000000000)**(1/3)) + 2*(704966930593670936740277648541223935870775995019826163729310179922474354087956414591800649953/8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 + sqrt(4176563721214961521026417694955136953714825217199604642869248664796023172422674692165308442655306961942463737618615469818663523407583102219569144299457956960070280847076949520807345)*I/50000000000000000000000000000000000000000000000000000000000000000000000000000000000000)**(1/3))/2]

re()

但它返回此错误:

  

TypeError:无法确定Relational的真值

1 个答案:

答案 0 :(得分:1)

re函数的文档字符串说

  

返回表达式的实部。该函数仅执行基本分析,因此将无法正确分解更复杂的表达式。如果需要完全简化的结果,则使用Basic.as_real_imag()或对该函数的实例执行复杂的扩展。

在SymPy 1.3中,egV.as_real_imag()返回一个矩阵元组:实部和虚部。虚部都是零,这告诉我们特征值是实数。显然,I的存在来自立方方程的casus irreducibilis(该方程具有三个实根,但是它们的代数公式必须包含复数)。