#09 ふれてみよう高校数学 代数と式の操作

二次方程式の解法

2次方程式とは

ボールを投げたとき、飛距離は「投げた速度の2乗に比例する」——こういった「2乗が含まれる式」が絡む問題を解くのが2次方程式です。

ax2+bx+c=0ax^2 + bx + c = 0a0a \neq 0)の形の方程式を2次方程式と言います。

解法は主に3種類あります——どれを使うかは問題の形によって変わります。

  1. 因数分解:最もシンプル(使えるときだけ)
  2. 平方完成:どんな式にも使える本質的な方法
  3. 解の公式:すべてのケースに対応する万能公式

方法1:因数分解

x2+5x+6=0x^2 + 5x + 6 = 0 の場合:

(x + 2)(x + 3) = 0
∴ x = -2  または  x = -3

「掛けて6、足して5になる2数」を探せば 2233 が見つかります——「どんな2数を足し算・掛け算したらこの値になるか」という逆算の問題です。

積がゼロ少なくとも一方がゼロ という論理を使います。「AかけるBがゼロならAかBのどちらかがゼロ」——これは普通の数でも同じです。

方程式因数分解
x29=0x^2 - 9 = 0(x+3)(x3)=0(x+3)(x-3)=0x=±3x = \pm 3
x2+4x+4=0x^2 + 4x + 4 = 0(x+2)2=0(x+2)^2=0x=2x = -2(重解)
x25x=0x^2 - 5x = 0x(x5)=0x(x-5)=0x=0,5x = 0, 5

方法2:平方完成

「因数分解できない式はどうするの?」——そこで登場するのが平方完成です。

ax2+bx+c=0ax^2 + bx + c = 0(x+p)2=q(x + p)^2 = q の形に変形します。「完全な平方式に変換する」という発想です。

例:x2+6x+7=0x^2 + 6x + 7 = 0

x² + 6x = -7
x² + 6x + 9 = -7 + 9    ← (6/2)² = 9 を両辺に加える
(x + 3)² = 2
x + 3 = ±√2
x = -3 ± √2

xx の係数の半分を2乗した数を足す」のがコツです。(6/2)2=9(6/2)^2 = 9 を足すと「(x+3)2=x2+6x+9(x+3)^2 = x^2 + 6x + 9」という完全な平方式が完成します。

平方完成の手順

  1. 定数項を右辺に移す
  2. 左辺を (x+b2)2(x + \frac{b}{2})^2 にする((b2)2(\frac{b}{2})^2 を両辺に足す)
  3. 両辺の平方根を取る(±\pm を忘れず——プラスとマイナスの両方)

方法3:解の公式

平方完成を一般の ax2+bx+c=0ax^2 + bx + c = 0 に適用すると解の公式が導けます——「いつでも使える万能の公式」です。

x=b±b24ac2ax = \dfrac{-b \pm \sqrt{b^2 - 4ac}}{2a}

判別式 D=b24acD = b^2 - 4ac が解の個数を決定します——\sqrt{} の中がプラスかゼロかマイナスかで答えの種類が変わります。

DD の値解の個数放物線の形
D>0D > 02つの実数解x軸と2点で交わる
D=0D = 01つの重解x軸に接する
D<0D < 0実数解なし(虚数解)x軸と交わらない

インタラクティブ放物線

マウスのX座標で係数 bb を変化させながら、判別式と解の変化を確認しましょう。bb を大きくすると放物線が左右にスライドし、x軸との交わり方が変わります。

