markdown
Basics of the least squares methodmd 57a5a10
lecture/math/linear-algebra/least-squares-basics.lecture.n.md
Download PDF

Basics of the least squares method最小二乗法さいしょうにじょうほう

date2026-07-14document_iddoc_9b6f246f2ba44be78ee1e0c83cc1edf6description最小二乗法を、解けない連立一次方程式を列空間への直交射影で近似する方法として導入し、正規方程式まで導く講義である。prerequisites直交補空間と射影 / 階数の基本 / 連立一次方程式と掃き出し法type講義content_typelecturestatusactiverelateddata/lecture/math/linear-algebra/linear-algebra-portal.lecture.n.md / data/lecture/math/linear-algebra/orthogonal-complements-and-projections.lecture.n.md / data/lecture/math/linear-algebra/complex-inner-products-and-unitary-matrices.lecture.n.md / data/lecture/math/linear-algebra/rank-basics.lecture.n.md / data/lecture/math/linear-algebra/pseudoinverse-basics.lecture.n.md / data/exercise/math/linear-algebra/inner-products-orthogonality-and-projections.exercise.n.md / data/exercise/math/linear-algebra/complex-inner-products-and-unitary-matrices.exercise.n.md
mathlinear-algebraundergraduatelecture

1Introduction

The key point of this lecture is that the least squares method最小二乗法さいしょうにじょうほう is not a way to force an inconsistent equation to have an exact solution. It is the method of projecting the right-hand side右辺うへん onto the column space列空間れつくうかん.

The equation Ax=b has a solution exactly when b lies in Col(A). In applications, measured data often put b slightly outside the column space列空間れつくうかん. Then the correct problem is to choose Ax as the point of Col(A) closest to b.

2Terms and definitions

Least squares最小二乗法さいしょうにじょうほう means minimizing

Ax-b2

over x.

The residual残差ざんさ is

r=b-Ax.

For real matrices, the normal equations正規方程式せいきほうていしき are

ATAx=ATb.

In the complex case, AT is replaced by the conjugate transpose共役転置きょうやくてんち A*:

A*Ax=A*b.

3Plan

Since Ax always lies in Col(A), minimizing Ax-b means projecting b onto that column space列空間れつくうかん. The best approximation Ax and the error b-Ax are orthogonal, and that orthogonality gives the normal equations正規方程式せいきほうていしき.

data/lecture/math/linear-algebra/orthogonal-complements-and-projections.lecture.n.md data/lecture/math/linear-algebra/complex-inner-products-and-unitary-matrices.lecture.n.md

4Intuitive explanation

Think of the column space列空間れつくうかん as a plane. If b is not on the plane, Ax=b cannot hold. But there is a closest point on the plane. That point is Ax, and the perpendicular error is the residual.

The reason we project onto the column space列空間れつくうかん is built into the expression Ax: no matter how x is chosen, Ax is a linear combination線型結合せんけいけつごう of the columns of A. Therefore the reachable right-hand sides are exactly Col(A).

At the closest point b^, the residual r=b-b^ has no component along the column space列空間れつくうかん. Otherwise one could move within the column space列空間れつくうかん and reduce the distance. Hence

b=b^+r,b^Col(A),rCol(A).

5Precise explanation

5.11. Projection onto the column space列空間れつくうかん

For a least squares solution, Ax is the orthogonal projection直交射影ちょっこうしゃえい of b onto Col(A). Therefore

r=b-Ax

is orthogonal to every column of A.

5.22. From orthogonality to normal equations正規方程式せいきほうていしき

Let the columns of A be a1,,an. The condition

r,aj=0(j=1,,n)

is written in matrix form as

ATr=0

in the real case. Substituting r=b-Ax gives

AT(b-Ax)=0,

so

ATAx=ATb.

In the complex case, the same orthogonality condition is written as A*r=0, hence

A*(b-Ax)=0,A*Ax=A*b.

5.33. Uniqueness

If the columns of A are linearly independent, then ATA is invertible可逆かぎゃく and the least squares solution is unique:

x=(ATA)-1ATb.

If the columns are linearly dependent, the projection b^ is still unique, but the coefficient vector x may not be unique. The pseudoinverse matrix擬似逆行列ぎじぎゃくぎょうれつ selects the least-norm solution最小さいしょうノルムかい.

5.44. Projection matrix

If A has full column rank階数かいすう, the orthogonal projection直交射影ちょっこうしゃえい onto Col(A) is

P=A(ATA)-1AT.

Then

b^=Pb,r=(I-P)b.

The matrix P satisfies

P2=P,PT=P.

In the complex case,

P=A(A*A)-1A*.

6Concrete examples

For

A=(111),b=(124),

the vector Ax has all entries equal to x. The normal equation is

3x=7,

so x=7/3. This is the average of 1,2,4 and is the best constant approximation.

For a line fit through (0,1),(1,2),(2,2) using y=α+βt, write

A=(101112),x=(αβ),b=(122).

Then

ATA=(3335),ATb=(56).

Solving gives

α=76,β=12.

The best-fit line is

y=76+12t,

and the residual is orthogonal to both columns of A.

7Another viewpoint

Geometrically, the least squares method最小二乗法さいしょうにじょうほう projects a point onto a subspace部分空間ぶぶんくうかん. Statistically, it minimizes the sum of squared differences between observed values and predicted values.

