In slightly older versions of Matlab (back to R2012a), one can use the isAlways
as a way to test symbolic equations. This function is also useful for testing inequalities. Just don't forget that the "A" is capitalized in the function name. Taking the liberty to use @zachd1_618's example:
syms x;
f = 3*x^3-2*log(x);
g = 9*x^2 - 2/x;
isAlways(f == g)
returns 0
, but
isAlways(diff(f,x) == g)
returns 1
.
In using either isequaln
or isAlways
, it's a good idea to take advantage of assumptions. Also interesting is sym/logical
:
syms x;
isAlways(1 == sin(x)^2+cos(x)^2)
returns 1
, but
logical(1 == sin(x)^2+cos(x)^2)
returns 0
because it does not simplify the expressions before comparing.