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.

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}$
