# Solving the root of 5 equations with 5 unknowns.

2 views (last 30 days)
Kaleb Crook on 28 Oct 2019
Commented: Walter Roberson on 29 Nov 2019
I am struggling to solve this for the 5 symbolic variables necessary. I've searched and tried to find how solve this, but still cannot seem to get past my last line.
syms x1 x2 x3 x4 x5
1-(2*x5)>0;
2-(2*x3)-(2*x4)>0;
2*x5>0;
-x2+x3+x5>0;
2*x2>0;
-x1+2*x3+x4>0;
2*x1>0;
2*x4>0;
y1=0.02497==((2*x1)^2)/((-x1+2*x3+x4)*(3+x1+x2+x3+x4+x5));
y2=0.01283==(2*x2)^2/((-x2+x3+x5)*(3+x1+x2+x3+x4+x5));
y3=0.002062==(((-x1+2*x3+x4)^2)*(-x2+x3+x5))/((2-2*x3-2*x4)^2)*(3+x1+x2+x3+x4+x5);
y4=0.002894==((-x1+2*x3+x4)*(2*x4)^2)/((2-2*x3-2*x4)^2)*(3+x1+x2+x3+x4+x5);
y5=0.10894==(((2*x5)^2)*(-x2+x3+x5))/((1-2*x5)^2)*(3+x1+x2+x3+x4+x5);
sol = fsolve(y1,y2,y3,y4,y5)

Walter Roberson on 29 Oct 2019
You can start by rewriting
Q = @(v) sym(v); %convert to rational
syms x1 x2 x3 x4 x5
assume(1-(2*x5)>0);
assume(2-(2*x3)-(2*x4)>0);
assume(2*x5>0);
assume(-x2+x3+x5>0);
assume(2*x2>0);
assume(-x1+2*x3+x4>0);
assume(2*x1>0);
assume(2*x4>0);
y1=Q(0.02497)==((2*x1)^2)/((-x1+2*x3+x4)*(3+x1+x2+x3+x4+x5));
y2=Q(0.01283)==(2*x2)^2/((-x2+x3+x5)*(3+x1+x2+x3+x4+x5));
y3=Q(0.002062)==(((-x1+2*x3+x4)^2)*(-x2+x3+x5))/((2-2*x3-2*x4)^2)*(3+x1+x2+x3+x4+x5);
y4=Q(0.002894)==((-x1+2*x3+x4)*(2*x4)^2)/((2-2*x3-2*x4)^2)*(3+x1+x2+x3+x4+x5);
y5=Q(0.10894)==(((2*x5)^2)*(-x2+x3+x5))/((1-2*x5)^2)*(3+x1+x2+x3+x4+x5);
after which it would be logical to think of
sol = vpasolve([y1,y2,y3,y4,y5])
but in practice that takes a long time.
The Q part there is to provide a fixed meaning for those floating point numbers. Remember that in formulae, a floating point number such as 0.02497 would represent the entire set of numbers that rounds to 2497/100000, so 2497/10000 - 5/100000 inclusive to 2497/10000 + 5/100000 exclusive.
MATLAB does not do a good job with inequalities. Even when it is able to figure out the answer, then typically it will just give one representative solution, rather than the set of solutions.
A lot of the time it is better to convert simple constraints such as 1-(2*x5)>0 into bounds constraints (vpa accepts them). When that cannot be done, it is often better to introduce a new auxillary variable to transform the expression into an equality, such as 1-(2*x5)=temp5 assuming temp5>0
Walter Roberson on 29 Oct 2019
Maple was able to find a solution after about 3 hours of computation.
The solutions involve taking the roots of a degree 96 polynomial, and raising the roots to various powers up to 95'th power.
The values of the intermediate terms are large enough that MATLAB would not be able to calculate the expressions at all accurately if you were to try to proceed in double precision. To get anywhere, you would have to proceed in symbolic toolbox. I do not know how long it would take the MATLAB Symbolic Toolbox to find the solution; hours very likely.
All 96 roots of the polynomial need to be evaluated and substituted into the expressions, and then the constraints would have to be cross-checked.

Alex Sha on 29 Nov 2019
Hi， Kaleb Crook， refer to the below results:
x1: 0.0481826850207524
x2: 0.0410231263942099
x3: 0.0404768236956547
x4: 0.0777819259818105
x5: 0.156515018083457
Walter Roberson on 29 Nov 2019
Note there are a total of 96 roots. If I recall correctly (it has been a while), about 32 of them satisfied back-checking for validity.