# If $x \neq 0,y \neq 0,$ then $x^2+xy+y^2$ is …

I came across the following problem that says:

If $x \neq 0,y \neq 0,$ then $x^2+xy+y^2$ is
1.Always positive
2.Always negative
3.zero
4.Sometimes positive and sometimes negative.

I have to determine which of the aforementioned options is right.

Now since $x \neq 0,y \neq 0$, so $x^2+xy+y^2=(x-y)^2+3xy > 0$,if $x,y$ are of same sign. But if $x,y$ are of different sign,I am not sure about the conclusion.

Can someone point me in the right direction? Thanks in advance for your time.

-
2. Because $x^2+xy+y^2=x^2(1+(y/x)+(y/x)^2)=x^2[(y/x + 1/2)^2 +3/4]>0$ –  tetori Apr 3 '13 at 9:38
You can check the sign of discriminant and conclude . –  boywholived Apr 3 '13 at 12:54

$x^2+xy+y^2 = \frac{3}{4}(x+y)^2+\frac{1}{4}(x-y)^2 >0$, when $x \ne 0$ and $y \ne 0$.

-
Lovely solution! (+5 if I could) –  Ittay Weiss Apr 3 '13 at 9:38
Why did you say "when $x\neq0$ and $y\neq0$"? You need neither for the equality, and only one of them for the inequality. –  Marc van Leeuwen Apr 3 '13 at 9:54
@MarcvanLeeuwen, yes, answer can be expanded with words "equality - in the unique case $(x,y)=(0,0)$". –  Oleg567 Apr 3 '13 at 10:07
How did you get that solution? What transformations (edits) are needed? –  Buksy Apr 3 '13 at 11:38
@Buksy: 1) $(x \pm y)^2 = x^2 \pm 2xy + y^2$. 2) $x^2+xy+y^2$ is ~ like 1), but with multiplier 1 instead of $\pm 2$. 3) $4(x^2+xy+y^2) = \alpha (x+y)^2 + \beta (x-y)^2$. 4) to fit $\alpha$, $\beta$. –  Oleg567 Apr 3 '13 at 11:49

Why not simply $x^2+xy+y^2=(x+\frac{y}{2})^2+\frac{3}{4}y^2>0$?

-
Yes, it is similar too. Nice observation. In general (if we talk about real values), our formulas can be described as: let $a$ $-$ any angle, $b=a\pm\pi/3$. So, $(x\cos{a}+y\cos{b})^2+(x\sin{a}+y\sin{b})^2$ = $(\cos^2{a}+\sin^2{a})x^2 + 2(\cos{a}\cos{b}+\sin{a}\sin{b})xy+(\cos^2{b}+\sin^2{b})y^2$ = $x^2+2\cos(\pm \pi/3)xy+y^2 = x^2+xy+y^2$. Your case: $a=0, b=\pi/3$ $-$ more short (has zero). My case: $a=\pi/6, b=-\pi/6$ $-$ more symmetric. –  Oleg567 Apr 4 '13 at 9:35
@Oleg567, I think you just want $x=x'\cos\alpha+y'\sin\alpha,y=x'(-\sin\alpha)+y'\cos\alpha$, which is geometrically understood as a rotation about the origin. But what I did was just simply completing the squares, this is a very useful trick for treating quadratics. –  Easy Apr 5 '13 at 9:21

As you say, if $x,y$ have the same sign then: $x^2+xy+y^2=(x-y)^2+3xy>0$. If $x,y$ have opposite signs then $x^2+xy+y^2=(x+y)^2-xy>0$.

-
Thanks a lot ,sir.Great concept. –  learner Apr 3 '13 at 9:38
+1 . You know why I did it :-) –  boywholived Apr 3 '13 at 15:34

Hint: $\displaystyle x^2+xy+y^2=y^2 \left( \left( \frac{x}{y} \right)^2+ \frac{x}{y} +1 \right)$; so you just have to study the polynomial $P(z)=z^2+z+1$.

-
I can't see what this is getting at. –  Hammerite Apr 3 '13 at 10:31
@Hammerite: You have $x^2+xy+y^2=y^2P(y/x)$, with $P(z)=z^2+z+1$; but $P(z)>0$ (since its discriminant is negative). –  Seirios Apr 3 '13 at 11:06
I see. Could you make a minor edit to your answer, this site wo't let me cancel my downvote unless you do. –  Hammerite Apr 4 '13 at 12:34
@Hammerite: It's done. –  Seirios Apr 4 '13 at 13:00

