Verifying inequalities in Mathematica
Shuvomoy Das Gupta
November 15, 2020
In applied mathematics, we often need to use inequalities to simplify our computation. Of course, verifying an inequality would requires picking up pen and paper and proving the it rigorously. However, a good idea prior to that proving phase is to test if the inequality holds for smaller dimensions. This verification for an inequality over smaller dimension can be done efficiently using Mathematica. Here are two simple examples.
A simple example: AM-GM inequality
We start with a very simple example: the well-known AM-GM inequality. It states that for we have
We can verify it as follows.
(* Clear all the variables, this often comes handy*)
ClearAll["Global`*"];
(*construct the conditions*)
conditions = x > 0 && y > 0;
(*check wheather the AM-GM inequality holds for all x,y satisfying conditions*)
(*Create the AM GM inequality*)
inequalityAMGM =
ForAll[{x, y},
conditions, (x + y)/2 >=
Sqrt[x y]]
(*Verify if the inequality holds for all x,y satisfying conditions*)
Resolve[inequalityAMGM] where we get the output True, so we have verified the AM-GM inequality.
Cauchy inequality
The Cauchy inequality probably one of the most famous inequalities. Let us verify it in Mathematica for dimension 3.
(* Clear all the variables *)
ClearAll["Global`*"];
(* Create the Cauchy inequality *)
ineqCauchy = ForAll[{x, y}, Element[x | y, Vectors[3, Reals]],
Abs[x . y] <= Norm[x]*Norm[y]];
(* Verify if the inequality holds *)
Resolve[ineqCauchy] which outputs True again. We can run this for larger dimension too. However, keep in mind that larger the dimension, longer it would take for Mathematica to verify it. Hence, it is best if this verification process is kept confined to a smaller dimension, and then if the verification process yields True, then go for the good old pen and paper to prove it formally.
A more complicated example: Performance Estimation Problem
As our final example, we consider verifying an inequality that shows up in the performance estimation problem, for more details about this problem, please see the paper by Taylor et al. here. We want to verify an identity that shows up in Theorem 4 of the mentioned paper. Given vectors we want to show that the following two terms and are equal to each other. We have:
and
Where .
First we clear the variables.
(*Clear all the variables*)
ClearAll["Global`*"]; We are going to do this test for . Let us create our assumptions.
n = 3;
myAssumptions = (xi | xj | gi | gj) \[Element]
Vectors[n, Reals] && (\[Mu] | L) \[Element] Reals && \[Mu] > 0 &&
L > 0 && \[Mu] < L Let us construct first.
t1 = fi - fj -
gj.(xi - xj) - (-((2 \[Mu] (-gi + gj).(-xi + xj))/L) +
Norm[gi - gj]^2/L + \[Mu] Norm[xi - xj]^2)/(2 (1 - \[Mu]/L)) Now, let us construct by constructing and .
si = \[Mu]/(L - \[Mu]) Dot[gi,
xi] - (\[Mu] L)/(2 (L - \[Mu])) Norm[xi]^2 -
1/(2 (L - \[Mu])) Norm[gi]^2 + fi;
sj = \[Mu]/(L - \[Mu]) Dot[gj,
xj] - (\[Mu] L)/(2 (L - \[Mu])) Norm[xj]^2 -
1/(2 (L - \[Mu])) Norm[gj]^2 + fj;
pij = Dot[
gj - \[Mu] xj, (L/(L - \[Mu]) xi -
1/(L - \[Mu]) gi) - (L/(L - \[Mu]) xj - 1/(L - \[Mu]) gj)];
t2 = si - sj - pij Construct the identity now.
identityPEP = ForAll[{gi, gj, xi, xj, \[Mu], L}, myAssumptions, t1== t2]
Time to resolve.
Resolve[identityPEP]
This yields True (it will take a few minutes) so the identity in question is true for .