Survey of Mathematics

2.9 Inner products, orthogonality, Gram–Schmidt, projection

An inner product gives any vector space lengths, angles and perpendicularity. With it, orthogonal bases make coordinates easy, Gram–Schmidt builds them, and projection onto a subspace gives the closest point.

Taught in 375/376Apostol, not taughtBeyond the courseApostol 1.11 to 1.17Spagnolie, Lectures 4 to 6MATH 375 HW3 and HW4

So far a vector space can add and scale, but it has no length, no angle and no idea of “perpendicular”. In JEE you learned the dot product as a⃗⋅b⃗=∣a⃗∣∣b⃗∣cos⁡θ\vec a\cdot\vec b = |\vec a||\vec b|\cos\theta, which starts from the angle. This chapter goes the other way. We write down a few properties of the dot product as axioms (an inner product), and then we define length and angle from it. That works in any vector space, including spaces of functions, and it leads to the most useful idea in applied mathematics: the closest point to a vector, inside a subspace, is its shadow.

Before you start

You need bases and coordinates (2.2), matrix multiplication and the transpose (2.5), and one fact from 2.8 near the end. Some integration is used for function spaces. Three quick checks:

Quick checkIs {(1,0),(1,1)}\{(1, 0), (1, 1)\} a basis of R2\mathbb R^2?
Quick checkWhat are the coordinates of (3,5)(3, 5) in the basis {(1,0),(1,1)}\{(1, 0), (1, 1)\}?
Quick checkFor column vectors x=(1,2)x = (1, 2) and y=(3,4)y = (3, 4), what is the 1×11\times1 matrix product xTyx^{\mathsf T}y?

The picture

Drag the blue vector vv and the grey direction uu. The green arrow pp is the shadow of vv on the line through uu. The red dashed arrow ee is what is left over. It meets the line at a right angle, and the little square marks that. Now use the slider under the picture to move the orange point along the line. It is never closer to vv than the shadow is. This one picture is the backbone of the chapter: Cauchy–Schwarz, Gram–Schmidt, best approximation, Fourier series and least squares are all this triangle in different spaces.

Where this came from· Cauchy, Bunyakovsky, Schwarz

The inequality that makes angles possible grew in steps, each for a bigger setting. Cauchy published it in 1821 for finite sums of numbers. Bunyakovsky (1859) proved the matching inequality for integrals, which is the version for functions that you use in this chapter. Schwarz (1888) gave the modern proof of the integral version. Some books, especially Russian ones, use all three names. The three versions are one theorem, because the proof below uses only the inner-product axioms and never what the vectors are. That is the point of defining an inner product by axioms: one proof then covers sums, integrals and every other case.

The idea, in words

The dot product x⋅y=x1y1+⋯+xnynx\cdot y = x_1y_1 + \dots + x_ny_n does three jobs. It measures length (x⋅x\sqrt{x\cdot x}), it detects perpendicular vectors (x⋅y=0x\cdot y = 0), and it measures how much xx points along yy. All three come from four properties of the dot product. So we take those four properties as the rules, call anything that obeys them an inner product, and everything else follows by algebra. The payoff is that functions can be “perpendicular” too, and we can ask for the nearest function in a family.

Why· How much does x point along y?

Look at the picture. The shadow of vv on the line of uu is p=c up = c\,u with c=v⋅uu⋅uc = \dfrac{v\cdot u}{u\cdot u}. That is the whole idea of projection: the number cc is the dot product, divided by the length of uu squared so that uu‘s own size does not matter. When vv is perpendicular to uu, the shadow is zero. When vv is a multiple of uu, the shadow is vv itself. Every formula later in the chapter is this one repeated.

Definitions and theorems

Inner products

Definition T

Inner product

Let VV be a real vector space. An inner product assigns to every pair x,yx, y in VV a real number (x,y)(x, y) such that, for all x,y,zx, y, z in VV and every real cc:

  1. (x,y)=(y,x)(x, y) = (y, x) (symmetry);
  2. (x+z,y)=(x,y)+(z,y)(x + z, y) = (x, y) + (z, y) (additivity);
  3. (cx,y)=c (x,y)(cx, y) = c\,(x, y) (homogeneity);
  4. (x,x)>0(x, x) > 0 whenever x≠Ox \ne O (positivity).

A real vector space with an inner product is a Euclidean space (Apostol and Spagnolie). Many books write ⟨x,y⟩\langle x, y\rangle.

In one lineA rule (x,y)(x, y) giving a real number for every pair of vectors, symmetric, linear, and positive on non-zero vectors. The dot product is the model.

Why it existsIt lets any vector space have length, angle and perpendicularity, and these are what make 'closest point' mean something.

By symmetry, additivity and homogeneity also hold in the second slot, so (x,y)(x, y) is linear in each entry separately. Taking c=0c = 0 in rule 3 gives (O,y)=0(O, y) = 0, so (x,x)=0(x, x) = 0 exactly when x=Ox = O. Axiom 4 is the one that fails most often.

Examples.

  • The dot product on Rn\mathbb R^n: (x,y)=x1y1+⋯+xnyn=xTy(x, y) = x_1y_1 + \dots + x_ny_n = x^{\mathsf T}y. Symmetry is clear, additivity and homogeneity are arithmetic, and (x,x)=x12+⋯+xn2>0(x, x) = x_1^2 + \dots + x_n^2 > 0 unless every xi=0x_i = 0.
  • Functions: on C[a,b]C[a, b], the continuous functions on [a,b][a, b], put (f,g)=∫abf(t)g(t) dt(f, g) = \displaystyle\int_a^b f(t)g(t)\,dt. Rules 1 to 3 hold because integrals are symmetric and linear. For rule 4, if f≠0f \ne 0 then f(t0)≠0f(t_0) \ne 0 for some t0t_0, so by continuity f(t)2>c>0f(t)^2 > c > 0 on a small interval around t0t_0, and the integral of f2f^2 is positive. Here continuity matters: a function that is 11 at a single point and 00 elsewhere has ∫f2=0\int f^2 = 0 but is not the zero function.
  • A weighted inner product: (f,g)w=∫abw(t)f(t)g(t) dt(f, g)_w = \int_a^b w(t)f(t)g(t)\,dt for any positive function ww. Spagnolie stressed “there is no unique inner product” on a space.
  • Another one on R2\mathbb R^2: (x,y)=x1y1+2x2y2(x, y) = x_1y_1 + 2x_2y_2. Positivity holds since x12+2x22>0x_1^2 + 2x_2^2 > 0 for x≠Ox \ne O.
Worked example Apostol 1.13 #1(c), MATH 375 HW3
Is (x, y) = (x1 + x2 + x3)(y1 + y2 + y3) an inner product on R³?

Solution.

  1. Check symmetry. Swapping xx and yy gives the same product of two sums. Multiplication of numbers is commutative.
  2. Check additivity and homogeneity. (x+z,y)=(∑(xi+zi))(∑yi)=(x,y)+(z,y)(x + z, y) = \big(\sum(x_i + z_i)\big)\big(\sum y_i\big) = (x, y) + (z, y) and (cx,y)=c (x,y)(cx, y) = c\,(x, y). The sum of coordinates is linear in xx, and multiplying by the fixed number ∑yi\sum y_i keeps that.
  3. Check positivity. Here (x,x)=(x1+x2+x3)2≥0(x, x) = (x_1 + x_2 + x_3)^2 \ge 0, but it equals 00 whenever the coordinates add to zero. Take x=(1,0,−1)x = (1, 0, -1): (x,x)=0⋅0=0(x, x) = 0\cdot0 = 0 although x≠Ox \ne O. Axiom 4 demands (x,x)>0(x, x) > 0 for every non-zero xx. One counterexample is enough to break it.

Answer. No. It fails axiom 4. (Spagnolie’s remark: positivity is the usual failure, and one counterexample vector shows it.)

Quick checkIs (x,y)=x1y1−x2y2(x, y) = x_1y_1 - x_2y_2 an inner product on R2\mathbb R^2?
Your answerOn R2\mathbb R^2 use the inner product (x,y)=x1y1+2x2y2(x, y) = x_1y_1 + 2x_2y_2. What is the norm ∥(2,1)∥\lVert(2, 1)\rVert?

Length and angle

Definition T

Norm

In a Euclidean space the norm of xx is ∥x∥=(x,x)\lVert x\rVert = \sqrt{(x, x)}, which makes sense because (x,x)≥0(x, x) \ge 0. The distance between xx and yy is ∥x−y∥\lVert x - y\rVert. In Rn\mathbb R^n with the dot product this is the usual length x12+⋯+xn2\sqrt{x_1^2 + \dots + x_n^2}. In C[a,b]C[a, b] it is (∫abf2)1/2\big(\int_a^b f^2\big)^{1/2}.

In one lineThe length of a vector, ∥x∥=(x,x)\lVert x\rVert = \sqrt{(x, x)}, defined from the inner product.

Why it existsDistance and size are needed to say that one vector is closer to a target than another.

Now we want an angle. In JEE, cos⁡θ=x⋅y∣x∣∣y∣\cos\theta = \dfrac{x\cdot y}{|x||y|} was a consequence of the picture. Here we want to use that formula as the definition of the angle between non-zero vectors. There is a problem: cos⁡θ\cos\theta must lie in [−1,1][-1, 1], or the inverse cosine does not exist. Why would (x,y)∥x∥∥y∥\dfrac{(x, y)}{\lVert x\rVert\lVert y\rVert} always be in that range, for functions, say? That is exactly what the next theorem proves.

Theorem T Apostol Thm 1.8; Spagnolie Lecture 4

Cauchy–Schwarz inequality

In any Euclidean space, for all xx and yy,

∣(x,y)∣≤∥x∥ ∥y∥,|(x, y)| \le \lVert x\rVert\,\lVert y\rVert,

and equality holds if and only if xx and yy are linearly dependent.

In one line∣(x,y)∣≤∥x∥ ∥y∥|(x, y)| \le \lVert x\rVert\,\lVert y\rVert, with equality exactly when xx and yy are linearly dependent.

Why it is trueThe squared length ∥x+ty∥2\lVert x + ty\rVert^2 is a parabola in tt that never goes below zero. Evaluating it at its lowest point gives the inequality, and that lowest point is the projection of xx onto yy.

Why· The picture behind the proof

In the picture above, the point of the line closest to vv is the shadow. The proof walks along the line x+tyx + ty and looks at its smallest distance from the origin. That smallest length cannot be negative, and writing it out gives the inequality. The special value t0=−(x,y)/(y,y)t_0 = -(x, y)/(y, y) that makes x+t0yx + t_0y shortest is exactly the leftover vector ee in the picture (with the roles v=xv = x, u=yu = y): it is the part of xx that does not point along yy.

ProofSpagnolie Lecture 4 (the quadratic p(t)); Apostol 1.8
The idea: Look at the squared length of x + ty as a function of t. It is a quadratic that is never negative. Plug in the value of t where it is smallest. What is left is the inequality.
Assume y≠Oy \ne O, so (y,y)>0(y, y) > 0.
If y=Oy = O then (x,y)=0(x, y) = 0 and ∥y∥=0\lVert y\rVert = 0, so both sides are 00 and x,Ox, O are dependent.
For every real tt: 0≤(x+ty, x+ty)0 \le (x + ty,\ x + ty).
Axiom 4 and (O,O)=0(O, O) = 0: an inner product of a vector with itself is never negative. We apply it to the vector x+tyx + ty, for each real tt.
(x+ty,x+ty)=(x,x)+2t (x,y)+t2(y,y)(x + ty, x + ty) = (x, x) + 2t\,(x, y) + t^2(y, y).
Additivity and homogeneity in both slots, plus symmetry (y,x)=(x,y)(y, x) = (x, y).
Choose t0=−(x,y)(y,y)t_0 = -\dfrac{(x, y)}{(y, y)}.
This is the value of tt at the bottom of the parabola: the derivative 2(x,y)+2t(y,y)2(x, y) + 2t(y, y) is zero there. It is also the projection coefficient from the picture. We are free to choose any tt because the inequality holds for all of them.
0≤(x,x)−(x,y)2(y,y)0 \le (x, x) - \dfrac{(x, y)^2}{(y, y)}.
Substitute t0t_0 into step 3 and simplify: −2(x,y)2/(y,y)+(x,y)2/(y,y)=−(x,y)2/(y,y)-2(x,y)^2/(y,y) + (x,y)^2/(y,y) = -(x,y)^2/(y,y).
(x,y)2≤∥x∥2∥y∥2(x, y)^2 \le \lVert x\rVert^2\lVert y\rVert^2, so ∣(x,y)∣≤∥x∥∥y∥|(x, y)| \le \lVert x\rVert\lVert y\rVert.
Multiply both sides by (y,y)>0(y, y) > 0, then take square roots (both sides are non-negative).
Equality implies x=−t0yx = -t_0y, so x,yx, y are dependent.
If equality holds, the right side of step 5 is exactly 00, so (x+t0y, x+t0y)=0(x + t_0y,\ x + t_0y) = 0. Axiom 4 then forces x+t0y=Ox + t_0y = O.
Conversely, dependent vectors give equality.
If x=cyx = cy, then ∣(cy,y)∣=∣c∣ (y,y)|(cy, y)| = |c|\,(y, y) by homogeneity. And ∥cy∥=(cy,cy)=c2(y,y)=∣c∣ ∥y∥\lVert cy\rVert = \sqrt{(cy, cy)} = \sqrt{c^2(y, y)} = |c|\,\lVert y\rVert, so ∥cy∥∥y∥=∣c∣ (y,y)\lVert cy\rVert\lVert y\rVert = |c|\,(y, y) too. (With y≠Oy \ne O, dependent means x=cyx = cy.)
Proof workshopRebuild the Cauchy–Schwarz proof

