Comment #7 on issue 3512 by [email protected]: solve is slow for a simple set of equations.
http://code.google.com/p/sympy/issues/detail?id=3512

I report similar issues as described.
PYTHON SOLVE SEEMS TO BE MUCH MUCH SLOWER THAN SAGE SOLVE.
I have tried the options manual=True simplify=False and others with no success. with manual=False or =True in the code below it is the same
If I am doing something wrong please help me.
Here the python sympy code and then the sage code.
sympy version 0.7.1.rc1
python version: 2.7.3.

Here is the code:


from sympy import __version__
print __version__
from sympy import *

s = var('s')

V_6, V_8, V_2, r0_Q1, Gm_Q1, CBE_Q1, CBC_Q1, rpi_Q1, V_1, V_0, R5, V_initial_C4_6_0, C4, V_initial_C3_1_6, C3, V_initial_C2_2_1, C2, V_7, I_initial_L1_7_2, L1, R2, V_5, R4, V_4, R3, I_initial_L2_4_5, L2, r0_Q1, V_initial_CBC_Q1_6_8, CBC_Q1, V_initial_CBE_Q1_8_2, CBE_Q1, rpi_Q1, V_initial_C1_8_0, C1, R1 = var(' V_6 V_8 V_2 r0_Q1 Gm_Q1 CBE_Q1 CBC_Q1 rpi_Q1 V_1 V_0 R5 V_initial_C4_6_0 C4 V_initial_C3_1_6 C3 V_initial_C2_2_1 C2 V_7 I_initial_L1_7_2 L1 R2 V_5 R4 V_4 R3 I_initial_L2_4_5 L2 r0_Q1 V_initial_CBC_Q1_6_8 CBC_Q1 V_initial_CBE_Q1_8_2 CBE_Q1 rpi_Q1 V_initial_C1_8_0 C1 R1')


eqnssimple = [(V_4 - V_6)/R3 + I_initial_L2_4_5/s + (V_4 - V_5)/(L2*s)]

a, b, c = var('a b c')
print(solve([a + b, b + c], a,b))

print(solve(eqnssimple, [V_4], manual=True))

eqns = [(V_1 - V_6)*C3*s + (V_1 - V_2)*C2*s + C2*V_initial_C2_2_1 - C3*V_initial_C3_1_6 - (V_0 - V_1)/R5, (V_2 - V_8)*CBE_Q1*s - (V_1 - V_2)*C2*s - C2*V_initial_C2_2_1 + CBE_Q1*V_initial_CBE_Q1_8_2 + (V_2 - V_8)/rpi_Q1 + (V_2 - V_6)/r0_Q1 - I_initial_L1_7_2/s + (V_2 - V_7)/(L1*s), -(V_0 - V_5)/R4 - I_initial_L2_4_5/s - (V_4 - V_5)/(L2*s), (V_4 - V_6)/R3 + I_initial_L2_4_5/s + (V_4 - V_5)/(L2*s), (V_7 - V_8)/R1 + I_initial_L1_7_2/s - (V_2 - V_7)/(L1*s), (V_6 - V_8)*CBC_Q1*s - (V_1 - V_6)*C3*s - (V_0 - V_6)*C4*s + C3*V_initial_C3_1_6 - C4*V_initial_C4_6_0 - CBC_Q1*V_initial_CBC_Q1_6_8 - (V_4 - V_6)/R3 - (V_2 - V_6)/r0_Q1, -(V_6 - V_8)*CBC_Q1*s - (V_2 - V_8)*CBE_Q1*s - (V_0 - V_8)*C1*s - C1*V_initial_C1_8_0 + CBC_Q1*V_initial_CBC_Q1_6_8 - CBE_Q1*V_initial_CBE_Q1_8_2 - (V_7 - V_8)/R1 - (V_2 - V_8)/rpi_Q1 - (V_0 - V_8)/R2]

print(solve(eqns, [V_1, V_2, V_4, V_5, V_6, V_7, V_8]))

# END ---------------------------
Here is the output:
0.7.1.rc1
{a: c, b: -c}
{V_4: (-I_initial_L2_4_5*L2*R3 + L2*V_6*s + R3*V_5)/(L2*s + R3)}

and then the systems hangs up.

In Sage I obtain for the following code:
s = var('s')

