MATLAB: How to simplify a symbolic polynomial with respect to x

simplify polynomial

Thanks. What I want is:
syms a b c x
equ = (x-a)*(x-b)+(x-c)
%some code
ans = x^2-(a+b-1)*x+a*b-c

Best Answer

Hi,
use the
collect
command:
syms a b c x
equ = (x-a)*(x-b)+(x-c)
f = collect(equ)
gives:
f =
x^2 + (1 - b - a)*x - c + a*b
which is the version you want sorted by powers of x - just a little bit rewritten, but following your wishes.
Best regards
Stephan