MATLAB: Solve: Cannot find explicit solution but it have solutions, matlab’s bug

solve

this is my code:
syms x0 x1 x2 x3 x4;
cond1 = (1.00028*x0+1.00045*x1)>=1.00035*(x0+x1);
cond2 = ((1.00028*x0+1.00045*x1) + 1.00063*x2)>=1.00054*(x0+x1+x2);
cond3 = (((1.00028*x0+1.00045*x1) + 1.00063*x2)+1.00082*x3)>=1.00076*(x0+x1+x2+x3);
cond4 = ((((1.00028*x0+1.00045*x1) + 1.00063*x2)+1.00082*x3)+1.00101*x4)>=1.00091*(x0+x1+x2+x3+x4);
cond5 = x0+x1+x2+x3+x4>=0;
condconds = [cond1 cond2 cond3 cond4 cond5];
sol = solve(condconds, [x0 x1 x2 x3 x4])
Does my code have any error or matlab have bugs???
My solution :
x0 1
x1 1
x2 3.44
x3 19.94
x4 38.07
by the way, i just need integer x

Best Answer

Look at what you have. A linear system of inequalities. Solve is designed to solve equalities. The solution that you have may be a solution. However, there are infinitely many solutions. One of those solutions must be the zero solution, since your problem is a homogeneous one, with no constant terms.
But, is your "solution truly a solution? I'm afraid not.
vpa(subs(condconds,[x0,x1,x2,x3,x4],[1,1,3.44,19.94,38.07]),10)
ans =
[ 2.0007 <= 2.00073, 5.4429376 <= 5.4428972, 25.3992888 <= 25.399248, 63.5077395 <= 63.5076987, 0.0 <= 63.45]
So the 2nd, 3rd and 4th constraints are all invalidated by your solution, though the errors are small. So I'll ssume you have merely rounded off what may be a valid solution.
Now let me look at the equality form of your constraint system that Stefan found. Is that actually rank deficient?
svd(double(A))
ans =
2.2361
0.00074952
0.00018996
0.00011237
9.3138e-05
NO. Not at all.
Regardless, if we return to the inequality constrained form of your problem, can we find solutions? Probably. A common trick is to use linear programming.
linprog wants <= inequalities, so I'll swap the signs on A.
DA = double(A);
linprog(ones(5,1),-DA,zeros(5,1))
Optimal solution found.
ans =
0
0
0
0
0
linprog(-ones(5,1),-DA,zeros(5,1))
Problem is unbounded.
ans =
[]
So we do find a solution as the zero vector, as we must, since A is actually non-singular. But by looking in another direction, linprog tells us the problem is unbounded. So there are infinitely many solutions in some direction.
Is there a solution where all of the knowns are no smaller than 1?
format long g
>> X = linprog(rand(5,1),-DA,zeros(5,1),[],[],ones(5,1))
Optimal solution found.
X =
1
1
3.88888888889285
21.5925925926071
41.2222222222452
Interesting, in that linprog finds one near what you called the solution. As I said though, there will be infinitely many solutions, but perhaps this will be good enough for you.