Method on @sym: eq (a, b)
Operator on @sym: a == b

Test for symbolic equality, and/or define equation.

The code a == b can do one of two things:

  • Return a symbolic boolean value if it can quickly determine that a and b are the same or not:
    sym(1) == sym(pi)
      ⇒ (sym) False
    
  • Otherwise, return a symbolic equation:
    syms x y
    3*y == 24*x
      ⇒ ans = (sym) 3⋅y = 24⋅x
    solve(ans, y)
      ⇒ (sym) 8⋅x
    

Exactly which behaviour happens is a potential source of bugs! When a and/or b contain variables, we usually (but not always) expect a symbolic equation. Compare:

x == 3*x
  ⇒ (sym) x = 3⋅x
x == x
  ⇒ (sym) True

If you wish to force a boolean result, see ‘@sym/logical’ and see ‘@sym/isAlways’:

logical(x == 3*x)
  ⇒ 0
islogical(ans)
  ⇒ 1

syms x y z
eqn = x*(y + z) == x*y + x*z
  ⇒ eqn = (sym) x⋅(y + z) = x⋅y + x⋅z
logical(eqn)
  ⇒ 0
isAlways(eqn)
  ⇒ 1

Currently, these is no robust way to force an an equality equation x == x.

See also: @sym/logical, @sym/isAlways, @sym/isequal, @sym/ne, @sym/le.

Package: symbolic