# Quadratic form with Lagrange method

I am trying to understand how to use lagrange method, on the following quadratic form:

$$q(x_1, x_2, x_3, x_4) = 2x_1x_4 - 6x_2x_3$$

1. First, how did they get the following equation? $$q(x_1, x_2, x_3, x_4) = \frac{1}{2}(x_1+x_4)^2 - \frac{1}{2}(x_1-x_4)^2+\frac{3}{2}(x_2-x_3)^2 - \frac{3}{2}(x_2+x_3)^2$$

2. Then they continued and said that $$y_1 = x_1 + x_4$$ $$y_2 = x_1 - x_4$$ $$y_3 = x_2 - x_3$$ $$y_4 = x_2 + x_3$$ While: $$x_1 = \frac{y_1+y_2}{2}$$ $$x_4 = \frac{y_1-y_2}{2}$$ $$x_2 = \frac{y_3+y_3}{2}$$ $$x_3 = \frac{-y_3+y_4}{2}$$ and found that: $$q = \frac{1}{2}y_1^2- \frac{1}{2}y_2^2+\frac{3}{2}y_3^2 - \frac{3}{2}y_4^2$$

Now, I'm trying to figure out the steps they did in order to find those equations

$$2x_{1}x_{4} = (x_{1}+x_{4})^{2}-x_{1}^{2}-x_{4}^{2}$$
Also $$(x_{1}-x_{4})^{2}=x_{1}^{2}+x_{4}^{2}-2x_{1}x_{4}$$ Thus $$2x_{1}x_{4}=\frac{1}{2}(x_{1}+x_{4})^{2} - \frac{1}{2}(x_{1} - x_{4})^{2}$$ Repeat for the remaining term. The next set of $y_{i}$'s play on the fact that it is now 'obvious' to substitute new variables into the quadratic form.
$$(a+b)^2-(a-b)^2\,=\,4ab$$
If you multiply out in the first equation you will get the original one. How did they come with it? Basically experience. Why? In order to obtain a symmetric expression. The $y_i$'s are then defined only to simplify and then the $x_i$'s are just expressed in terms of the $y_i$'s because, they will solve in terms of the $y_i$'s and then they want to substitute in order to find the values of the $x_i$'s.