#12 ふれてみよう高校数学 離散数学・数論

逆行列と連立方程式——行列で「割り算」をする

逆行列とは

55 の逆数は 15\frac{1}{5} で、5×15=15 \times \frac{1}{5} = 1 になる」——行列でも同じように、「掛けると単位行列になる相手」が存在する場合があります。これが逆行列です。

行列 AA に対して、AB=BA=IAB = BA = I(単位行列)を満たす行列 BBAA逆行列(inverse matrix)といい、A1A^{-1} と書きます。

スカラーでいえば「a×a1=1a \times a^{-1} = 1」に相当する関係です——「掛けると元に戻る行列」。

逆行列が存在する行列を正則行列(invertible / non-singular matrix)といいます。


行列式(determinant)

「逆行列が存在するかどうかを一つの数で判定できる」——その数が行列式です。

2×22 \times 2 行列 A=(abcd)A = \begin{pmatrix} a & b \\ c & d \end{pmatrix}行列式を:

det(A)=adbc\det(A) = ad - bc

と定義します。記号:A|A| または det(A)\det(A)

det(A)\det(A)意味
0\neq 0逆行列が存在する(正則)
=0= 0逆行列が存在しない(退化)

幾何学的意味:行列 AA{R}2\mathbb\{R\}^2 の単位正方形を変換したときの面積の拡大率(符号はorientation)——「行列式 =0= 0 は面積が潰れてゼロになる、つまり次元が下がる」。


2×2 逆行列の公式

「対角を入れ替えて、非対角の符号を反転させて、行列式で割る」——手順さえ覚えれば機械的に求められます:

det(A)=adbc0\det(A) = ad - bc \neq 0 のとき:

A1=1adbc(dbca)A^{-1} = \frac{1}{ad-bc}\begin{pmatrix} d & -b \\ -c & a \end{pmatrix}

覚え方:

  • 対角成分を入れ替えada \leftrightarrow d)——「左上と右下を交換する」
  • 非対角成分の符号を反転bbb \to -bccc \to -c
  • 全体を 1det(A)\dfrac{1}{\det(A)} で割る

検証AA1=IA \cdot A^{-1} = I になることを確認してみましょう。


連立方程式を行列で解く

「連立方程式を行列で書くと、解き方がスッキリする」——2本の式を1つの行列の式にまとめて考えます。

連立方程式を行列の言葉で書き直すと:

