MATLAB Answers

How to get the factor format of a polynomial

28 views (last 30 days)
Moisés Antonio Fonseca Beltrán
Moisés Antonio Fonseca Beltrán on 17 Apr 2021 at 9:38
Commented: Alan Stevens on 18 Apr 2021 at 7:36
Hi,
I want to get the factorized format of a symbolic polynomial.
I know how to get the factors in symbolic way:
syms x
factor(x.^2-1)
ans =
[ x - 1, x + 1]
This is an array with factors.
But, I want to get as answer something like
(x - 1)*(x + 1)
how could I get it? I remember in ancient versions this was the result.
Do I have to build this expression?
In this case, any sugestion in order to make it?
Thanks in advance.

Accepted Answer

Alan Stevens
Alan Stevens on 17 Apr 2021 at 10:14
syms x
y=x^2-1;
a = factor(y)
a = 
b = a(1)*a(2)
b = 
  2 Comments
Alan Stevens
Alan Stevens on 18 Apr 2021 at 7:36
Yes, it looks like you'll have to deal with the scalar factor by hand.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!