# Quadratic form, Lagrange method

I can't transform quadratic form to canonical using Lagrange method. I know how it works, but still can't. Form is $$x^2 +4xy +8xz -3y^2 + 5z^2$$. I have got some variants, but there is always something unnecessary.

Lagrange's method is just a fancy name for iteratively completing the square: \begin{align*}\require{color} {\color{red}x^2+4xy+8xz}-3y^2+5z^2 &= {\color{red}(x+2y+4z)^2-(2y+4z)^2}-3y^2+5z^2\\ &=(x+2y+4z)^2-4y^2-16yz-16z^2-3y^2+5z^2\\ &=(x+2y+4z)^2{\color{blue}-7y^2-16yz}-11z^2\\ &=(x+2y+4z)^2{\color{blue}-7\left(y+\frac87z\right)^2+\frac{64}7z^2}-11z^2\\ &=(x+2y+4z)^2-7\left(y+\frac87z\right)^2-\frac{13}7z^2\\ \end{align*}