# How can I find the trivial solution to a polynomial equation?

9 views (last 30 days)
MathWorks Support Team on 24 Sep 2021 at 4:00
Answered: MathWorks Support Team on 24 Sep 2021 at 10:32
Given is a polynomial of the folllowing form,
pol = c11 + c12*x + c13*x^2 + c14*x^3 - (c21 + c22*x + c23*x^2 + c34*x^3)
How can I have MATLAB find the trivial roots 'c11 = c21', 'c12 = c22', 'c13 = c23' and 'c14 = c34' by means of the Symbolic Math Toolbox?

MathWorks Support Team on 24 Sep 2021 at 4:00
Firstly, function 'coeffs' has to be used in order to factorize the latter expression with respect to the unknown variable 'x', namely,

syms c11 c12 c13 c14 c21 c22 c23 c34 x
pol = c11 + c12*x + c13*x^2 + c14*x^3 - (c21 + c22*x + c23*x^2 + c34*x^3);
pol_c = coeffs(pol,x)
This will return a vector of the corresponding factors of the latter polynomial expression with respect to 'x' that has the size of the number of powers of 'x' in the expression, from 0 up to the highest power. Thus, in this case one would obtain a vector 'pol_c' with four symbolic factors, namely,
>> pol_c
pol_c =
[c11 - c21, c12 - c22, c13 - c23, c14 - c34]
Then, please consider using function 'solve' for the symbolic equation that results if you set the latter vector equal to a vector of zeros, namely,
sol = solve(pol_c == zeros(1, length(pol_c)));
In this way, 'sol' is a struct that contains as field names the names of the unknown variables and as fields the corresponding solution for each of the aforementioned equations. For instance,
>> sol.c11
ans =
c21

### Tags

No tags entered yet.

R2018a

### Community Treasure Hunt

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

Start Hunting!