how to write a long term in function of other terms in matlab

1 view (last 30 days)
Hello everyone,
I have a very long characteristic polynomial called Poly, which is:
syms lambda beta1 beta2 d1 alpha d2 k d3 p c d4
alpha = evalin(symengine, '`α`');
lambda = evalin(symengine, '`λ`');
beta1 = evalin(symengine, '`β1`');
beta2 = evalin(symengine, '`β2`');
d1 = evalin(symengine, '`d1`');
d2 = evalin(symengine, '`d2`');
d3 = evalin(symengine, '`d3`');
d4 = evalin(symengine, '`d4`');
Poly=x^4 - (4*beta2*d1*d2^2*d3*d4^2*(alpha^2*c^2*d1^2 + 2*alpha*beta1*c*d1*d2*d4 - 2*alpha*beta2*c^2*d1*lambda + 2*alpha*c^2*d1^2*d2 + beta1^2*d2^2*d4^2 + 2*beta1*beta2*c*d2*d4*lambda + 2*beta1*c*d1*d2^2*d4 + beta2^2*c^2*lambda^2 - 2*beta2*c^2*d1*d2*lambda + c^2*d1^2*d2^2)^(1/2) - 2*d1*d2*d4*k*(alpha^2*c^2*d1^2 + 2*alpha*beta1*c*d1*d2*d4 - 2*alpha*beta2*c^2*d1*lambda + 2*alpha*c^2*d1^2*d2 + beta1^2*d2^2*d4^2 + 2*beta1*beta2*c*d2*d4*lambda + 2*beta1*c*d1*d2^2*d4 + beta2^2*c^2*lambda^2 - 2*beta2*c^2*d1*d2*lambda + c^2*d1^2*d2^2) + 2*beta1*d1*d2^2*d4^2*k*(alpha^2*c^2*d1^2 + 2*alpha*beta1*c*d1*d2*d4 - 2*alpha*beta2*c^2*d1*lambda + 2*alpha*c^2*d1^2*d2 + beta1^2*d2^2*d4^2 + 2*beta1*beta2*c*d2*d4*lambda + 2*beta1*c*d1*d2^2*d4 + beta2^2*c^2*lambda^2 - 2*beta2*c^2*d1*d2*lambda + c^2*d1^2*d2^2)^(1/2) + 2*c*d1^2*d2^2*d4*k*(alpha^2*c^2*d1^2 + 2*alpha*beta1*c*d1*d2*d4 - 2*alpha*beta2*c^2*d1*lambda + 2*alpha*c^2*d1^2*d2 + beta1^2*d2^2*d4^2 + 2*beta1*beta2*c*d2*d4*lambda + 2*beta1*c*d1*d2^2*d4 + beta2^2*c^2*lambda^2 - 2*beta2*c^2*d1*d2*lambda + c^2*d1^2*d2^2)^(1/2) + 2*alpha*c*d1^2*d2*d4*k*(alpha^2*c^2*d1^2 + 2*alpha*beta1*c*d1*d2*d4 - 2*alpha*beta2*c^2*d1*lambda + 2*alpha*c^2*d1^2*d2 + beta1^2*d2^2*d4^2 + 2*beta1*beta2*c*d2*d4*lambda + 2*beta1*c*d1*d2^2*d4 + beta2^2*c^2*lambda^2 - 2*beta2*c^2*d1*d2*lambda + c^2*d1^2*d2^2)^(1/2) - 2*beta2*c*d1*d2*d4*k*lambda*(alpha^2*c^2*d1^2 + 2*alpha*beta1*c*d1*d2*d4 - 2*alpha*beta2*c^2*d1*lambda + 2*alpha*c^2*d1^2*d2 + beta1^2*d2^2*d4^2 + 2*beta1*beta2*c*d2*d4*lambda + 2*beta1*c*d1*d2^2*d4 + beta2^2*c^2*lambda^2 - 2*beta2*c^2*d1*d2*lambda + c^2*d1^2*d2^2)^(1/2))/(4*beta2*c*d1*d2^2*d4) - (x^2*(beta1^2*d2^3*d4^2*k - d2*k*(alpha^2*c^2*d1^2 + 2*alpha*beta1*c*d1*d2*d4 - 2*alpha*beta2*c^2*d1*lambda + 2*alpha*c^2*d1^2*d2 + beta1^2*d2^2*d4^2 + 2*beta1*beta2*c*d2*d4*lambda + 2*beta1*c*d1*d2^2*d4 + beta2^2*c^2*lambda^2 - 2*beta2*c^2*d1*d2*lambda + c^2*d1^2*d2^2) - alpha^2*c^2*d1^3*k - d1*k*(alpha^2*c^2*d1^2 + 2*alpha*beta1*c*d1*d2*d4 - 2*alpha*beta2*c^2*d1*lambda + 2*alpha*c^2*d1^2*d2 + beta1^2*d2^2*d4^2 + 2*beta1*beta2*c*d2*d4*lambda + 2*beta1*c*d1*d2^2*d4 + beta2^2*c^2*lambda^2 - 2*beta2*c^2*d1*d2*lambda + c^2*d1^2*d2^2) + c^2*d1^2*d2^3*k + c^2*d1^3*d2^2*k + 2*alpha*c^2*d1^2*d2^2*k + alpha^2*c^2*d1^2*d2*k + beta1^2*d1*d2^2*d4^2*k + 2*c^2*d1^2*d2^2*d4*k - beta2^2*c^2*d1*k*lambda^2 + beta2^2*c^2*d2*k*lambda^2 - 4*beta2*d1*d2^2*d4*(alpha^2*c^2*d1^2 + 2*alpha*beta1*c*d1*d2*d4 - 2*alpha*beta2*c^2*d1*lambda + 2*alpha*c^2*d1^2*d2 + beta1^2*d2^2*d4^2 + 2*beta1*beta2*c*d2*d4*lambda + 2*beta1*c*d1*d2^2*d4 + beta2^2*c^2*lambda^2 - 2*beta2*c^2*d1*d2*lambda + c^2*d1^2*d2^2)^(1/2) + 2*alpha*c*d1^2*k*(alpha^2*c^2*d1^2 + 2*alpha*beta1*c*d1*d2*d4 - 2*alpha*beta2*c^2*d1*lambda + 2*alpha*c^2*d1^2*d2 + beta1^2*d2^2*d4^2 + 2*beta1*beta2*c*d2*d4*lambda + 2*beta1*c*d1*d2^2*d4 + beta2^2*c^2*lambda^2 - 2*beta2*c^2*d1*d2*lambda + c^2*d1^2*d2^2)^(1/2) + 2*beta1*c*d1*d2^3*d4*k + 4*beta2*c*d1*d2^2*d3*d4^2 + 2*alpha*c^2*d1^2*d2*d4*k + 2*beta1*c*d1*d2^2*d4^2*k + 2*beta1*c*d1^2*d2^2*d4*k + 2*alpha*beta2*c^2*d1^2*k*lambda - 2*beta2*c^2*d1*d2^2*k*lambda - 2*c*d1*d2*d4*k*(alpha^2*c^2*d1^2 + 2*alpha*beta1*c*d1*d2*d4 - 2*alpha*beta2*c^2*d1*lambda + 2*alpha*c^2*d1^2*d2 + beta1^2*d2^2*d4^2 + 2*beta1*beta2*c*d2*d4*lambda + 2*beta1*c*d1*d2^2*d4 + beta2^2*c^2*lambda^2 - 2*beta2*c^2*d1*d2*lambda + c^2*d1^2*d2^2)^(1/2) - 2*beta2*c*d1*k*lambda*(alpha^2*c^2*d1^2 + 2*alpha*beta1*c*d1*d2*d4 - 2*alpha*beta2*c^2*d1*lambda + 2*alpha*c^2*d1^2*d2 + beta1^2*d2^2*d4^2 + 2*beta1*beta2*c*d2*d4*lambda + 2*beta1*c*d1*d2^2*d4 + beta2^2*c^2*lambda^2 - 2*beta2*c^2*d1*d2*lambda + c^2*d1^2*d2^2)^(1/2) + 2*alpha*beta1*c*d1*d2^2*d4*k - 2*alpha*beta2*c^2*d1*d2*k*lambda + 2*beta1*beta2*c*d2^2*d4*k*lambda - 2*beta2*c^2*d1*d2*d4*k*lambda))/(4*beta2*c*d1*d2^2*d4) + (x^3*(2*beta2*d2^2*d4*(alpha^2*c^2*d1^2 + 2*alpha*beta1*c*d1*d2*d4 - 2*alpha*beta2*c^2*d1*lambda + 2*alpha*c^2*d1^2*d2 + beta1^2*d2^2*d4^2 + 2*beta1*beta2*c*d2*d4*lambda + 2*beta1*c*d1*d2^2*d4 + beta2^2*c^2*lambda^2 - 2*beta2*c^2*d1*d2*lambda + c^2*d1^2*d2^2)^(1/2) - 2*c^2*d1^2*d2^2*k - 2*beta1*beta2*d2^3*d4^2 + 2*beta1*beta2*d1*d2^2*d4^2 + 2*beta2*c*d1^2*d2^2*d4 - 2*alpha*c^2*d1^2*d2*k - 2*beta2^2*c*d2^2*d4*lambda + 2*beta2*d1*d2*d4*(alpha^2*c^2*d1^2 + 2*alpha*beta1*c*d1*d2*d4 - 2*alpha*beta2*c^2*d1*lambda + 2*alpha*c^2*d1^2*d2 + beta1^2*d2^2*d4^2 + 2*beta1*beta2*c*d2*d4*lambda + 2*beta1*c*d1*d2^2*d4 + beta2^2*c^2*lambda^2 - 2*beta2*c^2*d1*d2*lambda + c^2*d1^2*d2^2)^(1/2) + 2*c*d1*d2*k*(alpha^2*c^2*d1^2 + 2*alpha*beta1*c*d1*d2*d4 - 2*alpha*beta2*c^2*d1*lambda + 2*alpha*c^2*d1^2*d2 + beta1^2*d2^2*d4^2 + 2*beta1*beta2*c*d2*d4*lambda + 2*beta1*c*d1*d2^2*d4 + beta2^2*c^2*lambda^2 - 2*beta2*c^2*d1*d2*lambda + c^2*d1^2*d2^2)^(1/2) + 2*beta2*c*d1*d2^3*d4 + 2*alpha*beta2*c*d1*d2^2*d4 - 2*alpha*beta2*c*d1^2*d2*d4 - 2*beta1*c*d1*d2^2*d4*k + 2*beta2^2*c*d1*d2*d4*lambda + 2*beta2*c^2*d1*d2*k*lambda))/(4*beta2*c*d1*d2^2*d4) - (x*(2*beta2*d2^2*d3*d4^2*(alpha^2*c^2*d1^2 + 2*alpha*beta1*c*d1*d2*d4 - 2*alpha*beta2*c^2*d1*lambda + 2*alpha*c^2*d1^2*d2 + beta1^2*d2^2*d4^2 + 2*beta1*beta2*c*d2*d4*lambda + 2*beta1*c*d1*d2^2*d4 + beta2^2*c^2*lambda^2 - 2*beta2*c^2*d1*d2*lambda + c^2*d1^2*d2^2)^(1/2) - 2*d1*d2*k*(alpha^2*c^2*d1^2 + 2*alpha*beta1*c*d1*d2*d4 - 2*alpha*beta2*c^2*d1*lambda + 2*alpha*c^2*d1^2*d2 + beta1^2*d2^2*d4^2 + 2*beta1*beta2*c*d2*d4*lambda + 2*beta1*c*d1*d2^2*d4 + beta2^2*c^2*lambda^2 - 2*beta2*c^2*d1*d2*lambda + c^2*d1^2*d2^2) - d1*d4*k*(alpha^2*c^2*d1^2 + 2*alpha*beta1*c*d1*d2*d4 - 2*alpha*beta2*c^2*d1*lambda + 2*alpha*c^2*d1^2*d2 + beta1^2*d2^2*d4^2 + 2*beta1*beta2*c*d2*d4*lambda + 2*beta1*c*d1*d2^2*d4 + beta2^2*c^2*lambda^2 - 2*beta2*c^2*d1*d2*lambda + c^2*d1^2*d2^2) - d2*d4*k*(alpha^2*c^2*d1^2 + 2*alpha*beta1*c*d1*d2*d4 - 2*alpha*beta2*c^2*d1*lambda + 2*alpha*c^2*d1^2*d2 + beta1^2*d2^2*d4^2 + 2*beta1*beta2*c*d2*d4*lambda + 2*beta1*c*d1*d2^2*d4 + beta2^2*c^2*lambda^2 - 2*beta2*c^2*d1*d2*lambda + c^2*d1^2*d2^2) - 2*beta1*beta2*d2^3*d3*d4^3 - beta1^2*d2^3*d4^3*k + 2*beta1*d2^2*d4^2*k*(alpha^2*c^2*d1^2 + 2*alpha*beta1*c*d1*d2*d4 - 2*alpha*beta2*c^2*d1*lambda + 2*alpha*c^2*d1^2*d2 + beta1^2*d2^2*d4^2 + 2*beta1*beta2*c*d2*d4*lambda + 2*beta1*c*d1*d2^2*d4 + beta2^2*c^2*lambda^2 - 2*beta2*c^2*d1*d2*lambda + c^2*d1^2*d2^2)^(1/2) + 2*c*d1^2*d2^2*k*(alpha^2*c^2*d1^2 + 2*alpha*beta1*c*d1*d2*d4 - 2*alpha*beta2*c^2*d1*lambda + 2*alpha*c^2*d1^2*d2 + beta1^2*d2^2*d4^2 + 2*beta1*beta2*c*d2*d4*lambda + 2*beta1*c*d1*d2^2*d4 + beta2^2*c^2*lambda^2 - 2*beta2*c^2*d1*d2*lambda + c^2*d1^2*d2^2)^(1/2) - alpha^2*c^2*d1^3*d4*k + beta1^2*d1*d2^2*d4^3*k + 2*beta1^2*d1*d2^3*d4^2*k + c^2*d1^2*d2^3*d4*k + c^2*d1^3*d2^2*d4*k + 2*beta2*d1*d2*d3*d4^2*(alpha^2*c^2*d1^2 + 2*alpha*beta1*c*d1*d2*d4 - 2*alpha*beta2*c^2*d1*lambda + 2*alpha*c^2*d1^2*d2 + beta1^2*d2^2*d4^2 + 2*beta1*beta2*c*d2*d4*lambda + 2*beta1*c*d1*d2^2*d4 + beta2^2*c^2*lambda^2 - 2*beta2*c^2*d1*d2*lambda + c^2*d1^2*d2^2)^(1/2) + 2*alpha*c*d1^2*d2*k*(alpha^2*c^2*d1^2 + 2*alpha*beta1*c*d1*d2*d4 - 2*alpha*beta2*c^2*d1*lambda + 2*alpha*c^2*d1^2*d2 + beta1^2*d2^2*d4^2 + 2*beta1*beta2*c*d2*d4*lambda + 2*beta1*c*d1*d2^2*d4 + beta2^2*c^2*lambda^2 - 2*beta2*c^2*d1*d2*lambda + c^2*d1^2*d2^2)^(1/2) + 2*alpha*c*d1^2*d4*k*(alpha^2*c^2*d1^2 + 2*alpha*beta1*c*d1*d2*d4 - 2*alpha*beta2*c^2*d1*lambda + 2*alpha*c^2*d1^2*d2 + beta1^2*d2^2*d4^2 + 2*beta1*beta2*c*d2*d4*lambda + 2*beta1*c*d1*d2^2*d4 + beta2^2*c^2*lambda^2 - 2*beta2*c^2*d1*d2*lambda + c^2*d1^2*d2^2)^(1/2) + 2*beta1*beta2*d1*d2^2*d3*d4^3 + 2*beta2*c*d1*d2^3*d3*d4^2 + 2*beta1*c*d1^2*d2^3*d4*k + 2*beta2*c*d1^2*d2^2*d3*d4^2 + 2*alpha*c^2*d1^2*d2^2*d4*k + alpha^2*c^2*d1^2*d2*d4*k + 2*beta1*c*d1^2*d2^2*d4^2*k - 2*beta2^2*c*d2^2*d3*d4^2*lambda - beta2^2*c^2*d1*d4*k*lambda^2 + beta2^2*c^2*d2*d4*k*lambda^2 - 2*beta2*c*d1*d2*k*lambda*(alpha^2*c^2*d1^2 + 2*alpha*beta1*c*d1*d2*d4 - 2*alpha*beta2*c^2*d1*lambda + 2*alpha*c^2*d1^2*d2 + beta1^2*d2^2*d4^2 + 2*beta1*beta2*c*d2*d4*lambda + 2*beta1*c*d1*d2^2*d4 + beta2^2*c^2*lambda^2 - 2*beta2*c^2*d1*d2*lambda + c^2*d1^2*d2^2)^(1/2) - 2*beta2*c*d1*d4*k*lambda*(alpha^2*c^2*d1^2 + 2*alpha*beta1*c*d1*d2*d4 - 2*alpha*beta2*c^2*d1*lambda + 2*alpha*c^2*d1^2*d2 + beta1^2*d2^2*d4^2 + 2*beta1*beta2*c*d2*d4*lambda + 2*beta1*c*d1*d2^2*d4 + beta2^2*c^2*lambda^2 - 2*beta2*c^2*d1*d2*lambda + c^2*d1^2*d2^2)^(1/2) + 2*alpha*beta2*c*d1*d2^2*d3*d4^2 - 2*alpha*beta2*c*d1^2*d2*d3*d4^2 + 2*alpha*beta1*c*d1^2*d2^2*d4*k + 2*beta2^2*c*d1*d2*d3*d4^2*lambda + 2*alpha*beta2*c^2*d1^2*d4*k*lambda - 2*beta2*c^2*d1*d2^2*d4*k*lambda - 2*alpha*beta2*c^2*d1*d2*d4*k*lambda + 2*beta1*beta2*c*d1*d2^2*d4*k*lambda))/(4*beta2*c*d1*d2^2*d4)
I want to write it like that Poly=(x+A1)*(x^(3)+B1x^2+B2x+B3)
Where, A1 could be written in function of V1
B1 could be written in function of I1 and T1 and V1
B3 could be written in function of V1 et I1
Where,
T1=(alpha*d3 + d2*d3)/(beta2*d3 + beta1*k);
I1=-(alpha*d1*d3 + d1*d2*d3 - beta2*d3*lambda - beta1*k*lambda)/(d2*(beta2*d3 + beta1*k));
V1=-(k*(alpha*d1*d3 + d1*d2*d3 - beta2*d3*lambda - beta1*k*lambda))/(d2*d3*(beta2*d3 + beta1*k));
I have try the function rewrite but without any result, thanks for any help.

