Automatic tools for solving a set of inequalities

241 Views Asked by At

I am trying to solve problems such as the following:

Find real numbers $a_1,a_2,a_3, b_1,b_2,b_3$ such that all following expressions are true:

  • $a_1+a_2+a_3=0$
  • $b_1+b_2+b_3=0$
  • $a_1>0$ or $b_1>0$
  • $a_1+a_2>0$ or $b_1+b_2<0$
  • ...

The constraints are all additive, in the form: "sum-of-variables < or = or > 0". Some constraints are a disjunction of two such inequalities.

Is there an automatic tool or mathematical software that can solve such systems easily?

1

There are 1 best solutions below

0
On BEST ANSWER

OK, I found out that it can be done quite easily with SageMath. For reference, here is a program that does just what I wanted. Each line in "lists" is a set of one or more conditions connected by "or" (i.e, one of them must be correct).

import itertools

var('a1,a2,a3,a4,a5,a6,b1,b2,b3,b4,b5,b6')
lists=[
[a1+a2+a3+a4+a5+a6==0],
[b1+b2+b3+b4+b5+b6==0],

[a1+a2<0,b1+b2>0],
[a2+a3<0,b2+b3>0],
[a3+a4<0,b3+b4>0],
[a4+a5<0,b4+b5>0],
[a5+a6<0,b5+b6>0],
[a6+a1<0,b6+b1>0],

[b1+b2+b3<0,a1+a2+a3>0],
[b2+b3+b4<0,a2+a3+a4>0],
[b3+b4+b5<0,a3+a4+a5>0],
[b4+b5+b6<0,a4+a5+a6>0],
[b5+b6+b1<0,a5+a6+a1>0],
[b6+b1+b2<0,a6+a1+a2>0],

[a1>0,b1>0],
[a2>0,b2>0],
[a3>0,b3>0],
[a4>0,b4>0],
[a5>0,b5>0],
[a6>0,b6>0],
]

index=1
for ineq in itertools.product(*lists):
    print index, ". ", solve_ineq(list(ineq)), " : ", ineq
    index += 1​