y = x² + bx + 2 の放物線:マウスで b を変え判別式の変化を見る
function loop() {
ctx.clearRect(0, 0, W, H);

var a = 1, c = 2;
var b = -6 + (mx / W) * 12;  // b from -6 to 6
var D = b*b - 4*a*c;

var cx = W/2, cy = 200;
var scaleX = 45, scaleY = 18;

// Grid
ctx.strokeStyle = '#1a2036';
ctx.lineWidth = 1;
for (var gx = -6; gx <= 6; gx++) {
  ctx.beginPath(); ctx.moveTo(cx+gx*scaleX,0); ctx.lineTo(cx+gx*scaleX,H); ctx.stroke();
}

// Axes
ctx.strokeStyle = '#334155'; ctx.lineWidth = 1.5;
ctx.beginPath(); ctx.moveTo(0,cy); ctx.lineTo(W,cy); ctx.stroke();
ctx.beginPath(); ctx.moveTo(cx,0); ctx.lineTo(cx,H); ctx.stroke();

ctx.fillStyle = '#475569'; ctx.font = '11px monospace'; ctx.textAlign = 'center';
for (var n = -6; n <= 6; n++) {
  if (n===0) continue;
  ctx.fillText(n, cx+n*scaleX, cy+14);
}

// Parabola color based on D
var curveColor = D > 0.01 ? '#3b82f6' : (D < -0.01 ? '#ef4444' : '#fbbf24');

ctx.strokeStyle = curveColor;
ctx.lineWidth = 2.5;
ctx.beginPath();
var started = false;
for (var px = 0; px <= W; px += 2) {
  var xv = (px - cx) / scaleX;
  var yv = a*xv*xv + b*xv + c;
  var py = cy - yv * scaleY;
  if (py < -100 || py > H + 100) { started = false; continue; }
  if (!started) { ctx.moveTo(px, py); started = true; }
  else ctx.lineTo(px, py);
}
ctx.stroke();

// Roots
if (D >= 0) {
  var r1 = (-b + Math.sqrt(D)) / (2*a);
  var r2 = (-b - Math.sqrt(D)) / (2*a);
  ctx.fillStyle = '#fbbf24';
  ctx.beginPath();
  ctx.arc(cx + r1*scaleX, cy, 6, 0, Math.PI*2);
  ctx.fill();
  if (Math.abs(r1-r2) > 0.01) {
    ctx.beginPath();
    ctx.arc(cx + r2*scaleX, cy, 6, 0, Math.PI*2);
    ctx.fill();
    ctx.fillStyle = '#fde68a'; ctx.font = '12px monospace'; ctx.textAlign = 'center';
    ctx.fillText('x₁=' + r1.toFixed(2), cx + r1*scaleX, cy - 14);
    ctx.fillText('x₂=' + r2.toFixed(2), cx + r2*scaleX, cy - 14);
  } else {
    ctx.fillStyle = '#fde68a'; ctx.font = '12px monospace'; ctx.textAlign = 'center';
    ctx.fillText('x=' + r1.toFixed(2) + '(重解)', cx + r1*scaleX, cy - 14);
  }
}

// Info panel
ctx.fillStyle = '#0f172a';
ctx.fillRect(8, 8, 260, 90);
ctx.strokeStyle = '#334155'; ctx.lineWidth = 1; ctx.strokeRect(8, 8, 260, 90);

ctx.font = '13px monospace'; ctx.textAlign = 'left';
ctx.fillStyle = '#e2e8f0';
ctx.fillText('y = x² + (' + b.toFixed(2) + ')x + 2', 18, 28);
ctx.fillStyle = D > 0 ? '#22c55e' : D === 0 ? '#fbbf24' : '#ef4444';
ctx.fillText('D = b²-4ac = ' + D.toFixed(2), 18, 50);
ctx.fillStyle = D > 0.01 ? '#22c55e' : D < -0.01 ? '#ef4444' : '#fbbf24';
ctx.fillText(D > 0.01 ? '→ 2つの実数解' : D < -0.01 ? '→ 実数解なし' : '→ 重解(1つ)', 18, 70);
ctx.fillStyle = '#94a3b8';
ctx.fillText('マウスで b を変える', 18, 88);

requestAnimationFrame(loop);
}
loop();

解と係数の関係(ビエタの公式)

「解を直接求めなくても、解の和と積がわかる」——これがビエタの公式の便利なところです。

ax2+bx+c=0ax^2 + bx + c = 0 の2解を α,β\alpha, \beta とすると:

α+β=ba,αβ=ca\alpha + \beta = -\dfrac{b}{a}, \quad \alpha\beta = \dfrac{c}{a}

これをビエタの公式と言います。解を直接求めなくても、解の和・積がわかります。

応用例

x25x+6=0x^2 - 5x + 6 = 0 の2解について:

  • α+β=5\alpha + \beta = 5b=5b = -5 なので (5)/1=5-(-5)/1 = 5
  • αβ=6\alpha\beta = 6c/a=6/1=6c/a = 6/1 = 6
  • α2+β2=(α+β)22αβ=2512=13\alpha^2 + \beta^2 = (\alpha+\beta)^2 - 2\alpha\beta = 25 - 12 = 13

