How does this transformation happen? $$
ax^2+2hxy+by^2 = a\left(x+ \frac{h}{a}y \right)^2 + \frac{ab-h^2}{a}y^2
$$
How do I go from the equation on the LHS to the equation on the right hand side? My study material mentions "completing the square", which I know but I can't understand how it applies to this particular equation.
 A: *

*Factor out $a$, this will leave $a(x^2+2(h/a)xy + (b/a)y^2)$

*To make a perfect square $(x+v)^2=x^2+2xv+v^2$ so $2xv$ must match your middle term $2hxy/a$ so let $v=hy/a$ and add and subtract $v^2$. You get $$a\left(x + \frac{h}{a}y\right)^2 - (hy/a)^2 + (b/a)y^2.$$


Can you now finish it?
A: Remember the following identity. $$ a^2+2ab+b^2 =(a+b)^2$$
The process is called completing  the square.
first we divide by $a$ to get $$ ax^2+2hxy+by^2 =a(x^2+2(h/a)xy + (b/a)y^2)$$
Then we add and subtract $$    (h/a)^2y^2$$ to the first two terms to make a perfect square.$$ a(x^2+2(h/a)xy +(h/a)^2y^2 -(h/a)^2y^2 + (b/a)y^2)=$$
$$ a[(x + (h/a)y)^2 -(h/a)^2y^2 + (b/a)y^2)]=$$
$$a\left(a+ \frac{h}{a}y \right)^2 + \frac{ab-h^2}{a}y^2$$
A: For completing the square the coefficient of $\,x^2$ should be one ,so factor out $\,a$ then complete the square as normal with the coefficient of $\,y$ being $\,\frac{2hx}{a}$
ie.
$\,ax^2+2hxy+by^2 $
$= a(x^2+\frac{2hxy}{a}+\frac{by^2}{a}) $
$= a(x^2+\frac{2hxy}{a}+\frac{by^2}{a}+(\frac{hy}{a})^2-(\frac{hy}{a})^2)$
$ = a\big((x +\frac{h}{a}y)^2 -\frac{h^2y^2}{a^2} + \frac{by^2}{a})$
$ = a\big((x +\frac{h}{a}y)^2 + \frac{bay^2-h^2y^2}{a^2})$
$ = a(x +\frac{h}{a}y)^2 + y^2\frac{ba-h^2}{a}$
