I need to solve this apparently simple system of equations in Mathematica, but it gives me an error message, that Equations may not give solutions for all “solve” variables. The command is
sol = Solve[{x1 == x A1/(x A1 + y A3), x2 == x A2/(x A2 + y A4),
x3 == y A3/(x A1 + y A3), x4 == y A4/(x A2 + y A4),
x1 + x2 + x3 + x4 == 2, x + y == 1}, {x1, x2, x3, x4, x, y}]
I try now reduce, but it seems still not getting me a solution for say, x variable I am interested in.
Reduce[{x1 == x A1/(x A1 + y A3) && x2 == x A2/(x A2 + y A4) &&
x3 == y A3/(x A1 + y A3) && x4 == y A4/(x A2 + y A4) &&
x1 + x2 + x3 + x4 == 2 && x + y == 1 && 0 < x < 1 && A1 > 0 &&
A2 > 0 && A3 > 0 && A4 > 0}, {x1, x2, x3, x4, x, y},
Reals] // Simplify
Your system has a 1-parameter family of solutions, that is, infinitely many of them. In the solution returned by Solve, the parameter y can be anything (that does not make a denominator zero).
Here’s a way to figure out if there’s a redundant equation.
vars = {x1, x2, x3, x4, x, y};
sys = {x1 == x A1/(x A1 + y A3), x2 == x A2/(x A2 + y A4),
x3 == y A3/(x A1 + y A3), x4 == y A4/(x A2 + y A4),
x1 + x2 + x3 + x4 == 2, x + y == 1};
(* calculate rank of system *)
ideal = sys /. Equal -> Subtract; (* convert equations to polynomial/rational expressions *)
basis = GroebnerBasis[ideal, vars];
relations = PolynomialReduce[ideal, basis, vars]; (* writes system in terms of basis *)
"rank" -> MatrixRank[relations[[All, 1]]] (* number of independent equations *)
(* construct minimal system *)
minpos = FirstPosition[#, 1, Nothing] & /@ RowReduce[relations[[All, 1]]];
"independent" -> minpos
min = Extract[sys, minpos]; (* extract the minimal system (drop redundant equation) *)
sol2 = Solve[min, DeleteCases[vars, y]] // Simplify; (* delete y to control which variable are solved for *)
sol = Solve[sys, vars] // Simplify; (* Simplify puts solutions in the same form *)
"SameQ[sol1,sol2]" -> sol === sol2 (* compare solutions *)
(*
"rank" -> 5
"independent" -> {{1}, {2}, {3}, {5}, {6}} <-- equation 4 is redundant
"SameQ[sol1,sol2]" -> True
*)