V_6, V_8, V_2, r0_Q1, Gm_Q1, CBE_Q1, CBC_Q1, rpi_Q1, V_1, V_0, R5, V_initial_C4_6_0, C4, V_initial_C3_1_6, C3, V_initial_C2_2_1, C2, V_7, I_initial_L1_7_2, L1, R2, V_5, R4, V_4, R3, I_initial_L2_4_5, L2, r0_Q1, V_initial_CBC_Q1_6_8, CBC_Q1, V_initial_CBE_Q1_8_2, CBE_Q1, rpi_Q1, V_initial_C1_8_0, C1, R1 = var(' V_6 V_8 V_2 r0_Q1 Gm_Q1 CBE_Q1 CBC_Q1 rpi_Q1 V_1 V_0 R5 V_initial_C4_6_0 C4 V_initial_C3_1_6 C3 V_initial_C2_2_1 C2 V_7 I_initial_L1_7_2 L1 R2 V_5 R4 V_4 R3 I_initial_L2_4_5 L2 r0_Q1 V_initial_CBC_Q1_6_8 CBC_Q1 V_initial_CBE_Q1_8_2 CBE_Q1 rpi_Q1 V_initial_C1_8_0 C1 R1')


eqnssimple = [(V_4 - V_6)/R3 + I_initial_L2_4_5/s + (V_4 - V_5)/(L2*s)]

a, b, c = var('a b c')
print(solve([a + b, b + c], a,b))

print(solve(eqnssimple, [V_4]))

eqns = [(V_1 - V_6)*C3*s + (V_1 - V_2)*C2*s + C2*V_initial_C2_2_1 - C3*V_initial_C3_1_6 - (V_0 - V_1)/R5, (V_2 - V_8)*CBE_Q1*s - (V_1 - V_2)*C2*s - C2*V_initial_C2_2_1 + CBE_Q1*V_initial_CBE_Q1_8_2 + (V_2 - V_8)/rpi_Q1 + (V_2 - V_6)/r0_Q1 - I_initial_L1_7_2/s + (V_2 - V_7)/(L1*s), -(V_0 - V_5)/R4 - I_initial_L2_4_5/s - (V_4 - V_5)/(L2*s), (V_4 - V_6)/R3 + I_initial_L2_4_5/s + (V_4 - V_5)/(L2*s), (V_7 - V_8)/R1 + I_initial_L1_7_2/s - (V_2 - V_7)/(L1*s), (V_6 - V_8)*CBC_Q1*s - (V_1 - V_6)*C3*s - (V_0 - V_6)*C4*s + C3*V_initial_C3_1_6 - C4*V_initial_C4_6_0 - CBC_Q1*V_initial_CBC_Q1_6_8 - (V_4 - V_6)/R3 - (V_2 - V_6)/r0_Q1, -(V_6 - V_8)*CBC_Q1*s - (V_2 - V_8)*CBE_Q1*s - (V_0 - V_8)*C1*s - C1*V_initial_C1_8_0 + CBC_Q1*V_initial_CBC_Q1_6_8 - CBE_Q1*V_initial_CBE_Q1_8_2 - (V_7 - V_8)/R1 - (V_2 - V_8)/rpi_Q1 - (V_0 - V_8)/R2]

print(solve(eqns, [V_1, V_2, V_4, V_5, V_6, V_7, V_8]))

# -----------------END
when loaded in sage with load. I obtain the result in a couple of seconds. Here it is
----------------------------------------------------------------------
| Sage Version 5.6, Release Date: 2013-01-21                         |
| Type "notebook()" for the browser-based notebook interface.        |
| Type "help()" for help.                                            |
----------------------------------------------------------------------
sage: load("sage_issue.py")
[
[a == c, b == -c]
]
[
V_4 == -(I_initial_L2_4_5*L2*R3 - L2*V_6*s - R3*V_5)/(L2*s + R3)
]
[
[V_1 ==
a very very long list of hopefully correct solution obtainend in just a couple of seconds.

How can I obtain this in sympy too ?
Am I doing something wrong ?

--
You received this message because this project is configured to send all issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

--
You received this message because you are subscribed to the Google Groups 
"sympy-issues" 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 http://groups.google.com/group/sympy-issues?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to