Search code examples
pythonsympysolver

I got an empty list when solving two equation


I tried to solve two simple equations but I got nothing.

from sympy import *

x, y = symbols('x y')
eq1=Function('eq1')
eq2=Function('eq2')

eq1 = Eq(x + y , 1)        # x + y   = 1
eq2 = Eq(x + y ,3)         # x + y  = 3
ans = solve([eq1, eq2] , [x, y])
print(ans)

I got

[]

Solution

  • You set everything up ok. The empty list is the way that solve tells you that it could not find a solution for x and y that satisfied the equations. And, indeed, there are no values which, when added, will give two different results (as others have noted).