MATLAB Answers

Can I check if factored and expanded polynomial forms are equal?

1 view (last 30 days)
Jacob L
Jacob L on 1 Feb 2020
Answered: Steven Lord on 1 Feb 2020
>> syms w k
>> isequal((w^2-k^2),(w+k)*(w-k))
ans =
logical
0
Is there a way to tell that w^2-k^2 and (w+k)*(w-k) are equal?
Also tried isequal(expand(),expand()) method but expand() may order two polynomials that are the same differently and in these instances isequal() returns logical = 0.

  0 Comments

Sign in to comment.

Accepted Answer

Vladimir Sovkov
Vladimir Sovkov on 1 Feb 2020
Edited: Vladimir Sovkov on 1 Feb 2020
simplify((w^2-k^2) - (w+k)*(w-k))
ans =
0
expand((w+k)*(w-k))
ans =
w^2 - k^2
factor(w^2-k^2)
ans =
[ -1, k - w, k + w]

  1 Comment

Vladimir Sovkov
Vladimir Sovkov on 1 Feb 2020
isequal ( sort ( factor(w^2-k^2) ) , sort ( factor((w-k)*(w+k)) ) )
ans =
logical
1

Sign in to comment.

More Answers (1)

Steven Lord
Steven Lord on 1 Feb 2020
>> syms w k
>> x1 = (w^2-k^2);
>> x2 = (w+k)*(w-k);
>> isAlways(x1 == x2)
ans =
logical
1

  0 Comments

Sign in to comment.

Sign in to answer this question.