Products & Services Solutions Academia Support User Community Company

Learn more about Symbolic Math Toolbox   

eq - Perform symbolic equality test

Syntax

eq(A, B)
A == B

Description

eq(A, B) compares each element of A for equality with the corresponding element of B. If the elements are not equal or if either element is undefined, the test fails. eq does not expand or simplify expressions before making the comparison.

A == B is the alternate syntax for eq(A, B).

Examples

Check equality of two symbolic matrices:

A = sym(hilb(10));
B = sym([1/11 1/12 1/13 1/14 1/15 1/16]);
eq(A(9, 3:8), B)

The result is:

ans =
     1     1     1     1     1     1
 

Check the trigonometric identity:

syms x;
sin(x)^2 + cos(x)^2 == 1

The symbolic equality test might fail to recognize mathematical equivalence of polynomial or trigonometric expressions because it does not simplify or expand them. The result is:

ans =
     0

When testing mathematical equivalence of such expressions, simplify the difference between the expressions, and then compare the result with 0:

syms x;
simplify(sin(x)^2 + cos(x)^2 - 1) == 0

The result is:

ans =
     1

See Also

simplify

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS