半分の二乗がポイント
よく凡ミスしてしまう。記憶に留めるために書き出しておく。
$$\begin{aligned}
y &= ax^{2} +bx+c
\\
\Leftrightarrow ~ y &= a\left( x^{2} +\frac{b}{a} x\right) +c & \cdots(1)
\\
\\
( x+p)^{2} &= x^{2} +2px+a^{2}
\\
\Leftrightarrow ~ ( x+p)^{2} -p^{2} &= x^{2} +2px
\\
\Leftrightarrow ~ x^{2} +2px &= ( x+p)^{2} -p^{2} & \cdots(2)
\end{aligned}$$
$(2)より(1)式の\displaystyle\frac{b}{a}を2pと捉えるとp=\frac{b}{2a}となるので$
$$\begin{aligned}
&y=a\left(\left( x+\frac{b}{2a}\right)^{2} -\left(\frac{b}{2a}\right)^{2}\right) +c
\\
\Leftrightarrow ~ &y=a\left( x+\frac{b}{2a}\right)^{2} -a\frac{b^{2}}{4a^{2}} +c
\\
\Leftrightarrow ~ &y=a\left( x+\frac{b}{2a}\right)^{2} -\frac{b^{2}}{4a} +c\frac{4a}{4a}
\\
\Leftrightarrow ~ &y=a\left( x+\frac{b}{2a}\right)^{2} -\frac{b^{2} -4ac}{4a}
\end{aligned}$$