I have the following system with mixed equality and inequalities defined as:
n = 100;
eqn = (n1 + n3 + n5 == n2 + n4 + n6) && (n1 >=
n2) && (n1 - n2 + n3 - n4 >= 0) && (n1 <= n) && (n1 - n2 + n3 <=
n) && (n1 - n2 + n3 - n4 + n5 <= n) && (2 n <=
n1 + n2 + n3 + n4 + n5 + n6 <= 6 n) && (n1 > 0) && (n2 > 0) && (n3 > 0) && (n4 > 0) && (n5 > 0) && (n6 > 0);
How can I find all the integer solutions and especially the number of all integer solutions?
It seems Reduce
or Solve
does not work:
sol = Reduce[eqn, {n1, n2, n3, n4, n5, n6}, Integers]
produces:
(n1 | n2 | n3 | n4 | n5 | n6) \[Element]
Integers && ((1 <= n1 <= 99 &&
0 < n2 <=
n1 && ((0 < n3 < 100 - n1 && 0 < n4 <= n1 - n2 + n3 &&
100 - n1 - n3 <= n5 <= 100 - n1 + n2 - n3 + n4 &&
n6 == n1 - n2 + n3 - n4 + n5) || (100 - n1 <= n3 <=
100 - n1 + n2 && 0 < n4 <= n1 - n2 + n3 &&
0 < n5 <= 100 - n1 + n2 - n3 + n4 &&
n6 == n1 - n2 + n3 - n4 + n5))) || (n1 == 100 &&
1 <= n2 <= 100 && 0 < n3 <= n2 && 0 < n4 <= 100 - n2 + n3 &&
0 < n5 <= n2 - n3 + n4 && n6 == 100 - n2 + n3 - n4 + n5))
FindInstance[eqn, {n1, n2, n3, n4, n5, n6}, Integers, 10]
will give you the first ten sols, but there are more ... $\endgroup$FIndInstance
by setting the number10
as10,000
instead; it has more than10,000
solutions! The computation is very slow and has a very high demand on memory. $\endgroup$