# Computing possibles values (range) for an (polynomial) expression that takes values from two 2-simplex

Let $$(p,q) \in \Delta_2$$ and $$(k,m) \in \Delta_2$$, where $$\Delta_2$$ is the 2-simplex, that is, $$0\leq p\leq 1$$, $$0\leq q\leq 1$$, and $$0\leq 1-p-q\leq 1$$.

Consider the expression

2 (p - q) + 3 k^2 (-1 + 2 p + q) +
k (1 + 6 (-1 + m) p + (3 - 6 m) q) -
m (1 + 3 p - 6 q + 3 m (-1 + p + 2 q))


I want to find the values that the expression above can take, given the conditions on p, q, m, and k.

I tried an approach using Interval

expression[p_, q_, m_, k_] :=
2 (p - q) + 3 k^2 (-1 + 2 p + q) +
k (1 + 6 (-1 + m) p + (3 - 6 m) q) -
m (1 + 3 p - 6 q + 3 m (-1 + p + 2 q))


and observing the values that it takes

substitute[$p_,$k_] :=
N[(2 (p - q) + 3 k^2 (-1 + 2 p + q) +
k (1 + 6 (-1 + m) p + (3 - 6 m) q) -
m (1 + 3 p - 6 q + 3 m (-1 + p + 2 q)) /. {p -> $p, k ->$k}) /. {q -> Interval[{0, 1 - $p}], m -> Interval[{0, 1 -$k}]}]


then

Manipulate[substitute[p, q], {p, 0, 1, 1/10}, {q, 0, 1, 1/10}]


However, using this values in the original expression, return lower values:

Table[expression[0, i, j, 0], {i, 0, 1, .1}, {j, 0, 1, .1}] //
Flatten // MinMax


Your expression appears to take on all values in [-2,2].

expr[{p_, q_}, {k_, m_}] :=
2 (p - q) + 3 k^2 (-1 + 2 p + q) +
k (1 + 6 (-1 + m) p + (3 - 6 m) q) -
m (1 + 3 p - 6 q + 3 m (-1 + p + 2 q));

spx = Simplex[{{0, 0}, {0, 1}, {1, 0}}];
Graphics[spx, Axes -> True]

(* Get the maximum value of expr in the simplex *)
Maximize[expr[X, Y], (X | Y) ∈ spx]
(* Returns: {2, {X -> {1, 0}, Y -> {0, 0}}} *)

(* Get the minimum value of expr in the simplex *)
Minimize[expr[X, Y], (X | Y) ∈ spx]
(* Returns: {-2, {X -> {0, 1}, Y -> {0, 0}}} *)

(* Try out random points *)
points = RandomPoint[Simplex[{{0, 0}, {0, 1}, {1, 0}}], {100000, 2}];
(* a close fit maybe? *)
dist = TruncatedDistribution[{-2, 2}, LaplaceDistribution[0, 0.185]];
pdf = PDF[dist, x];
Show[
Histogram[expr @@@ points, 200, "PDF"],
Plot[pdf, {x, -2, 2}, PlotRange -> {0, 3}, Exclusions -> None]]


... and this proves it:

Resolve[ForAll[{p, q, k, m},
0 <= p <= 1 && 0 <= q <= 1 && 0 <= 1 - p - q <= 1 &&
0 <= k <= 1 && 0 <= m <= 1 && 0 <= 1 - k - m <= 1,
-2 <= expr[{p, q}, {k, m}] <= 2
], Reals]
(* Result: True *)

• The part about random points is nice but not necessary because expr is a continuous function on a convex compact subset of $\mathbb R^4$, therefore it reaches its upper and lower bounds as well as all intermediate values.
– A.G.
Apr 11, 2021 at 21:54
• @A.G. It helps to visualize what's going on. Of course it's continuous - that's assumed, otherwise I'd had to prove there are some values it didn't assume in the simplex and I'd imagine that would be tricky. Apr 11, 2021 at 21:56