1
$\begingroup$

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.

$\endgroup$
1
  • 1
    $\begingroup$ 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}} $\endgroup$ May 29 at 15:52

2 Answers 2

4
$\begingroup$

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}} *)
$\endgroup$
5
  • $\begingroup$ 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. $\endgroup$
    – rrrrr
    May 29 at 15:55
  • $\begingroup$ 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)! $\endgroup$
    – rrrrr
    May 29 at 16:01
  • 2
    $\begingroup$ @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: $\endgroup$
    – Domen
    May 29 at 16:02
  • $\begingroup$ I am! Ok I will remove my edits and look through the tutorial :) $\endgroup$
    – rrrrr
    May 29 at 16:04
  • 2
    $\begingroup$ (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. $\endgroup$
    – Domen
    May 29 at 16:04
4
$\begingroup$

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:

enter image description here

$\endgroup$

Your Answer

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

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