# Sage solve returns empty list

I have very complex formula, and I have to solve that formula for one of variables (get some variable from expression). If I use solve() function is sage, it returns empty list, which is odd, but I found that it could be caused by too complex expression. So I managed to use sympy.solve(), but it returns exception. Here is part of my code:

 k, u, v ,w , E, B, S, J, C1, C2 = var('k', 'u', 'v', 'w', 'E', 'B', 'S', 'J', 'C1', 'C2')
#assumptions
assume(B > 0)
assume(S > 0)
assume(J > 0)
assume(k > 0)
assume((u*E^2 + v*E + w) > 0)

f1 = (S == 1/6*(4*E^3*u + 3*E^2*v)/B + 1/6*(2*E^3*u + 3*E^2*v + 6*E*w)/B - k)
f2 = (J == E/B - k/(E^2*u + E*v + w))

#solve f1 and f2 for E

E_S = solve(f1, E)
E_J = solve(f2, E)

#under our assumptions only E_S and A_J are real
#so for that solutions lets find S

f_S1 = (E_S.right() == E_J.right())

#show(f_S1)

solve(f_S1, S) #returns []

import sympy
sympy.solve(f_S1, S) #returns exception


I tried to rewrite to sympy in spyder as well, but computations didint finish in two days so I canceled it.

edit retag close merge delete

It seems that your equation is polynomial, is that right? If you so, you should be using Gröbner basis directly. The solve command does not do that.

I turned the equations f1, f2 into definitions for S, J. Then it seems that we have to solve the equation S==J. So let us factor the difference:

k, u, v ,w , E, B, S, J = var('k', 'u', 'v', 'w', 'E', 'B', 'S', 'J')

S = 1/6*(4*E^3*u + 3*E^2*v)/B + 1/6*(2*E^3*u + 3*E^2*v + 6*E*w)/B - k
S = S.factor()
print S

J = E/B - k/(E^2*u + E*v + w)
J = J.factor()
print J

print (S-J).factor()


This gives:

(E^3*u + E^2*v - B*k + E*w)/B
(E^3*u + E^2*v - B*k + E*w)/((E^2*u + E*v + w)*B)
(E^3*u + E^2*v - B*k + E*w)*(E^2*u + E*v + w - 1)/((E^2*u + E*v + w)*B ...
(more)