I am posting 2 ways of solving this:

$(1)$ If $x,y$ belong to positive real numbers only:

We know that $x^2 + y^2 \geq 2xy$.

Hence we can say that $x^2 + y^2 > xy$

Hence even if $xy$ is negative $x^2 + y^2$,which is positive, is always greater than $xy$ making the sum $x^2 + y^2 + xy$ always positive.

$(2)$ If $x,y$ belong to real numbers:

$$x^2 + y^2 + xy$$

$$= x^2 + 2(x)(\dfrac{y}{2}) + \dfrac{y^2}{4} + \dfrac{3y^2}{4}$$

$$={(x+\dfrac{y}{2})}^2 + \dfrac{3y^2}{4}$$which is always positive.

Hope the answer is clear now !!

-
Thanks a lot.Got it. –  learner Apr 3 '13 at 9:34
@learner: Please do accept this (or any better) solution so that the question is marked as solved. –  user65119 Apr 3 '13 at 9:43
(-1) as, say, $xy = -3$ and $x^2 + y^2 = 1$ is not excluded by your reasoning (but in which case $x^2 + xy + y^2 < 0$) –  TMM Apr 3 '13 at 10:18
Please note $x^2+y^2 \ge 2xy$ does not mean for real numbers $x,y$ $x^2+y^2>xy$ as $2xy>xy$ is valid only when $xy>0$ or both $x,y$ are of same sign. So your proof is valid only when both $x$ and $y$ are of the same sign. –  boywholived Apr 3 '13 at 12:56
TMM and boywholived are both right -- this is not a valid solution. –  Jonathan Apr 3 '13 at 14:10

Don't give up so soon! Your idea also works when they have opposite sign:

$$x^2+xy+y^2=(x+y)^2-xy>0$$

-
This really is the most natural answer by far (for this particular OP). It also captures, more easily than the diagonalization answers, the range of $c$ for which $x^2+cxy+y^2$ is positive definite. –  Erick Wong Apr 4 '13 at 7:29

$x^2 + xy + y^2$ is a quadratic form and can be written $$x^2 + xy + y^2 = \begin{bmatrix} x & y\end{bmatrix}\begin{bmatrix} 1 & \frac{1}{2} \\ \frac{1}{2} & 1 \end{bmatrix}\begin{bmatrix} x \\ y\end{bmatrix}$$

A matrix $\mathbf{A}$ is positive-definite if $\mathbf{z'}\mathbf{A}\mathbf{z}>0$ for all $\mathbf{z}\neq 0$

Show that $\begin{bmatrix} 1 & \frac{1}{2} \\ \frac{1}{2} & 1 \end{bmatrix}$ is a positive-definite matrix and you will have a very nice solution to your problem

-
Thanks a lot,Gabra. Got it. +1 from me.Nice approach. –  learner Apr 3 '13 at 12:54
By making an eigen-decomposition of A above you will get the solution provided by @Oleg567. –  Gabra Apr 3 '13 at 20:22

Some of the answers here are rigorous but overly complicated. Consider that $x^2$ is positive and $y^2$ is positive. The only term that could be negative is $xy$.

Suppose that $xy$ is negative. If abs($x$)>abs($y$), then $x²>-xy,$ so the whole expression is positive. The same logic applies for abs($y$)>abs($x$). The $x=y$ case is clearly positive.

Therefore the whole expression is positive.

-

Writing the given expression in the quadratic matrix form: $$x^2 + xy + y^2 = \begin{bmatrix} x \\ y \end{bmatrix}^T \underbrace{\begin{bmatrix} 1 & a \\ (1-a) & 1 \end{bmatrix}}_{A} \begin{bmatrix} x \\ y \end{bmatrix} \quad\quad\quad (a \in [0,1])$$

According to the Gershgorin Circle Theorem, both the eigenvalues of $A$ may lie in $[0,2]$, and two of them cannot be zero at the same time; so A is at least positive semi-definite.

But, if we manually check for extreme cases (i.e.; $a=0$ and $a=1$) for a more strict analysis, we see that both the eigenvalues are $1$ when $a=1$ and $a=0$.

Therefore, $A$ is positive definite. The given expression is always positive under the given conditions.

-