1
$\begingroup$

I have given statements for example:

  • $ax + by < c_1$
  • $cx + by + dz < c_2$

And I want to create larger system of inequations in such a way (suppose variables $x,y,z$ from intervals): I replace all variables $x,y,z$ for all of the possible upper/lower bounds from given intervals.

Simple example: Given:

  • $ax + by < c_1$
  • $cx + by < c_2$
  • $x$ is elem from $(-10, 10)$, $y$ from $(-5, 5)$

Goal: Get this new system:

  • $-10a - 5b < c_1$
  • $10a - 5b < c_1$
  • $-10a + 5b < c_2$
  • $10a + 5b < c_2$
  • And solve this system for variables $a,b$ and given constants $c_1, c_2$.

Is any way how to automatize this step in mathematica, that I type the given inequations, intervals and get this new system and solve it? This example is very simple but in larger systems it is mad to do it manually (the all possible combinations rise very quickly).

$\endgroup$
3

1 Answer 1

3
$\begingroup$

Table does the trick:

Table[{a x + b y < c1, c x + d y < c2}, {x, {-10, 10}}, {y, {-5, 5}}]

Don't forget the inner curly brackets in the specifications for x and y. This guarantees that only the boundary values get substituted instead of -10, -9, -8, ..., 9, 10. (The bounds don't need to be integers.)

Note that the equations come grouped into various nested lists, which is not what you will want:

{{{-10 a - 5 b < c1, -10 c - 5 d < c2}, {-10 a + 5 b < c1, -10 c + 5 d < c2}}, {{10 a - 5 b < c1, 10 c - 5 d < c2}, {10 a + 5 b < c1, 10 c + 5 d < c2}}}

This is easily fixed using Flatten on the result.

Flatten[Table[{a x + b y < c1, c x + d y < c2}, {x, {-10, 10}}, {y, {-5, 5}}]]

{-10 a - 5 b < c1, -10 c - 5 d < c2, -10 a + 5 b < c1, -10 c + 5 d < c2, 10 a - 5 b < c1, 10 c - 5 d < c2, 10 a + 5 b < c1, 10 c + 5 d < c2}

This is ready for the various *Solve commands.

It's not clear from your question what the rule for choosing c1 or c2 is. This generates all 8 combinations, so some of them will be superfluous, but they shouldn't do any harm.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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