# Are there any built-in functions to find the feasible space for a set of constraints? [closed]

I have a set of constants including linear and nonlinear equalities and inequalities. How can I obtain the the admissible values of each dimension (so-called feasible solution space) . Are there any built-in Mathematica functions that can solve these constraints together and find the feasible space?

For example, assume these constraints:

2 == x1 + x2 - x3 - x4/2 + x5;
0 == 4 x1 - 2 x2 + 8 x3/10 + 6 x4/10 + x5^2/2;
(10 <= x1^2 + x2^2 + x3^2 + x4^2 + x5^2);


Also, how could I plot the solution space if the number of dimensions were less than three?

• Please post Mathematica code, not formulas. And if possible, without subscripts – Dr. belisarius Feb 11 '15 at 6:56
• I am not using Mathematica, I am matlab user. But I know most mathematicians use this programe. so I thought to ask my question here and when I got the answer, convert their codes to matlab. or at least I can get the gist of solving such problem. So, if that helps, Please edit my question with Mathematica code. Thanks @belisarius – Electricman Feb 11 '15 at 7:03
• So yours is a question about mathematics, not Mathematica(TM). And I doubt most mathematicians are using this program. Sorry. – Dr. belisarius Feb 11 '15 at 7:10
• You may ask questions about matlab on stackoverflow.com – Dr. belisarius Feb 11 '15 at 7:10
• This question appears to be off-topic because the issue it raises is not a Mathematica issue but a mathematics one. That it is formulated in terms of Mathematica is not sufficient to make it an appropriate question for Mathematica.SE. – m_goldberg Feb 11 '15 at 7:52

Perhaps you are looking forReduce. It will find the solution space for your example problem.

Reduce[
{2 == x1 + x2 - x3 - x4/2 + x5,
0 == 4 x1 - 2 x2 + 8 x3/10 + 6 x4/10 + x5^2/2,
10 <= x1^2 + x2^2 + x3^2 + x4^2 + x5^2},
{x1, x2, x3, x4, x5}, Reals]


It produces a very large result, but does so rather quickly, The result is too large to display in this answer. You will have to run Mathematica to see it and decide for yourself if the result will of any use to you.

• I do have Mathematica .But I don't know how to use it. I copy-pasted the piece of code you wrote in a *.nb file and pressed shift+enter. SO what should I do next? Also, lets assume x4 and x5 are zero. Is it possible to plot the feasible region? Thanks @m_goldberg – Electricman Feb 11 '15 at 8:57
• @Electricman with x4 and x5 zero the result of Solve is rather short and can be used easily (eq1 = 2 == x1 + x2 - x3; eq2 = 0 == 4 x1 - 2 x2 + 8 x3/10; eq3 = (10 <= x1^2 + x2^2 + x3^2); Solve[{eq1 && eq2 && eq3}, {x1, x2, x3}, Reals]). The result lies on a line so RegionPlot3D cannot be used here, but you can use the following: Show[ParametricPlot3D[{2 - x2 + 1/12 (-20 + 15 x2), x2, 1/12 (-20 + 15 x2)}, {x2, -20, 16/63 (3 - Sqrt[51])}], ParametricPlot3D[{2 - x2 + 1/12 (-20 + 15 x2), x2, 1/12 (-20 + 15 x2)}, {x2, 16/63 (3 + Sqrt[51]), 20}], PlotRange -> All], ... – Sjoerd C. de Vries Feb 11 '15 at 11:08
• ... which uses elements picked from the output of Solve – Sjoerd C. de Vries Feb 11 '15 at 11:08
• I got the plot with you codes, But I didnt understand the second part of your code. :( @SjoerdC.deVries – Electricman Feb 12 '15 at 14:28