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?


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





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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.