{2x+3y=8xy=1(2311){A}(xy)x=(81)b\begin{cases} 2x + 3y = 8 \\ x - y = 1 \end{cases} \quad \Leftrightarrow \quad \underbrace{\begin{pmatrix}2&3\\1&-1\end{pmatrix}}_\{A\} \underbrace{\begin{pmatrix}x\\y\end{pmatrix}}_{\mathbf{x}} = \underbrace{\begin{pmatrix}8\\1\end{pmatrix}}_{\mathbf{b}}

AA が正則なら、両辺に左から A1A^{-1} を掛ければ解が求まります——「両辺を AA で割る」:

x=A1b\mathbf{x} = A^{-1}\mathbf{b}

計算:det(A)=2×(1)3×1=5\det(A) = 2 \times (-1) - 3 \times 1 = -5

A1=15(1312)=(1/53/51/52/5)A^{-1} = \frac{1}{-5}\begin{pmatrix}-1&-3\\-1&2\end{pmatrix} = \begin{pmatrix}1/5&3/5\\1/5&-2/5\end{pmatrix}

x=(1/53/51/52/5)(81)=(11/56/5)\mathbf{x} = \begin{pmatrix}1/5&3/5\\1/5&-2/5\end{pmatrix}\begin{pmatrix}8\\1\end{pmatrix} = \begin{pmatrix}11/5\\6/5\end{pmatrix}

x=2.2,y=1.2x = 2.2, y = 1.2


直線の交点として可視化

「2元連立方程式は『2本の直線が交わる点を求める』問題」——グラフで見ると、直感的に理解できます。マウスを動かして定数ベクトル b\mathbf{b} を変えながら、交点の移動を観察しましょう。

連立方程式の解 = 2直線の交点:マウスを左右に動かして b₁ を変えよう。青い直線と橙の直線の交点(緑の点)が解 (x, y)。直線の傾きは変わらず、平行移動するたびに交点が動く。行列式が 0 になると2直線が平行になり交点がなくなる(解なし)。
var b1, b2, detA, invA00, invA01, invA10, invA11, solX, solY;
var ox, oy, scale, a11, a12, a21, a22;

a11 = 2; a12 = 1; a21 = 1; a22 = -2;

function worldToScreen(wx, wy) {
return [ox + wx * scale, oy - wy * scale];
}

function loop() {
ctx.clearRect(0, 0, W, H);

b1 = Math.round((mx / W) * 12 - 2);
b2 = 1;

detA = a11 * a22 - a12 * a21;
ox = W / 2; oy = H / 2; scale = 40;

// axes
ctx.strokeStyle = '#1e293b';
ctx.lineWidth = 1;
for (var g = -6; g <= 6; g++) {
  var sp = worldToScreen(g, -6), ep = worldToScreen(g, 6);
  ctx.beginPath(); ctx.moveTo(sp[0], sp[1]); ctx.lineTo(ep[0], ep[1]); ctx.stroke();
  sp = worldToScreen(-6, g); ep = worldToScreen(6, g);
  ctx.beginPath(); ctx.moveTo(sp[0], sp[1]); ctx.lineTo(ep[0], ep[1]); ctx.stroke();
}
ctx.strokeStyle = '#334155';
ctx.lineWidth = 2;
var axH = worldToScreen(-6, 0), axHe = worldToScreen(6, 0);
ctx.beginPath(); ctx.moveTo(axH[0],axH[1]); ctx.lineTo(axHe[0],axHe[1]); ctx.stroke();
var axV = worldToScreen(0, -6), axVe = worldToScreen(0, 6);
ctx.beginPath(); ctx.moveTo(axV[0],axV[1]); ctx.lineTo(axVe[0],axVe[1]); ctx.stroke();

// line 1: a11*x + a12*y = b1  => y = (b1 - a11*x)/a12
ctx.strokeStyle = '#60a5fa';
ctx.lineWidth = 2.5;
ctx.beginPath();
for (var xi = -6; xi <= 6; xi += 0.1) {
  var yi1 = (b1 - a11 * xi) / a12;
  var pt = worldToScreen(xi, yi1);
  if (xi === -6) ctx.moveTo(pt[0], pt[1]); else ctx.lineTo(pt[0], pt[1]);
}
ctx.stroke();

// line 2: a21*x + a22*y = b2  => y = (b2 - a21*x)/a22
ctx.strokeStyle = '#f97316';
ctx.lineWidth = 2.5;
ctx.beginPath();
for (var xj = -6; xj <= 6; xj += 0.1) {
  var yi2 = (b2 - a21 * xj) / a22;
  var pt2 = worldToScreen(xj, yi2);
  if (xj === -6) ctx.moveTo(pt2[0], pt2[1]); else ctx.lineTo(pt2[0], pt2[1]);
}
ctx.stroke();

// solution point
if (Math.abs(detA) > 0.001) {
  invA00 = a22 / detA; invA01 = -a12 / detA;
  invA10 = -a21 / detA; invA11 = a11 / detA;
  solX = invA00 * b1 + invA01 * b2;
  solY = invA10 * b1 + invA11 * b2;
  var sp2 = worldToScreen(solX, solY);
  ctx.fillStyle = '#22c55e';
  ctx.beginPath();
  ctx.arc(sp2[0], sp2[1], 7, 0, Math.PI * 2);
  ctx.fill();
  ctx.fillStyle = '#e2e8f0';
  ctx.font = '12px monospace';
  ctx.textAlign = 'left';
  ctx.fillText('解: x=' + solX.toFixed(2) + ', y=' + solY.toFixed(2), sp2[0]+10, sp2[1]-8);
}

ctx.fillStyle = '#60a5fa';
ctx.font = '13px monospace';
ctx.textAlign = 'left';
ctx.fillText(a11 + 'x + ' + a12 + 'y = ' + b1, 14, 20);
ctx.fillStyle = '#f97316';
ctx.fillText(a21 + 'x + (' + a22 + ')y = ' + b2, 14, 38);
ctx.fillStyle = '#94a3b8';
ctx.fillText('det(A) = ' + detA, 14, 56);

requestAnimationFrame(loop);
}
loop();

クラメルの公式

「行列式だけを使って解を直接求める方法」——2×22 \times 2 連立方程式 Ax=bA\mathbf{x} = \mathbf{b} の解はクラメルの公式でも求められます:

x=det(Ax)det(A),y=det(Ay)det(A)x = \frac{\det(A_x)}{\det(A)}, \quad y = \frac{\det(A_y)}{\det(A)}

ここで AxA_xAA の第1列を b\mathbf{b} で置換した行列、AyA_y は第2列を置換した行列——「分子の行列式が変わるだけで、計算の構造は同じ」。


逆行列が存在しない場合

「行列式がゼロのとき、連立方程式は特別な状況になる」:

det(A)=0\det(A) = 0 のとき:

  • 2本の直線が平行(解なし)または同一直線(解が無限にある)
  • 行列式 =0= 0 は「変換が面積を 00 に潰す」こと、つまり次元が下がることを意味する——「平面の情報が失われてしまい、元に戻せない」

まとめ

  • det(A)=adbc\det(A) = ad - bc:逆行列の存在判定と変換の拡大率——「ゼロかどうかで逆行列の有無が決まる」
  • 2×22 \times 2 逆行列:対角入れ替え・非対角符号反転・1/det1/\det 倍——「3ステップで求まる」
  • Ax=bA\mathbf{x} = \mathbf{b} の解:x=A1b\mathbf{x} = A^{-1}\mathbf{b}——「行列の『割り算』で連立方程式が解ける」
  • 幾何的には:2本の直線の交点を求める操作——「グラフで見ると交点が解」
  • det(A)=0\det(A) = 0 のとき逆行列は存在しない——「次元が潰れると元に戻せない」

次回は行列の固有値・固有ベクトル——行列が「引き伸ばすだけ」の特別な方向を探します。