8Theorem: existence and projection characterization

For every ARm×n and bRm, a minimizer of Ax-b exists. The minimizing vector x may not be unique, but the best approximation b^=Ax is unique and equals the orthogonal projection直交射影ちょっこうしゃえい of b onto Col(A).

Indeed, since Col(A) is finite-dimensional, we can decompose

b=b^+r,b^Col(A),rCol(A).

Choose x such that Ax=b^. For any y,

Ay-b2=Ay-b^2+r2[PARSE ERROR: Undefined("Command(\"ge\")")]r2=Ax-b2.

This proof shows that least squares is fundamentally an orthogonal-decomposition argument.

9rank階数かいすう-deficient case and least-norm solutions

If the columns of A are dependent, ATA is not invertible可逆かぎゃく. The normal equations正規方程式せいきほうていしき may have multiple solutions. All such solutions give the same projection b^, and their differences lie in kerA. To choose a unique representative, one selects the solution with no component in the nullspace direction, namely the least-norm solution最小さいしょうノルムかい. This is what the pseudoinverse matrix擬似逆行列ぎじぎゃくぎょうれつ provides.

data/lecture/math/linear-algebra/pseudoinverse-basics.lecture.n.md

10Numerical warning

The normal equations正規方程式せいきほうていしき are theoretically important, but forming ATA can roughly square the condition number. A mildly ill-conditioned matrix can therefore become much more unstable. In numerical computation, QR decomposition or singular value decomposition特異値分解とくいちぶんかいSVD is usually safer.

data/lecture/math/linear-algebra/introduction-to-singular-value-decomposition.lecture.n.md

11Criteria

  • Use least squares when Ax=b is overdetermined or inconsistent.
  • The residual must be orthogonal to the column space列空間れつくうかん.
  • If the columns of A are independent, use the invertibility of ATA.
  • If the columns are dependent, distinguish the unique projection from nonunique coefficient vectors.

12Scope and limitations

In real standard inner products, use AT. In complex spaces, use A*. When the columns are dependent, the projection b^ is unique but the coefficients x need not be. Numerical algorithms often avoid explicitly forming ATA.

13Theorem: existence of least-squares solutions and orthogonal projection

For ARm×n and bRm, a vector x minimizing Ax-b always exists. However, x need not be unique. The unique object is the best approximation b^=Ax, namely the orthogonal projection直交射影ちょっこうしゃえい of b onto Col(A).

The reason is that Col(A) is a finite-dimensional subspace部分空間ぶぶんくうかん, so

b=b^+r,b^Col(A),rCol(A).

Choose x with Ax=b^. For any y,

Ay-b2=Ay-b^2+r2[PARSE ERROR: Undefined("Command(\"ge\")")]r2=Ax-b2.

Here Ay-b^Col(A) and rCol(A) are used. This proof shows that least squares is based on orthogonal decomposition直交分解ちょっこうぶんかい, not merely on differentiation.

14rank階数かいすう-deficient case and least-norm solutions

If the columns of A are linearly dependent一次従属いちじじゅうぞく, then ATA is not invertible. The normal equations正規方程式せいきほうていしき

ATAx=ATb

may have multiple solutions. Those solutions give the same Ax=b^, and their differences lie in kerA. To select a unique representative, choose the least-norm solution with no component in the kerA direction. The pseudoinverse matrix擬似逆行列ぎじぎゃくぎょうれつ realizes this choice.

data/lecture/math/linear-algebra/pseudoinverse-basics.lecture.n.md

15Calculation example: fitting a line with two variables

Approximate the points (0,1),(1,2),(2,2) by y=α+βt. In matrix form,

A=(101112),x=(αβ),b=(122).

The normal equations are

ATA=(3335),ATb=(56),

so

(3335)(αβ)=(56).

Solving gives

α=76,β=12.

Thus the best-fitting line is

y=76+12t.

The residual b-Ax is orthogonal直交ちょっこう to the two columns of A.

16Practical numerical warning

Forming ATA roughly squares the condition number. Thus even if A is only moderately ill-conditioned, ATA can become much more unstable. Normal equations show the theoretical structure, but in numerical computation QR decomposition or singular value decompositionSVD特異値分解とくいちぶんかい is safer.

data/lecture/math/linear-algebra/introduction-to-singular-value-decomposition.lecture.n.md

17Final forms

[PARSE ERROR: Undefined("Command(\"boxed\")")]minxAx-b2
[PARSE ERROR: Undefined("Command(\"boxed\")")]AT(b-Ax)=0
[PARSE ERROR: Undefined("Command(\"boxed\")")]ATAx=ATb
[PARSE ERROR: Undefined("Command(\"boxed\")")]P=A(ATA)-1AT(fullcolumnrank)
[PARSE ERROR: Undefined("Command(\"boxed\")")]A*Ax=A*b(complexcase)

18In one sentence

The least squares method最小二乗法さいしょうにじょうほう projects b onto the column space列空間れつくうかん and makes the residual orthogonal to that column space列空間れつくうかん.

raw .n.md をコピー
loc をコピー (filepath:line ~ line)
copy share link
copy encoded share link
path をコピー
copy share link
copy encoded share link
copy share link
copy encoded share link
タブを全て閉じる