Dear all:
I'm wondering why solve in sympy is very slow for linear equation system.
For example with
from sympy import *
v11, v12, v21, v22 = symbols('v11, v12, v21, v22')
w11, w12, w21, w22 = symbols('w11, w12, w21, w22')
x11, x12, x21, x22 = symbols('x11, x12, x21, x22')
y11, y12, y21, y22 = symbols('y11, y12, y21, y22')
z11, z12, z21, z22 = symbols('z11, z12, z21, z22')
r11, r12, r21, r22 = symbols('r11, r12, r21, r22')
a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \
a12, a13, a14, a15, a16, a17, a18 = symbols('a1:19')
# want to solve
b1, b2 = symbols('b1, b2')
# system of equations
eqn1 = a1*v11 + a2*v12 - b1 # a1 = 1
eqn2 = a1*v21 + a2*v22 - a3
eqn3 = a3*r11 + a4*r12 - a2
eqn4 = a3*r21 + a4*r22 - a5
eqn5 = a5*w11 + a6*w12 - a4
eqn6 = a5*w21 + a6*w22 - a7
eqn7 = a7*r11 + a8*r12 - a6
eqn8 = a7*r21 + a8*r22 - a9
eqn9 = a9*x11 + a10*x12 - a8
eqn10 = a9*x21 + a10*x22 - a11
eqn11 = a11*r11 + a12*r12 - a10
eqn12 = a11*r21 + a12*r22 - a13
eqn13 = a13*y11 + a14*y12 - a12
eqn14 = a13*y21 + a14*y22 - a15
eqn15 = a15*r11 + a16*r12 - a14
eqn16 = a15*r21 + a16*r22 - a17
eqn17 = a17*z11 + a18*z12 - a16 # a18 = 0
eqn18 = a17*z21 + a18*z22 - b2
print('begin')
result = solve([eqn1, eqn2, eqn3, eqn4, eqn5, eqn6, eqn7, \
eqn8, eqn9, eqn10, eqn11, eqn12, eqn13, \
eqn14, eqn15, eqn16, eqn17, eqn18], \
[a2, a3, a4, a5, a6, a7, a8, a9, a10, \
a11, a12, a13, a14, a15, a16, a17, b1, b2], \
simplify=False, rational=False, manual=True)
b1_ans = result[b1]
b2_ans = result[b2]print(b1_ans)
to solve these equations needs Matlab only some seconds, but for solve in
sympy i can't get the result..
I have tried some solvers likw solve and linsolve, also some flag like
simplify=False, still cannot get the result.
Are there any way to speed up?
Thanks in advance
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit
https://groups.google.com/d/msgid/sympy/f643bb88-1aa1-47f4-83cc-1f0e8bf8d24d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.