Home > Back-end >  Sympy "not equal" equation
Sympy "not equal" equation

Time:07-04

Is there any way to solve algebra equations that contain ≠?

for example: 2-x ≠ 3

So, may be it looks like this:

print(solve(not_equal(2-x, 3)))

CodePudding user response:

You should solve the == equation and take complement of the solution in the reals.

You can also try to solve inequation < and > and take the union of the solution sets.

CodePudding user response:

You can use the Unequality class to represent the "not equal", or its alias Ne. For example:

print(solve(Ne(2-x, 3)))
# out: (x > -oo) & (x < oo) & Ne(x, -1)
  • Related