# Generate family of linear inequalities from vector variable for use in FindInstance

Suppose that I have a vector variable xvec = Array[x, 10]. How do I generate the family of linear inequalities

$$F = \{ {x\in\mathbb{R}^{10}:x_1\geq x_2,\ldots,x_9\geq x_{10}} \}$$

xvec[[1]] >= xvec[[2]] ,..., xvec[[9]] >= xvec[[10]]


Specifically, I would like to do something like:

xvec = Array[x, 10]
FindInstance[xvec[[1]]>=xvec[[2]],...,xvec[[9]]>=xvec[[10]],{xvec}]


which is trivial now but is trying to get at a MWE.

• FindInstance[GreaterEqual @@ xvec, xvec] gives: {x[1] -> 0, x[2] -> 0, x[3] -> 0, x[4] -> 0, x[5] -> 0, x[6] -> 0, x[7] -> 0, x[8] -> 0, x[9] -> 0, x[10] -> 0}} Commented May 29, 2023 at 15:52

Use Table.

xvec = Array[x, 10];

ineqs = Table[x[i] >= x[i + 1], {i, 1, Length[xvec] - 1}]
(* {x[1] >= x[2], x[2] >= x[3], x[3] >= x[4], x[4] >= x[5], x[5] >= x[6],
x[6] >= x[7], x[7] >= x[8], x[8] >= x[9], x[9] >= x[10]} *)

FindInstance[ineqs, xvec]
(* {{x[1] -> 0, x[2] -> 0, x[3] -> 0, x[4] -> 0, x[5] -> 0, x[6] -> 0,
x[7] -> 0, x[8] -> 0, x[9] -> 0, x[10] -> 0}} *)

• Thanks, this is great! If I have another variable, say a scalar y that I would like to include in the FindInstance, how would I add this in? For example, suppose I have another inequality ineqy = y>0 and I would like to do FindInstance[ineqs && y > 0, {xvec, y}] but I get an error saying FindInstance::ivar: {x[1],x[2],x[3],x[4],x[5],x[6],x[7],x[8],x[9],x[10]} is not a valid variable. Commented May 29, 2023 at 15:55
• Not sure if this question is related enough to my original one. If not, then I can create a new question (albeit in like 15 minutes when my post-time-limit deactivates)! Commented May 29, 2023 at 16:01
• @rrrrr, you seem to be a novice in Mathematica. I know it can be difficult in the beginning, but it will not be very productive or helpful if you keep asking many small question on StackExchange (yes, there is a good reason for the time-limit). Also, changing a question or adding new subquestions after you got the answer is really discouraged here. I strongly suggest you read through Mathematica tutorials for beginners. There are many of them: Commented May 29, 2023 at 16:02
• I am! Ok I will remove my edits and look through the tutorial :) Commented May 29, 2023 at 16:04
• (1) Fast Introduction for Math Students, (2) The Wolfram Language: Fast Introduction for Programmers, (3) Stephen Wolfram: An Elementary Introduction to the Wolfram Language, and of course tens of thousands of existing questions on this StackExchange. Commented May 29, 2023 at 16:04

In version 12, Mathematica introduced a family of vector comparisons including \[VectorLessEqual]. We can use Differences and then the above operator to get the same effect:

xvec = Array[x, 10]

FindInstance[Differences[xvec] \[VectorLessEqual] 0, xvec]

(* Out: {{x[1] -> 0, x[2] -> 0, x[3] -> 0, x[4] -> 0, x[5] -> 0, x[6] -> 0,
x[7] -> 0, x[8] -> 0, x[9] -> 0, x[10] -> 0}} *)


It's much nicer to see in Mathematica than code: