Writing $k(x_1+\frac{x_2+1}{2k})^2+\frac{4k^2-1}{4k}x_2^2+\frac{2k-1}{2k}x_2-\frac{4k^2+1}{4k}$ in the form $A(x_1+Bx_2+C)^2+E(x_2+F)^2+G$
If we have the following expression:
$$\lambda\left(x_1+\dfrac{x_2+1}{2\lambda}\right)^2+\dfrac{4\lambda^2-1}{4\lambda}x_2^2+\dfrac{2\lambda-1}{2\lambda}x_2-\dfrac{4\lambda^2+1}{4\lambda}$$
and we want to go to the following:
$$A(x_1+Bx_2+C)^2+E(x_2+F)^2+G$$
I can see that $\lambda\left(x_1+\dfrac{x_2+1}{2\lambda}\right)^2$ can be changed into
$\\A(x_1+Bx_2+C)^2$ with $A = \lambda$, $B = C = \frac{1}{2\lambda}$
But how to transform $\dfrac{4\lambda^2-1}{4\lambda}x_2^2+\dfrac{2\lambda-1}{2\lambda}x_2-\dfrac{4\lambda^2+1}{4\lambda}$ to $D(x_2+E)^2+F$
So $D$ looks like to be $\dfrac{4\lambda^2-1}{4\lambda}$, but how to chose $E$ and $F$ so that this transformation holds?
Solution 1:
This is just an application of completing the square. \begin{align*} \frac{4\lambda^2-1}{4\lambda}x_2^2+\frac{2\lambda-1}{2\lambda}x_2-\frac{4\lambda^2+1}{4\lambda}&=\frac{4\lambda^2-1}{4\lambda}\left(x_2^2+\frac{2}{2\lambda+1}x-\frac{4\lambda^2+1}{4\lambda^2-1}\right)\\ &=\frac{4\lambda^2-1}{4\lambda}\left(x_2^2+\frac2{2\lambda+1}x+\frac1{(2\lambda+1)^2}-\frac{4\lambda^2+1}{4\lambda^2-1}-\frac1{(2\lambda+1)^2}\right)\\ &=\frac{4\lambda^2-1}{4\lambda}\left(x_2+\frac1{2\lambda+1}\right)^2-\frac{4\lambda^2+1}{4\lambda}-\frac{(2\lambda-1)}{4\lambda(2\lambda+1)}. \end{align*} So $D=\dfrac{4\lambda^2-1}{4\lambda}$, $E=\dfrac1{2\lambda+1}$, and $F=-\dfrac{4\lambda^2+1}{4\lambda}-\dfrac{2\lambda-1}{4\lambda(2\lambda+1)}$.
Solution 2:
Expand the desired form first:
$D(x_2+E)^2+F=D(x_2^2+2Ex_2+E^2)+F=Dx_2^2+2DEx_2+DE^2+F$.
Then, equate the coefficients above with the coefficients in $\dfrac{4\lambda^2-1}{4\lambda}x_2^2+\dfrac{2\lambda-1}{2\lambda}x_2-\dfrac{4\lambda^2+1}{4\lambda}$ to obtain
$$ \begin{align} &D=\dfrac{4\lambda^2-1}{4\lambda},\\ &2DE=\dfrac{2\lambda-1}{2\lambda},\\ &DE^2+F=-\dfrac{4\lambda^2+1}{4\lambda}. \end{align} $$ Can you solve from here?