# Comparison of symbolic expressions

40 views (last 30 days)
reincornator on 16 Feb 2021
Commented: reincornator on 16 Feb 2021
Welcome.
A certain set of symbolic calculations is performed in two different ways. After that, you need to compare the results (we want them to be equal). But using " eq " or "= = " you can't get the desired result. You can use a trick and subtract or divide the results, but this method does not always work correctly.
Is there a function for comparing symbolic calculations?
Example:
##### 0 CommentsShowHide -1 older comments

Sign in to comment.

### Answers (2)

KSSV on 16 Feb 2021
syms a b
c = a+b ;
d = b+a ;
isequal(c,d)
ans = logical
1
##### 2 CommentsShowHide 1 older comment
reincornator on 16 Feb 2021
isequal(expand((x+1)^3),x^3 + 3*x^2 + 3*x + 1)

Sign in to comment.

Walter Roberson on 16 Feb 2021
isAlways(c == d, 'Unknown', false)
##### 1 CommentShowHide None
reincornator on 16 Feb 2021
Edited: reincornator on 16 Feb 2021
Thanks!
syms a b c
d=c*(a+b);
e=c*b+c*a;
j=a*b;
isAlways(e == d, 'Unknown', 'false')
isAlways(j == d, 'Unknown', 'false')

Sign in to comment.

### Categories

Find more on Number Theory in Help Center and File Exchange

R2020a

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!