Finding maximum of $y-z$ given quadratic constraint

93 Views Asked by At

Problem

According to my friend, this is a problem that seems to be solvable by observation.

Try to find the maximum of $(y-z)$ given following two constraints

$$ \begin{aligned} x+y+z=3\\ x^2+y^2+z^2=9 \end{aligned} $$

This is a convex QCQP problem and it is solvable by some solver like cvxpy but I am not sure how do I solve this problem by observation?

Except treating it as a QCQP problem, I also tried to eliminate $z$ and finally cast it into maximizing $x+2y-3$ given $$ x^2+y^2+2xy-3(x+y)=0\tag{1} $$ the hope is that I factor (1) into terms of $(x+2y-3)$, but I failed to do this.

So does anyone know how to solve this, thank you in advance.

1

There are 1 best solutions below

2
On BEST ANSWER

I'm not sure about using "observation", but here is how I would approach solving your $2$ equations of

$$x + y + z = 3 \tag{1}\label{eq1}$$ $$x^2 + y^2 + z^2 = 9 \tag{2}\label{eq2}$$

You can start to "complete the square" by using \eqref{eq2} - $2 \times$ \eqref{eq1} to get

$$x^2 - 2x + y^2 - 2y + z^2 - 2z = 9 - 2 \times 3 = 3 \tag{3}\label{eq3}$$

Each of $x$, $y$ and $z$ need a term of $1$, so adding this to both sides and then completing the square for each variable gives that

$$\left(x - 1\right)^2 + \left(y - 1\right)^2 + \left(z - 1\right)^2 = 6 \tag{4}\label{eq4}$$

First, note that $y - z = \left(y - 1\right) - \left(z - 1\right)$. Since each term above is squared, the solutions would involve $x - 1 = \pm m$, for some non-negative $m$, and likewise for the other $2$ terms. Also, the maximum values for $\mid y - 1 \mid$ and $\mid z - 1 \mid$ will be reached when $x = 1$ so the first term is $0$ and we then get

$$\left(y - 1\right)^2 + \left(z - 1\right)^2 = 6 \tag{5}\label{eq5}$$

As the MSE question at Maximizing the sum of two numbers, the sum of whose squares is constant shows in several ways, the maximum value of the sum of absolute values is achieved when $\left(y - 1\right)^2 = \left(z - 1\right)^2 = 3$, giving $y - 1 = \sqrt{3}$ and $z - 1 = -\sqrt{3}$, for a maximum value of $y - z$ being $2\sqrt{3}$. Note \eqref{eq1} still holds as $x = 1$, $y = 1 + \sqrt{3}$ and $z = 1 - \sqrt{3}$ gives $x + y + z = 3$, plus \eqref{eq2} also holds, confirming this is a valid solution.

It's important to check the original equations since if we had instead added $2 \times$ \eqref{eq1} to \eqref{eq2} to complete the squares to get $\left(x + 1\right)^2 + \left(y + 1\right)^2 + \left(z + 1\right)^2 = 18$ and then followed the same procedure to set $x = -1$, we would have got $y + 1 = 3$ and $z + 1 = -3$ for $y - z = 6$. However, $x + y + z = -3$ in this case, so \eqref{eq1} wouldn't be true then, and $x^2 + y^2 + z^2 = 21$, so \eqref{eq2} would also fail! Completing the squares by subtracting allows determining the maximum value of $y - z$ most easily as $x = 1$ works in that case to simplify both the resulting equation & to get a maximum result with $x, y, z$ values that still satisfy both of the original $2$ equations.

It's possible this, or something similar, is what your friend was referring to, where if they have enough knowledge & experience doing this sort of thing, then to them it's solved by "observation". However, it's of course best to ask your friend what they specifically meant.

Update: I think I see how this can be solved by "inspection". First, split the RHS value of \eqref{eq1} equally among the $3$ variables to do a similar linear transform of $x = x_1 + 1$, $y = y_1 + 1$ and $z = z_1 + 1$. Now, \eqref{eq1} becomes

$$x_1 + y_1 + z_1 = 0 \tag{6}\label{eq6}$$

Also, the LHS of \eqref{eq2} becomes, including using \eqref{eq6} after grouping,

\begin{align} x^2 + y^2 + z^2 & = \left(x_1 + 1\right)^2 + \left(y_1 + 1\right)^2 + \left(z_1 + 1\right)^2 \\ & = x_1^2 + 2x_1 + 1 + y_1^2 + 2y_1 + 1 + z_1^2 + 2z_1 + 1 \\ & = x_1^2 + y_1^2 + z_1^2 + 2\left(x_1 + y_1 + z_1\right) + 3 \\ & = x_1^2 + y_1^2 + z_1^2 + 3 \tag{7}\label{eq7} \end{align}

Thus, \eqref{eq2} is now

$$x_1^2 + y_1^2 + z_1^2 = 6 \tag{8}\label{eq8}$$

The condition to maximize of $y - z = y_1 - z_1$ can now easily be done due to the special condition that allows $x_1 = 0$ in \eqref{eq8} to permit a maximum value where $y_1 = -z_1$ exactly matches the resulting condition in \eqref{eq7} when $x_1 = 0$!

More generally, if the LHS of \eqref{eq1} is $c$ & the LHS of \eqref{eq2} is $d$, the maximum value of $y - z$ would be $2\sqrt{\frac{3d \, - \, c^2}{6}}$, which simplifies to $2\sqrt{3}$ in our case.