Revision history [back]

Well, Sage doesn't checks its solutions against the assumptions. So you have to add them to the system of inequations you're trying to solve:

SRC=64
a, b, c, d = var('a', 'b', 'c', 'd')
Cns=[a >= 1, a <= 8, b >=4, b <= 512, c >= 2, c <= 128]
eq1 = (SRC / a) * b <= 418
eq2 = (((SRC / a) * b) / c) / d <= 200
eq3 = ((SRC / a) * b) / c <= 480


Since we note that eq3 is redundant against eq2:

sage: eq3.subs(d==1)
64*b/(a*c) <= 480


We can build our set of inequations quite easily:

Sys=copy(Cns)
Sys.append(eq1)
Sys.append(eq2.subs(d==1))


which is easily, if a bit slowly) solved:

sage: %time Sol=solve(Sys,[a,b,c])
CPU times: user 19.1 s, sys: 47.9 ms, total: 19.2 s
Wall time: 16.4 s


The solution seems a bit intricate:

sage: len(Sol)
54


but it could be considerably simplified with a bit of rewriting:

sage: for s in Sol:
....:     print(s)
....:
[max(1, 32/209*b) < a, a < 8, 4 < b, b < (209/4), 2 < c, c < 128, 25*a*c - 8*b == 0]
[max(1, 32/209*b) < a, a < 8, 4 < b, b < (209/4), 2 < c, c < 128, 25*a*c - 8*b > 0]
[a == 1, 4 < b, b < (209/32), 2 < c, c < 128, -8*b + 25*c == 0]
[a == 1, 4 < b, b < (209/32), 2 < c, c < 128, -8*b + 25*c > 0]
[a == 1, b == 4, 2 < c, c < 128, 25*c - 32 == 0]
[a == 1, b == 4, 2 < c, c < 128, 25*c - 32 > 0]
[a == 1, b == 4, c == 2, 18 == 0]
[a == 1, b == 4, c == 2, 18 > 0]
[a == 1, b == 4, c == 128, 3168 == 0]
[a == 1, b == 4, c == 128, 3168 > 0]
[a == 1, b == (209/32), 2 < c, c < 128, 25*c - 209/4 == 0]
[a == 1, b == (209/32), 2 < c, c < 128, 25*c - 209/4 > 0]
[a == 1, b == (209/32), c == 2, (-9/4) == 0]
[a == 1, b == (209/32), c == 2, (-9/4) > 0]
[a == 1, b == (209/32), c == 128, (12591/4) == 0]
[a == 1, b == (209/32), c == 128, (12591/4) > 0]
[a == 1, c == 2, 4 < b, b < (209/32), -8*b + 50 == 0]
[a == 1, c == 2, 4 < b, b < (209/32), -8*b + 50 > 0]
[a == 1, c == 128, 4 < b, b < (209/32), -8*b + 3200 == 0]
[a == 1, c == 128, 4 < b, b < (209/32), -8*b + 3200 > 0]
[a == 8, 4 < b, b < (209/4), 2 < c, c < 128, -8*b + 200*c == 0]
[a == 8, 4 < b, b < (209/4), 2 < c, c < 128, -8*b + 200*c > 0]
[a == 8, b == 4, 2 < c, c < 128, 200*c - 32 == 0]
[a == 8, b == 4, 2 < c, c < 128, 200*c - 32 > 0]
[a == 8, b == 4, c == 2, 368 == 0]
[a == 8, b == 4, c == 2, 368 > 0]
[a == 8, b == 4, c == 128, 25568 == 0]
[a == 8, b == 4, c == 128, 25568 > 0]
[a == 8, b == (209/4), 2 < c, c < 128, 200*c - 418 == 0]
[a == 8, b == (209/4), 2 < c, c < 128, 200*c - 418 > 0]
[a == 8, b == (209/4), c == 2, -18 == 0]
[a == 8, b == (209/4), c == 2, -18 > 0]
[a == 8, b == (209/4), c == 128, 25182 == 0]
[a == 8, b == (209/4), c == 128, 25182 > 0]
[a == 8, c == 2, 4 < b, b < (209/4), -8*b + 400 == 0]
[a == 8, c == 2, 4 < b, b < (209/4), -8*b + 400 > 0]
[a == 8, c == 128, 4 < b, b < (209/4), -8*b + 25600 == 0]
[a == 8, c == 128, 4 < b, b < (209/4), -8*b + 25600 > 0]
[a == 32/209*b, (209/32) < b, b < (209/4), 2 < c, c < 128, 800/209*b*c - 8*b == 0]
[a == 32/209*b, (209/32) < b, b < (209/4), 2 < c, c < 128, 800/209*b*c - 8*b > 0]
[b == 4, 1 < a, a < 8, 2 < c, c < 128, 25*a*c - 32 == 0]
[b == 4, 1 < a, a < 8, 2 < c, c < 128, 25*a*c - 32 > 0]
[b == 4, c == 2, 1 < a, a < 8, 50*a - 32 == 0]
[b == 4, c == 2, 1 < a, a < 8, 50*a - 32 > 0]
[b == 4, c == 128, 1 < a, a < 8, 3200*a - 32 == 0]
[b == 4, c == 128, 1 < a, a < 8, 3200*a - 32 > 0]
[b == 209/32*a, c == 2, 1 < a, a < 8, -9/4*a == 0]
[b == 209/32*a, c == 2, 1 < a, a < 8, -9/4*a > 0]
[b == 209/32*a, c == 128, 1 < a, a < 8, 12591/4*a == 0]
[b == 209/32*a, c == 128, 1 < a, a < 8, 12591/4*a > 0]
[c == 2, max(1, 32/209*b) < a, a < 8, 4 < b, b < (209/4), 50*a - 8*b == 0]
[c == 2, max(1, 32/209*b) < a, a < 8, 4 < b, b < (209/4), 50*a - 8*b > 0]
[c == 128, max(1, 32/209*b) < a, a < 8, 4 < b, b < (209/4), 3200*a - 8*b == 0]
[c == 128, max(1, 32/209*b) < a, a < 8, 4 < b, b < (209/4), 3200*a - 8*b > 0]


Supposing u<v, Sage insist to write [[u==t,...],[u<t, t<v, ...], [t==v, ...]] in place of [u<=t, t<=v, ...]. It is certainly possible to write something for automatically rewrite this, but I'm not currently aware of how...

Cheating a bit :

sage: %time MSol=mathematica.Reduce(Sys,[a,b,c])
CPU times: user 6.76 ms, sys: 0 ns, total: 6.76 ms
Wall time: 31.3 ms
sage: MSol
Inequality[1, LessEqual, a, LessEqual, 8] &&
((Inequality[4, LessEqual, b, LessEqual, (25*a)/4] &&
Inequality[2, LessEqual, c, LessEqual, 128]) ||
(Inequality[(25*a)/4, Less, b, LessEqual, (209*a)/32] &&
Inequality[(8*b)/(25*a), LessEqual, c, LessEqual, 128]))


faster and considerably terset (but not as explicit) as Sage's solution...

HTH,