平方完成(へいほうかんせい、英: completing the square)とは、二次式(二次関数)を式変形して a ( x − h ) 2 {\displaystyle a(x-h)^{2}} の形を作り、一次の項を見かけ上なくすことである。この式変形は全ての二次式に可能で、一意に決まる。 a x 2 + b x + c = a ( x − h ) 2 + k ( a ≠ 0 ) {\displaystyle ax^{2}+bx+c=a(x-h)^{2}+k\quad (a\neq 0)}
x − h {\displaystyle x-h} の h {\displaystyle h} を除けば、つまり x − h = t {\displaystyle x-h=t} と変換すれば a t 2 + k {\displaystyle at^{2}+k}
の形に帰着される。このことより、以下のことが導出できる:
二次方程式の解を求める(→二次方程式の解の公式)
二次関数のグラフの頂点の座標を求める
微分積分学で、冪指数に一次の項を含むガウス積分の計算
ラプラス変換の計算
また、平方完成の考え方を応用して解く手法も見られる(#類似の手法)。 二次式 a x 2 + b x + c ( a ≠ 0 ) {\displaystyle ax^{2}+bx+c\ (a\neq 0)} において、一次の項「 + b x {\displaystyle +\;\!\;\!bx} 」があるのとないのでは、応用上の取り扱いが大きく異なる。 変数 x {\displaystyle x} が x − h {\displaystyle x-h} の形になる代わりに一次の項がなくなれば、 h {\displaystyle h} の違いだけで済むことができる。 ここでは、二次の係数(最高次係数)が 1 の場合とそうでない場合に分けてみる。 の一次の項「 + b x {\displaystyle +\;\!\;\!bx} 」をなくして x 2 {\displaystyle x^{2}} を ( x − h ) 2 {\displaystyle (x-h)^{2}} の形にする。 ( x − h ) 2 = x 2 − 2 h x + h 2 {\displaystyle (x-h)^{2}=x^{2}-2hx+h^{2}} より、一次の係数を比較すると b = − 2 h {\displaystyle b=-2h} h = − b 2 {\displaystyle h=-{\frac {b}{2}}} これにより、x2 + bx + c の平方完成は次の式になる: x 2 + b x + c = ( x + b 2 ) 2 − b 2 4 + c {\displaystyle x^{2}+bx+c=\left(x+{\frac {b}{2}}\right)^{2}-{\frac {b^{2}}{4}}+c} の一次の項「 + b x {\displaystyle +\;\!\;\!bx} 」をなくして x {\displaystyle x} を x − h {\displaystyle x-h} にする。 二次の係数が 1 の場合で得られた等式 x 2 + b x = ( x + b 2 ) 2 − b 2 4 {\displaystyle x^{2}+bx=\left(x+{\frac {b}{2}}\right)^{2}-{\frac {b^{2}}{4}}} を利用する。 a x 2 + b x + c = a ( x 2 + b a x ) + c = a { ( x + b 2 a ) 2 − ( b 2 a ) 2 } + c = a ( x + b 2 a ) 2 − b 2 4 a + c = a ( x + b 2 a ) 2 − b 2 − 4 a c 4 a {\displaystyle {\begin{aligned}ax^{2}+bx+c&=a\left(x^{2}+{\frac {b}{a}}x\right)+c\\&=a\left\{\left(x+{\frac {b}{2a}}\right)^{2}-\left({\frac {b}{2a}}\right)^{2}\right\}+c\\&=a\left(x+{\frac {b}{2a}}\right)^{2}-{\frac {b^{2}}{4a}}+c\\&=a\left(x+{\frac {b}{2a}}\right)^{2}-{\frac {b^{2}-4ac}{4a}}\end{aligned}}} [1]
概観
二次の係数(最高次係数)が 1 の場合
x 2 + b x + c {\displaystyle x^{2}+bx+c}
二次の係数(最高次係数)が 1 でない場合
a x 2 + b x + c ( a ≠ 0 ) {\displaystyle ax^{2}+bx+c\quad (a\neq 0)}