MATLAB: Can’t separate the two variables for which solution needs to be found

separating the 2 variables

I have to find x1 & x2 in terms of other variables.
x = l/m*s1;
x1 = (l/(m1*(s1+s-s*s1))*(1 + (s1/s)*(1-s) + (s/s1)*(1-s1)) + (l/s1*m1) + (3*l/s*m1)
x2 = l*(3-2*s2)/(m2*s2*(2-s2)) + (4*l/m2*s2)
m1 = m2 = m = p
s = (1 – x*p), s1 = (1 – x1*p)*(1 – x2*p), s2 = (1 – x1*p)*(1-x*p)
x = 1 in the given case. All these are symbols and I tried using expand, then collect & roots function in m – file to solve for x1 & x2, but I can't seem to separate x1 & x2. Is there an easier way to solve this ?

Best Answer

Well, you can reduce everything down to an expression in p and L, generating a 15th degree polynomial if solved for p, or a 12th degree polynomial if solved for L. There are, of course, no analytical roots for either of them.
To make the expression clearer, I will show it collected by p within L, and by L within p:
(-p^12 + (4*p^12-24*p^11+72*p^10-152*p^9+252*p^8-336*p^7+368*p^6-336*p^5+252*p^4-152*p^3+72*p^2-24*p+4)*L^11 + (-12*p^13+24*p^12+24*p^11-132*p^10+264*p^9-384*p^8+384*p^7-264*p^6+132*p^5-24*p^4-24*p^3+12*p^2)*L^10 + p^10 + (12*p^14+60*p^13-216*p^12+240*p^11-260*p^10+292*p^9-132*p^8+16*p^7+56*p^6-188*p^5+188*p^4-96*p^3+32*p^2-4*p)*L^9 + (-4*p^15-96*p^14-24*p^13+376*p^12-348*p^11+383*p^10-407*p^9+36*p^8+116*p^7-46*p^6-22*p^5+40*p^4-5*p^2+p)*L^8 + (36*p^15+252*p^14-240*p^13-120*p^12+39*p^11-138*p^10+276*p^9-312*p^8+194*p^7+48*p^6-52*p^5+16*p^4+3*p^3-2*p^2)*L^7 + (-108*p^15-204*p^14+332*p^13-175*p^12-105*p^11+150*p^10+98*p^9+22*p^8-62*p^7+63*p^6-p^5-12*p^4+2*p^3)*L^6 + (108*p^15-72*p^14-119*p^13+364*p^12-82*p^11-63*p^10+119*p^9+23*p^8-10*p^7-28*p^6+32*p^5-22*p^4+6*p^3)*L^5 + (108*p^14-54*p^13-37*p^12+166*p^11-43*p^10-29*p^9+18*p^8+26*p^7-45*p^6+16*p^5+3*p^4-p^3)*L^4 + (45*p^13-29*p^12-16*p^11+47*p^10-21*p^9-23*p^8+17*p^7+9*p^6-6*p^5+p^4)*L^3 + (p^13+17*p^12-20*p^11+3*p^10+11*p^9+5*p^8-9*p^7+3*p^6)*L^2 + (-3*p^13+3*p^12+3*p^11-2*p^10-4*p^9+3*p^8)*L) / ((p-1)*(p^4+(p^4-2*p^3+2*p^2-2*p+1)*L^3+p^3+(-p^5-2*p^4+2*p^3+p^2)*L^2+(3*p^5+p)*L)*(-p^2+(p-1)*L)^2*p^2)
Or alternately,
((-4*L^8+36*L^7-108*L^6+108*L^5)*p^15 + (12*L^9-96*L^8+252*L^7-204*L^6-72*L^5+108*L^4)*p^14 + (-12*L^10+60*L^9-24*L^8-240*L^7+332*L^6-119*L^5-54*L^4+45*L^3+L^2-3*L)*p^13 + (4*L^11+24*L^10-216*L^9+376*L^8-120*L^7-175*L^6+364*L^5-37*L^4-29*L^3+17*L^2+3*L-1)*p^12 + 4*L^11 + (-24*L^11+24*L^10+240*L^9-348*L^8+39*L^7-105*L^6-82*L^5+166*L^4-16*L^3-20*L^2+3*L)*p^11 + (72*L^11-132*L^10-260*L^9+383*L^8-138*L^7+150*L^6-63*L^5-43*L^4+47*L^3+3*L^2-2*L+1)*p^10 + (-152*L^11+264*L^10+292*L^9-407*L^8+276*L^7+98*L^6+119*L^5-29*L^4-21*L^3+11*L^2-4*L)*p^9 + (252*L^11-384*L^10-132*L^9+36*L^8-312*L^7+22*L^6+23*L^5+18*L^4-23*L^3+5*L^2+3*L)*p^8 + (-336*L^11+384*L^10+16*L^9+116*L^8+194*L^7-62*L^6-10*L^5+26*L^4+17*L^3-9*L^2)*p^7 + (368*L^11-264*L^10+56*L^9-46*L^8+48*L^7+63*L^6-28*L^5-45*L^4+9*L^3+3*L^2)*p^6 + (-336*L^11+132*L^10-188*L^9-22*L^8-52*L^7-L^6+32*L^5+16*L^4-6*L^3)*p^5 + (252*L^11-24*L^10+188*L^9+40*L^8+16*L^7-12*L^6-22*L^5+3*L^4+L^3)*p^4 + (-152*L^11-24*L^10-96*L^9+3*L^7+2*L^6+6*L^5-L^4)*p^3 + (72*L^11+12*L^10+32*L^9-5*L^8-2*L^7)*p^2 + (-24*L^11-4*L^9+L^8)*p) / ((p-1)*((-L^2+3*L)*p^5+(L^3-2*L^2+1)*p^4+L^3+(-2*L^3+2*L^2+1)*p^3+(2*L^3+L^2)*p^2+(-2*L^3+L)*p)*(L*p-p^2-L)^2*p^2)
Not so nice, either way you look at it.
If you examine the first variant, collected by L, and look at the denominator, you can see that the expression blows up for several cases -- p = 0, p = 1, p = L/2 +/- sqrt(L^2-4*L)/2, or p^4+(p^4-2*p^3+2*p^2-2*p+1)*L^3+p^3+(-p^5-2*p^4+2*p^3+p^2)*L^2+(3*p^5+p)*L = 0 which has 3 roots when solved for L.
The third of those conditions can be expressed as L = p^2/(p-1) which is real-valued for all p except p = 1, so no matter how the cubic behaves, there will be at least one non-solution for each p. In fact the cubic has a minimum of 1 real L root for each positive p (two real solutions beyond a point), and a minimum of two real L roots for each negative p. I believe that the cubic has three real roots for each negative p, but some fancy algebraic mangling would be necessary to prove that those vanishingly small imaginary components are necessarily zero.
Anyhow, for each p there are thus between 1 and 4 L for which x1 and x2 have no solution.