Python-不是有效的Sympy表达式

时间:2018-12-03 08:44:15

标签: python sympy

我无法使用Sympy解决表达式:

当我尝试

solution = solveset(exp, pod) 

我得到一个不是有效的SymPy表达式 错误

exp = [Eq(P132590, 0.958918*F1 + 0.00041*F10 + 0.000403*F11 + 0.000387*F12 + 0.00037*F13 + 0.000303*F14 + 0.000298*F15 + 0.00029*F16 + 0.000279*F17 + 0.000256*F18 + 0.00025*F19 + 0.004505*F2 + 0.000209*F20 + 0.000185*F21 + 0.000165*F22 + 0.000165*F23 + 0.000162*F24 + 0.000135*F25 + 0.000132*F26 + 0.000126*F27 + 0.000119*F28 + 0.000111*F29 + 0.002258*F3 + 0.000111*F30 + 0.00011*F31 + 0.000108*F32 + 9.0e-5*F33 + 8.5e-5*F34 + 7.8e-5*F35 + 7.3e-5*F36 + 7.1e-5*F37 + 6.6e-5*F38 + 6.2e-5*F39 + 0.001563*F4 + 6.0e-5*F40 + 6.0e-5*F41 + 6.0e-5*F42 + 5.9e-5*F43 + 0.000977*F5 + 0.000656*F6 + 0.000613*F7 + 0.000533*F8 + 0.000531*F9 + 8.9e-5*P114823 + 7.7e-5*P117466 + 0.000295*P144432 + 0.000164*P167691 + 7.2e-5*P174313 + 0.002293*P184270 + 0.000142*P292780),
 Eq(P184270, 1.0*P288742)]

pod = [P132590, P184270]

当我尝试

solution = linsolve(exp, pod)

solution = solve(exp, pod)

流程 HANGS

1 个答案:

答案 0 :(得分:0)

尝试以下操作:

from sympy import *
from sympy.solvers.solveset import linsolve
P184270, P288742 = symbols('P184270, P288742') 
P132590, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24, F25, F26, F27, F28, F29, F30, F31, F32, F33, F34, F35, F36, F37, F38, F39, F40, F41, F42, F43, P114823, P117466, P144432, P167691, P174313, P184270, P292780 = symbols('P132590, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24, F25, F26, F27, F28, F29, F30, F31, F32, F33, F34, F35, F36, F37, F38, F39, F40, F41, F42, F43, P114823, P117466, P144432, P167691, P174313, P184270, P292780')

linsolve([0.958918*F1 + 0.00041*F10 + 0.000403*F11 + 0.000387*F12 + 0.00037*F13 + 0.000303*F14 + 0.000298*F15 + 0.00029*F16 + 0.000279*F17 + 0.000256*F18 + 0.00025*F19 + 0.004505*F2 + 0.000209*F20 + 0.000185*F21 + 0.000165*F22 + 0.000165*F23 + 0.000162*F24 + 0.000135*F25 + 0.000132*F26 + 0.000126*F27 + 0.000119*F28 + 0.000111*F29 + 0.002258*F3 + 0.000111*F30 + 0.00011*F31 + 0.000108*F32 + 9.0e-5*F33 + 8.5e-5*F34 + 7.8e-5*F35 + 7.3e-5*F36 + 7.1e-5*F37 + 6.6e-5*F38 + 6.2e-5*F39 + 0.001563*F4 + 6.0e-5*F40 + 6.0e-5*F41 + 6.0e-5*F42 + 5.9e-5*F43 + 0.000977*F5 + 0.000656*F6 + 0.000613*F7 + 0.000533*F8 + 0.000531*F9 + 8.9e-5*P114823 + 7.7e-5*P117466 + 0.000295*P144432 + 0.000164*P167691 + 7.2e-5*P174313 + 0.002293*P184270 + 0.000142*P292780-P132590, P288742-P132590], (P132590, P184270))