Answers (1)

Walter Roberson
Walter Roberson on 7 Apr 2021
syms lambda beta1 beta2 d1 alpha d2 k d3 p c d4 x
alpha = evalin(symengine, '`α`');
lambda = evalin(symengine, '`λ`');
beta1 = evalin(symengine, '`β1`');
beta2 = evalin(symengine, '`β2`');
d1 = evalin(symengine, '`d1`');
d2 = evalin(symengine, '`d2`');
d3 = evalin(symengine, '`d3`');
d4 = evalin(symengine, '`d4`');
Poly=x^4 - (4*beta2*d1*d2^2*d3*d4^2*(alpha^2*c^2*d1^2 + 2*alpha*beta1*c*d1*d2*d4 - 2*alpha*beta2*c^2*d1*lambda + 2*alpha*c^2*d1^2*d2 + beta1^2*d2^2*d4^2 + 2*beta1*beta2*c*d2*d4*lambda + 2*beta1*c*d1*d2^2*d4 + beta2^2*c^2*lambda^2 - 2*beta2*c^2*d1*d2*lambda + c^2*d1^2*d2^2)^(1/2) - 2*d1*d2*d4*k*(alpha^2*c^2*d1^2 + 2*alpha*beta1*c*d1*d2*d4 - 2*alpha*beta2*c^2*d1*lambda + 2*alpha*c^2*d1^2*d2 + beta1^2*d2^2*d4^2 + 2*beta1*beta2*c*d2*d4*lambda + 2*beta1*c*d1*d2^2*d4 + beta2^2*c^2*lambda^2 - 2*beta2*c^2*d1*d2*lambda + c^2*d1^2*d2^2) + 2*beta1*d1*d2^2*d4^2*k*(alpha^2*c^2*d1^2 + 2*alpha*beta1*c*d1*d2*d4 - 2*alpha*beta2*c^2*d1*lambda + 2*alpha*c^2*d1^2*d2 + beta1^2*d2^2*d4^2 + 2*beta1*beta2*c*d2*d4*lambda + 2*beta1*c*d1*d2^2*d4 + beta2^2*c^2*lambda^2 - 2*beta2*c^2*d1*d2*lambda + c^2*d1^2*d2^2)^(1/2) + 2*c*d1^2*d2^2*d4*k*(alpha^2*c^2*d1^2 + 2*alpha*beta1*c*d1*d2*d4 - 2*alpha*beta2*c^2*d1*lambda + 2*alpha*c^2*d1^2*d2 + beta1^2*d2^2*d4^2 + 2*beta1*beta2*c*d2*d4*lambda + 2*beta1*c*d1*d2^2*d4 + beta2^2*c^2*lambda^2 - 2*beta2*c^2*d1*d2*lambda + c^2*d1^2*d2^2)^(1/2) + 2*alpha*c*d1^2*d2*d4*k*(alpha^2*c^2*d1^2 + 2*alpha*beta1*c*d1*d2*d4 - 2*alpha*beta2*c^2*d1*lambda + 2*alpha*c^2*d1^2*d2 + beta1^2*d2^2*d4^2 + 2*beta1*beta2*c*d2*d4*lambda + 2*beta1*c*d1*d2^2*d4 + beta2^2*c^2*lambda^2 - 2*beta2*c^2*d1*d2*lambda + c^2*d1^2*d2^2)^(1/2) - 2*beta2*c*d1*d2*d4*k*lambda*(alpha^2*c^2*d1^2 + 2*alpha*beta1*c*d1*d2*d4 - 2*alpha*beta2*c^2*d1*lambda + 2*alpha*c^2*d1^2*d2 + beta1^2*d2^2*d4^2 + 2*beta1*beta2*c*d2*d4*lambda + 2*beta1*c*d1*d2^2*d4 + beta2^2*c^2*lambda^2 - 2*beta2*c^2*d1*d2*lambda + c^2*d1^2*d2^2)^(1/2))/(4*beta2*c*d1*d2^2*d4) - (x^2*(beta1^2*d2^3*d4^2*k - d2*k*(alpha^2*c^2*d1^2 + 2*alpha*beta1*c*d1*d2*d4 - 2*alpha*beta2*c^2*d1*lambda + 2*alpha*c^2*d1^2*d2 + beta1^2*d2^2*d4^2 + 2*beta1*beta2*c*d2*d4*lambda + 2*beta1*c*d1*d2^2*d4 + beta2^2*c^2*lambda^2 - 2*beta2*c^2*d1*d2*lambda + c^2*d1^2*d2^2) - alpha^2*c^2*d1^3*k - d1*k*(alpha^2*c^2*d1^2 + 2*alpha*beta1*c*d1*d2*d4 - 2*alpha*beta2*c^2*d1*lambda + 2*alpha*c^2*d1^2*d2 + beta1^2*d2^2*d4^2 + 2*beta1*beta2*c*d2*d4*lambda + 2*beta1*c*d1*d2^2*d4 + beta2^2*c^2*lambda^2 - 2*beta2*c^2*d1*d2*lambda + c^2*d1^2*d2^2) + c^2*d1^2*d2^3*k + c^2*d1^3*d2^2*k + 2*alpha*c^2*d1^2*d2^2*k + alpha^2*c^2*d1^2*d2*k + beta1^2*d1*d2^2*d4^2*k + 2*c^2*d1^2*d2^2*d4*k - beta2^2*c^2*d1*k*lambda^2 + beta2^2*c^2*d2*k*lambda^2 - 4*beta2*d1*d2^2*d4*(alpha^2*c^2*d1^2 + 2*alpha*beta1*c*d1*d2*d4 - 2*alpha*beta2*c^2*d1*lambda + 2*alpha*c^2*d1^2*d2 + beta1^2*d2^2*d4^2 + 2*beta1*beta2*c*d2*d4*lambda + 2*beta1*c*d1*d2^2*d4 + beta2^2*c^2*lambda^2 - 2*beta2*c^2*d1*d2*lambda + c^2*d1^2*d2^2)^(1/2) + 2*alpha*c*d1^2*k*(alpha^2*c^2*d1^2 + 2*alpha*beta1*c*d1*d2*d4 - 2*alpha*beta2*c^2*d1*lambda + 2*alpha*c^2*d1^2*d2 + beta1^2*d2^2*d4^2 + 2*beta1*beta2*c*d2*d4*lambda + 2*beta1*c*d1*d2^2*d4 + beta2^2*c^2*lambda^2 - 2*beta2*c^2*d1*d2*lambda + c^2*d1^2*d2^2)^(1/2) + 2*beta1*c*d1*d2^3*d4*k + 4*beta2*c*d1*d2^2*d3*d4^2 + 2*alpha*c^2*d1^2*d2*d4*k + 2*beta1*c*d1*d2^2*d4^2*k + 2*beta1*c*d1^2*d2^2*d4*k + 2*alpha*beta2*c^2*d1^2*k*lambda - 2*beta2*c^2*d1*d2^2*k*lambda - 2*c*d1*d2*d4*k*(alpha^2*c^2*d1^2 + 2*alpha*beta1*c*d1*d2*d4 - 2*alpha*beta2*c^2*d1*lambda + 2*alpha*c^2*d1^2*d2 + beta1^2*d2^2*d4^2 + 2*beta1*beta2*c*d2*d4*lambda + 2*beta1*c*d1*d2^2*d4 + beta2^2*c^2*lambda^2 - 2*beta2*c^2*d1*d2*lambda + c^2*d1^2*d2^2)^(1/2) - 2*beta2*c*d1*k*lambda*(alpha^2*c^2*d1^2 + 2*alpha*beta1*c*d1*d2*d4 - 2*alpha*beta2*c^2*d1*lambda + 2*alpha*c^2*d1^2*d2 + beta1^2*d2^2*d4^2 + 2*beta1*beta2*c*d2*d4*lambda + 2*beta1*c*d1*d2^2*d4 + beta2^2*c^2*lambda^2 - 2*beta2*c^2*d1*d2*lambda + c^2*d1^2*d2^2)^(1/2) + 2*alpha*beta1*c*d1*d2^2*d4*k - 2*alpha*beta2*c^2*d1*d2*k*lambda + 2*beta1*beta2*c*d2^2*d4*k*lambda - 2*beta2*c^2*d1*d2*d4*k*lambda))/(4*beta2*c*d1*d2^2*d4) + (x^3*(2*beta2*d2^2*d4*(alpha^2*c^2*d1^2 + 2*alpha*beta1*c*d1*d2*d4 - 2*alpha*beta2*c^2*d1*lambda + 2*alpha*c^2*d1^2*d2 + beta1^2*d2^2*d4^2 + 2*beta1*beta2*c*d2*d4*lambda + 2*beta1*c*d1*d2^2*d4 + beta2^2*c^2*lambda^2 - 2*beta2*c^2*d1*d2*lambda + c^2*d1^2*d2^2)^(1/2) - 2*c^2*d1^2*d2^2*k - 2*beta1*beta2*d2^3*d4^2 + 2*beta1*beta2*d1*d2^2*d4^2 + 2*beta2*c*d1^2*d2^2*d4 - 2*alpha*c^2*d1^2*d2*k - 2*beta2^2*c*d2^2*d4*lambda + 2*beta2*d1*d2*d4*(alpha^2*c^2*d1^2 + 2*alpha*beta1*c*d1*d2*d4 - 2*alpha*beta2*c^2*d1*lambda + 2*alpha*c^2*d1^2*d2 + beta1^2*d2^2*d4^2 + 2*beta1*beta2*c*d2*d4*lambda + 2*beta1*c*d1*d2^2*d4 + beta2^2*c^2*lambda^2 - 2*beta2*c^2*d1*d2*lambda + c^2*d1^2*d2^2)^(1/2) + 2*c*d1*d2*k*(alpha^2*c^2*d1^2 + 2*alpha*beta1*c*d1*d2*d4 - 2*alpha*beta2*c^2*d1*lambda + 2*alpha*c^2*d1^2*d2 + beta1^2*d2^2*d4^2 + 2*beta1*beta2*c*d2*d4*lambda + 2*beta1*c*d1*d2^2*d4 + beta2^2*c^2*lambda^2 - 2*beta2*c^2*d1*d2*lambda + c^2*d1^2*d2^2)^(1/2) + 2*beta2*c*d1*d2^3*d4 + 2*alpha*beta2*c*d1*d2^2*d4 - 2*alpha*beta2*c*d1^2*d2*d4 - 2*beta1*c*d1*d2^2*d4*k + 2*beta2^2*c*d1*d2*d4*lambda + 2*beta2*c^2*d1*d2*k*lambda))/(4*beta2*c*d1*d2^2*d4) - (x*(2*beta2*d2^2*d3*d4^2*(alpha^2*c^2*d1^2 + 2*alpha*beta1*c*d1*d2*d4 - 2*alpha*beta2*c^2*d1*lambda + 2*alpha*c^2*d1^2*d2 + beta1^2*d2^2*d4^2 + 2*beta1*beta2*c*d2*d4*lambda + 2*beta1*c*d1*d2^2*d4 + beta2^2*c^2*lambda^2 - 2*beta2*c^2*d1*d2*lambda + c^2*d1^2*d2^2)^(1/2) - 2*d1*d2*k*(alpha^2*c^2*d1^2 + 2*alpha*beta1*c*d1*d2*d4 - 2*alpha*beta2*c^2*d1*lambda + 2*alpha*c^2*d1^2*d2 + beta1^2*d2^2*d4^2 + 2*beta1*beta2*c*d2*d4*lambda + 2*beta1*c*d1*d2^2*d4 + beta2^2*c^2*lambda^2 - 2*beta2*c^2*d1*d2*lambda + c^2*d1^2*d2^2) - d1*d4*k*(alpha^2*c^2*d1^2 + 2*alpha*beta1*c*d1*d2*d4 - 2*alpha*beta2*c^2*d1*lambda + 2*alpha*c^2*d1^2*d2 + beta1^2*d2^2*d4^2 + 2*beta1*beta2*c*d2*d4*lambda + 2*beta1*c*d1*d2^2*d4 + beta2^2*c^2*lambda^2 - 2*beta2*c^2*d1*d2*lambda + c^2*d1^2*d2^2) - d2*d4*k*(alpha^2*c^2*d1^2 + 2*alpha*beta1*c*d1*d2*d4 - 2*alpha*beta2*c^2*d1*lambda + 2*alpha*c^2*d1^2*d2 + beta1^2*d2^2*d4^2 + 2*beta1*beta2*c*d2*d4*lambda + 2*beta1*c*d1*d2^2*d4 + beta2^2*c^2*lambda^2 - 2*beta2*c^2*d1*d2*lambda + c^2*d1^2*d2^2) - 2*beta1*beta2*d2^3*d3*d4^3 - beta1^2*d2^3*d4^3*k + 2*beta1*d2^2*d4^2*k*(alpha^2*c^2*d1^2 + 2*alpha*beta1*c*d1*d2*d4 - 2*alpha*beta2*c^2*d1*lambda + 2*alpha*c^2*d1^2*d2 + beta1^2*d2^2*d4^2 + 2*beta1*beta2*c*d2*d4*lambda + 2*beta1*c*d1*d2^2*d4 + beta2^2*c^2*lambda^2 - 2*beta2*c^2*d1*d2*lambda + c^2*d1^2*d2^2)^(1/2) + 2*c*d1^2*d2^2*k*(alpha^2*c^2*d1^2 + 2*alpha*beta1*c*d1*d2*d4 - 2*alpha*beta2*c^2*d1*lambda + 2*alpha*c^2*d1^2*d2 + beta1^2*d2^2*d4^2 + 2*beta1*beta2*c*d2*d4*lambda + 2*beta1*c*d1*d2^2*d4 + beta2^2*c^2*lambda^2 - 2*beta2*c^2*d1*d2*lambda + c^2*d1^2*d2^2)^(1/2) - alpha^2*c^2*d1^3*d4*k + beta1^2*d1*d2^2*d4^3*k + 2*beta1^2*d1*d2^3*d4^2*k + c^2*d1^2*d2^3*d4*k + c^2*d1^3*d2^2*d4*k + 2*beta2*d1*d2*d3*d4^2*(alpha^2*c^2*d1^2 + 2*alpha*beta1*c*d1*d2*d4 - 2*alpha*beta2*c^2*d1*lambda + 2*alpha*c^2*d1^2*d2 + beta1^2*d2^2*d4^2 + 2*beta1*beta2*c*d2*d4*lambda + 2*beta1*c*d1*d2^2*d4 + beta2^2*c^2*lambda^2 - 2*beta2*c^2*d1*d2*lambda + c^2*d1^2*d2^2)^(1/2) + 2*alpha*c*d1^2*d2*k*(alpha^2*c^2*d1^2 + 2*alpha*beta1*c*d1*d2*d4 - 2*alpha*beta2*c^2*d1*lambda + 2*alpha*c^2*d1^2*d2 + beta1^2*d2^2*d4^2 + 2*beta1*beta2*c*d2*d4*lambda + 2*beta1*c*d1*d2^2*d4 + beta2^2*c^2*lambda^2 - 2*beta2*c^2*d1*d2*lambda + c^2*d1^2*d2^2)^(1/2) + 2*alpha*c*d1^2*d4*k*(alpha^2*c^2*d1^2 + 2*alpha*beta1*c*d1*d2*d4 - 2*alpha*beta2*c^2*d1*lambda + 2*alpha*c^2*d1^2*d2 + beta1^2*d2^2*d4^2 + 2*beta1*beta2*c*d2*d4*lambda + 2*beta1*c*d1*d2^2*d4 + beta2^2*c^2*lambda^2 - 2*beta2*c^2*d1*d2*lambda + c^2*d1^2*d2^2)^(1/2) + 2*beta1*beta2*d1*d2^2*d3*d4^3 + 2*beta2*c*d1*d2^3*d3*d4^2 + 2*beta1*c*d1^2*d2^3*d4*k + 2*beta2*c*d1^2*d2^2*d3*d4^2 + 2*alpha*c^2*d1^2*d2^2*d4*k + alpha^2*c^2*d1^2*d2*d4*k + 2*beta1*c*d1^2*d2^2*d4^2*k - 2*beta2^2*c*d2^2*d3*d4^2*lambda - beta2^2*c^2*d1*d4*k*lambda^2 + beta2^2*c^2*d2*d4*k*lambda^2 - 2*beta2*c*d1*d2*k*lambda*(alpha^2*c^2*d1^2 + 2*alpha*beta1*c*d1*d2*d4 - 2*alpha*beta2*c^2*d1*lambda + 2*alpha*c^2*d1^2*d2 + beta1^2*d2^2*d4^2 + 2*beta1*beta2*c*d2*d4*lambda + 2*beta1*c*d1*d2^2*d4 + beta2^2*c^2*lambda^2 - 2*beta2*c^2*d1*d2*lambda + c^2*d1^2*d2^2)^(1/2) - 2*beta2*c*d1*d4*k*lambda*(alpha^2*c^2*d1^2 + 2*alpha*beta1*c*d1*d2*d4 - 2*alpha*beta2*c^2*d1*lambda + 2*alpha*c^2*d1^2*d2 + beta1^2*d2^2*d4^2 + 2*beta1*beta2*c*d2*d4*lambda + 2*beta1*c*d1*d2^2*d4 + beta2^2*c^2*lambda^2 - 2*beta2*c^2*d1*d2*lambda + c^2*d1^2*d2^2)^(1/2) + 2*alpha*beta2*c*d1*d2^2*d3*d4^2 - 2*alpha*beta2*c*d1^2*d2*d3*d4^2 + 2*alpha*beta1*c*d1^2*d2^2*d4*k + 2*beta2^2*c*d1*d2*d3*d4^2*lambda + 2*alpha*beta2*c^2*d1^2*d4*k*lambda - 2*beta2*c^2*d1*d2^2*d4*k*lambda - 2*alpha*beta2*c^2*d1*d2*d4*k*lambda + 2*beta1*beta2*c*d1*d2^2*d4*k*lambda))/(4*beta2*c*d1*d2^2*d4)
Poly = 
factors = factor(Poly);
depends_on_x = arrayfun(@(V) ismember(x, findSymType(V,'variable')), factors);
other_terms = prod(factors(~depends_on_x));
CC = coeffs(factors(depends_on_x), x, 'all');
c3 = CC(end-3);
c2 = CC(end-2);
c1 = CC(end-1);
c0 = CC(end);
%x^4 + (A1 + B1)*x^3 + (B2 + A1*B1)*x^2 + (B3 + A1*B2)*x + A1*B3
syms A1 B1 B2 B3
eqn1 = c3 == A1 + B1;
eqn2 = c2 == B2 + A1*B1;
eqn3 = c1 == B3 + A1*B2;
eqn4 = c0 == A1*B3;
sol = solve([eqn1, eqn2, eqn3, eqn4], [A1,B1,B2,B3]);
for K = 1 : size(sol.A1,1)
terms(K,:) = [sol.A1(K), sol.B1(K), sol.B2(K), sol.B3(K)];
end
forms = subs(other_terms * (x+A1)*(x^(3)+B1*x^2+B2*x+B3), sol);
sol.A1(1)
ans = 
  1 Comment
Walter Roberson
Walter Roberson on 7 Apr 2021
There are four solutions. They are layed out in the variable terms with the first column being A1, then B1, B2, B3.
The equation is reconstructed into forms
I do not show any of the output other than one of the A1 because the interactive session I am using to display content times out after 55 seconds of execution, and formatting more output takes longer than that.
You might notice that A1(1) involves root() of a degree 4 polynomial. You could get the exact output by using the option 'MaxDegree', 4 on the solve() call, but the output will be quite long.
Please notice that the reconstruction of the full equation requires multiplying by the variable other_terms -- that is a series of constants that multiply through the whole x^4 form. It is necessary to extract them so that the x^3 term has an implicit coefficient of 1 in order to match up the parts properly.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!