Tap the lines in the order a proof would write them. Each line can only use what is already above it.

    So the angle is well defined.

    Definition T

    Orthogonal

    For non-zero x,yx, y in a Euclidean space, the angle between them is θ=arccos⁡(x,y)∥x∥∥y∥∈[0,π]\theta = \arccos\dfrac{(x, y)}{\lVert x\rVert\lVert y\rVert} \in [0, \pi]. The vectors x,yx, y are orthogonal (written x⊥yx \perp y) if (x,y)=0(x, y) = 0. This agrees with θ=π/2\theta = \pi/2, and it also allows x=Ox = O, which is orthogonal to everything. A set SS is orthogonal if (x,y)=0(x, y) = 0 for all different x,yx, y in SS.

    In one lineTwo vectors are orthogonal when their inner product is 00; a set is orthogonal when every two different members are.

    Why it existsIt is the abstract version of 'at right angles', and it is the property that makes coordinates and projections easy to compute.

    Definition T

    Orthonormal

    A set is orthonormal if it is orthogonal and ∥x∥=1\lVert x\rVert = 1 for each member. Dividing any non-zero vector by its norm makes it have length 11: ∥x/∥x∥ ∥=1\lVert x/\lVert x\rVert\,\rVert = 1.

    In one lineAn orthogonal set in which every vector has length 11.

    Why it existsUnit lengths remove the division in every formula, so the coefficient of a vector is an inner product, with no division.

    Why the old and the new angle agree. In R2\mathbb R^2 or R3\mathbb R^3, the cosine rule from the geometry you did in JEE says ∣x−y∣2=∣x∣2+∣y∣2−2∣x∣∣y∣cos⁡θ|x - y|^2 = |x|^2 + |y|^2 - 2|x||y|\cos\theta. Expanding the left side with the dot product gives ∣x∣2+∣y∣2−2 x⋅y|x|^2 + |y|^2 - 2\,x\cdot y. Comparing the two, x⋅y=∣x∣∣y∣cos⁡θx\cdot y = |x||y|\cos\theta. So the JEE formula is a theorem about the dot product, and in higher dimensions and in function spaces we turn it around into a definition.

    Worked example
    Find the angle between (1, 1, 0) and (0, 1, 1) in R³.

    Solution.

    1. Compute the inner product. (x,y)=1⋅0+1⋅1+0⋅1=1(x, y) = 1\cdot0 + 1\cdot1 + 0\cdot1 = 1. The dot product is the inner product on R3\mathbb R^3.
    2. Compute the norms. ∥x∥=1+1+0=2\lVert x\rVert = \sqrt{1 + 1 + 0} = \sqrt2 and ∥y∥=0+1+1=2\lVert y\rVert = \sqrt{0 + 1 + 1} = \sqrt2. The norm is (x,x)\sqrt{(x, x)}.
    3. Form the cosine. cos⁡θ=12⋅2=12\cos\theta = \dfrac{1}{\sqrt2\cdot\sqrt2} = \dfrac12. This is the definition of the angle. Cauchy–Schwarz guarantees this number lies in [−1,1][-1, 1].
    4. Invert. θ=arccos⁡12=60°\theta = \arccos\tfrac12 = 60°. The inverse cosine of 12\tfrac12 is π/3\pi/3.

    Answer. θ=60°\theta = 60°.

    Your answerFind cos⁡θ\cos\theta for the angle between (1,2,2)(1, 2, 2) and (3,0,4)(3, 0, 4).
    Quick checkWhen does equality ∣(x,y)∣=∥x∥∥y∥|(x, y)| = \lVert x\rVert\lVert y\rVert hold in the Cauchy–Schwarz inequality?
    Theorem T Apostol Thm 1.9; Spagnolie Lecture 4

    Properties of the norm

    In a Euclidean space: (a) ∥x∥≥0\lVert x\rVert \ge 0, and ∥x∥=0\lVert x\rVert = 0 iff x=Ox = O. (b) ∥cx∥=∣c∣ ∥x∥\lVert cx\rVert = |c|\,\lVert x\rVert for every real cc. (c) ∥x+y∥≤∥x∥+∥y∥\lVert x + y\rVert \le \lVert x\rVert + \lVert y\rVert.

    In one line∥x∥≥0\lVert x\rVert \ge 0 with equality only for OO; ∥cx∥=∣c∣∥x∥\lVert cx\rVert = |c|\lVert x\rVert; and the triangle inequality ∥x+y∥≤∥x∥+∥y∥\lVert x + y\rVert \le \lVert x\rVert + \lVert y\rVert.

    Why it is trueExpand ∥x+y∥2\lVert x + y\rVert^2 and bound the cross term with Cauchy–Schwarz.

    ProofSpagnolie Lecture 4; Apostol 1.9
    The idea: (a) and (b) follow directly from the axioms. For (c), square both sides so that no square roots remain, expand, and use Cauchy–Schwarz on the one cross term.
    (a) ∥x∥=(x,x)≥0\lVert x\rVert = \sqrt{(x,x)} \ge 0, with 00 only for x=Ox = O.
    Axiom 4: (x,x)>0(x, x) > 0 for x≠Ox \ne O, and (O,O)=0(O, O) = 0.
    (b) ∥cx∥=c2(x,x)=∣c∣ ∥x∥\lVert cx\rVert = \sqrt{c^2(x, x)} = |c|\,\lVert x\rVert.
    Homogeneity in each slot gives (cx,cx)=c2(x,x)(cx, cx) = c^2(x, x), and c2=∣c∣\sqrt{c^2} = |c|, not cc.
    (c) ∥x+y∥2=(x,x)+2(x,y)+(y,y)=∥x∥2+2(x,y)+∥y∥2\lVert x + y\rVert^2 = (x, x) + 2(x, y) + (y, y) = \lVert x\rVert^2 + 2(x, y) + \lVert y\rVert^2.
    Expand by additivity and symmetry, as in the Cauchy–Schwarz proof.
    ≤∥x∥2+2∥x∥∥y∥+∥y∥2=(∥x∥+∥y∥)2\le \lVert x\rVert^2 + 2\lVert x\rVert\lVert y\rVert + \lVert y\rVert^2 = (\lVert x\rVert + \lVert y\rVert)^2.
    Cauchy–Schwarz: (x,y)≤∣(x,y)∣≤∥x∥∥y∥(x, y) \le |(x, y)| \le \lVert x\rVert\lVert y\rVert.
    ∥x+y∥≤∥x∥+∥y∥\lVert x + y\rVert \le \lVert x\rVert + \lVert y\rVert.
    Both sides are non-negative, so taking square roots keeps the inequality.
    Worked example Apostol 1.13 #3; MATH 375 HW3
    Prove that (x, y) = 0 if and only if the norm of x + y equals the norm of x − y. Then deduce the parallelogram law and the polarization identity.

    Solution.

    1. Expand the sum. ∥x+y∥2=(x+y,x+y)=∥x∥2+2(x,y)+∥y∥2\lVert x + y\rVert^2 = (x + y, x + y) = \lVert x\rVert^2 + 2(x, y) + \lVert y\rVert^2. Additivity in both slots gives four terms, and symmetry makes the two cross terms equal.
    2. Expand the difference. ∥x−y∥2=∥x∥2−2(x,y)+∥y∥2\lVert x - y\rVert^2 = \lVert x\rVert^2 - 2(x, y) + \lVert y\rVert^2. Same computation with −y-y in place of yy. Homogeneity with c=−1c = -1 flips the sign of the cross term.
    3. Subtract. ∥x+y∥2−∥x−y∥2=4(x,y)\lVert x + y\rVert^2 - \lVert x - y\rVert^2 = 4(x, y). The terms ∥x∥2\lVert x\rVert^2 and ∥y∥2\lVert y\rVert^2 cancel, and the cross terms add.
    4. Both directions. If (x,y)=0(x, y) = 0 the two squares are equal, so the norms are equal (norms are non-negative). If the norms are equal, the left side of step 3 is 00, so (x,y)=0(x, y) = 0. Squaring and taking square roots are reversible for non-negative numbers.
    5. Add instead of subtracting. ∥x+y∥2+∥x−y∥2=2∥x∥2+2∥y∥2\lVert x + y\rVert^2 + \lVert x - y\rVert^2 = 2\lVert x\rVert^2 + 2\lVert y\rVert^2, the parallelogram law. Now the cross terms cancel. The picture: the two diagonals of a parallelogram have squared lengths adding to twice the sum of the squared sides.
    6. Divide step 3 by 4. (x,y)=14(∥x+y∥2−∥x−y∥2)(x, y) = \tfrac14\big(\lVert x + y\rVert^2 - \lVert x - y\rVert^2\big), the polarization identity. The inner product can be recovered from the norm alone.

    Answer. (x,y)=0(x, y) = 0 exactly when the two diagonals x+yx + y and x−yx - y have equal length, which for a parallelogram says it is a rectangle. The parallelogram law and polarization both follow from the same two expansions.

    Beyond the course: for understanding· Norms without inner products

    A norm in general is any function with properties (a), (b), (c), whether or not it comes from an inner product. Spagnolie lists ∥x∥1=∑∣xi∣\lVert x\rVert_1 = \sum|x_i|, the pp-norms (∑∣xi∣p)1/p\big(\sum|x_i|^p\big)^{1/p}, and ∥x∥∞=max⁡∣xi∣\lVert x\rVert_\infty = \max|x_i|. In the plane their unit “balls” (∥x∥=1\lVert x\rVert = 1) are a diamond, a circle and a square. Only the circle comes from an inner product; the others have no angle. Spagnolie’s non-example: ∥F∥=∫01F′(x)2 dx\lVert F\rVert = \int_0^1 F'(x)^2\,dx on differentiable functions is not a norm. It is 00 for F=32F = 32, it scales like c2c^2 instead of ∣c∣|c|, and F(x)=g(x)=xF(x) = g(x) = x gives ∥F+g∥=4>2=∥F∥+∥g∥\lVert F + g\rVert = 4 > 2 = \lVert F\rVert + \lVert g\rVert, which breaks the triangle inequality. In machine learning the 1-norm gives sparse solutions (lasso), and the 2-norm used in this chapter gives least squares.

    Worked example Apostol 1.13 #8, MATH 375 HW3
    With weight log x on [1, e], find the norm of f(x) = √x, and a linear polynomial g = a + bx orthogonal to the constant 1.

    Solution. The inner product is (f,g)=∫1e(log⁡x) f(x)g(x) dx(f, g) = \int_1^e (\log x)\,f(x)g(x)\,dx.

    1. Squared norm of ff. ∥f∥2=∫1exlog⁡x dx\lVert f\rVert^2 = \int_1^e x\log x\,dx. f2=xf^2 = x, and the norm is the square root of (f,f)(f, f).
    2. Integrate by parts. ∫1exlog⁡x dx=[x22log⁡x]1e−∫1ex2 dx=e22−e2−14=e2+14\int_1^e x\log x\,dx = \Big[\tfrac{x^2}{2}\log x\Big]_1^e - \int_1^e\tfrac x2\,dx = \tfrac{e^2}{2} - \tfrac{e^2 - 1}{4} = \tfrac{e^2 + 1}{4}. Take u=log⁡xu = \log x, dv=x dxdv = x\,dx.
    3. Take the square root. ∥f∥=12e2+1≈1.448\lVert f\rVert = \tfrac12\sqrt{e^2 + 1} \approx 1.448.
    4. Orthogonality to 11. (1,a+bx)=a∫1elog⁡x dx+b∫1exlog⁡x dx=a⋅1+b⋅e2+14(1, a + bx) = a\int_1^e\log x\,dx + b\int_1^e x\log x\,dx = a\cdot1 + b\cdot\tfrac{e^2 + 1}{4}. ∫1elog⁡x dx=[xlog⁡x−x]1e=1\int_1^e\log x\,dx = [x\log x - x]_1^e = 1, and the second integral is from step 2.
    5. Set it to zero. a=−b e2+14a = -b\,\tfrac{e^2 + 1}{4}. Taking b=1b = 1: g(x)=x−e2+14g(x) = x - \tfrac{e^2 + 1}{4}. One linear equation in two unknowns, so there is a whole line of answers; any multiple works.

    Answer. ∥x∥=12e2+1\lVert\sqrt x\rVert = \tfrac12\sqrt{e^2 + 1}, and g(x)=x−e2+14g(x) = x - \tfrac{e^2 + 1}{4} (or any multiple) is orthogonal to 11.

    Orthogonal sets and coordinates

    Theorem T Apostol Thm 1.10; Spagnolie Lecture 5

    Orthogonal sets are independent

    If x1,…,xkx_1, \dots, x_k are non-zero and (xi,xj)=0(x_i, x_j) = 0 for i≠ji \ne j, then x1,…,xkx_1, \dots, x_k are linearly independent.

    In one lineAn orthogonal set of non-zero vectors is linearly independent.

    Why it is trueTake the inner product of a supposed dependence with one member. Every cross term vanishes and one coefficient is isolated.

    ProofSpagnolie Lecture 5; Apostol 1.12
    The idea: Suppose a combination is O. Take the inner product with x₁: all terms except the first vanish, leaving c₁‖x₁‖² = 0. Repeat for each vector.
    Suppose c1x1+⋯+ckxk=Oc_1x_1 + \dots + c_kx_k = O.
    The definition of dependence, to be refuted.
    (x1, c1x1+⋯+ckxk)=0(x_1,\ c_1x_1 + \dots + c_kx_k) = 0.
    Take the inner product of both sides with x1x_1. The inner product with OO is 00.
    c1(x1,x1)+c2(x1,x2)+⋯=c1∥x1∥2=0c_1(x_1, x_1) + c_2(x_1, x_2) + \dots = c_1\lVert x_1\rVert^2 = 0.
    Additivity and homogeneity expand the left side. Orthogonality kills every (x1,xj)(x_1, x_j) with j≠1j \ne 1.
    c1=0c_1 = 0.
    x1≠Ox_1 \ne O so ∥x1∥2>0\lVert x_1\rVert^2 > 0. Divide by it.
    Likewise every cj=0c_j = 0, so the set is independent.
    Repeat with x2,…,xkx_2, \dots, x_k in place of x1x_1.
    Quick checkTrue or false: every linearly independent set of non-zero vectors is orthogonal.

    Here is why orthogonal bases are worth the trouble. Suppose e1,…,ene_1, \dots, e_n is an orthogonal basis and x=c1e1+⋯+cnenx = c_1e_1 + \dots + c_ne_n. The same trick isolates each coefficient.

    Theorem T Apostol Thm 1.11; Spagnolie Lecture 5

    Coordinates in an orthogonal basis

    Let e1,…,ene_1, \dots, e_n be an orthogonal basis of VV with all ei≠Oe_i \ne O. Then for every xx,

    x=∑i=1n(x,ei)(ei,ei) ei,and∥x∥2=∑i=1n(x,ei)2(ei,ei).x = \sum_{i=1}^n \frac{(x, e_i)}{(e_i, e_i)}\,e_i, \qquad\text{and}\qquad \lVert x\rVert^2 = \sum_{i=1}^n \frac{(x, e_i)^2}{(e_i, e_i)}.

    If the basis is orthonormal this reads x=∑(x,ei)eix = \sum(x, e_i)e_i and ∥x∥2=∑(x,ei)2\lVert x\rVert^2 = \sum(x, e_i)^2.

    In one lineIn an orthogonal basis, the coordinate of xx on eie_i is (x,ei)/(ei,ei)(x, e_i)/(e_i, e_i); in an orthonormal basis it is (x,ei)(x, e_i) itself.

    Why it is trueTaking the inner product with eie_i kills every term except the eie_i one.

    ProofSpagnolie Lecture 5; Apostol 1.11 and 1.12
    The idea: Write x in the basis with unknown coefficients, take the inner product with eᵢ, and solve. For the norm, expand (x, x) in the same way.
    Write x=c1e1+⋯+cnenx = c_1e_1 + \dots + c_ne_n.
    Coordinates exist and are unique (2.2).
    (x,ei)=ci(ei,ei)(x, e_i) = c_i(e_i, e_i).
    Take the inner product with eie_i. Additivity, homogeneity, and (ei,ej)=0(e_i, e_j) = 0 for j≠ij \ne i.
    ci=(x,ei)/(ei,ei)c_i = (x, e_i)/(e_i, e_i).
    (ei,ei)>0(e_i, e_i) > 0 since ei≠Oe_i \ne O.
    ∥x∥2=∑ci(x,ei)=∑(x,ei)2(ei,ei)\lVert x\rVert^2 = \sum c_i(x, e_i) = \sum\dfrac{(x, e_i)^2}{(e_i, e_i)}.
    (x,x)=(x,∑ciei)=∑ci(x,ei)(x, x) = (x, \sum c_ie_i) = \sum c_i(x, e_i), and substitute cic_i from step 3.

    Spagnolie warns about an easy mistake. The denominator is (ei,ei)(e_i, e_i), which is ∥ei∥2\lVert e_i\rVert^2 and not ∥ei∥\lVert e_i\rVert. His unit check: xx and eie_i have the same units (say metres), so the coefficient cic_i must have no units. (x,ei)/∥ei∥2(x, e_i)/\lVert e_i\rVert^2 is metre-squared over metre-squared, which is fine. (x,ei)/∥ei∥(x, e_i)/\lVert e_i\rVert would be metre-squared over metre, which has units of length, so it cannot be right.

    Worked example Spagnolie Lecture 5 (these vectors are built in the Gram–Schmidt example below)
    Write z = (1, 2, 3) as a combination of the orthogonal vectors y1 = (1, 0, 1), y2 = (1/2, 1, -1/2), y3 = (-1/3, 1/3, 1/3).

    Solution.

    1. Check they are orthogonal. (y1,y2)=12+0−12=0(y_1, y_2) = \tfrac12 + 0 - \tfrac12 = 0, (y1,y3)=−13+0+13=0(y_1, y_3) = -\tfrac13 + 0 + \tfrac13 = 0, (y2,y3)=−16+13−16=0(y_2, y_3) = -\tfrac16 + \tfrac13 - \tfrac16 = 0. The coordinate formula needs an orthogonal basis. Three non-zero orthogonal vectors in R3\mathbb R^3 are independent, hence a basis.
    2. Compute the denominators. (y1,y1)=2(y_1, y_1) = 2, (y2,y2)=32(y_2, y_2) = \tfrac32, (y3,y3)=13(y_3, y_3) = \tfrac13.
    3. Compute the numerators. (z,y1)=1+3=4(z, y_1) = 1 + 3 = 4, (z,y2)=12+2−32=1(z, y_2) = \tfrac12 + 2 - \tfrac32 = 1, (z,y3)=−13+23+1=43(z, y_3) = -\tfrac13 + \tfrac23 + 1 = \tfrac43.
    4. Divide. c1=42=2c_1 = \tfrac42 = 2, c2=13/2=23c_2 = \tfrac{1}{3/2} = \tfrac23, c3=4/31/3=4c_3 = \tfrac{4/3}{1/3} = 4. Coefficient == (inner product with yiy_i) divided by (yi,yi)(y_i, y_i). No equation system is solved.
    5. Check. 2(1,0,1)+23(12,1,−12)+4(−13,13,13)=(2+13−43, 23+43, 2−13+43)=(1,2,3)2(1,0,1) + \tfrac23(\tfrac12,1,-\tfrac12) + 4(-\tfrac13,\tfrac13,\tfrac13) = (2 + \tfrac13 - \tfrac43,\ \tfrac23 + \tfrac43,\ 2 - \tfrac13 + \tfrac43) = (1, 2, 3). Adding the pieces back must give zz.

    Answer. z=2y1+23y2+4y3z = 2y_1 + \tfrac23y_2 + 4y_3. For comparison, Spagnolie’s non-orthogonal basis x1=(1,0,0)x_1 = (1,0,0), x2=(1,1,0)x_2 = (1,1,0), x3=(1,1,1)x_3 = (1,1,1) and z=(0,1,1)z = (0,1,1): taking inner products with each xix_i leaves a 3×33\times3 system with matrix [111122123]\begin{bmatrix}1&1&1\\1&2&2\\1&2&3\end{bmatrix}, whose solution is z=−x1+x3z = -x_1 + x_3. That is the “annoying” computation that an orthogonal basis avoids.

    Your answerIn an orthonormal basis q1,q2,q3q_1, q_2, q_3 of R3\mathbb R^3 a vector xx has (x,q1)=2(x, q_1) = 2, (x,q2)=−6(x, q_2) = -6, (x,q3)=3(x, q_3) = 3. What is ∥x∥\lVert x\rVert?

    Gram–Schmidt: making an orthogonal basis

    Not every basis is orthogonal. The Gram–Schmidt process turns any basis into an orthogonal one with the same spans. Its idea is the picture at the top of the chapter, used repeatedly: to make a vector perpendicular to earlier ones, subtract its shadows on them.

    Definition T

    Gram–Schmidt process

    Given independent x1,…,xkx_1, \dots, x_k, the Gram–Schmidt process defines

    y1=x1,ym=xm−∑j=1m−1(yj,xm)(yj,yj) yj(m=2,…,k).y_1 = x_1, \qquad y_m = x_m - \sum_{j=1}^{m-1}\frac{(y_j, x_m)}{(y_j, y_j)}\,y_j \quad (m = 2, \dots, k).

    Dividing each ymy_m by its norm then gives an orthonormal list.

    In one lineFrom independent vectors x1,x2,…x_1, x_2, \dots build orthogonal vectors y1,y2,…y_1, y_2, \dots by subtracting from each xkx_k its projections on the earlier yjy_j.

    Why it existsIt turns any basis into an orthogonal (then orthonormal) one without changing what each initial segment spans.

    Theorem T Apostol Thm 1.13; Spagnolie Lecture 5

    Gram–Schmidt theorem

    If x1,…,xkx_1, \dots, x_k are linearly independent, the vectors y1,…,yky_1, \dots, y_k above are non-zero, pairwise orthogonal, and L(y1,…,ym)=L(x1,…,xm)L(y_1, \dots, y_m) = L(x_1, \dots, x_m) for each mm. (Here L(⋅)L(\cdot) is the span, Apostol’s notation.) Consequently every finite-dimensional Euclidean space has an orthonormal basis (Apostol Thm 1.14).

    In one lineThe ymy_m are non-zero and orthogonal, and y1,…,ymy_1, \dots, y_m span the same space as x1,…,xmx_1, \dots, x_m for every mm.

    Why it is trueEach step subtracts exactly the part of xmx_m along the earlier yjy_j, so what is left is perpendicular to them, and the subtraction does not change the span.

    ProofSpagnolie Lecture 5; Apostol 1.13
    The idea: Induction on m. Assume y₁,…,y_{m−1} are orthogonal and span the same as x₁,…,x_{m−1}. Then y_m is x_m minus a combination of earlier y's, so it is in the same span as x₁…x_m, it is not zero because x_m is outside the earlier span, and it is perpendicular to each earlier y_i by a one-line computation.
    Base case m=1m = 1.
    For m=1m = 1: y1=x1≠Oy_1 = x_1 \ne O (independent vectors are non-zero), and the spans are equal.
    Assume y1,…,ym−1y_1, \dots, y_{m-1} are non-zero, orthogonal, and L(y1,…,ym−1)=L(x1,…,xm−1)L(y_1, \dots, y_{m-1}) = L(x_1, \dots, x_{m-1}).
    The induction hypothesis: the claim holds for m−1m - 1.
    L(y1,…,ym)=L(x1,…,xm)L(y_1, \dots, y_m) = L(x_1, \dots, x_m).
    By the formula, ymy_m is xmx_m minus a combination of y1,…,ym−1y_1, \dots, y_{m-1}, which lie in L(x1,…,xm−1)L(x_1, \dots, x_{m-1}). Conversely xm=ym+x_m = y_m + (a combination of yjy_j), so xm∈L(y1,…,ym)x_m \in L(y_1, \dots, y_m).
    ym≠Oy_m \ne O.
    If ym=Oy_m = O, then xmx_m would be a combination of y1,…,ym−1y_1, \dots, y_{m-1}, hence of x1,…,xm−1x_1, \dots, x_{m-1}, contradicting independence of the xx's. (When Gram–Schmidt is applied to dependent vectors, a zero yy appears, and that is how it reveals dependence: Apostol 1.17 #2(b).)
    (yi,ym)=(yi,xm)−(yi,xm)(yi,yi)(yi,yi)(y_i, y_m) = (y_i, x_m) - \dfrac{(y_i, x_m)}{(y_i, y_i)}(y_i, y_i).
    Take the inner product of the defining formula with yiy_i for some i<mi < m. By the induction hypothesis (yi,yj)=0(y_i, y_j) = 0 for j≠ij \ne i, so only the j=ij = i term of the sum survives.
    (yi,ym)=0(y_i, y_m) = 0 for every i<mi < m. The claim holds for mm, so by induction for all mm.
    The two terms are equal.
    An orthonormal basis exists.
    Start with any basis of the space, apply the process, divide each yy by its norm.
    Quick checkIn Gram–Schmidt, when we compute y3y_3, which vectors do we subtract projections onto?
    Worked example Spagnolie Lecture 5 (with its arithmetic corrected)
    Apply Gram–Schmidt to x1 = (1, 0, 1), x2 = (1, 1, 0), x3 = (0, 0, 1) in R³, then normalize.

    Solution.

    1. Keep the first vector. y1=x1=(1,0,1)y_1 = x_1 = (1, 0, 1), with (y1,y1)=2(y_1, y_1) = 2. There is nothing earlier to be perpendicular to.
    2. Remove the shadow of x2x_2 on y1y_1. (y1,x2)=1(y_1, x_2) = 1, so y2=x2−12y1=(12,1,−12)y_2 = x_2 - \tfrac12y_1 = (\tfrac12, 1, -\tfrac12), and (y2,y2)=32(y_2, y_2) = \tfrac32. This is the red dashed leftover of the picture at the top of the chapter.
    3. Check. (y1,y2)=12+0−12=0(y_1, y_2) = \tfrac12 + 0 - \tfrac12 = 0. Checking each new vector against the earlier ones catches arithmetic slips immediately.
    4. Remove both shadows from x3x_3. (y1,x3)=1(y_1, x_3) = 1 and (y2,x3)=−12(y_2, x_3) = -\tfrac12, so the coefficients are 12\tfrac12 and −1/23/2=−13\tfrac{-1/2}{3/2} = -\tfrac13. Then y3=x3−12y1+13y2=(−13,13,13)y_3 = x_3 - \tfrac12y_1 + \tfrac13y_2 = (-\tfrac13, \tfrac13, \tfrac13). We project on the yy‘s, not on x1,x2x_1, x_2, because the yy‘s are perpendicular, so the shadows do not interfere. The minus before −13-\tfrac13 turns into a plus.
    5. Check again. (y1,y3)=−13+13=0(y_1, y_3) = -\tfrac13 + \tfrac13 = 0 and (y2,y3)=−16+13−16=0(y_2, y_3) = -\tfrac16 + \tfrac13 - \tfrac16 = 0. Both are 00, so y1,y2,y3y_1, y_2, y_3 are an orthogonal basis.
    6. Normalize. Divide each yy by its length 2\sqrt2, 3/2\sqrt{3/2}, 1/3\sqrt{1/3} to get φ1,φ2,φ3\varphi_1, \varphi_2, \varphi_3. Unit lengths make the coefficient of each vector a plain inner product.

    The step-through below shows the same computation with every product written out.

    Answer. y1=(1,0,1)y_1 = (1, 0, 1), y2=(12,1,−12)y_2 = (\tfrac12, 1, -\tfrac12), y3=(−13,13,13)y_3 = (-\tfrac13, \tfrac13, \tfrac13) are orthogonal, and φ1,φ2,φ3\varphi_1, \varphi_2, \varphi_3 above are orthonormal. In the orthonormal basis the coordinates of z=(0,0,1)z = (0, 0, 1) are (z,φi)=12,−16,13(z, \varphi_i) = \tfrac1{\sqrt2}, -\tfrac1{\sqrt6}, \tfrac1{\sqrt3}, and the squares add up to 12+16+13=1=∥z∥2\tfrac12 + \tfrac16 + \tfrac13 = 1 = \lVert z\rVert^2, as the coordinate theorem says.

    Your answerGram–Schmidt on x1=(3,4)x_1 = (3, 4) and x2=(1,0)x_2 = (1, 0) gives y1=x1y_1 = x_1 and y2=x2−(y1,x2)(y1,y1)y1y_2 = x_2 - \frac{(y_1, x_2)}{(y_1, y_1)}y_1. What is the length ∥y2∥\lVert y_2\rVert?
    Worked example Apostol 1.17 #2(b), new numbers
    Apply Gram–Schmidt to x1 = (1, 1, 0), x2 = (0, 1, 1), x3 = (1, 2, 1) in R³. What does the result say about the three vectors?

    Solution.

    1. First vector. y1=x1=(1,1,0)y_1 = x_1 = (1, 1, 0), and (y1,y1)=2(y_1, y_1) = 2. The first vector is kept.
    2. Second vector. (y1,x2)=1(y_1, x_2) = 1, so y2=x2−12y1=(−12,12,1)y_2 = x_2 - \tfrac12y_1 = (-\tfrac12, \tfrac12, 1), and (y2,y2)=32(y_2, y_2) = \tfrac32. Subtract the shadow of x2x_2 on y1y_1. Check: (y1,y2)=−12+12=0(y_1, y_2) = -\tfrac12 + \tfrac12 = 0.
    3. Third vector, the two coefficients. (y1,x3)=3(y_1, x_3) = 3 gives 32\tfrac32, and (y2,x3)=−12+1+1=32(y_2, x_3) = -\tfrac12 + 1 + 1 = \tfrac32 gives 3/23/2=1\tfrac{3/2}{3/2} = 1. Divide by (yj,yj)(y_j, y_j) in each case, as in the formula.
    4. Subtract. y3=(1,2,1)−32(1,1,0)−1⋅(−12,12,1)=(1−32+12, 2−32−12, 1−0−1)=(0,0,0)y_3 = (1, 2, 1) - \tfrac32(1, 1, 0) - 1\cdot(-\tfrac12, \tfrac12, 1) = (1 - \tfrac32 + \tfrac12,\ 2 - \tfrac32 - \tfrac12,\ 1 - 0 - 1) = (0, 0, 0). The shadows on y1y_1 and y2y_2 account for all of x3x_3.
    5. Read the zero. y3=Oy_3 = O means x3x_3 lies in the span of x1,x2x_1, x_2. If y3y_3 were non-zero, the Gram–Schmidt theorem says it would be a new direction. A zero output is how the process reports dependence.
    6. Check the dependence directly. x3=x1+x2x_3 = x_1 + x_2, since (1,1,0)+(0,1,1)=(1,2,1)(1, 1, 0) + (0, 1, 1) = (1, 2, 1). The conclusion agrees with a direct look at the vectors.

    Answer. y3=Oy_3 = O, so the three vectors are linearly dependent. The span is a plane with orthogonal basis y1,y2y_1, y_2. Discard y3y_3 and carry on with the next vector, if any.

    Gram–Schmidt works in any Euclidean space, including a space of functions. Take polynomials on [−1,1][-1, 1] with (f,g)=∫−11f(t)g(t) dt(f, g) = \int_{-1}^1 f(t)g(t)\,dt. The monomials 1,t,t2,…1, t, t^2, \dots are a basis but not orthogonal: (1,t2)=23≠0(1, t^2) = \tfrac23 \ne 0.

    Worked example Spagnolie Lecture 5 (Legendre polynomials)
    Apply Gram–Schmidt to 1, t, t², t³ on [-1, 1] with (f, g) = ∫ f g dt.

    Solution.

    1. Start with the constant. y0=1y_0 = 1, and (y0,y0)=∫−111 dt=2(y_0, y_0) = \int_{-1}^1 1\,dt = 2. The first vector is kept.
    2. Second vector. (y0,t)=∫−11t dt=0(y_0, t) = \int_{-1}^1 t\,dt = 0, so nothing is subtracted and y1=ty_1 = t, with (y1,y1)=23(y_1, y_1) = \tfrac23. tt is odd and 11 is even; an odd function integrates to 00 over a symmetric interval.
    3. Third vector. (y0,t2)=23(y_0, t^2) = \tfrac23 and (y1,t2)=∫t3=0(y_1, t^2) = \int t^3 = 0. So y2=t2−2/32⋅1−0=t2−13y_2 = t^2 - \dfrac{2/3}{2}\cdot1 - 0 = t^2 - \tfrac13. Coefficient of y0y_0 is (y0,t2)/(y0,y0)=13(y_0, t^2)/(y_0, y_0) = \tfrac13. By the parity argument the y1y_1 coefficient is 00.
    4. Check. (y0,y2)=23−13⋅2=0(y_0, y_2) = \tfrac23 - \tfrac13\cdot2 = 0 and (y1,y2)=∫(t3−t/3) dt=0(y_1, y_2) = \int(t^3 - t/3)\,dt = 0. Always check orthogonality; it catches slips.
    5. Fourth vector. (y1,t3)=∫t4=25(y_1, t^3) = \int t^4 = \tfrac25, so the coefficient of y1y_1 is 2/52/3=35\dfrac{2/5}{2/3} = \tfrac35. The coefficients of y0y_0 and y2y_2 are 00 by parity (odd times even). So y3=t3−35ty_3 = t^3 - \tfrac35t. Same formula; t3t^3 is odd, so it is orthogonal to the even y0y_0 and y2y_2 already.

    Answer. 1, t, t2−13, t3−35t1,\ t,\ t^2 - \tfrac13,\ t^3 - \tfrac35t, the Legendre polynomials. They are usually scaled so that the value at t=1t = 1 is 11: P2=12(3t2−1)P_2 = \tfrac12(3t^2 - 1) and P3=12(5t3−3t)P_3 = \tfrac12(5t^3 - 3t).

    Orthogonal complement and projection

    Definition T

    Orthogonal complement

    For a subspace SS of a Euclidean space VV, the orthogonal complement is

    S⊥={v∈V:(v,s)=0 for every s∈S}.S^\perp = \{v \in V : (v, s) = 0 \text{ for every } s \in S\}.

    In one lineAll vectors orthogonal to every vector of a subspace SS; written S⊥S^\perp ('S perp').

    Why it existsIt collects exactly the leftover parts that projection throws away.

    Theorem T Apostol 1.15

    The orthogonal complement is a subspace meeting S only at O

    For a subspace SS of VV, S⊥S^\perp is a subspace of VV, and S∩S⊥={O}S \cap S^\perp = \{O\}. If SS has a basis e1,…,eke_1, \dots, e_k, then v∈S⊥v \in S^\perp if and only if (v,ei)=0(v, e_i) = 0 for each ii.

    In one lineS⊥S^\perp is a subspace, and the only vector in both SS and S⊥S^\perp is OO.

    Why it is trueInner products are linear, so orthogonality passes through sums and multiples. A vector orthogonal to itself has zero length.

    ProofApostol 1.15
    The idea: Use the subspace test for the first part, then expand in the basis for the 'if and only if', and use positivity for the intersection.
    O∈S⊥O \in S^\perp.
    (O,s)=0(O, s) = 0 for every ss.
    If v,w∈S⊥v, w \in S^\perp then v+wv + w and cvcv are in S⊥S^\perp. So S⊥S^\perp is a subspace.
    Additivity and homogeneity in the first slot: (v+w,s)=(v,s)+(w,s)=0(v + w, s) = (v, s) + (w, s) = 0 and (cv,s)=c(v,s)=0(cv, s) = c(v, s) = 0.
    So if (v,ei)=0(v, e_i) = 0 for all ii, then (v,s)=0(v, s) = 0 for all s∈Ss \in S. The converse is immediate.
    Every s∈Ss \in S is ∑aiei\sum a_ie_i, and (v,∑aiei)=∑ai(v,ei)(v, \sum a_ie_i) = \sum a_i(v, e_i).
    S∩S⊥={O}S \cap S^\perp = \{O\}.
    If v∈S∩S⊥v \in S \cap S^\perp then vv can be used as the ss: (v,v)=0(v, v) = 0, and axiom 4 gives v=Ov = O.

    In R3\mathbb R^3, if SS is a plane through the origin then S⊥S^\perp is the line through the origin perpendicular to it. Spagnolie’s picture: a plane SS, a vector xx above it, and a dotted perpendicular down to its foot in the plane.

    Theorem T Apostol Thm 1.15; Spagnolie Lecture 6

    Orthogonal decomposition theorem

    Let SS be a subspace of a Euclidean space VV with a finite basis. Then every x∈Vx \in V can be written in exactly one way as x=s+s⊥x = s + s^\perp, where s∈Ss \in S and s⊥∈S⊥s^\perp \in S^\perp. Moreover ∥x∥2=∥s∥2+∥s⊥∥2\lVert x\rVert^2 = \lVert s\rVert^2 + \lVert s^\perp\rVert^2 (Pythagoras).

    In one lineIf SS is a finite-dimensional subspace, every xx splits uniquely as x=s+s⊥x = s + s^\perp with s∈Ss \in S and s⊥∈S⊥s^\perp \in S^\perp, and ∥x∥2=∥s∥2+∥s⊥∥2\lVert x\rVert^2 = \lVert s\rVert^2 + \lVert s^\perp\rVert^2.

    Why it is trueTake ss to be the sum of the shadows of xx on an orthonormal basis of SS. What is left over is perpendicular to every basis vector.

    ProofSpagnolie Lecture 6; Apostol 1.15
    The idea: Choose an orthonormal basis of S by Gram–Schmidt. Define s by the shadow formula and s⊥ = x − s. Check that s⊥ is orthogonal to each basis vector. Uniqueness comes from S ∩ S⊥ = {O}, and Pythagoras from s ⟂ s⊥.
    Let q1,…,qkq_1, \dots, q_k be an orthonormal basis of SS.
    Gram–Schmidt applied to a basis of SS, then normalizing.
    Define s=∑i(x,qi)qis = \sum_i (x, q_i)q_i and s⊥=x−ss^\perp = x - s.
    ss is a combination of the qiq_i, so it is in SS. And s+s⊥=xs + s^\perp = x by definition of s⊥s^\perp.
    (s⊥,qj)=(x,qj)−(s,qj)=(x,qj)−(x,qj)=0(s^\perp, q_j) = (x, q_j) - (s, q_j) = (x, q_j) - (x, q_j) = 0 for each jj.
    Expand (s,qj)(s, q_j): only the i=ji = j term survives because (qi,qj)=0(q_i, q_j) = 0 for i≠ji \ne j and (qj,qj)=1(q_j, q_j) = 1.
    So s⊥∈S⊥s^\perp \in S^\perp. This proves existence.
    Orthogonal to a basis of SS means orthogonal to all of SS (the previous theorem).
    s−s′s - s' lies in S∩S⊥S \cap S^\perp.
    Suppose x=s+s⊥=s′+s′⊥x = s + s^\perp = s' + s'^\perp are two splits. Subtracting, s−s′=s′⊥−s⊥s - s' = s'^\perp - s^\perp. The left side is in SS (a subspace) and the right side is in S⊥S^\perp (a subspace).
    s=s′s = s' and s⊥=s′⊥s^\perp = s'^\perp. This proves uniqueness (and shows the projection does not depend on the chosen basis).
    S∩S⊥={O}S \cap S^\perp = \{O\} from the previous theorem.
    ∥x∥2=∥s∥2+∥s⊥∥2\lVert x\rVert^2 = \lVert s\rVert^2 + \lVert s^\perp\rVert^2.
    (s,s⊥)=0(s, s^\perp) = 0 because s∈Ss \in S and s⊥∈S⊥s^\perp \in S^\perp. Expanding (s+s⊥,s+s⊥)(s + s^\perp, s + s^\perp), the cross terms vanish.

    The proof shows that the piece ss is well defined, so it gets a name.

    Definition T

    Projection

    The vector ss in the decomposition is the projection of xx onto SS, written proj⁡Sx\operatorname{proj}_S x. If q1,…,qkq_1, \dots, q_k is an orthonormal basis of SS, it is s=∑i=1k(x,qi) qis = \sum_{i=1}^k (x, q_i)\,q_i. If e1,…,eke_1, \dots, e_k is an orthogonal basis, it is ∑(x,ei)(ei,ei)ei\sum \dfrac{(x, e_i)}{(e_i, e_i)}e_i. For a line spanned by uu it is (x,u)(u,u)u\dfrac{(x, u)}{(u, u)}u, the shadow in the picture.

    In one lineThe SS-part ss of x=s+s⊥x = s + s^\perp: the shadow of xx on the subspace SS.

    Why it existsIt is the point of SS that best stands in for xx, which the next theorem proves.

    Worked example Spagnolie Lecture 5/6, continuing the example above
    Project x = (0, 0, 1) onto the plane S spanned by x1 = (1, 0, 1) and x2 = (1, 1, 0), and find its distance from the plane.

    Solution.

    1. Get an orthogonal basis of SS. From the Gram–Schmidt example, y1=(1,0,1)y_1 = (1, 0, 1) and y2=(12,1,−12)y_2 = (\tfrac12, 1, -\tfrac12) are orthogonal and span the same plane. The projection formula needs an orthogonal basis; the original x1,x2x_1, x_2 are not orthogonal.
    2. Coefficients. (x,y1)(y1,y1)=12\dfrac{(x, y_1)}{(y_1, y_1)} = \dfrac12 and (x,y2)(y2,y2)=−1/23/2=−13\dfrac{(x, y_2)}{(y_2, y_2)} = \dfrac{-1/2}{3/2} = -\dfrac13.
    3. The projection. s=12(1,0,1)−13(12,1,−12)=(13,−13,23)s = \tfrac12(1, 0, 1) - \tfrac13(\tfrac12, 1, -\tfrac12) = (\tfrac13, -\tfrac13, \tfrac23).
    4. The leftover. s⊥=x−s=(−13,13,13)s^\perp = x - s = (-\tfrac13, \tfrac13, \tfrac13), which is exactly the y3y_3 of Gram–Schmidt. The last Gram–Schmidt vector is x3x_3 minus its projection on the span of the earlier ones. This is the same computation.
    5. The distance. ∥s⊥∥=19+19+19=13≈0.577\lVert s^\perp\rVert = \sqrt{\tfrac19 + \tfrac19 + \tfrac19} = \tfrac1{\sqrt3} \approx 0.577. The distance from a point to a plane is the length of the perpendicular.

    Answer. proj⁡Sx=(13,−13,23)\operatorname{proj}_S x = (\tfrac13, -\tfrac13, \tfrac23), at distance 1/31/\sqrt3 from xx. Check with Pythagoras: ∥x∥2=1=∥s∥2+∥s⊥∥2=69+39\lVert x\rVert^2 = 1 = \lVert s\rVert^2 + \lVert s^\perp\rVert^2 = \tfrac69 + \tfrac39.

    Your answerThe projection of x=(5,5)x = (5, 5) onto the line through u=(1,2)u = (1, 2) is c uc\,u. Find cc.
    Worked example Axler 6C
    Let S be a subspace of a finite-dimensional Euclidean space. Prove that the orthogonal complement of S⊥ is S.

    Solution.

    1. The easy inclusion. Take s∈Ss \in S. Every v∈S⊥v \in S^\perp has (s,v)=0(s, v) = 0, so ss is orthogonal to all of S⊥S^\perp, that is, s∈(S⊥)⊥s \in (S^\perp)^\perp. This is the definition of S⊥S^\perp and of (S⊥)⊥(S^\perp)^\perp, unpacked once each.
    2. The hard inclusion: split a vector. Take x∈(S⊥)⊥x \in (S^\perp)^\perp and write x=s+s⊥x = s + s^\perp with s∈Ss \in S and s⊥∈S⊥s^\perp \in S^\perp. The orthogonal decomposition theorem gives this split for every vector. It needs SS finite-dimensional, which holds here.
    3. Show the leftover is zero. s⊥=x−ss^\perp = x - s. Now x∈(S⊥)⊥x \in (S^\perp)^\perp is orthogonal to s⊥∈S⊥s^\perp \in S^\perp, and s∈Ss \in S is orthogonal to s⊥s^\perp. So (s⊥,s⊥)=(x,s⊥)−(s,s⊥)=0−0=0(s^\perp, s^\perp) = (x, s^\perp) - (s, s^\perp) = 0 - 0 = 0. Both inner products are 00 for the reasons stated in this step.
    4. Conclude. Axiom 4 gives s⊥=Os^\perp = O, so x=s∈Sx = s \in S. A vector with zero squared length is OO.

    Answer. (S⊥)⊥=S(S^\perp)^\perp = S. In R3\mathbb R^3: the perpendicular line to the perpendicular line of a plane is the plane again.

    Worked example MATH 375 Lecture 19, version 1
    Let A be a real symmetric matrix and x, y eigenvectors with different eigenvalues λ and μ. Prove that x is perpendicular to y.

    Solution.

    1. Move AA across the dot product. (Ax)⋅y=(Ax)Ty=xTATy=xTAy=x⋅(Ay)(Ax)\cdot y = (Ax)^{\mathsf T}y = x^{\mathsf T}A^{\mathsf T}y = x^{\mathsf T}Ay = x\cdot(Ay). (AB)T=BTAT(AB)^{\mathsf T} = B^{\mathsf T}A^{\mathsf T}, and AT=AA^{\mathsf T} = A because AA is symmetric. This is the only place symmetry is used.
    2. Evaluate the left side. (Ax)⋅y=λ (x⋅y)(Ax)\cdot y = \lambda\,(x\cdot y). Ax=λxAx = \lambda x, and a scalar comes out of the dot product.
    3. Evaluate the right side. x⋅(Ay)=μ (x⋅y)x\cdot(Ay) = \mu\,(x\cdot y). Ay=μyAy = \mu y.
    4. Compare. (λ−μ)(x⋅y)=0(\lambda - \mu)(x\cdot y) = 0. Steps 1 to 3 say λ(x⋅y)=μ(x⋅y)\lambda(x\cdot y) = \mu(x\cdot y).
    5. Use that the eigenvalues differ. λ−μ≠0\lambda - \mu \ne 0, so x⋅y=0x\cdot y = 0. A product of two numbers is 00 only if one of them is 00.

    Answer. x⊥yx \perp y. Check on S=[5225]S = \begin{bmatrix}5&2\\2&5\end{bmatrix} from 2.8: the eigenvectors (1,1)(1, 1) for 77 and (1,−1)(1, -1) for 33 have dot product 1−1=01 - 1 = 0.

    Best approximation

    Now the payoff. The closest point of a subspace to xx is its projection.

    Theorem T Apostol Thm 1.16; Spagnolie Lecture 6

    Best approximation theorem

    Let SS be a finite-dimensional subspace of a Euclidean space VV, let x∈Vx \in V, and let s=proj⁡Sxs = \operatorname{proj}_S x. Then for every t∈St \in S,

    ∥x−t∥2=∥x−s∥2+∥s−t∥2 ≥ ∥x−s∥2,\lVert x - t\rVert^2 = \lVert x - s\rVert^2 + \lVert s - t\rVert^2 \ \ge\ \lVert x - s\rVert^2,

    with equality only when t=st = s.

    In one lineAmong all points of SS, the projection ss is the unique closest point to xx: ∥x−s∥≤∥x−t∥\lVert x - s\rVert \le \lVert x - t\rVert for every t∈St \in S.

    Why it is trueFor any other point tt of the subspace, the three points xx, ss, tt form a right triangle with the right angle at ss, so the hypotenuse xtx t is longer than the leg xsx s.

    Go back to the picture and move the slider so the orange point slides along the line. The green arrow pp is ss, the orange point is tt, the red dashed arrow is x−sx - s, and the right-angle mark is the fact (x−s)⊥(s−t)(x - s) \perp (s - t) that the proof uses. The “distance to the orange point” in the readout is always larger than the distance to the shadow, and its square exceeds the shadow’s by exactly the squared length from the shadow to the orange point.

    ProofSpagnolie Lecture 6; Apostol 1.16
    The idea: Write x − t as the sum of two pieces: x − s, which is perpendicular to S, and s − t, which lies in S. The pieces are perpendicular, so Pythagoras applies.
    x−t=(x−s)+(s−t)x - t = (x - s) + (s - t).
    Add and subtract ss. In the picture: the hypotenuse from xx to the orange point tt is the sum of the red leg x−sx - s and the leg along the line, s−ts - t.This is the red dashed arrow plus the segment from the shadow to the orange point.
    So (x−s, s−t)=0(x - s,\ s - t) = 0.
    x−s=s⊥∈S⊥x - s = s^\perp \in S^\perp by the decomposition theorem. And s−t∈Ss - t \in S, since both ss and tt are in the subspace SS.
    ∥x−t∥2=∥x−s∥2+∥s−t∥2\lVert x - t\rVert^2 = \lVert x - s\rVert^2 + \lVert s - t\rVert^2.
    Expand (x−t,x−t)(x - t, x - t) using the two pieces. The cross terms are 2(x−s,s−t)=02(x - s, s - t) = 0.This is Pythagoras on the right angle marked in the picture.
    ∥x−t∥2≥∥x−s∥2\lVert x - t\rVert^2 \ge \lVert x - s\rVert^2, so ∥x−t∥≥∥x−s∥\lVert x - t\rVert \ge \lVert x - s\rVert.
    A square is never negative.
    Equality holds only for t=st = s.
    Equality needs ∥s−t∥=0\lVert s - t\rVert = 0, and axiom 4 gives s−t=Os - t = O.
    Proof workshopGive the reason for each line: the projection is the closest point

    Each line of the proof is shown in order. Choose the reason that justifies it, then press Check.

    1. x−t=(x−s)+(s−t)x - t = (x - s) + (s - t)
    2. (x−s, s−t)=0(x - s,\ s - t) = 0
    3. ∥x−t∥2=∥x−s∥2+∥s−t∥2\lVert x - t\rVert^2 = \lVert x - s\rVert^2 + \lVert s - t\rVert^2
    4. ∥x−t∥≥∥x−s∥\lVert x - t\rVert \ge \lVert x - s\rVert
    5. t=st = s if the two distances are equal

    The squared error has a neat formula too. Since x−s=s⊥x - s = s^\perp, Pythagoras from the decomposition theorem gives ∥x−s∥2=∥x∥2−∥s∥2\lVert x - s\rVert^2 = \lVert x\rVert^2 - \lVert s\rVert^2. With an orthonormal basis qiq_i of SS, that is ∥x∥2−∑(x,qi)2\lVert x\rVert^2 - \sum(x, q_i)^2. In particular ∑i(x,qi)2≤∥x∥2\sum_i(x, q_i)^2 \le \lVert x\rVert^2 (Bessel’s inequality), since the error cannot be negative.

    Your answerq1,q2q_1, q_2 are orthonormal vectors and xx has ∥x∥2=30\lVert x\rVert^2 = 30, (x,q1)=3(x, q_1) = 3, (x,q2)=4(x, q_2) = 4. What is the squared distance from xx to the plane spanned by q1q_1 and q2q_2?
    Worked example Apostol 1.17 #8, MATH 375 HW4
    Find the linear polynomial g nearest to f(t) = e^t on [-1, 1], with (f, g) = ∫ f g dt, and the squared error.

    Solution. The family of linear polynomials S={a+bt}S = \{a + bt\} is a 2-dimensional subspace of C[−1,1]C[-1, 1].

    1. Orthonormal basis of SS. From the Legendre example, y0=1y_0 = 1 and y1=ty_1 = t are orthogonal, with (y0,y0)=2(y_0, y_0) = 2 and (y1,y1)=23(y_1, y_1) = \tfrac23. So φ0=12\varphi_0 = \tfrac1{\sqrt2} and φ1=32 t\varphi_1 = \sqrt{\tfrac32}\,t. The projection formula in this simple form needs an orthonormal basis.
    2. Two integrals. I0=∫−11et dt=e−e−1I_0 = \int_{-1}^1e^t\,dt = e - e^{-1} and I1=∫−11tet dt=[tet−et]−11=2e−1I_1 = \int_{-1}^1te^t\,dt = [te^t - e^t]_{-1}^1 = 2e^{-1}. Integration by parts. These are the inner products of ff with 11 and with tt.
    3. Projection. g=(f,φ0)φ0+(f,φ1)φ1=I02+32I1 t=e−e−12+3e t≈1.1752+1.1036 tg = (f, \varphi_0)\varphi_0 + (f, \varphi_1)\varphi_1 = \dfrac{I_0}{2} + \dfrac{3}{2}I_1\,t = \dfrac{e - e^{-1}}{2} + \dfrac{3}{e}\,t \approx 1.1752 + 1.1036\,t. (f,φ0)φ0=I02⋅12(f, \varphi_0)\varphi_0 = \tfrac{I_0}{\sqrt2}\cdot\tfrac1{\sqrt2} and (f,φ1)φ1=32I1t(f, \varphi_1)\varphi_1 = \tfrac32I_1t.
    4. Squared error. ∥f−g∥2=∥f∥2−∥g∥2=e2−e−22−(I022+32I12)=1−7e−2≈0.0527\lVert f - g\rVert^2 = \lVert f\rVert^2 - \lVert g\rVert^2 = \dfrac{e^2 - e^{-2}}{2} - \Big(\dfrac{I_0^2}{2} + \dfrac32I_1^2\Big) = 1 - 7e^{-2} \approx 0.0527. The error formula above. Here I022=e2−2+e−22\dfrac{I_0^2}{2} = \dfrac{e^2 - 2 + e^{-2}}{2} and 32I12=6e−2\dfrac32I_1^2 = 6e^{-2}.
    5. Check numerically. ∥f∥2=3.6269\lVert f\rVert^2 = 3.6269, ∥g∥2=2.7622+0.8120=3.5742\lVert g\rVert^2 = 2.7622 + 0.8120 = 3.5742, difference 0.05270.0527. A second route to the same number.

    Answer. g(t)=12(e−e−1)+3e−1tg(t) = \tfrac12(e - e^{-1}) + 3e^{-1}t, with squared error 1−7/e2≈0.05271 - 7/e^2 \approx 0.0527. (Calculus gives the same by minimizing ∥f−a−bt∥2\lVert f - a - bt\rVert^2 over a,ba, b: setting the two partial derivatives to zero gives the same a,ba, b. Those equations are the “normal equations” of chapter 2.10.)

    Quick checkIn the best approximation theorem, why is the projection ss closer to xx than any other point tt of SS?

    Fourier series: best approximation by waves

    Where this came from· Heat, waves and least squares

    Fourier presented his memoir on how heat spreads through a solid body to the Paris Institute in December 1807 (the book Théorie analytique de la chaleur followed in 1822). He wrote the starting temperature as a sum of sine and cosine waves, because the heat equation treats each wave separately (each one fades at its own rate), and added the results. Lagrange, one of the committee that read the memoir, objected to expanding an arbitrary function in a trigonometric series. The inner-product view of this chapter explains the practical side: the coefficients are inner products, and a partial sum is a best approximation. Gram (1883) studied expanding functions in series by least squares and gave the orthogonalization process there. Erhard Schmidt (1907) used the process for integral equations, and acknowledged Gram’s earlier work. The process now carries both names, although Laplace was already familiar with the idea.

    Take V=C[0,2π]V = C[0, 2\pi] with (f,g)=∫02πf(x)g(x) dx(f, g) = \int_0^{2\pi}f(x)g(x)\,dx. The functions

    φ0=12π,φ2k−1=1πcos⁡kx,φ2k=1πsin⁡kx(k=1,2,… )\varphi_0 = \tfrac1{\sqrt{2\pi}}, \qquad \varphi_{2k-1} = \tfrac1{\sqrt\pi}\cos kx, \qquad \varphi_{2k} = \tfrac1{\sqrt\pi}\sin kx \qquad (k = 1, 2, \dots)

    are orthonormal. (The check uses the product-to-sum identities. The next example does the cosine case on [0,π][0, \pi], and on [0,2π][0, 2\pi] the computation is the same.) Let SnS_n be the span of the first 2n+12n + 1 of them. By the best approximation theorem, the closest function in SnS_n to ff is the projection, whose coefficients are inner products:

    sn=∑j=02n(f,φj) φj,(f,φj)=∫02πf(x)φj(x) dx.s_n = \sum_{j=0}^{2n}(f, \varphi_j)\,\varphi_j, \qquad (f, \varphi_j) = \int_0^{2\pi}f(x)\varphi_j(x)\,dx.

    This is the partial Fourier series of ff. “Closest” means smallest ∫02π(f−s)2\int_0^{2\pi}(f - s)^2, the root-mean-square error. The infinite sum is a different matter (the φj\varphi_j are an orthonormal “basis” only in a limiting sense, which analysis in MATH 521 makes precise), and we use only partial sums and their errors.

    Worked example Apostol 1.17 #3, MATH 375 HW3
    Show that cos(mt) and cos(nt) are orthogonal on [0, π] for m ≠ n, and find the norm of cos(nt).

    Solution.

    1. Use the product-to-sum identity. cos⁡mtcos⁡nt=12[cos⁡(m+n)t+cos⁡(m−n)t]\cos mt\cos nt = \tfrac12\big[\cos(m + n)t + \cos(m - n)t\big]. Turns a product into a sum of two cosines, each easy to integrate.
    2. Integrate for m≠nm \ne n. ∫0πcos⁡mtcos⁡nt dt=12[sin⁡(m+n)tm+n+sin⁡(m−n)tm−n]0π=0\int_0^\pi\cos mt\cos nt\,dt = \tfrac12\Big[\tfrac{\sin(m+n)t}{m+n} + \tfrac{\sin(m-n)t}{m-n}\Big]_0^\pi = 0. sin⁡\sin of an integer multiple of π\pi is 00, and both denominators are non-zero.
    3. Integrate for m=n≥1m = n \ge 1. ∫0πcos⁡2nt dt=12∫0π(cos⁡2nt+1) dt=π2\int_0^\pi\cos^2nt\,dt = \tfrac12\int_0^\pi(\cos2nt + 1)\,dt = \tfrac\pi2. Now m−n=0m - n = 0, so the second cosine is the constant 11.
    4. For n=0n = 0: ∫0π1 dt=π\int_0^\pi1\,dt = \pi.
    5. Normalize. y0=1πy_0 = \tfrac1{\sqrt\pi} and yn=2πcos⁡nty_n = \sqrt{\tfrac2\pi}\cos nt are orthonormal. Divide each function by its norm, π\sqrt\pi and π/2\sqrt{\pi/2}.

    Answer. The cosines are orthogonal, with ∥1∥2=π\lVert1\rVert^2 = \pi and ∥cos⁡nt∥2=π/2\lVert\cos nt\rVert^2 = \pi/2.

    Worked example Spagnolie Lecture 6 (the Mathematica example), numbers computed here
    Approximate the triangle wave f(x) = x on [0, π], 2π − x on [π, 2π] by constants, then by a constant plus a cosine, and measure the error.

    Solution.

    1. The squared length of ff. ∥f∥2=2∫0πx2 dx=2π33≈20.671\lVert f\rVert^2 = 2\int_0^\pi x^2\,dx = \tfrac{2\pi^3}{3} \approx 20.671. The two halves are mirror images.
    2. Best constant. The coefficient on φ0\varphi_0 is (f,φ0)=12π∫02πf=π22π(f, \varphi_0) = \tfrac1{\sqrt{2\pi}}\int_0^{2\pi}f = \tfrac{\pi^2}{\sqrt{2\pi}}, so the best constant is π22π⋅12π=π2\tfrac{\pi^2}{\sqrt{2\pi}}\cdot\tfrac1{\sqrt{2\pi}} = \tfrac\pi2, the average height of the wave. Its squared “energy” is (f,φ0)2=π32≈15.503(f, \varphi_0)^2 = \tfrac{\pi^3}{2} \approx 15.503. The area under the triangle is π2\pi^2. The projection onto the constants is the average value.
    3. Error of the best constant. ∥f−π2∥2=2π33−π32=π36≈5.168\lVert f - \tfrac\pi2\rVert^2 = \tfrac{2\pi^3}{3} - \tfrac{\pi^3}{2} = \tfrac{\pi^3}{6} \approx 5.168. Error =∥f∥2−∥s∥2=\lVert f\rVert^2 - \lVert s\rVert^2, from the best approximation theorem.
    4. The cosine term. (f,φ1)=1π∫02πf(x)cos⁡x dx=−4π≈−2.257(f, \varphi_1) = \tfrac1{\sqrt\pi}\int_0^{2\pi}f(x)\cos x\,dx = -\tfrac4{\sqrt\pi} \approx -2.257. (The sine coefficient is 00 because ff is symmetric about x=πx = \pi.) Integration by parts on each half; the answer matches a numerical integration.
    5. Add it. s=π2−4πcos⁡xs = \tfrac\pi2 - \tfrac4\pi\cos x. The squared energy added is (f,φ1)2=16π≈5.093(f, \varphi_1)^2 = \tfrac{16}{\pi} \approx 5.093, so the new error is π36−16π≈0.0748\tfrac{\pi^3}{6} - \tfrac{16}\pi \approx 0.0748. Each new orthonormal function removes exactly its coefficient squared from the error.
    6. Read the result. Two terms already remove 98.6%98.6\% of the error left by the constant. Adding cos⁡3x\cos3x (energy 1681π\tfrac{16}{81\pi}) brings the error to 0.01190.0119, and cos⁡5x\cos5x to 0.00370.0037. The coefficients fall off like 1/k21/k^2 for this wave because it has corners but no jumps. This is the shape of the three Mathematica plots in Spagnolie’s Lecture 6.

    Answer. f≈π2−4π(cos⁡x+cos⁡3x9+cos⁡5x25+⋯)f \approx \tfrac\pi2 - \tfrac4\pi\Big(\cos x + \tfrac{\cos3x}{9} + \tfrac{\cos5x}{25} + \cdots\Big). At x=0x = 0 the two-term version gives π2−4π=0.30\tfrac\pi2 - \tfrac4\pi = 0.30 where the true value is 00.

    Where it is used

    Used inside maths· Inside maths: a sum of 1/k⁴ from Pythagoras

    For the triangle wave, the squared length of ff is the sum of the squares of its coefficients (Parseval’s equality, which holds because the trigonometric system is complete; Bessel’s inequality above gives only "≤\le", and completeness, which is MATH 521 material, gives "=="). The nonzero coefficients are the constant and the cosines of odd frequency kk, and the square of the coefficient of cos⁡kx\cos kx is 16πk4\dfrac{16}{\pi k^4}. So

    2π33=π32+16π∑k odd1k4,hence1+134+154+⋯=π496.\frac{2\pi^3}{3} = \frac{\pi^3}{2} + \frac{16}{\pi}\sum_{k\ \text{odd}}\frac1{k^4}, \qquad\text{hence}\qquad 1 + \frac1{3^4} + \frac1{5^4} + \cdots = \frac{\pi^4}{96}.

    A numerical check: π4/96=1.014678…\pi^4/96 = 1.014678\ldots, and the first terms 1+0.012346+0.0016+0.00042+⋯1 + 0.012346 + 0.0016 + 0.00042 + \cdots add to the same. An infinite sum, found by applying Pythagoras in a function space.

    Used in the real world· Signal processing: a Fourier coefficient is an inner product

    An audio signal on one second of time, x(t)=3cos⁡(2π⋅5t)+sin⁡(2π⋅12t)x(t) = 3\cos(2\pi\cdot5t) + \sin(2\pi\cdot12t), is a mix of a 5 Hz cosine and a 12 Hz sine. To find how much of the 5 Hz cosine is present, take the inner product on [0,1][0, 1]: (x,cos⁡2π5t)=32(x, \cos2\pi5t) = \tfrac32 and (cos⁡2π5t,cos⁡2π5t)=12(\cos2\pi5t, \cos2\pi5t) = \tfrac12, so the amount is 3/21/2=3\tfrac{3/2}{1/2} = 3, which is right. Likewise (x,sin⁡2π12t)=12(x, \sin2\pi12t) = \tfrac12 gives amount 11. The inner product with any other frequency (say cos⁡2π12t\cos2\pi12t, sin⁡2π5t\sin2\pi5t or cos⁡2π7t\cos2\pi7t) is 00, because the waves are orthogonal. This is exactly the coordinate theorem for an orthogonal basis. A JPEG file does the same with a cosine basis: each 8×88\times8 block of pixels is treated as a vector with 6464 numbers and expanded in 6464 orthonormal cosine patterns; the small coefficients are thrown away. By the best approximation theorem, keeping the largest coefficients gives the closest picture that uses that many patterns. MP3 applies a related cosine transform to short frames of audio.

    Used in the real world· Search and AI: cosine similarity

    A text-embedding model turns each word or sentence into a vector (hundreds or thousands of numbers). Similar meanings should give similar directions, so the similarity is the cosine of the angle, defined above. Toy example with three numbers: king=(0.9,0.8,0.1)\text{king} = (0.9, 0.8, 0.1), queen=(0.85,0.75,0.2)\text{queen} = (0.85, 0.75, 0.2), apple=(0.1,0.2,0.95)\text{apple} = (0.1, 0.2, 0.95). Then (king,queen)=1.385(\text{king}, \text{queen}) = 1.385, with norms 1.2081.208 and 1.1511.151, so cos⁡θ=0.9958\cos\theta = 0.9958 and θ≈5.3°\theta \approx 5.3°. But (king,apple)=0.345(\text{king}, \text{apple}) = 0.345 with norms 1.2081.208 and 0.9760.976 gives cos⁡θ=0.293\cos\theta = 0.293, θ≈73°\theta \approx 73°. Cauchy–Schwarz is what guarantees every such number lies in [−1,1][-1, 1], whatever the dimension. Multiplying a vector by 1010 changes the inner product but not the cosine, so similarity ignores length. A transformer’s attention scores q⋅kq\cdot k are inner products of the same kind.

    A preview· Preview: the closest point is least squares (chapter 2.10)

    A GPS receiver measures its distance to four or more satellites. Each measurement is one equation in four unknowns (three position coordinates and the receiver’s clock error). With more than four equations and noisy measurements there is usually no exact solution. The fix is to find the vector of unknowns whose predicted measurements are closest to the actual ones. The predicted measurements lie in a subspace (the span of the columns of a matrix), so the closest point is the projection of the data onto that subspace, and the error vector is perpendicular to it. Chapter 2.10 turns this into a formula. Fitting a line to data points works the same way, as in the ete^t example above where the “data” is a whole function.

    Beyond the course: for understanding· QR decomposition: Gram–Schmidt written as a matrix factorization

    Let AA have the columns x1,x2,x3x_1, x_2, x_3 of the Gram–Schmidt example. Put the orthonormal vectors φ1,φ2,φ3\varphi_1, \varphi_2, \varphi_3 as the columns of a matrix QQ. Since xmx_m is ymy_m plus a combination of earlier yy‘s, each xmx_m is a combination of φ1,…,φm\varphi_1, \dots, \varphi_m with coefficients rim=(φi,xm)r_{im} = (\varphi_i, x_m), and so A=QRA = QR with RR upper triangular. Here

    R=[22222062−660033]=[1.4140.7070.70701.225−0.408000.577],R = \begin{bmatrix}\sqrt2 & \tfrac{\sqrt2}{2} & \tfrac{\sqrt2}{2}\\ 0 & \tfrac{\sqrt6}{2} & -\tfrac{\sqrt6}{6}\\ 0 & 0 & \tfrac{\sqrt3}{3}\end{bmatrix} = \begin{bmatrix}1.414&0.707&0.707\\0&1.225&-0.408\\0&0&0.577\end{bmatrix},

    and one can check QR=AQR = A entry by entry (for example the first column is 2φ1=(1,0,1)\sqrt2\varphi_1 = (1, 0, 1)). This factorization is how numerical software solves least-squares problems, because QQ has perpendicular unit columns and so does not magnify errors, and RR is solved by back-substitution. In practice the classical process above loses perpendicularity to rounding errors on hard matrices, so libraries use Householder reflections or the “modified” Gram–Schmidt instead.

    Beyond the course: for understanding· Orthogonal polynomials

    Changing the interval or the weight in the inner product gives other families by the same process. On [−1,1][-1, 1] with weight 11, Gram–Schmidt on 1,t,t2,…1, t, t^2, \dots gives the Legendre polynomials (electrostatic potentials, Gaussian quadrature). With weight 1/1−t21/\sqrt{1 - t^2} you get Chebyshev polynomials (used for stable polynomial approximation). On [0,∞)[0, \infty) with weight e−te^{-t} it gives the Laguerre polynomials: 1, t−1, t2−4t+2, t3−9t2+18t−61,\ t - 1,\ t^2 - 4t + 2,\ t^3 - 9t^2 + 18t - 6 (Apostol 1.17 #5). With weight e−t2e^{-t^2} on the whole line you get Hermite polynomials, which describe the quantum harmonic oscillator. All of them are one idea: the inner product decides what “orthogonal” means.

    Traps

    Watch out· Orthogonal depends on the inner product

    With the dot product (1,1)(1, 1) and (1,−1)(1, -1) are orthogonal. With (x,y)=x1y1+2x2y2(x, y) = x_1y_1 + 2x_2y_2 their inner product is 1−2=−11 - 2 = -1, so they are not. In function spaces, whether 11 and t2t^2 are orthogonal depends on the interval and the weight: on [−1,1][-1, 1] with weight 11 they are not (23\tfrac23). Always say which inner product.

    Watch out· Orthogonal implies independent, not the reverse; and O is excluded

    An orthogonal set of non-zero vectors is independent. An independent set need not be orthogonal ((1,0)(1,0) and (1,1)(1,1)). And the zero vector is orthogonal to everything, so including it in a list breaks the theorem: {O,x}\{O, x\} is orthogonal but dependent.

    Watch out· Gram–Schmidt: project onto the y's, divide by (y, y)

    Two slips: projecting x3x_3 onto the original x1,x2x_1, x_2 (they are not perpendicular, so you remove some directions twice), and dividing by ∥y∥\lVert y\rVert instead of (y,y)=∥y∥2(y, y) = \lVert y\rVert^2. A third: arithmetic. Spagnolie’s own class notes got a=1a = 1 and b=+13b = +\tfrac13 for the example above, instead of 12\tfrac12 and −13-\tfrac13, and the resulting y3y_3 was not orthogonal to y1y_1. Always check (yi,yj)=0(y_i, y_j) = 0 at the end. A zero vector appearing means the xx‘s were dependent.

    Watch out· Adding projections works only for an orthogonal basis

    Let S=R2S = \mathbb R^2 with the basis (1,0),(1,1)(1, 0), (1, 1) and x=(0,1)x = (0, 1). Projecting xx onto each basis vector separately gives (0,0)(0, 0) and (12,12)(\tfrac12, \tfrac12), and their sum (12,12)(\tfrac12, \tfrac12) is not xx, though xx is in SS. The sum-of-shadows formula needs the basis vectors to be perpendicular.

    Watch out· The norm scales by |c|, and not every integral is a norm

    ∥cx∥=∣c∣ ∥x∥\lVert cx\rVert = |c|\,\lVert x\rVert. A student summary sheet wrote c ∥x∥c\,\lVert x\rVert, which would give negative lengths for negative cc. And ∫F′2\int F'^2 (the example in the beyond-box) fails all three norm rules. Check the rules before calling something a norm.

    Watch out· Fourier 'basis' and cosine similarity are used loosely

    A Fourier “basis” is infinite, so the expansion of ff is a limit, and a statement like ”ff equals its Fourier series” needs a notion of convergence (and at jumps it is false pointwise). Cosine similarity ignores length: two vectors pointing the same way are “identical” however different their sizes. Be sure that is what you want.

    Problems

    check

    Is (x,y)=x1y1+2x2y2(x, y) = x_1y_1 + 2x_2y_2 an inner product on R2\mathbb R^2? Are (1,1)(1, 1) and (1,−1)(1, -1) orthogonal for it?

    Solution

    Symmetry, additivity and homogeneity are clear (it is the dot product with the second coordinate weighted by 22). Positivity: (x,x)=x12+2x22>0(x, x) = x_1^2 + 2x_2^2 > 0 unless x=Ox = O. So yes, it is an inner product. ((1,1),(1,−1))=1−2=−1≠0((1,1), (1,-1)) = 1 - 2 = -1 \ne 0, so they are not orthogonal for it, although they are for the dot product.

    check

    In C[−1,1]C[-1, 1] with (f,g)=∫−11fg dt(f, g) = \int_{-1}^1fg\,dt, are 11 and t2t^2 orthogonal? Are tt and t2−13t^2 - \tfrac13?

    Solution

    (1,t2)=∫−11t2 dt=23≠0(1, t^2) = \int_{-1}^1t^2\,dt = \tfrac23 \ne 0: not orthogonal (Spagnolie’s example showing the monomials are not orthogonal). (t,t2−13)=∫−11(t3−t3) dt=0(t, t^2 - \tfrac13) = \int_{-1}^1(t^3 - \tfrac t3)\,dt = 0 since the integrand is odd: orthogonal.

    check

    For x=(3,4)x = (3, 4) and y=(4,3)y = (4, 3) in R2\mathbb R^2, compute (x,y)(x, y), ∥x∥\lVert x\rVert, ∥y∥\lVert y\rVert and check Cauchy–Schwarz.

    Solution

    (x,y)=12+12=24(x, y) = 12 + 12 = 24. ∥x∥=∥y∥=5\lVert x\rVert = \lVert y\rVert = 5. Then ∣(x,y)∣=24≤25=∥x∥∥y∥|(x, y)| = 24 \le 25 = \lVert x\rVert\lVert y\rVert. The cosine of the angle is 24/25=0.9624/25 = 0.96 (θ≈16.3°\theta \approx 16.3°). They are not dependent, so the inequality is strict.

    check

    An orthonormal basis q1,q2q_1, q_2 of R2\mathbb R^2 is given, and xx has (x,q1)=3(x, q_1) = 3 and (x,q2)=−4(x, q_2) = -4. What is ∥x∥\lVert x\rVert?

    Solution

    x=3q1−4q2x = 3q_1 - 4q_2, so ∥x∥2=32+(−4)2=25\lVert x\rVert^2 = 3^2 + (-4)^2 = 25 and ∥x∥=5\lVert x\rVert = 5.

    useApostol 1.17 #2(b), MATH 375 HW3

    Apply Gram–Schmidt to x1=(1,1,0,1)x_1 = (1, 1, 0, 1), x2=(1,0,2,1)x_2 = (1, 0, 2, 1), x3=(1,2,−2,1)x_3 = (1, 2, -2, 1) in R4\mathbb R^4 and find an orthonormal basis of their span.

    Solution

    y1=x1y_1 = x_1, (y1,y1)=3(y_1, y_1) = 3. (y1,x2)=2(y_1, x_2) = 2, so y2=x2−23y1=(13,−23,2,13)=13(1,−2,6,1)y_2 = x_2 - \tfrac23y_1 = (\tfrac13, -\tfrac23, 2, \tfrac13) = \tfrac13(1, -2, 6, 1) and (y2,y2)=143(y_2, y_2) = \tfrac{14}{3}. For x3x_3: (y1,x3)=4(y_1, x_3) = 4 and (y2,x3)=13(1−4−12+1)=−143(y_2, x_3) = \tfrac13(1 - 4 - 12 + 1) = -\tfrac{14}{3}. So y3=x3−43y1+1⋅y2=(1−43+13, 2−43−23, −2+2, 1−43+13)=(0,0,0,0)y_3 = x_3 - \tfrac43y_1 + 1\cdot y_2 = (1 - \tfrac43 + \tfrac13,\ 2 - \tfrac43 - \tfrac23,\ -2 + 2,\ 1 - \tfrac43 + \tfrac13) = (0, 0, 0, 0). A zero vector means x3x_3 was dependent on x1,x2x_1, x_2 (x3=43x1−y2x_3 = \tfrac43x_1 - y_2). Discard it. The span is 2-dimensional with orthonormal basis 13(1,1,0,1)\tfrac1{\sqrt3}(1, 1, 0, 1) and 142(1,−2,6,1)\tfrac1{\sqrt{42}}(1, -2, 6, 1) (since ∥(1,−2,6,1)∥2=42\lVert(1,-2,6,1)\rVert^2 = 42).

    useApostol 1.17 #6, MATH 375 HW4

    In C[1,3]C[1, 3] with (f,g)=∫13fg dx(f, g) = \int_1^3fg\,dx, find the constant function nearest to f(x)=1/xf(x) = 1/x and the squared error.

    Solution

    The constants form a 1-dimensional subspace with orthonormal basis φ0=1/2\varphi_0 = 1/\sqrt2 (since ∫131=2\int_1^31 = 2). The nearest constant is (f,φ0)φ0=12∫131x dx=12log⁡3≈0.549(f, \varphi_0)\varphi_0 = \tfrac12\int_1^3\tfrac1x\,dx = \tfrac12\log3 \approx 0.549 (the average value of 1/x1/x). The squared error is ∥f∥2−∥g∥2=∫13x−2 dx−2⋅(12log⁡3)2=23−12(log⁡3)2≈0.0632\lVert f\rVert^2 - \lVert g\rVert^2 = \int_1^3x^{-2}\,dx - 2\cdot(\tfrac12\log3)^2 = \tfrac23 - \tfrac12(\log3)^2 \approx 0.0632, so the distance from ff to the nearest constant is 0.0632≈0.251\sqrt{0.0632} \approx 0.251.

    use

    Project x=(1,2,3)x = (1, 2, 3) onto the plane SS spanned by (1,1,0)(1, 1, 0) and (0,1,1)(0, 1, 1). Find the projection, the perpendicular part, and the distance from xx to the plane.

    Solution

    Make an orthogonal basis: y1=(1,1,0)y_1 = (1, 1, 0), and y2=(0,1,1)−12(1,1,0)=(−12,12,1)y_2 = (0, 1, 1) - \tfrac12(1, 1, 0) = (-\tfrac12, \tfrac12, 1) (since (y1,(0,1,1))=1(y_1, (0,1,1)) = 1 and (y1,y1)=2(y_1, y_1) = 2). Then (x,y1)=3(x, y_1) = 3, so the coefficient is 32\tfrac32; (x,y2)=−12+1+3=72(x, y_2) = -\tfrac12 + 1 + 3 = \tfrac72 and (y2,y2)=32(y_2, y_2) = \tfrac32, so the coefficient is 73\tfrac73. The projection is 32(1,1,0)+73(−12,12,1)=(13,83,73)\tfrac32(1,1,0) + \tfrac73(-\tfrac12,\tfrac12,1) = (\tfrac13, \tfrac83, \tfrac73). The perpendicular part is x−s=(23,−23,23)x - s = (\tfrac23, -\tfrac23, \tfrac23). Check: its inner products with (1,1,0)(1,1,0) and (0,1,1)(0,1,1) are both 00. The distance is ∥(23,−23,23)∥=23≈1.155\lVert(\tfrac23,-\tfrac23,\tfrac23)\rVert = \tfrac{2}{\sqrt3} \approx 1.155.

    useApostol 1.17 #5, MATH 375 HW3

    On the functions with ∫0∞e−tf2 dt<∞\int_0^\infty e^{-t}f^2\,dt < \infty, with (f,g)=∫0∞e−tfg dt(f, g) = \int_0^\infty e^{-t}fg\,dt, apply Gram–Schmidt to 1,t,t21, t, t^2. (Use In=∫0∞e−ttn dt=n!I_n = \int_0^\infty e^{-t}t^n\,dt = n!.)

    Solution

    y0=1y_0 = 1, (y0,y0)=I0=1(y_0, y_0) = I_0 = 1. For y1=t−a y0y_1 = t - a\,y_0: a=(y0,t)/(y0,y0)=I1=1a = (y_0, t)/(y_0, y_0) = I_1 = 1, so y1=t−1y_1 = t - 1, with (y1,y1)=I2−2I1+I0=2−2+1=1(y_1, y_1) = I_2 - 2I_1 + I_0 = 2 - 2 + 1 = 1. For y2=t2−a y0−b y1y_2 = t^2 - a\,y_0 - b\,y_1: a=I2=2a = I_2 = 2 and b=(y1,t2)/(y1,y1)=(I3−I2)/1=6−2=4b = (y_1, t^2)/(y_1, y_1) = (I_3 - I_2)/1 = 6 - 2 = 4. So y2=t2−2−4(t−1)=t2−4t+2y_2 = t^2 - 2 - 4(t - 1) = t^2 - 4t + 2. (Check: (y0,y2)=I2−4I1+2I0=2−4+2=0(y_0, y_2) = I_2 - 4I_1 + 2I_0 = 2 - 4 + 2 = 0.)

    proveApostol 1.13 #3, MATH 375 HW3

    Prove that (x,y)=0(x, y) = 0 if and only if ∥x+y∥=∥x−y∥\lVert x + y\rVert = \lVert x - y\rVert, in any Euclidean space.

    Solution

    Expand: ∥x+y∥2=∥x∥2+2(x,y)+∥y∥2\lVert x + y\rVert^2 = \lVert x\rVert^2 + 2(x, y) + \lVert y\rVert^2 and ∥x−y∥2=∥x∥2−2(x,y)+∥y∥2\lVert x - y\rVert^2 = \lVert x\rVert^2 - 2(x, y) + \lVert y\rVert^2. Subtracting, ∥x+y∥2−∥x−y∥2=4(x,y)\lVert x + y\rVert^2 - \lVert x - y\rVert^2 = 4(x, y). If (x,y)=0(x, y) = 0 the squares are equal, and norms are non-negative, so ∥x+y∥=∥x−y∥\lVert x + y\rVert = \lVert x - y\rVert. Conversely, equal norms give 4(x,y)=04(x, y) = 0. (Geometrically: the two diagonals of a parallelogram have equal length exactly when it is a rectangle.)

    proveApostol 1.13 exercises

    Prove the parallelogram law ∥x+y∥2+∥x−y∥2=2∥x∥2+2∥y∥2\lVert x + y\rVert^2 + \lVert x - y\rVert^2 = 2\lVert x\rVert^2 + 2\lVert y\rVert^2 and the polarization identity (x,y)=14(∥x+y∥2−∥x−y∥2)(x, y) = \tfrac14\big(\lVert x + y\rVert^2 - \lVert x - y\rVert^2\big).

    Solution

    From the two expansions in the previous solution, adding gives 2∥x∥2+2∥y∥22\lVert x\rVert^2 + 2\lVert y\rVert^2, which is the parallelogram law, and subtracting gives 4(x,y)4(x, y), which is polarization. So the inner product can be recovered from the norm alone.

    provefollows Apostol 1.15 and 1.16

    Prove Bessel’s inequality: if q1,…,qkq_1, \dots, q_k are orthonormal, then ∑i=1k(x,qi)2≤∥x∥2\sum_{i=1}^k(x, q_i)^2 \le \lVert x\rVert^2 for every xx.

    Solution

    Let S=L(q1,…,qk)S = L(q_1, \dots, q_k) and s=proj⁡Sx=∑(x,qi)qis = \operatorname{proj}_Sx = \sum(x, q_i)q_i. The qiq_i are orthonormal, so ∥s∥2=∑(x,qi)2\lVert s\rVert^2 = \sum(x, q_i)^2 (the coordinate theorem). By the decomposition theorem, ∥x∥2=∥s∥2+∥s⊥∥2≥∥s∥2\lVert x\rVert^2 = \lVert s\rVert^2 + \lVert s^\perp\rVert^2 \ge \lVert s\rVert^2. So ∑(x,qi)2≤∥x∥2\sum(x, q_i)^2 \le \lVert x\rVert^2, with equality exactly when s⊥=Os^\perp = O, that is, when x∈Sx \in S.

    proveAxler 6C

    Let VV be finite-dimensional and SS a subspace. Prove (S⊥)⊥=S(S^\perp)^\perp = S.

    Solution

    (⊇\supseteq) If s∈Ss \in S and v∈S⊥v \in S^\perp, then (s,v)=0(s, v) = 0, so ss is orthogonal to every vector of S⊥S^\perp, that is, s∈(S⊥)⊥s \in (S^\perp)^\perp. (⊆\subseteq) Let x∈(S⊥)⊥x \in (S^\perp)^\perp and write x=s+s⊥x = s + s^\perp with s∈Ss \in S, s⊥∈S⊥s^\perp \in S^\perp (decomposition theorem). Then s⊥=x−ss^\perp = x - s. Now x∈(S⊥)⊥x \in (S^\perp)^\perp is orthogonal to s⊥s^\perp, and s∈Ss \in S is also orthogonal to s⊥s^\perp. So (s⊥,s⊥)=(x−s,s⊥)=(x,s⊥)−(s,s⊥)=0−0=0(s^\perp, s^\perp) = (x - s, s^\perp) = (x, s^\perp) - (s, s^\perp) = 0 - 0 = 0, and axiom 4 gives s⊥=Os^\perp = O. Hence x=s∈Sx = s \in S.

    proveMATH 375 Lecture 19 (version 1); Apostol 5.x preview

    Let AA be a real symmetric matrix (AT=AA^{\mathsf T} = A) and let x,yx, y be eigenvectors of AA with different eigenvalues λ≠μ\lambda \ne \mu (see 2.8). Prove x⊥yx \perp y for the dot product.

    Solution

    Use (Ax)⋅y=(Ax)Ty=xTATy=xTAy=x⋅(Ay)(Ax)\cdot y = (Ax)^{\mathsf T}y = x^{\mathsf T}A^{\mathsf T}y = x^{\mathsf T}Ay = x\cdot(Ay), which holds because AT=AA^{\mathsf T} = A. Then (Ax)⋅y=λ (x⋅y)(Ax)\cdot y = \lambda\,(x\cdot y) and x⋅(Ay)=μ (x⋅y)x\cdot(Ay) = \mu\,(x\cdot y). So (λ−μ)(x⋅y)=0(\lambda - \mu)(x\cdot y) = 0, and since λ≠μ\lambda \ne \mu, x⋅y=0x\cdot y = 0. This is why the ellipse 5x2+4xy+5y2=15x^2 + 4xy + 5y^2 = 1 of 2.8 had perpendicular axes, and it is half of the spectral theorem (chapter 3.1).

    stretch

    Let SS be a finite-dimensional subspace of VV and P(x)=proj⁡SxP(x) = \operatorname{proj}_Sx. Prove that PP is a linear map with P∘P=PP\circ P = P, range SS, and null space S⊥S^\perp. If VV is finite-dimensional, deduce dim⁡V=dim⁡S+dim⁡S⊥\dim V = \dim S + \dim S^\perp.

    Solution

    Linearity: with an orthonormal basis qiq_i of SS, P(x)=∑(x,qi)qiP(x) = \sum(x, q_i)q_i, and x↦(x,qi)x \mapsto (x, q_i) is linear by additivity and homogeneity. For s∈Ss \in S, the decomposition of ss is s+Os + O, so P(s)=sP(s) = s. Every P(x)P(x) is in SS, so P(P(x))=P(x)P(P(x)) = P(x), and the range is exactly SS. P(x)=OP(x) = O means x=O+s⊥x = O + s^\perp, so x∈S⊥x \in S^\perp; conversely x∈S⊥x \in S^\perp has decomposition O+xO + x, so P(x)=OP(x) = O. Thus N(P)=S⊥N(P) = S^\perp. By rank–nullity (2.3): dim⁡V=rank⁡P+nullity⁡P=dim⁡S+dim⁡S⊥\dim V = \operatorname{rank}P + \operatorname{nullity}P = \dim S + \dim S^\perp.

    stretch

    Prove that ∥x+y∥=∥x∥+∥y∥\lVert x + y\rVert = \lVert x\rVert + \lVert y\rVert holds if and only if one of x,yx, y is a non-negative multiple of the other.

    Solution

    Square both sides: ∥x∥2+2(x,y)+∥y∥2=∥x∥2+2∥x∥∥y∥+∥y∥2\lVert x\rVert^2 + 2(x, y) + \lVert y\rVert^2 = \lVert x\rVert^2 + 2\lVert x\rVert\lVert y\rVert + \lVert y\rVert^2, so equality holds iff (x,y)=∥x∥∥y∥(x, y) = \lVert x\rVert\lVert y\rVert. If y=Oy = O or x=Ox = O this is true and one is 00 times the other. Otherwise this is equality in Cauchy–Schwarz (with a plus sign), which requires x=cyx = cy for some cc. Then (cy,y)=c∥y∥2(cy, y) = c\lVert y\rVert^2 and ∥cy∥∥y∥=∣c∣∥y∥2\lVert cy\rVert\lVert y\rVert = |c|\lVert y\rVert^2, so c=∣c∣c = |c|, that is, c≥0c \ge 0. Conversely, if x=cyx = cy with c≥0c \ge 0, both sides equal (c+1)∥y∥(c + 1)\lVert y\rVert.

    Summary

    • An inner product (x,y)(x, y) is symmetric, additive, homogeneous, and positive on non-zero vectors. The dot product is one; ∫fg\int fg is another. From it we define the norm ∥x∥=(x,x)\lVert x\rVert = \sqrt{(x,x)} and the angle cos⁡θ=(x,y)/(∥x∥∥y∥)\cos\theta = (x, y)/(\lVert x\rVert\lVert y\rVert). JEE derived the dot product’s cosine formula; we define the angle by it.
    • Cauchy–Schwarz ∣(x,y)∣≤∥x∥∥y∥|(x,y)| \le \lVert x\rVert\lVert y\rVert (proof: the parabola ∥x+ty∥2≥0\lVert x + ty\rVert^2 \ge 0 at its lowest point) is what makes the angle defined. It gives the triangle inequality.
    • Orthogonal means (x,y)=0(x, y) = 0. Orthogonal non-zero vectors are independent. In an orthogonal basis the coordinate of xx on eie_i is (x,ei)/(ei,ei)(x, e_i)/(e_i, e_i), with no equations to solve.
    • Gram–Schmidt builds an orthogonal basis from any basis: subtract from each vector its projections on the earlier yy‘s. A zero output means dependence. The Legendre polynomials come from doing it to 1,t,t2,…1, t, t^2, \dots.
    • Orthogonal complement S⊥S^\perp; every xx splits uniquely as s+s⊥s + s^\perp (the projection plus a perpendicular leftover) and ∥x∥2=∥s∥2+∥s⊥∥2\lVert x\rVert^2 = \lVert s\rVert^2 + \lVert s^\perp\rVert^2.
    • Best approximation: the projection is the unique closest point of SS to xx. Proof: Pythagoras on the right triangle x,s,tx, s, t. The error is ∥x∥2−∥s∥2\lVert x\rVert^2 - \lVert s\rVert^2.
    • Fourier coefficients are inner products with orthonormal waves, and a partial Fourier sum is a projection. Cosine similarity, JPEG, the least squares of chapter 2.10 and QR decomposition are the same picture.

    Watch and read

    The same ideas explained by someone else. Use these when an explanation here does not land.

    Where this sits

    Comes from
    2.2 Span, independence, basis, dimension
    2.5 Matrices as maps, multiplication, change of basis
    2.8 Eigenvalues and eigenvectors
    Leads to
    2.10 Least squares and regression as projection
    3.1 Symmetric matrices and the spectral theorem
    Same idea elsewhere
    MATH 521: Cauchy–Schwarz and the triangle inequality are the first tools of analysis. The same proofs work in the space of square-summable sequences and in function spaces, where the 'basis' is infinite.
    MATH 376: Fourier series solve the heat and wave equations. The coefficients are the inner products computed below, and each partial sum is a projection.
    CS 532 / AI: Cosine similarity of embeddings is the angle defined here. QR decomposition (Gram–Schmidt on the columns of a matrix) is how least squares is solved on a computer.
    MATH 541: Inner products over the complex numbers (Hermitian), and Hilbert spaces, where the closest-point theorem still holds.