2次方程式の作り方

「解がわかっているとき、逆に方程式を作れる」——答えから問題を作る逆の操作です。

解が 332-2 の2次方程式:

(x - 3)(x + 2) = 0
x² - x - 6 = 0

解が 1+21 + \sqrt{2}121 - \sqrt{2}(共役)の2次方程式:

和 = 2,  積 = 1² - (√2)² = -1
x² - 2x - 1 = 0
解の公式を使って x² + bx + c = 0 を解く:マウスで b を変化
function loop() {
ctx.clearRect(0, 0, W, H);

// b を連続値にして、D=0 になる b=±2 付近でスナップ
var bRaw = -6 + (mx / W) * 12;
var b = Math.round(bRaw);
// D=0 のスナップ点: b=±2 (c=1 のとき D=b²-4=0)
if (Math.abs(bRaw - 2) < 0.35) b = 2;
if (Math.abs(bRaw + 2) < 0.35) b = -2;
var a = 1, c = 1;
var D = b*b - 4*a*c;

ctx.fillStyle = '#94a3b8';
ctx.font = '15px monospace';
ctx.textAlign = 'center';
ctx.fillText('x² + (' + b + ')x + 1 = 0  の解', W/2, 28);

ctx.fillStyle = '#e2e8f0';
ctx.font = '14px monospace';
ctx.fillText('解の公式:x = ( -(' + b + ') ± √((' + b + ')² - 4·1·1) ) / 2', W/2, 60);
ctx.fillText('= ( ' + (-b) + ' ± √(' + D + ') ) / 2', W/2, 84);

if (D > 0) {
  var sqD = Math.sqrt(D);
  var x1 = (-b + sqD) / 2, x2 = (-b - sqD) / 2;
  ctx.fillStyle = '#22c55e';
  ctx.font = 'bold 18px monospace';
  ctx.fillText('x = ' + x1.toFixed(3) + '  または  x = ' + x2.toFixed(3), W/2, 122);
  ctx.fillStyle = '#86efac'; ctx.font = '13px monospace';
  ctx.fillText('D = ' + D + ' > 0  →  2つの実数解', W/2, 148);
} else if (D === 0) {
  ctx.fillStyle = '#fbbf24';
  ctx.font = 'bold 18px monospace';
  ctx.fillText('x = ' + (-b/2).toFixed(1) + '  (重解)', W/2, 122);
  ctx.fillStyle = '#fde68a'; ctx.font = '13px monospace';
  ctx.fillText('D = 0  →  重解', W/2, 148);
} else {
  var sqAbsD = Math.sqrt(-D);
  ctx.fillStyle = '#ef4444';
  ctx.font = 'bold 16px monospace';
  ctx.fillText('x = ' + (-b/2).toFixed(1) + ' ± ' + (sqAbsD/2).toFixed(3) + 'i', W/2, 122);
  ctx.fillStyle = '#fca5a5'; ctx.font = '13px monospace';
  ctx.fillText('D = ' + D + ' < 0  →  虚数解', W/2, 148);
}

ctx.fillStyle = '#fbbf24'; ctx.font = '14px monospace';
ctx.fillText('ビエタ:解の和 = ' + (-b) + ',  解の積 = ' + c, W/2, 188);

ctx.fillStyle = '#64748b'; ctx.font = '12px monospace';
ctx.fillText('マウスを左右に動かして b を変える  (b = ' + b + ')', W/2, 240);

requestAnimationFrame(loop);
}
loop();

まとめ

  • 因数分解:整数解が見つかるとき最速——「掛けて○、足して○になる2数を探す」
  • 平方完成(x+p)2=q(x+p)^2 = q の形に変形して解く——「xx の係数の半分を2乗して足す」
  • 解の公式x=b±D2ax = \dfrac{-b \pm \sqrt{D}}{2a}D=b24acD = b^2 - 4ac——「どんな2次方程式にも使える万能公式」
  • 判別式 DD正・ゼロ・負で解の個数(2・1・0)が決まる——「\sqrt{} の中の符号で勝負が決まる」
  • ビエタの公式α+β=b/a\alpha+\beta = -b/aαβ=c/a\alpha\beta = c/a——「解を求めなくても和と積がわかる」

次回は3次・4次方程式と因数定理を学びます。「ある値を代入してゼロになれば、それが根」という強力な定理です。