# How to minimize $x^2+4xy+5y^2-4x-6y+7$ without using calculus

I would like to find the smallest possible value of the function

$$f(x,y)=x^2+4xy+5y^2-4x-6y+7$$

without taking any derivatives. My thoughts were to complete the square on both $x$ and $y$ and choose appropriate values to make the nonnegative squared terms equal to $0$. Completing the square two times the function becomes

$$\left(x+2y \right)^2 + \left(y-3 \right)^2-4x-2$$

And then it seems appropriate to take $x=-2y$ and $y=3$. These values do not appear to be minimizers though, as calculus and the following graph can verify. The minimizing values appear to be $y=-1$ and $x=4$ instead.

Have I done something wrong in the above?

Thank you.

• That is the idea, but you didn't completely complete the square. You should take the $x^2+4xy-4x=x^2+2x(2y-4)$ and complete that square before moving to complete the square with the $y^2$.
– OR.
Apr 4, 2015 at 18:48
• ... $x^2+2x(2y-2)$*
– OR.
Apr 4, 2015 at 18:55

Write like this:

$$(y+1)^2+(x+2y-2)^2+2.$$

• I can see that this factorization gives the correct values but how can you tell which factorization to carry out? Apr 4, 2015 at 18:52
• @JohnK: Notice that the terms which are “left over” by your own factorization seem to remind us of $(x-2)^2$ But we already have a term of the form $(x+\ldots)^2$. So, putting the two together... Apr 4, 2015 at 18:59
• @Lucian I see, thank you. Apr 4, 2015 at 19:00
• Ignore the constant term. The 4xy tells you to think of (x+2y)^2. This takes care of x^2 and 4y^2 so you need a factor of (y+c)^2. To take care of the x term, we need to add a constant inside the (x+2y) term Apr 4, 2015 at 19:01

Here is an alternative way. When you see there is an extra $x$ term there, you can do a change of variable $u=x+2y$ and $v=y-3$. Then $x=u-2y=u-2(v+3)$. Then the equation can be changed into

$$u^2+v^2-4u+8v+22$$

Using this you can do another normal completing the square.

• (+1) I like the method but I wouldn't have spotted the substitution. How did you realise that particular substitution?
– Karl
Apr 4, 2015 at 19:03
• Well, there is that $x$ there that you want to get rid of, if you want to get the minimum point. Also linear substitution usually doesn't destroy the structure of the function, so the minimum can still be found this way.. Apr 4, 2015 at 19:06
• Thanks. I initially want to do $(x-2)^2-4+5(y-\frac{6}{10})^2-\frac{36}{100})+4xy+7$ So I was trying to ditch the $4xy$
– Karl
Apr 4, 2015 at 19:31