Orthogonality, Projections and Least Squares

Learn how the dot product turns questions about length, distance and angle into calculations, and how orthogonality makes linear algebra simpler. Project vectors onto lines and subspaces, find the closest point and the distance, build orthonormal bases with the Gram–Schmidt process and factor matrices as A=QR. Then use these tools to find least-squares solutions of systems that have no exact solution, and fit lines, parabolas and models with several variables to data.

IntermediateLesson 8 of 9 in Linear Algebra 1 Course

What you will learn

  1. Use the dot product to compute lengths, distances and angles in ℝn, decide when vectors are orthogonal, and describe the orthogonal complement of a subspace, including how the row space, column space and null spaces of a matrix fit together.
    • Compute dot products, lengths and distances
      Calculate the dot product of two vectors, use it to find lengths, unit vectors and distances, and apply its algebraic rules.
    • Test orthogonality and find angles between vectors
      Decide whether two vectors are orthogonal, use the Pythagorean theorem for vectors, and compute the angle between nonzero vectors from their dot product.
    • Describe orthogonal complements and the fundamental subspaces
      Find all vectors orthogonal to a subspace, and use the facts that the null space of a matrix is the orthogonal complement of its row space and that the null space of AT is the orthogonal complement of its column space.
  2. Recognize orthogonal and orthonormal sets, find coordinates in an orthogonal basis without solving a system, and use matrices with orthonormal columns, which preserve lengths and angles.
    • Find coordinates in an orthogonal basis
      Check that a set of vectors is orthogonal, explain why nonzero orthogonal vectors are independent, and compute the weights of a vector in an orthogonal basis with dot products.
    • Work with orthonormal bases and orthogonal matrices
      Normalize an orthogonal basis, recognize matrices with orthonormal columns by UTU=I, and use the facts that such matrices preserve lengths and dot products and that a square one has inverse UT.
  3. Split a vector into a part in a subspace and a part orthogonal to it, find the closest point of the subspace and the distance to it, and represent projections by matrices.
    • Project a vector onto a line
      Find the orthogonal projection of a vector onto the line spanned by a nonzero vector, the component orthogonal to that line, and the distance from the vector to the line.
    • Project onto a subspace and find the closest point
      Use the orthogonal decomposition theorem with an orthogonal basis to project a vector onto a subspace, and use the best approximation theorem to find the closest point and the distance to the subspace.
    • Write projections as matrices
      Build the matrix that projects onto a subspace from an orthonormal basis or from any basis, and use the properties P2=P and PT=P.
  4. Turn any basis of a subspace into an orthogonal or orthonormal basis with the Gram–Schmidt process, and record that process as the factorization A=QR of a matrix with independent columns.
    • Apply the Gram–Schmidt process
      Produce an orthogonal basis from a given basis step by step, normalize it, and recognize what happens when the given vectors are dependent.
    • Factor a matrix as A = QR
      Write a matrix with linearly independent columns as A=QR, with Q having orthonormal columns and R upper triangular, compute R=QTA, and explain what the factors are used for.
  5. When A𝐱=𝐛 has no solution, find the vectors 𝐱^ that make A𝐱^ as close as possible to 𝐛, using the normal equations, orthogonal columns or a QR factorization, and judge when the answer is unique.
    • Solve least-squares problems with the normal equations
      Explain what a least-squares solution is, derive and solve the normal equations, compute the least-squares error, and decide whether the solution is unique.
    • Use orthogonal columns and QR for least squares
      Find least-squares solutions directly when the columns of A are orthogonal, solve R𝐱^=QT𝐛 when A=QR, and explain why numerical software prefers QR.
  6. Set up a design matrix for data, find the least-squares line, parabola or multi-variable model, interpret residuals and coefficients, and recognize the limits of a fitted model.
    • Fit a least-squares line
      Write a line fit as a least-squares problem X𝜷=𝐲, solve its normal equations, and interpret the coefficients and residuals.
    • Fit curves and models with several predictors
      Build design matrices for general linear models such as parabolas and models with several input variables, solve them by least squares, and recognize when a fit is unique or misleading.

Orthogonality, Projections and Least Squares study guide

6 chapters

1

Measure vectors with the dot product

A list of coordinates can describe an arrow in the plane or a point in a space with many dimensions. The dot product gives those lists a geometry: length, distance, angle, and perpendicularity become calculations. Orthogonal complements then connect that geometry to the subspaces you already know, explaining why a homogeneous matrix equation can describe every direction perpendicular to a given space.

1.1 Dot products, lengths, and distances

The dot product combines two vectors with the same number of entries into one number. It is the inner product used in real coordinate spaces. Multiply matching entries, then add all the products.

Turn coordinates into a scalar

For 𝐮=(u1,…,un) and 𝐯=(v1,…,vn),

𝐮⋅𝐯=∑i=1nuivi=𝐮T𝐯.

The transpose turns a column into a row, so this matrix product has size 1×1. The dot product is read as a scalar. Keeping just the list of entrywise products would leave the calculation unfinished. Vectors of different sizes have no dot product with each other.

Take 𝐮=(1,−2,2) and 𝐯=(3,1,4). Their dot product is 1(3)+(−2)(1)+2(4)=3−2+8=9. The signs belong to the entries being multiplied.

Use the algebraic rules

The dot product is symmetric: 𝐮⋅𝐯=𝐯⋅𝐮. It distributes over addition, and a scalar can be pulled outside:

(𝐮+𝐯)⋅𝐰=𝐮⋅𝐰+𝐯⋅𝐰,(c𝐮)⋅𝐯=c(𝐮⋅𝐯).

Also, 𝐯⋅𝐯≥0, with equality exactly when 𝐯=𝟎. These rules allow familiar expansions, such as

(𝐮+𝐯)⋅(𝐮+𝐯)=𝐮⋅𝐮+2𝐮⋅𝐯+𝐯⋅𝐯.
Find length and direction

The norm, or length, is ∥𝐯∥=𝐯⋅𝐯. Squaring and adding makes every entry contribute nonnegatively; the square root converts squared length back to length. For the example, ∥𝐮∥=1+4+4=3 and ∥𝐯∥=9+1+16=26≈5.10.

A unit vector has length 1. Normalize a nonzero vector by dividing every entry by its length. Thus 𝐮/∥𝐮∥=(1/3,−2/3,2/3) points in the same direction as 𝐮. The zero vector cannot be normalized, because its length is zero.

Scaling obeys ∥c𝐯∥=∣c∣∥𝐯∥. A negative multiplier reverses direction, but length stays nonnegative: ∥−3𝐯∥=3∥𝐯∥.

Measure separation

The displacement between two vectors is their difference. Therefore dist⁡(𝐮,𝐯)=∥𝐮−𝐯∥. Here 𝐮−𝐯=(−2,−3,−2), so the distance is 4+9+4=17≈4.12. Reversing the subtraction changes the displacement's direction, not its length.

Lengths do not generally add. Here 𝐮+𝐯=(4,−1,6) has length 53≈7.28, while the separate lengths total about 8.10. The rule that always holds is the triangle inequality: ∥𝐮+𝐯∥≤∥𝐮∥+∥𝐯∥.

Key Takeaways

  • The dot product is a scalar: multiply matching entries and add.
  • Length is 𝐯⋅𝐯; distance is ∥𝐮−𝐯∥.
  • Normalize a nonzero vector by dividing by its length.
  • Scaling changes length by the absolute value of the scalar.
  • The triangle inequality bounds the length of a sum.

1.2 Orthogonality and angles

Two vectors are orthogonal when their dot product is zero. In the plane and in three-dimensional space, this expresses perpendicularity. The same test works in spaces with more coordinates, even when a picture is unavailable.

Check perpendicularity with a dot product

Write 𝐮⊥𝐯 when 𝐮⋅𝐯=0. For 𝐮=(2,1,−1) and 𝐯=(1,−1,1), the calculation is 2−1−1=0. Both vectors are nonzero. Unlike a product of real numbers, a zero dot product does not force one of its factors to be zero.

The zero vector is orthogonal to every vector. It is also the only vector orthogonal to itself, because 𝐯⋅𝐯=0 forces every entry to vanish. An angle involving the zero vector is undefined, so the angle formula below requires both vectors to be nonzero.

Connect the test to the Pythagorean theorem

Expanding squared length gives

∥𝐮+𝐯∥2=∥𝐮∥2+2𝐮⋅𝐯+∥𝐯∥2.

The middle term vanishes exactly when the vectors are orthogonal. Thus

𝐮⊥𝐯⟺∥𝐮+𝐯∥2=∥𝐮∥2+∥𝐯∥2.

For the example, the squared lengths are 6 and 3. The sum is (3,0,0), whose squared length is 9, as required. Expanding the difference changes the middle term's sign: ∥𝐮−𝐯∥2=∥𝐮∥2−2𝐮⋅𝐯+∥𝐯∥2. The sum and difference have equal lengths precisely when the dot product is zero.

Find an angle

For nonzero vectors, the angle in the range 0≤θ≤π satisfies

cos⁡θ=𝐮⋅𝐯∥𝐮∥∥𝐯∥.

The Cauchy–Schwarz inequality, ∣𝐮⋅𝐯∣≤∥𝐮∥∥𝐯∥, keeps this quotient between −1 and 1. Use inverse cosine after computing the quotient; choose degree or radian mode to match the answer required.

For (1,1,0) and (1,0,1), the dot product is 1 and each length is 2. Hence cos⁡θ=1/2 and θ=60∘=π/3. For (1,0) and (−1,1), the quotient is −1/2, giving 135∘=3π/4.

Read the sign before calculating

A positive dot product puts the angle in 0∘≤θ<90∘. A negative dot product puts it in 90∘<θ≤180∘. A zero dot product gives exactly 90∘ for nonzero vectors. Same-direction multiples have angle 0°; opposite-direction multiples have angle 180°.

In the plane, (−b,a) is orthogonal to (a,b) because −ab+ba=0. Parallel vectors need a different test: (1,2) and (2,4) are parallel but have dot product 10, so they are not orthogonal.

Key Takeaways

  • Orthogonality means a zero dot product, including when one vector is zero.
  • The Pythagorean identity holds exactly for orthogonal vectors.
  • Use cos⁡θ=(𝐮⋅𝐯)/(∥𝐮∥∥𝐯∥) for nonzero vectors.
  • The sign of the dot product locates the angle relative to 90°.

1.3 Orthogonal complements and matrix spaces

Being perpendicular to one direction gives one linear condition. Being perpendicular to a whole subspace gives a system of conditions. Its solutions form the orthogonal complement, another subspace in the same ambient space.

Find every perpendicular vector

For W⊆ℝn, the complement W⊥ contains all vectors orthogonal to every vector in W. It is enough to test a spanning set. If 𝐳⋅𝐰j=0 for every spanning vector, then

𝐳⋅(c1𝐰1+⋯+ck𝐰k)=c1(𝐳⋅𝐰1)+⋯+ck(𝐳⋅𝐰k)=0.

For W=Span⁡{(1,1,1)}, write an unknown vector as (z1,z2,z3). Its one condition is z1+z2+z3=0. Set z2=s and z3=t; then

𝐳=(−s−t,s,t)=s(−1,1,0)+t(−1,0,1).

Thus W⊥ is a plane with the displayed two-vector basis. Checking one perpendicular vector would establish only that vector's membership, not describe the whole complement.

Account for dimensions

Every subspace satisfies dim⁡W+dim⁡W⊥=n. A line in ℝ3 has a two-dimensional complement. A plane through the origin has a one-dimensional complement. At the extremes, {𝟎}⊥=ℝn and (ℝn)⊥={𝟎}.

Also, W∩W⊥={𝟎}: a vector in both would be perpendicular to itself. Taking the complement twice returns the original space: (W⊥)⊥=W.

Read matrix equations geometrically

For an m×n matrix A, each entry of A𝐱 is a row of A dotted with 𝐱. Therefore

(Row⁡A)⊥=Nul⁡Ain ℝn.

Apply the same statement to the transpose to obtain

(Col⁡A)⊥=Nul⁡ATin ℝm.

Keep those ambient spaces separate when the matrix is rectangular. The left null space is another name for Nul⁡AT.

For A=[121011], solving A𝐱=𝟎 gives 𝐱=t(1,−1,1). The checks against the two rows are 1−2+1=0 and −1+1=0. Rank 2 plus nullity 1 equals the number of columns, 3.

Distinguish orthogonal subspaces from intersecting planes

Two subspaces are orthogonal when every vector in one is perpendicular to every vector in the other. The coordinate xz- and yz-planes are not orthogonal subspaces: both contain (0,0,1), which is not perpendicular to itself. Their perpendicular appearance as surfaces is a different geometric statement.

For least squares, the residual 𝐫=𝐛−A𝐱^ lies in Nul⁡AT. Its orthogonality to the column space becomes the equation AT𝐫=𝟎.

Key Takeaways

  • Test a spanning set to find every vector in W⊥.
  • dim⁡W+dim⁡W⊥=n and (W⊥)⊥=W.
  • The row space and null space are orthogonal complements in ℝn.
  • The column space and left null space are orthogonal complements in ℝm.
  • Orthogonal subspaces share only the zero vector.
  • A least-squares residual lies in Nul⁡AT.
2

Read vectors in orthogonal bases

A basis gives coordinates, but an orthogonal basis makes each coordinate accessible through one dot product. Normalizing the basis removes even the division by squared length. These calculations lead to matrices with orthonormal columns, which keep lengths and angles intact, and to the special square case whose inverse is simply its transpose.

2.1 Coordinates in perpendicular directions

An orthogonal set has zero dot product between every pair of distinct vectors. To verify three vectors, check three pairs; four vectors require six checks. The lengths can differ, and the definition of an orthogonal set even allows the zero vector.

Why nonzero orthogonal vectors are independent

Suppose c1𝐮1+⋯+cp𝐮p=𝟎 for an orthogonal set of nonzero vectors. Dot with 𝐮j. Every term from another vector vanishes, leaving cj(𝐮j⋅𝐮j)=0. Since the squared length is positive, cj=0. This works for every coefficient, proving independence.

Such a set is an orthogonal basis for its span. In particular, three nonzero mutually orthogonal vectors in ℝ3 form a basis of the whole space. Including the zero vector would destroy independence, even though pairwise orthogonality could still hold.

Isolate one coordinate at a time

If 𝐲 belongs to the span of an orthogonal basis, write 𝐲=∑jcj𝐮j. Dotting with 𝐮j isolates just its coefficient:

cj=𝐲⋅𝐮j𝐮j⋅𝐮j.

The denominator is the squared length. Dividing by the length alone generally gives the wrong weight. This calculation avoids row reduction because perpendicular directions do not contribute to one another's dot products.

Recover a vector from its weights

Use 𝐮1=(1,1,1), 𝐮2=(1,−1,0), and 𝐮3=(1,1,−2). Their pairwise products are zero, and their squared lengths are 3, 2, and 6.

For 𝐲=(6,2,1), the numerators are 9, 4, and 6+2−2=6. Therefore c1=3, c2=2, and c3=1. Reconstructing gives

3(1,1,1)+2(1,−1,0)+(1,1,−2)=(6,2,1).

The coordinate vector relative to this ordered basis is (3,2,1). Its entries are weights, not the original entries of 𝐲. Reordering the basis reorders the weights.

Check the basis before using the shortcut

Independence alone is insufficient for the quotient formula. For the basis (1,0),(1,1) and target (3,2), the actual weights solve c1+c2=3 and c2=2. Thus they are 1 and 2.

The dot-product quotients would instead give 3 and 5/2. Their weighted sum is (11/2,5/2), which fails to reconstruct the target. The nonzero dot product between the basis vectors allows one direction to affect the other's equation. Use a linear system for such a basis, or first make it orthogonal.

When the target lies outside the span

Each term cj𝐮j is a projection onto a perpendicular line. If 𝐲 is outside the basis's span, the same sum belongs to the span but cannot equal 𝐲. It gives the orthogonal projection of 𝐲 onto that subspace, its closest point there.

Key Takeaways

  • Nonzero mutually orthogonal vectors are independent.
  • An orthogonal basis gives cj=(𝐲⋅𝐮j)/(𝐮j⋅𝐮j).
  • The denominator is squared length, and the formula requires orthogonality.
  • Weights reconstruct the target exactly when the target belongs to the span.

2.2 Orthonormal columns and orthogonal matrices

An orthonormal set is an orthogonal set whose vectors all have length 1. Normalize each vector of an orthogonal basis separately to obtain an orthonormal basis of the same space. Normalizing arbitrary nonorthogonal vectors changes their lengths but does not make them perpendicular.

Coordinates become dot products

The basis (1,1,1),(1,−1,0),(1,1,−2) becomes

𝐪1=(1,1,1)3,𝐪2=(1,−1,0)2,𝐪3=(1,1,−2)6.

For an orthonormal basis the coordinate formula simplifies to cj=𝐲⋅𝐪j. With 𝐲=(6,2,1), the first weight is 9/3=33. Multiplying it by 𝐪1 gives 3(1,1,1), the same vector contribution as before normalization. Changing the scale of a basis vector changes its weight.

Test all columns at once

Let U have n columns in ℝm. Entry (i,j) of UTU is the dot product of columns i and j. Thus

UTU=In

holds exactly when the columns are orthonormal: unit squared lengths on the diagonal, zero cross-products elsewhere.

For 𝐱,𝐲∈ℝn, this identity gives

(U𝐱)⋅(U𝐲)=𝐱TUTU𝐲=𝐱⋅𝐲.

Taking 𝐲=𝐱 proves ∥U𝐱∥=∥𝐱∥. Lengths, dot products, and angles between nonzero vectors are preserved, including when the output space has more dimensions.

The square case has an easy inverse

A square matrix with orthonormal columns is an orthogonal matrix. It satisfies U−1=UT, so its rows are orthonormal too. Its determinant is 1 or −1. Rotations about the origin and reflections across lines through the origin give examples in the plane.

For U=[3/5−4/54/53/5], each column has squared length 9/25+16/25=1 and their dot product is −12/25+12/25=0. For 𝐱=(5,10), multiplication gives U𝐱=(−5,10). Both squared lengths equal 125.

Keep rectangular matrices separate

For a tall matrix, UTU=In does not make UUT=Im. With columns (1,2,2)/3 and (2,1,−2)/3,

UUT=19[54−2452−228].

This projects onto the column plane. The tall matrix has no two-sided inverse and is not called an orthogonal matrix.

Even a square matrix with perpendicular columns needs normalization. For B=[111−1], BTB=2I, so B−1=BT/2. Dividing B by 2 makes it orthogonal.

Key Takeaways

  • Orthonormal vectors are perpendicular unit vectors.
  • Orthonormal coordinates are dot products with the basis vectors.
  • UTU=I tests orthonormal columns.
  • Such a matrix preserves lengths, angles, and dot products.
  • A square orthogonal matrix has inverse UT and determinant ±1.
  • For a tall matrix, UUT is a projection, not the identity.
3

Find the closest vector in a subspace

Projection splits a vector into a part you can represent in a chosen subspace and a perpendicular remainder. That remainder measures the distance to the subspace. Start with one line, add perpendicular basis directions to handle a larger space, and then write the calculation as a matrix that works for every input vector. The closest-point claim follows from the Pythagorean theorem.

3.1 Projection onto a line

To project 𝐲 onto a line through the origin, find the point on the line whose displacement from 𝐲 is perpendicular to it. Let the line be L=Span⁡{𝐮}, where 𝐮≠𝟎. Every possible point has the form α𝐮.

Derive the coefficient

Set 𝐩=α𝐮 and require the residual 𝐳=𝐲−α𝐮 to be orthogonal to 𝐮. Then

0=(𝐲−α𝐮)⋅𝐮=𝐲⋅𝐮−α(𝐮⋅𝐮).

The positive denominator gives

α=𝐲⋅𝐮𝐮⋅𝐮,𝐩=proj⁡L𝐲=𝐲⋅𝐮𝐮⋅𝐮𝐮.

The coefficient α is a number. The projection 𝐩 is a vector. Multiplying by 𝐮 is part of the answer whenever the question asks for the projection.

Work the two-dimensional example

Take 𝐲=(3,4) and 𝐮=(2,1). First compute 𝐲⋅𝐮=6+4=10 and 𝐮⋅𝐮=4+1=5. Thus α=2 and 𝐩=(4,2).

Subtract to get 𝐳=(3,4)−(4,2)=(−1,2). Two checks establish the decomposition: 𝐩+𝐳=𝐲 and 𝐳⋅𝐮=−2+2=0. The projection lies on the line because it is twice its direction vector.

The point 𝐩 is closest to 𝐲, so the distance is the residual's length: dist⁡(𝐲,L)=∥𝐳∥=5≈2.24. The length of 𝐩 measures how far along the line the projection lies from the origin; it measures a different distance.

Change the direction vector without changing the line

Replacing 𝐮 with any nonzero multiple c𝐮 leaves the projection unchanged. The numerator gains a factor c, the denominator gains c2, and the final direction vector supplies the second factor c.

For 𝐮′=(−4,−2) in the example, the coefficient is −20/20=−1, giving the same 𝐩=(4,2). A negative coefficient means the projection lies opposite to the chosen direction vector, not that the distance is negative.

Separate scalar component from vector projection

The signed length along 𝐮 is s=(𝐲⋅𝐮)/∥𝐮∥. Multiplying s by the unit direction 𝐮/∥𝐮∥ gives 𝐩. Using s𝐮 would scale the vector twice unless 𝐮 were already a unit vector.

In ℝ3, projecting (2,3,4) onto Span⁡{(1,1,1)} gives 𝐩=(9/3)(1,1,1)=(3,3,3). The residual is (−1,0,1), with length 2. This projection replaces entries by their mean. More generally, an input on the line projects to itself, while an input perpendicular to the line projects to zero.

Key Takeaways

  • Onto a nonzero direction 𝐮, use 𝐩=((𝐲⋅𝐮)/(𝐮⋅𝐮))𝐮.
  • The residual 𝐲−𝐩 is perpendicular to the line.
  • The residual length is the distance to the line.
  • Changing the nonzero spanning vector leaves the projection unchanged.
  • The scalar component and the vector projection have different meanings.

3.2 Projection onto a subspace

A subspace with several perpendicular basis directions lets you project onto each direction separately and add the resulting vectors. The answer is independent of the orthogonal basis used to describe that subspace.

Split the vector uniquely

The orthogonal decomposition theorem says that every 𝐲∈ℝn has exactly one representation 𝐲=𝐩+𝐳 with 𝐩∈W and 𝐳∈W⊥. Here 𝐩=proj⁡W𝐲 and 𝐳=proj⁡W⊥𝐲.

For an orthogonal basis 𝐮1,…,𝐮p of W,

proj⁡W𝐲=∑j=1p𝐲⋅𝐮j𝐮j⋅𝐮j𝐮j.

Each term lies in W. Dotting the difference from 𝐲 with any basis vector gives zero, which verifies the perpendicular part of the decomposition.

Add two projections

Let 𝐮1=(1,1,0), 𝐮2=(1,−1,1), and 𝐲=(4,0,5). The basis vectors are perpendicular because 1−1+0=0. Their squared lengths are 2 and 3.

The two weights are 4/2=2 and 9/3=3. Therefore

𝐩=2(1,1,0)+3(1,−1,1)=(5,−1,3).

The residual is 𝐳=(−1,1,2). Check both directions: 𝐳⋅𝐮1=−1+1=0 and 𝐳⋅𝐮2=−1−1+2=0.

The distance to the plane is ∥𝐳∥=1+1+4=6≈2.45. Keeping only the first projection gives the point (2,2,0). Its squared distance from 𝐲 is 22+(−2)2+52=33, so that partial projection is not the closest point in the whole plane.

Explain why the point is closest

For any 𝐯∈W,

𝐲−𝐯=(𝐲−𝐩)+(𝐩−𝐯).

The first term lies in W⊥ and the second in W. The Pythagorean theorem gives

∥𝐲−𝐯∥2=∥𝐲−𝐩∥2+∥𝐩−𝐯∥2.

The second square is positive unless 𝐯=𝐩. This proves the best approximation theorem: the projection is the unique closest point.

Use the right basis formula

The same plane is spanned by (1,1,0) and (2,0,1), but their dot product is 2. Adding the separate line projections in these directions gives (36/5,2,13/5), whose residual is not perpendicular to the plane. For a nonorthogonal basis, use Gram–Schmidt or the matrix formula for projection.

Projection is linear: projecting a𝐲1+b𝐲2 gives the same result as combining their projections with weights a,b. A vector already in W stays fixed; a vector in W⊥ is sent to zero.

Key Takeaways

  • Every vector splits uniquely into a part in W and a part in W⊥.
  • With an orthogonal basis, add all the individual line projections.
  • The projection is the unique closest point by the Pythagorean theorem.
  • Distance is the residual length, and the residual must be perpendicular to every basis direction.
  • The sum-of-line-projections formula requires an orthogonal basis.
  • Projection fixes vectors in the subspace and removes vectors in its orthogonal complement.

3.3 Matrices that project

Projection is linear, so one matrix can project every input onto the same subspace. Which formula is easiest depends on how the subspace's basis is supplied. The matrix acts on vectors in the original ambient space.

Start with an orthonormal basis

Put an orthonormal basis of W⊆ℝn into the columns of an n×p matrix U. Then UT𝐲 lists the dot-product weights. Multiplying those weights by U rebuilds the projection:

𝐩=UUT𝐲,P=UUT.

Keep the product order: UTU=Ip is a small identity matrix; UUT=P is an n×n matrix acting on the input space.

For one nonzero direction 𝐮, normalization gives

P=𝐮𝐮T𝐮T𝐮.

For 𝐮=(1,2), P=15[1224]. Applying it to (3,1) gives 15(5,10)=(1,2).

Use any independent basis columns

If the columns of A are a basis of W, a projection has the form A𝐱^. Its residual must be perpendicular to the columns, so

AT(𝐲−A𝐱^)=𝟎,ATA𝐱^=AT𝐲.

Independence makes ATA invertible. Solving for the coefficients and multiplying by A gives

P=A(ATA)−1AT.

For A=[111−101], ATA=[2003]. Multiplying Adiag⁡(1/2,1/3)AT yields

P=16[51215−22−22].

Consequently P(4,0,5)=16(30,−6,18)=(5,−1,3). This agrees with the orthogonal-basis calculation.

Recognize the matrix properties

An orthogonal projection satisfies P2=P: once a vector lies in W, projecting again changes nothing. It also satisfies PT=P, so it is symmetric. Together these properties characterize orthogonal projection matrices in real coordinate spaces.

Its column space is W, and rank⁡P=dim⁡W. The complementary matrix I−P projects onto W⊥. In the example, (I−P)(4,0,5)=(−1,1,2). Thus P𝐲+(I−P)𝐲=𝐲 records the orthogonal decomposition.

A projection onto a proper subspace loses information: nonzero vectors in W⊥ all map to zero. It has no inverse. Only projection onto the entire ambient space is invertible; then P=I.

Preserve the matrix order and conditions

Use AAT directly only when the columns are orthonormal. For a rectangular A, no A−1 exists, so splitting (ATA)−1 into inverses of its rectangular factors is invalid. The invertible object in the general formula is the square matrix ATA.

Key Takeaways

  • For orthonormal basis columns, P=UUT.
  • For arbitrary independent basis columns, P=A(ATA)−1AT.
  • Orthogonal projections satisfy P2=P and PT=P.
  • I−P projects onto the orthogonal complement.
  • A projection onto a proper subspace is not invertible.
4

Build bases with Gram–Schmidt and QR

A basis can span the right space while pointing in inconvenient directions. Gram–Schmidt removes the overlap with earlier directions, producing a perpendicular basis without changing the space. Normalizing those vectors builds the columns of Q. The coefficients needed to recover the original columns form an upper triangular matrix R, turning the basis construction into the factorization A = QR.

4.1 The Gram–Schmidt process

The Gram–Schmidt process turns an ordered basis into an orthogonal basis of the same subspace. At each stage, subtract the part already represented by earlier output vectors. The remainder supplies one new perpendicular direction.

Remove earlier components

Begin with 𝐯1=𝐱1. Then

𝐯2=𝐱2−𝐱2⋅𝐯1𝐯1⋅𝐯1𝐯1.

For the general step,

𝐯k=𝐱k−∑j=1k−1𝐱k⋅𝐯j𝐯j⋅𝐯j𝐯j.

The vectors used in the sum are the new orthogonal outputs, not the original inputs. Their mutual orthogonality lets separate projections remove all overlap. At every stage, the first k output vectors span the same space as the first k inputs.

Work through three vectors

Take 𝐱1=(1,1,0), 𝐱2=(1,0,1), and 𝐱3=(0,1,1). Set 𝐯1=(1,1,0). Since 𝐱2⋅𝐯1=1 and 𝐯1⋅𝐯1=2,

𝐯2=(1,0,1)−12(1,1,0)=(1/2,−1/2,1).

For simpler arithmetic, scale this direction to 𝐯2=(1,−1,2). Nonzero scaling keeps both orthogonality and the span, but the scaled vector must now be used consistently.

For the third input, 𝐱3⋅𝐯1=1, 𝐱3⋅𝐯2=1, and 𝐯2⋅𝐯2=6. Subtract both components:

𝐯3=(0,1,1)−12(1,1,0)−16(1,−1,2)=(−2/3,2/3,2/3).

Scale this to (−1,1,1). The pairwise dot products are 1−1=0, −1+1=0, and −1−1+2=0. Hence the three directions form an orthogonal basis of the original span.

Normalize after finding the directions

The scaled output lengths are 2, 6, and 3. Dividing gives the orthonormal basis

(1,1,0)2,(1,−1,2)6,(−1,1,1)3.

Changing the input order generally changes the output basis. It does not change the subspace spanned by all the inputs.

Interpret a zero remainder

With independent inputs, each new remainder is nonzero. If an input lies in the earlier span, subtracting its projection leaves zero. For example, replacing the third input by (2,1,1)=𝐱1+𝐱2 gives a zero third remainder. Discard that output and continue using the nonzero orthogonal vectors; zero cannot be normalized.

Subtracting projections onto both original inputs in the worked example would instead produce (−1,1/2,1/2). Its dot product with 𝐯1 is −1/2, exposing the error. Pairwise checks detect a missing component or inconsistent scaling before normalization.

Key Takeaways

  • Each step subtracts projection onto the span of earlier orthogonal outputs.
  • The span of the processed vectors is preserved.
  • Normalize nonzero outputs to obtain an orthonormal basis.
  • A zero remainder identifies a dependent direction.
  • Input order can change the basis.
  • Check pairwise dot products and use any scaling consistently.

4.2 The QR factorization

For a matrix A with independent columns, Gram–Schmidt can be recorded as a factorization A=QR. The columns of Q give perpendicular unit directions. The columns of R give the coordinates of the original columns in those directions.

Identify the factors and their sizes

If A is m×n with independent columns, the reduced QR factorization has Q of size m×n and R of size n×n. The columns of Q form an orthonormal basis of Col⁡A. The matrix R is upper triangular and invertible; choose positive diagonal entries.

Apply Gram–Schmidt to the columns in order and normalize each remainder to form Q. Then

R=QTA,

because QTQ=In. Each entry rjk=𝐪j⋅𝐚k is a coordinate of column k. Gram–Schmidt preserves the first-column spans, so 𝐚k needs only 𝐪1,…,𝐪k. Entries below the diagonal are zero. The diagonal entry is the length of the corresponding unnormalized remainder.

Factor a four-row matrix

Take A=[11121314]. The first column has length 2, giving 𝐪1=(1,1,1,1)/2. To remove its component from the second column, compute 10/4=2.5 and subtract:

𝐯2=(1,2,3,4)−2.5(1,1,1,1)=(−1.5,−0.5,0.5,1.5).

Its length is 5. Equivalently, use the direction (−3,−1,1,3) of length 25, so 𝐪2=(−3,−1,1,3)/(25).

Now compute the nonzero entries of R:

r11=2,r12=10/2=5,r22=−3−2+3+1225=5.

Thus R=[2505]. Check reconstruction: 2𝐪1 is the first column, while

5𝐪1+5𝐪2=(2.5,2.5,2.5,2.5)+(−1.5,−0.5,0.5,1.5)=(1,2,3,4).
Interpret what QR makes easier

For a tall matrix, QTQ=In but QQT is the projection onto Col⁡A, not Im. To solve a least-squares problem, use the triangular system R𝐱^=QT𝐛. For square invertible A the same procedure solves the exact system by back-substitution.

Independent columns are necessary for an invertible reduced R. A zero Gram–Schmidt remainder identifies failure of that condition. With positive diagonal entries, the reduced factors are unique. Software may instead use paired sign changes in a column of Q and row of R, or return a full square Q and a taller R with zero rows at the bottom. These conventions still multiply to A. Numerical QR can be computed with Householder reflections instead of Gram–Schmidt.

Key Takeaways

  • Reduced QR has orthonormal basis columns in Q and an upper triangular R.
  • Compute R=QTA, preserving the product order.
  • The positive diagonal records lengths of Gram–Schmidt remainders.
  • For tall matrices, QQT projects onto the column space.
5

Solve systems by least squares

An inconsistent system asks for a vector outside the matrix’s column space, so no coefficient vector can meet every equation. Least squares chooses the closest attainable output instead. The perpendicular residual gives the normal equations and a way to check an answer. Orthogonal columns and QR then turn the same geometric problem into simpler calculations, with independence deciding whether the coefficients are unique.

5.1 The normal equations and the residual

When A𝐱=𝐛 is inconsistent, 𝐛 lies outside Col⁡A. A least-squares solution 𝐱^ minimizes ∥𝐛−A𝐱∥ over all coefficient vectors. Minimizing the squared norm gives the same solutions, because square root is increasing on nonnegative numbers.

Project the output vector

Every attainable output is in Col⁡A. Its closest point to 𝐛 is the projection 𝐛^, so the least-squares solutions are exactly the solutions of A𝐱=𝐛^. Keep the roles separate: for an m×n matrix, coefficients lie in ℝn; fitted outputs and residuals lie in ℝm.

The residual 𝐫=𝐛−A𝐱^ is perpendicular to every column. Hence AT𝐫=𝟎, giving the normal equations

ATA𝐱^=AT𝐛.

They are consistent for every 𝐛, even when the original system is not. To solve by hand, form the square matrix ATA and the vector AT𝐛, then row-reduce their system.

Solve an inconsistent example

Let A=[100111] and 𝐛=(1,1,0). The original equations demand x1=1, x2=1, and x1+x2=0, which cannot all hold.

Here ATA=[2112] and AT𝐛=(1,1). The normal equations are 2x1+x2=1 and x1+2x2=1. Subtracting gives x1=x2, then 3x1=1. Thus 𝐱^=(1/3,1/3).

The fitted vector is (1/3,1/3,2/3) and the residual is (2/3,2/3,−2/3). Dotting this residual with either column gives zero. Its squared length is 4/9+4/9+4/9=4/3; the least-squares error, its length, is 2/3≈1.15. The sum of its entries is not an error measure: signs can cancel without a good fit.

Decide whether the coefficients are unique

Independent columns, invertibility of ATA, and uniqueness of the least-squares solution for every target are equivalent. With independent columns,

𝐱^=(ATA)−1AT𝐛.

Solving the normal equations is usually less work by hand than explicitly finding that inverse.

With dependent columns, the fitted vector is still unique. For A with three identical rows [1,2] and 𝐛=(1,2,6), the normal equations reduce to x1+2x2=3. Both (3,0) and (1,1) produce the same fit (3,3,3). Free variables describe infinitely many least-squares coefficient vectors.

If 𝐛 is already in the column space, the residual is zero and least squares gives the exact solutions. For an inconsistent system, cancelling AT from the normal equations is invalid: AT𝐫=0 permits a nonzero residual in Nul⁡AT. It forces 𝐫=0 only when that null space is trivial.

Key Takeaways

  • Least squares projects the target onto the column space.
  • The normal equations are ATA𝐱^=AT𝐛 and always have a solution.
  • The residual satisfies AT𝐫=𝟎.
  • Independent columns give unique coefficients.
  • Dependent columns still give one fitted vector.
  • Squared error is 𝐫⋅𝐫; least-squares error is ∥𝐫∥.

5.2 Least squares with orthogonal columns and QR

The normal equations express the right geometric condition, but the basis of the column space affects how much algebra is needed. Orthogonal columns separate the coefficient calculations. QR supplies such directions for any matrix with independent columns.

Use orthogonal columns directly

For nonzero mutually orthogonal columns 𝐚j,

x^j=𝐛⋅𝐚j𝐚j⋅𝐚j.

Each coefficient supplies one line projection, and their weighted sum is the projection onto the column space. Test orthogonality before using this shortcut.

Take columns (1,1,1,1) and (−3,−1,1,3) with 𝐛=(2,3,5,6). Their dot product is zero. Squared lengths are 4 and 20, while dot products with 𝐛 are 16 and −6−3+5+18=14. Thus 𝐱^=(4,0.7). The fit is

𝐛^=4(1,1,1,1)+0.7(−3,−1,1,3)=(1.9,3.3,4.7,6.1).
Reduce QR to a triangular solve

With A=QR and independent columns, the normal equations become RTR𝐱^=RTQT𝐛. Since RT is invertible, they reduce to

R𝐱^=QT𝐛.

Compute the dot products in QT𝐛, then solve from the last row upward. That vector contains coordinates of the fitted output in the Q basis. It is generally not the coefficient vector for the original columns of A.

For A with rows [1,1],[1,2],[1,3],[1,4], use 𝐪1=(1,1,1,1)/2, 𝐪2=(−3,−1,1,3)/(25), and R=[2505]. With the same target, QT𝐛=(8,7/5).

The bottom equation 5x^2=7/5 gives x^2=7/5=1.4. The top equation 2x^1+5(1.4)=8 gives x^1=0.5. Multiplying by A again gives (1.9,3.3,4.7,6.1). Equivalently, 𝐛^=QQT𝐛.

Explain different coefficients for the same fit

The orthogonal columns above span the same space as the two columns of this A, because (−3,−1,1,3)=2(1,2,3,4)−5(1,1,1,1). Changing basis changes the coefficients from (4,0.7) to (0.5,1.4). The fitted outputs agree since 4+0.7(2t−5)=0.5+1.4t. Normal equations with matrix [4101030] and right side (16,47) give the same latter coefficients.

Prefer stable calculations on a computer

Normal equations and QR agree in exact arithmetic. In floating-point arithmetic, nearly dependent columns can make forming ATA harmful: its 2-norm condition number is the square of that of A. QR avoids forming that product and is commonly used for numerical least squares. Keep exact fractions in small hand calculations and round only the final reported values.

Key Takeaways

  • Nonzero orthogonal columns give coefficients by individual dot-product quotients.
  • With QR, solve R𝐱^=QT𝐛 by back-substitution.
  • QT𝐛 gives coordinates in the new basis; the triangular solve returns original coefficients.
  • The same column space gives the same fitted output despite different basis coefficients.
  • QR avoids squaring the 2-norm condition number through ATA.
6

Fit linear models to data

Data rarely satisfy one exact equation, but their patterns can still be described by a least-squares model. A design matrix translates a chosen line, parabola, or several-predictor equation into columns and coefficients. The fit is a projection of the observations onto those columns. Residuals measure what remains, while the meaning of each coefficient and the range of the data guide how the fitted equation is interpreted.

6.1 Fit a line and read its residuals

For points (xi,yi), a line model predicts y^i=β0+β1xi. Treat the observed responses as a vector 𝐲. Each data point contributes one row [1,xi] to the design matrix X, and the parameter vector is 𝜷=(β0,β1).

Write the least-squares problem

The residual at point i is εi=yi−y^i, a signed vertical difference. The fit minimizes ∑iεi2=∥𝐲−X𝜷∥2. Its normal equations are XTX𝜷^=XT𝐲, where

XTX=[n∑xisumxi∑xi2],XT𝐲=[∑yisumxiyi].

The columns are independent as long as at least two input values differ. The line then has unique least-squares coefficients.

Fit measured heights

A seedling's heights at weeks 1, 2, 3, and 4 are 2, 3, 5, and 6 cm. The sums are ∑xi=10, ∑xi2=30, ∑yi=16, and ∑xiyi=2+6+15+24=47. Hence

4β0+10β1=16,10β0+30β1=47.

Multiply the first equation by 2.5 and subtract from the second: 5β1=7. Thus β1=1.4 and β0=(16−14)/4=0.5. The fitted equation is y^=0.5+1.4x. The slope describes an average increase of 1.4 cm per week over the measured period. The intercept is the prediction at week zero, outside the measured range.

Predicted heights are 1.9, 3.3, 4.7, and 6.1 cm. Subtract them from the observations to get residuals 0.1,−0.3,0.3,−0.1 cm. Squaring and adding gives 0.01+0.09+0.09+0.01=0.2 cm2.

Use the intercept and centered inputs

The residual vector is perpendicular to both design columns. The column of ones gives ∑iεi=0; the predictor column gives ∑ixiεi=0. Here the checks are 0.1−0.3+0.3−0.1=0 and 0.1−0.6+0.9−0.4=0.

An intercept also makes the line pass through (xˉ,yˉ). Here xˉ=2.5 and yˉ=4. Centering replaces the inputs by xi−xˉ, whose sum is zero, so the constant and predictor columns become orthogonal. The equivalent formulas are

β^1=∑i(xi−xˉ)(yi−yˉ)∑i(xi−xˉ)2,β^0=yˉ−β^1xˉ.

The example's numerator is 7 and denominator is 5, recovering the slope 1.4. Its centered inputs are half of (−3,−1,1,3).

Interpret the chosen model

Least squares minimizes squared vertical residuals. Swapping response and predictor generally changes the fitted line. Omitting the column of ones forces the line through the origin and removes the usual zero-sum-residual guarantee. At week 6 the fitted line predicts 8.9 cm, but this is extrapolation beyond weeks 1–4, where the growth pattern may change.

Key Takeaways

  • A line with an intercept has design rows [1,xi].
  • The fit minimizes squared vertical residuals.
  • Solve the normal equations or use centered-input formulas.
  • With an intercept, residuals sum to zero and the line passes through the point of means.
  • Two distinct input values ensure independent line-design columns.
  • Interpret slope units and treat extrapolation cautiously.

6.2 Fit curves and several predictors

A general linear model is linear in its unknown parameters. Its graph can be curved. Choosing columns that describe the input patterns turns a line, parabola, or several-predictor equation into the same least-squares calculation.

Build the design matrix from the model

Write 𝐲=X𝜷+𝜺. For y=β0+β1x+β2x2, a design row is [1,xi,xi2]. For y=β0+β1u+β2v, it is [1,ui,vi]. The parameter order must match the column order. Both models solve XTX𝜷^=XT𝐲.

Fit a parabola

Use data (−1,5),(0,1),(1,2),(2,6). The design rows are [1,−1,1], [1,0,0], [1,1,1], and [1,2,4]. The products are

XTX=[4262686818],XT𝐲=(14,9,31).

The equations are 4β0+2β1+6β2=14, 2β0+6β1+8β2=9, and 6β0+8β1+18β2=31. Subtract half the first from the second to get 5β1+5β2=2. Subtract 1.5 times the first from the third to get 5β1+9β2=10. Their difference gives 4β2=8.

Thus β2=2, β1=−1.6, and β0=1.3. The fitted curve is y^=1.3−1.6x+2x2. Its outputs are 4.9,1.3,1.7,6.1, giving residuals 0.1,−0.3,0.3,−0.1 and squared error 0.2.

Interpret several predictors

For daily heating energy in kWh, use outdoor temperature u in °C and floor area v in m². The model y^=β0+β1u+β2v describes a plane. The coefficient β1 is the change in predicted energy per 1 °C with floor area held fixed. Its meaning depends on holding the other input constant.

Unique coefficients require independent design columns and at least as many rows as parameters. Including area in both m² and cm² creates dependent columns, because one is 10,000 times the other. The fitted vector remains unique, but coefficients can trade off without changing it.

With a square invertible design matrix, the fit goes through every observation. A parabola can pass through any three points with distinct inputs. Zero training residuals in that situation establish exact interpolation, not reliable prediction on new data.

Distinguish transformations and model size

For positive responses in y=cekx, take logarithms: ln⁡y=ln⁡c+kx. Fit a line to the logged responses, then recover c=eβ0 and k=β1. The minimized errors are in ln⁡y, so this generally differs from minimizing squared errors in the original responses.

Adding design columns enlarges the available column space. The best squared error on the same data cannot increase, because the old fit remains available by setting new coefficients to zero. A smaller training error by itself does not establish better predictions.

Key Takeaways

  • A model can have a curved graph while remaining linear in its parameters.
  • Design rows follow the functions and parameter order in the model.
  • Unique coefficients require independent design columns.
  • With several predictors, interpret each slope while holding the others fixed.
  • Fitting log responses changes the error criterion.
  • Adding columns cannot increase the best training squared error, but predictive quality needs separate evidence.

Orthogonality, Projections and Least Squares examples

6 Walkthroughs

1

From coordinates to perpendicular spaces

13 steps
Compute lengths and angles, then find whole spaces of perpendicular vectors.
  1. 1
    IntroductionGive coordinates a geometry

    A vector can have more coordinates than you can draw. The dot product still lets you measure its length, compare directions, and describe perpendicular spaces.

    Start with computations on individual vectors. Then turn the requirement of perpendicularity into homogeneous equations, connecting geometry to null spaces.

  2. 2
    ExplanationMultiply, then add

    For real vectors with matching sizes, multiply corresponding entries and add:

    𝐮⋅𝐯=∑iuivi.

    For 𝐮=(1,−2,2) and 𝐯=(3,1,4), this is 3−2+8=9. The result is one number, not the list (3,−2,8). The same product is 𝐮T𝐯 when vectors are columns.

  3. 3
    ExampleMeasure length and distance

    Keep 𝐮=(1,−2,2) and 𝐯=(3,1,4). Length comes from a self-dot-product: ∥𝐮∥=1+4+4=3.

    For distance, subtract before taking length. The displacement is (−2,−3,−2), so ∥𝐮−𝐯∥=17. Taking the difference of the separate lengths would measure a different quantity.

  4. 4
    ChallengeKeep the direction, change the length

    What unit vector points in the direction of (0,3,−4)? What happens to its direction if you multiply that unit vector by −1?

    ---reveal---

    The length is 5, so normalization gives (0,3/5,−4/5). Multiplying by −1 reverses its direction while keeping length 1. Normalization itself uses the positive length and therefore keeps the original direction.

  5. 5
    ExplanationA zero dot product means orthogonality

    Two vectors are orthogonal when their dot product is zero. For (2,1,−1) and (1,−1,1), the product is 2−1−1=0.

    Their sum (3,0,0) has squared length 9. The separate squared lengths are 6 and 3, so this also illustrates the Pythagorean identity. The zero cross term makes squared lengths add.

  6. 6
    ExampleFind an angle from its cosine

    For nonzero vectors, use cos⁡θ=(𝐮⋅𝐯)/(∥𝐮∥∥𝐯∥).

    The vectors (1,1,0) and (1,0,1) have dot product 1 and lengths 2. Their cosine is 1/2, giving 60∘ or π/3. Cauchy–Schwarz guarantees that the quotient lies between −1 and 1, where inverse cosine is defined.

  7. 7
    ChallengeRead the sign correctly

    For nonzero vectors, a learner says, “A positive dot product always means an acute angle.” What endpoint must be included to make the statement correct?

    ---reveal---

    Include 0°. Positive dot product gives 0∘≤θ<90∘; a positive multiple of the same direction gives 0°. A zero vector is a separate case: it is orthogonal to every vector, but its angle is undefined.

  8. 8
    ExplanationBe perpendicular to a whole space

    The orthogonal complement W⊥ contains vectors perpendicular to every vector in W. Test a spanning set, since the dot product distributes across its linear combinations.

    For W=Span⁡{(1,1,1)}, an unknown vector must satisfy z1+z2+z3=0. One equation describes all the perpendicular directions at once.

  9. 9
    ExampleSolve for the complement

    Solve z1+z2+z3=0 by taking z2=s and z3=t. Then

    𝐳=s(−1,1,0)+t(−1,0,1).

    The two directions form a basis of W⊥. The original space is a line, and its complement is a plane in ℝ3. Their dimensions add to 3, and their only common vector is zero.

  10. 10
    ChallengeCheck every spanning direction

    Let W=Span⁡{(1,0,0),(0,1,1)}. Does (0,2,0) belong to W⊥?

    ---reveal---

    No. Its dot product with the first direction is zero, but its dot product with the second is 2. Membership requires perpendicularity to every spanning direction. Here W⊥ is the line spanned by (0,1,−1), obtained by solving z1=0 and z2+z3=0.

  11. 11
    ConnectionRead a null-space equation as dot products

    For an m×n matrix, A𝐱=0 says that x is perpendicular to every row. Thus Nul⁡A=(Row⁡A)⊥ in ℝn.

    Applying this to the transpose gives Nul⁡AT=(Col⁡A)⊥ in ℝm. This is why a perpendicular fitting residual will satisfy AT𝐫=0.

  12. 12
    ChallengeConnect dimension and orthogonality

    A 6×4 matrix has rank 3. How many dimensions does its left null space have, and why must a vector there be perpendicular to every attainable output?

    ---reveal---

    Its dimension is 6−3=3. A left-null vector is perpendicular to every column, so it is perpendicular to every linear combination of columns. Those combinations are exactly the attainable outputs A𝐱.

  13. 13
    RecapUse the right test

    Use a dot product to compare directions, a norm to measure length, and the norm of a difference to measure distance.

    For a whole subspace, test its spanning directions. A null-space equation records all those dot-product conditions together. Keep the ambient dimension in view when pairing row or column spaces with their complements.

2

Use perpendicular directions as coordinates

11 steps
Recover basis weights and distinguish orthonormal columns from square orthogonal matrices.

Save this lesson to follow every Walkthrough step by step.

  1. 1
    IntroductionMake each coordinate independent
  2. 2
    ExplanationWhy orthogonality gives independence
  3. 3
    ExampleRecover the weights
  4. 4
    ChallengeCheck the formula’s condition
  5. 5
    ExampleNormalize the basis
  6. 6
    ExplanationTest columns with a matrix product
  7. 7
    ExampleInvert a square orthogonal matrix
  8. 8
    ChallengeOrthogonal columns or an orthogonal matrix?
  9. 9
    Key InsightA tall matrix has two different products
  10. 10
    ChallengeRecover coefficients, then reconstruct
  11. 11
    RecapCoordinates and geometry
3

Project a vector and verify the closest point

15 steps
Build line and subspace projections, then express them with matrices.

Save this lesson to follow every Walkthrough step by step.

  1. 1
    IntroductionFind the attainable part
  2. 2
    ExplanationRequire a perpendicular remainder
  3. 3
    ExampleCalculate the line projection
  4. 4
    ExampleCheck the residual and distance
  5. 5
    ChallengeRescale the direction
  6. 6
    ExplanationAdd perpendicular basis components
  7. 7
    ExampleCompute both weights for a plane
  8. 8
    ExampleTest the whole residual
  9. 9
    Key InsightWhy no different point can be closer
  10. 10
    ChallengeTwo checks for a proposed closest point
  11. 11
    ExplanationSave the projection in a matrix
  12. 12
    ConnectionUse any independent basis
  13. 13
    ChallengeProject twice
  14. 14
    ChallengeA matrix and a distance
  15. 15
    RecapCheck the point and its remainder
4

Build perpendicular directions and record QR

13 steps
Work Gram–Schmidt through three inputs, then factor a tall matrix.

Save this lesson to follow every Walkthrough step by step.

  1. 1
    IntroductionRemove what earlier vectors already represent
  2. 2
    ExplanationSubtract the earlier projections
  3. 3
    ExampleFind the first two directions
  4. 4
    ExampleRemove two components from the third input
  5. 5
    ExampleNormalize the outputs
  6. 6
    ChallengeFind an omitted component
  7. 7
    Key InsightA zero remainder has a meaning
  8. 8
    ExplanationRecord the basis as QR
  9. 9
    ExampleBuild Q for a line-design matrix
  10. 10
    ExampleCalculate R and reconstruct a column
  11. 11
    ChallengeDistinguish the two identities
  12. 12
    ChallengeRead dependence from the construction
  13. 13
    RecapPreserve spans and track coefficients
5

Find and check a least-squares solution

13 steps
Connect projection to normal equations, then solve with orthogonal columns and QR.

Save this lesson to follow every Walkthrough step by step.

  1. 1
    IntroductionFit what cannot be solved exactly
  2. 2
    ExplanationDerive the normal equations
  3. 3
    ExampleForm the square system
  4. 4
    ExampleSolve for the coefficients
  5. 5
    ExampleVerify and measure the residual
  6. 6
    ChallengeOne fitted vector, several coefficients
  7. 7
    Key InsightIndependence controls uniqueness
  8. 8
    ExampleSeparate orthogonal-column coefficients
  9. 9
    ExampleUse Q to find the new coordinates
  10. 10
    ExampleFinish by back-substitution
  11. 11
    ChallengeDo not stop at the new coordinates
  12. 12
    ChallengeChoose a numerical method
  13. 13
    RecapFit, solve, and verify
6

Build and interpret least-squares models

15 steps
Fit a line and a parabola, then reason about predictors, transformations, and model size.

Save this lesson to follow every Walkthrough step by step.

  1. 1
    IntroductionTranslate a model into columns
  2. 2
    ExplanationSeparate inputs from responses
  3. 3
    ExampleCollect the line-fit sums
  4. 4
    ExampleSolve the line coefficients
  5. 5
    ExampleRead the signed residuals
  6. 6
    ChallengeInterpret a prediction outside the data
  7. 7
    ConnectionCenter the predictor
  8. 8
    ExplanationA curved graph can be a linear model
  9. 9
    ExampleForm the parabola equations
  10. 10
    ExampleFinish the curve and check its predictions
  11. 11
    ChallengeFind a redundant predictor
  12. 12
    ConnectionHold the other predictor fixed
  13. 13
    ExplanationTransform the response and track the criterion
  14. 14
    ChallengeInterpret a perfect fit
  15. 15
    RecapRead the model as well as the answer

Orthogonality, Projections and Least Squares practice questions

50 Practice Questions in 5 sets

Set 1: Projection matrices and model setup10 Practice Questions

Question 1 of 10

What is a basis of the orthogonal complement of Span⁡{(2,−1,0),(0,0,1)}?
  1. {(2,−1,0)}
  2. {(1,−2,0)}
  3. {(1,2,1)}
  4. {(1,2,0)}
Show answerHide answer
Answer: D
Orthogonality requires 2z1−z2=0 and z3=0, so every solution is t(1,2,0). This nonzero vector is a basis of the one-dimensional complement. Giving the last entry as 1 would violate perpendicularity to (0,0,1).

Question 2 of 10

For 𝐮=(2,1,−2) and 𝐯=(−1,3,2), what is ∥𝐮−𝐯∥?
  1. 29
  2. 17
  3. 29
  4. 3+14
Show answerHide answer
Answer: A
The displacement is (3,−2,−4), so its squared length is 9+4+16=29 and its length is 29. The value 17 comes from the sum vector instead. Adding the separate lengths gives a bound, not the distance formula.

Question 3 of 10

What is the inverse of U=[0−110]?
  1. [0−110]
  2. [01−10]
  3. [0110]
  4. [0−1−10]
Show answerHide answer
Answer: B
The columns are perpendicular unit vectors, so the inverse is the transpose, [01−10]. Using U itself would apply the quarter-turn twice, producing a half-turn instead of the identity. Transposition swaps the off-diagonal entries with their signs intact.

Question 4 of 10

What matrix projects onto the line spanned by (2,−1)?
  1. [4−2−21]
  2. 15[1224]
  3. 15[4−2−21]
  4. 15[4221]
Show answerHide answer
Answer: C
Form the outer product of (2,−1) with itself and divide by its squared length 5. This gives the displayed matrix, which fixes (2,−1). Omitting the denominator would multiply that direction by 5 instead of leaving it fixed, so it would not be a projection.

Question 5 of 10

A vector is perpendicular to a line through the origin. What is its orthogonal projection onto that line?
  1. The zero vector.
  2. The vector itself.
  3. A unit vector.
  4. Its own negative.
Show answerHide answer
Answer: A
The dot product with a direction vector of the line is zero, so the projection coefficient is zero. The original vector is entirely in the perpendicular component. Projection returns the vector itself only when it already lies on the line.

Question 6 of 10

Gram–Schmidt processes (1,0,0),(1,1,0),(2,1,0) in that order. What happens at the third input?
  1. The remainder is nonzero because the three inputs are distinct.
  2. The remainder is zero because the input is in the earlier span.
  3. The remainder is nonzero because its length exceeds the first input’s.
  4. The remainder is zero because the input is orthogonal to the first two.
Show answerHide answer
Answer: B
The third input equals the sum of the first two, so removing its component in their span leaves zero. Distinct vectors can still be linearly dependent. A zero remainder indicates that the input adds no new direction, not that it was originally perpendicular to earlier inputs.

Question 7 of 10

Let A=[1−12−200] and 𝐛=(1,3,2). What are all least-squares coefficient vectors?
  1. {(1+t,t):t∈ℝ}
  2. {(7/5,0)}
  3. {(t,7/5−t):t∈ℝ}
  4. {(7/5+t,t):t∈ℝ}
Show answerHide answer
Answer: D
Every output has form (d,2d,0) with d=x1−x2. Projecting onto (1,2,0) gives d=(1+6)/5=7/5, so x1=7/5+x2. The single vector (7/5,0) is one minimizer, but dependence leaves infinitely many coefficients with the same fit.

Question 8 of 10

In a QR least-squares problem, R=[2−103] and QT𝐛=(1,6). What is 𝐱^?
  1. (1,6)
  2. (1/2,2)
  3. (3/2,2)
  4. (5/2,2)
Show answerHide answer
Answer: C
The bottom row gives 3x^2=6, so x^2=2. The top row then gives 2x^1−2=1, hence x^1=3/2. Taking the first coefficient as 1/2 ignores the contribution of the second unknown to the top equation.

Question 9 of 10

For a line model y=β0+β1x, what design row corresponds to the observation (x,y)=(−3,8)?
  1. [1,8]
  2. [1,−3]
  3. [−3,8]
  4. [−3,1]
Show answerHide answer
Answer: B
The coefficients multiply 1 and x, so this observation supplies the row [1,−3]. Its response 8 belongs in the observation vector on the right side. Using [−3,8] confuses the data pair with the functions that multiply the unknown parameters.

Question 10 of 10

The model y=β0+β1u+β2v is fitted to rows [1,0,1],[1,1,3],[1,2,5]. How do its coefficient uniqueness and fitted-vector uniqueness compare?
  1. Coefficients are nonunique; the fitted vector is unique.
  2. Both coefficients and the fitted vector are unique.
  3. Coefficients are unique; the fitted vector is nonunique.
  4. Both coefficients and the fitted vector are nonunique.
Show answerHide answer
Answer: A
The columns satisfy v=1+2u, so they are dependent despite having three rows for three parameters. Different coefficients can therefore give the same predictions. The fitted vector is still the unique projection onto the design column space; a square shape alone does not ensure invertibility.
Set 2: Lengths, coordinates, and first fits10 Practice Questions

Save this lesson to see every answer and practice every set.

Question 1 of 10

What is the length of (4,−4,2)?
  1. 36
  2. 2
  3. 6
  4. 12
Show answerHide answer

Save this lesson to see this answer.

Question 2 of 10

For 𝐮=(3,−2,1) and 𝐯=(1,1,−1), are the vectors orthogonal?
  1. Yes, because their dot product is zero.
  2. No, because their dot product is two.
  3. No, because neither vector is zero.
  4. Yes, because their lengths are equal.
Show answerHide answer

Save this lesson to see this answer.

Question 3 of 10

A 5×2 matrix U satisfies UTU=I2. What are the rank and nullity of the projection matrix UUT?
  1. Rank 5 and nullity 0.
  2. Rank 2 and nullity 0.
  3. Rank 3 and nullity 2.
  4. Rank 2 and nullity 3.
Show answerHide answer

Save this lesson to see this answer.

Question 4 of 10

A matrix U has orthonormal columns and 𝐱=(2,−1,2). What is ∥U𝐱∥?
  1. 9
  2. 3
  3. 3
  4. 1
Show answerHide answer

Save this lesson to see this answer.

Question 5 of 10

What is the projection of (2,5) onto the line spanned by (1,2)?
  1. (12/5,12/5)
  2. (12/5,24/5)
  3. (12,24)
  4. (1,2)
Show answerHide answer

Save this lesson to see this answer.

Question 6 of 10

Let W=Span⁡{(1,0,1),(0,1,0)} and 𝐲=(2,−1,4). What are the closest point in W and its distance from 𝐲?
  1. (3,0,3) and 3
  2. (3,−1,3) and 19
  3. (3,−1,3) and 2
  4. (2,−1,2) and 2
Show answerHide answer

Save this lesson to see this answer.

Question 7 of 10

Gram–Schmidt begins with (1,0,1) followed by (1,2,1). What is the unnormalized second remainder?
  1. (0,2,0)
  2. (0,1,0)
  3. (1,2,1)
  4. (−1,2,−1)
Show answerHide answer

Save this lesson to see this answer.

Question 8 of 10

In reduced QR of a 7×3 matrix with independent columns, what are the shapes of Q and R?
  1. Q:7×7; R:3×3
  2. Q:3×7; R:7×3
  3. Q:7×3; R:7×3
  4. Q:7×3; R:3×3
Show answerHide answer

Save this lesson to see this answer.

Question 9 of 10

For A=(1,1,1)T and 𝐛=(0,2,7), what are the least-squares coefficient and the squared error?
  1. x^=3; squared error=0
  2. x^=9; squared error=134
  3. x^=3; squared error=26
  4. x^=3; squared error=26
Show answerHide answer

Save this lesson to see this answer.

Question 10 of 10

A fitted height model is h^=1.8+0.6t, with height in centimeters and time in weeks. How should its slope be interpreted?
  1. Predicted height at week zero is 0.6 cm.
  2. Predicted height increases by 0.6 cm per week.
  3. Predicted height increases by 1.8 cm per week.
  4. Predicted time increases by 0.6 weeks per cm.
Show answerHide answer

Save this lesson to see this answer.

Set 3: Connect geometry, factorizations, and fits10 Practice Questions

Save this lesson to see every answer and practice every set.

Question 1 of 10

Let P=12[1111]. What is the projection of (5,1) onto the orthogonal complement of Col⁡P?
  1. (3,3)
  2. (−2,2)
  3. (5,1)
  4. (2,−2)
Show answerHide answer

Save this lesson to see this answer.

Question 2 of 10

If A=QR, QTQ=I, and the columns of A are independent, what product equals R?
  1. AQT
  2. QTA
  3. QAT
  4. ATQ
Show answerHide answer

Save this lesson to see this answer.

Question 3 of 10

For A=[101101] and 𝐛=(3,0,0), what is the least-squares error?
  1. 3
  2. 0
  3. 3
  4. 6
Show answerHide answer

Save this lesson to see this answer.

Question 4 of 10

For A with columns (1,−1,0) and (1,1,2) and target (4,0,1), what is the least-squares coefficient vector?
  1. (2,1)
  2. (4,6)
  3. (1,2)
  4. (2,3)
Show answerHide answer

Save this lesson to see this answer.

Question 5 of 10

What is the least-squares line for (0,2),(1,2),(2,5)?
  1. y^=2+1.5x
  2. y^=1.5+1.5x
  3. y^=3+1.5x
  4. y^=1.5+3x
Show answerHide answer

Save this lesson to see this answer.

Question 6 of 10

What is the angle between (1,0,−1) and (0,1,1)?
  1. 60∘
  2. 120∘
  3. 135∘
  4. 90∘
Show answerHide answer

Save this lesson to see this answer.

Question 7 of 10

An 8×5 matrix has rank 3. What is the dimension of the orthogonal complement of its column space?
  1. 2
  2. 3
  3. 8
  4. 5
Show answerHide answer

Save this lesson to see this answer.

Question 8 of 10

In the ordered orthogonal basis (2,0),(0,3), what are the coordinates of (6,−6)?
  1. (3,−2)
  2. (12,−18)
  3. (6,−6)
  4. (2,−3)
Show answerHide answer

Save this lesson to see this answer.

Question 9 of 10

Let W={(a,b,c):a+2b−c=0} and 𝐲=(4,1,0). What is its closest point in W?
  1. (1,2,−1)
  2. (5,3,−1)
  3. (3,−1,1)
  4. (4,1,6)
Show answerHide answer

Save this lesson to see this answer.

Question 10 of 10

A parabola model y=β0+β1x+β2x2 is fitted to four observations. What must hold for its coefficients to be unique?
  1. The four responses must all be different.
  2. The three design columns must have equal lengths.
  3. The four residuals must all be zero.
  4. The three design columns must be linearly independent.
Show answerHide answer

Save this lesson to see this answer.

Set 4: Diagnose and justify the methods10 Practice Questions

Save this lesson to see every answer and practice every set.

Question 1 of 10

A nonzero vector 𝐯 has length 5. What is ∥−2𝐯∥?
  1. 10
  2. −10
  3. 25
  4. 10
Show answerHide answer

Save this lesson to see this answer.

Question 2 of 10

Let A=[101011] and 𝐲=(2,1,0). What is the projection of 𝐲 onto Row⁡A?
  1. (1,1,−1)
  2. (3,2,−1)
  3. (1,0,1)
  4. (2,1,3)
Show answerHide answer

Save this lesson to see this answer.

Question 3 of 10

An orthogonal set {𝐮1,𝐮2} contains 𝐮1=𝟎 and 𝐮2≠𝟎. What can be concluded about independence?
  1. It is independent because the two vectors are orthogonal.
  2. It is independent because the nonzero vector has positive squared length.
  3. It is dependent because every orthogonal set has a free coefficient.
  4. It is dependent because a nonzero coefficient on the zero vector gives a zero combination.
Show answerHide answer

Save this lesson to see this answer.

Question 4 of 10

What are the coordinates of (7,−1) in the ordered basis (1,1),(1,−1)?
  1. (6,8)
  2. (4,3)
  3. (7,−1)
  4. (3,4)
Show answerHide answer

Save this lesson to see this answer.

Question 5 of 10

The same line is represented by 𝐮=(2,3) and 𝐯=−2𝐮. If the projection of 𝐲 is 4𝐮, what is its coefficient along 𝐯?
  1. 4
  2. −8
  3. −2
  4. 2
Show answerHide answer

Save this lesson to see this answer.

Question 6 of 10

Let W=Span⁡{(1,1,0),(1,0,1)} and 𝐲=(1,2,3). What is the squared distance from 𝐲 to W?
  1. 16/3
  2. 4/3
  3. 14
  4. 26/3
Show answerHide answer

Save this lesson to see this answer.

Question 7 of 10

After Gram–Schmidt produces a nonzero orthogonal remainder 𝐯2, a learner replaces it by 5𝐯2. How should later projections onto this direction be computed?
  1. Use the scaled vector only as the final vector factor.
  2. Use the scaled vector in both numerator and denominator and as the final vector factor.
  3. Keep the old denominator and scale only the numerator.
  4. Divide the old projection coefficient by 25 and keep the old vector.
Show answerHide answer

Save this lesson to see this answer.

Question 8 of 10

For A=[210202], what reduced QR factors have positive diagonal in R?
  1. Q=[1001/201/2], R=[2104]
  2. Q=[1001/201/2], R=[20022]
  3. Q=[100−1/20−1/2], R=[21022]
  4. Q=[1001/201/2], R=[21022]
Show answerHide answer

Save this lesson to see this answer.

Question 9 of 10

Let A=[10011−1] and 𝐛=(1,2,4). What is the least-squares coefficient vector?
  1. (1,2)
  2. (8/3,1/3)
  3. (2/3,5/3)
  4. (8/3,−1/3)
Show answerHide answer

Save this lesson to see this answer.

Question 10 of 10

Two models use the same response data, with design matrices X and [X 𝐜]. How can their minimum training sums of squared residuals compare?
  1. The added-column model’s minimum is strictly smaller.
  2. The added-column model’s minimum is always equal.
  3. The added-column model’s minimum is no larger.
  4. The added-column model’s minimum is no smaller.
Show answerHide answer

Save this lesson to see this answer.

Set 5: Transfer to new spaces and data10 Practice Questions

Save this lesson to see every answer and practice every set.

Question 1 of 10

Nonzero vectors satisfy ∥𝐮∥=2, ∥𝐯∥=3, and ∥𝐮+𝐯∥=7. What is the angle between them?
  1. 60∘
  2. 90∘
  3. 150∘
  4. 120∘
Show answerHide answer

Save this lesson to see this answer.

Question 2 of 10

For a square orthogonal matrix U and vectors 𝐱,𝐲, what is (U𝐱)⋅(U𝐲)?
  1. 0
  2. 𝐱⋅𝐲
  3. ∥𝐱∥∥𝐲∥
  4. ∥𝐱−𝐲∥2
Show answerHide answer

Save this lesson to see this answer.

Question 3 of 10

An orthogonal projection P on ℝ3 has kernel Span⁡{(1,−1,0)}. What is P(4,1,2)?
  1. (5/2,5/2,2)
  2. (3/2,−3/2,0)
  3. (4,1,0)
  4. (1,4,2)
Show answerHide answer

Save this lesson to see this answer.

Question 4 of 10

For 𝐩=proj⁡W𝐲, suppose ∥𝐲−𝐩∥=2. A point 𝐯∈W satisfies ∥𝐯−𝐩∥=3. What is ∥𝐲−𝐯∥?
  1. 5
  2. 1
  3. 13
  4. 5
Show answerHide answer

Save this lesson to see this answer.

Question 5 of 10

Apply Gram–Schmidt in order to (1,0,1),(1,1,0),(0,1,1). What is the positive multiple of the third unnormalized remainder whose last entry is 1?
  1. (1,−1,1)
  2. (−1,1,0)
  3. (−1,0,1)
  4. (−1,1,1)
Show answerHide answer

Save this lesson to see this answer.

Question 6 of 10

In A=QR, the diagonal of R is positive. A learner negates column 2 of Q. What matching change to R preserves the product A?
  1. Negate row 2 of R.
  2. Negate column 2 of R.
  3. Negate row 1 of R.
  4. Leave R unchanged.
Show answerHide answer

Save this lesson to see this answer.

Question 7 of 10

For A=[101101] and 𝐛=(1,2,4), let 𝐝=(1,−1,1). How does replacing 𝐛 by 𝐛+3𝐝 change the least-squares coefficients?
  1. They increase by 3 because the target vector increases in each equation.
  2. They change because every nonzero target change alters the projection.
  3. They stay the same because the added vector is perpendicular to every column.
  4. They become nonunique because the added vector is outside the column space.
Show answerHide answer

Save this lesson to see this answer.

Question 8 of 10

A tall matrix with two independent columns has R=[3102] in its reduced QR, QT𝐛=(5,4), and ∥𝐛∥2=50. What are the coefficients and minimum squared error?
  1. 𝐱^=(1,2); squared error=25
  2. 𝐱^=(1,2); squared error=9
  3. 𝐱^=(5,4); squared error=9
  4. 𝐱^=(1,2); squared error=3
Show answerHide answer

Save this lesson to see this answer.

Question 9 of 10

Data are (1,3),(2,4),(3,8),(4,9). What is the least-squares line and its sum of squared residuals?
  1. y^=1+2x; sum=2
  2. y^=0.5+2.2x; sum=0
  3. y^=6+2.2x; sum=122.8
  4. y^=0.5+2.2x; sum=1.8
Show answerHide answer

Save this lesson to see this answer.

Question 10 of 10

A fit to positive responses gives ln⁡y^=0.4−0.2x. What exponential model and fitting criterion does this represent?
  1. y^=e0.4e−0.2x, minimizing squared log-response residuals.
  2. y^=0.4e−0.2x, minimizing squared log-response residuals.
  3. y^=e0.4e−0.2x, minimizing squared original-response residuals.
  4. y^=e0.4e0.2x, minimizing squared original-response residuals.
Show answerHide answer

Save this lesson to see this answer.

Stuck on your own question? Homework Help

Key Terms

62 Key Terms, each with its definition

A

Angle between vectors
The angle between vectors is the angle from 0 to π whose cosine is their dot product divided by the product of their nonzero lengths.
The vectors (1,0) and (1,1) have cosine 1/2 and meet at 45°.

B

Back-substitution
Back-substitution solves an upper triangular system from the last equation upward, using each new value in the equations above.
After computing QT𝐛, back-substitution in R𝐱^=QT𝐛 finishes a QR fit.
Basis coordinate
A basis coordinate is a scalar weight in the unique expansion of a vector as a linear combination of an ordered basis.
In the basis (1,1),(1,−1), the vector (5,1) has coordinates (3,2).
Best approximation theorem
The best approximation theorem states that orthogonal projection gives the unique closest point in a subspace to any input vector.
Every different point in the subspace adds a positive squared term to the minimum squared distance.

C

Cauchy–Schwarz inequality
The Cauchy–Schwarz inequality bounds the absolute dot product of two vectors by the product of their lengths.
The bound keeps (𝐮⋅𝐯)/(∥𝐮∥∥𝐯∥) within the cosine range.
Centering
Centering subtracts a variable’s mean from each value, producing entries that sum to zero and are orthogonal to a column of ones.
Inputs 2, 4, and 6 become −2, 0, and 2 after centering at their mean of 4.
Column space
The column space is the span of a matrix’s columns and consists of every output attainable by multiplying that matrix by a vector.
Least squares chooses the closest point in the column space when the target lies outside it.
Complementary projection matrix
The complementary projection matrix is I−P when P is an orthogonal projection, and it projects onto the orthogonal complement.
If P𝐲 is the fitted part, (I−P)𝐲 is the perpendicular residual.
Complementary projections
Complementary projections split an input between a subspace and its orthogonal complement, and their outputs add to that input.
For a vector in the plane, projections onto the two coordinate axes add to the original vector.
Condition number
The condition number measures sensitivity of a matrix problem to perturbations; forming ATA squares the 2-norm condition number.
Nearly dependent columns can make normal-equation calculations sensitive to small rounding errors.

D

Dependent input direction
A dependent input direction is an input vector already expressible as a linear combination of earlier input vectors.
If the third input is the sum of the first two, its Gram–Schmidt remainder is zero.
Design matrix
A design matrix holds the chosen input functions in its columns, with one row per observation and one column per model parameter.
A line with an intercept has rows [1,xi], while a parabola adds the column xi2.
Distance between vectors
The distance between vectors is the norm of their difference, measuring the separation between their endpoints.
The distance between (1,1) and (4,5) is 32+42=5.
Distance to a subspace
The distance to a subspace is the length of the residual after orthogonally projecting the vector onto that subspace.
If 𝐲−proj⁡W𝐲=(1,−2,2), the distance to W is 3.
Dot product
The dot product is the scalar obtained by multiplying matching entries of two real vectors and adding the products.
For (1,−1,2) and (3,2,4), the dot product is 3−2+8=9.

E

Extrapolation
Extrapolation uses a fitted model to predict outside the observed input range, where the measured pattern may no longer hold.
A line fitted to weeks 1–4 extrapolates when used to predict a seedling’s height at week 10.

F

Fitted vector
A fitted vector is the matrix output at a least-squares solution, equal to the target’s orthogonal projection onto the column space.
Dependent columns can give many coefficient vectors while every one produces the same fitted vector.
Floating-point arithmetic
Floating-point arithmetic represents numbers with finitely many significant digits, so calculations may introduce small rounding errors.
QR avoids the additional sensitivity caused by forming ATA in a numerical least-squares calculation.

G

General linear model
A general linear model expresses the response as a linear combination of specified input functions plus a residual term.
A quadratic curve is a linear model because its unknown coefficients multiply fixed functions of the input.
Gram–Schmidt process
The Gram–Schmidt process constructs orthogonal directions by subtracting each input’s projection onto the span of earlier outputs.
From (1,0) and (2,3), Gram–Schmidt produces (1,0) and (0,3).
Gram–Schmidt remainder
A Gram–Schmidt remainder is the part of the current input left after removing its components in the earlier orthogonal directions.
A zero remainder shows that the current input adds no direction to the span already built.

I

Idempotence
Idempotence is the property P2=P, meaning that applying the same transformation twice gives the same result as applying it once.
After a vector has been projected into a subspace, projecting it again leaves it unchanged.
Intercept
An intercept is the constant term in a fitted line, predicting the response when the input is zero.
In y^=2+0.8x for height in centimeters, the intercept predicts 2 cm at input zero.
Interpolation
Interpolation fits observed points exactly; an invertible square design gives zero residuals at every observation.
Three distinct input values determine a unique quadratic polynomial through their three observed points.

L

Least-squares error
The least-squares error is the norm of the residual at a best fit, measuring the distance from the target to the column space.
A residual (1,−2,2) has least-squares error 3 and squared error 9.
Least-squares solution
A least-squares solution is a coefficient vector that minimizes the squared length of the residual between the target and the matrix output.
An inconsistent system still has least-squares solutions because its column space has a closest point.
Left null space
The left null space of a matrix is the null space of its transpose, consisting of vectors perpendicular to every column.
If A has four rows, a vector in its left null space has four entries and satisfies AT𝐳=0.
Linear independence
Linear independence means that a zero linear combination of the vectors forces every coefficient to be zero.
Nonzero mutually orthogonal vectors are independent because dotting isolates one coefficient at a time.
Log transformation
A log transformation replaces positive responses by their logarithms, turning an exponential model into a line in the transformed response.
Fitting ln⁡y=β0+β1x estimates an exponential model by errors measured in log response.

N

Norm
The norm is a vector’s length, computed as the square root of the sum of its squared entries.
The vector (2,−1,2) has norm 4+1+4=3 despite its negative second entry.
Normal equations
The normal equations are ATA𝐱^=AT𝐛, expressing that the least-squares residual is orthogonal to the columns.
Solving the normal equations finds coefficients even when A𝐱=𝐛 has no solution.
Normalization
Normalization is the operation of dividing a nonzero vector by its length to obtain a unit vector in the same direction.
Normalizing (0,−6) gives (0,−1), which keeps the downward direction and has length 1.

O

Orthogonal basis
An orthogonal basis is a basis whose distinct vectors are perpendicular, allowing coordinates to be found with dot-product quotients.
The vectors (1,1) and (1,−1) form an orthogonal basis of the plane.
Orthogonal complement
The orthogonal complement of a subspace is the set of all vectors perpendicular to every vector of that subspace.
The orthogonal complement of the horizontal axis in the plane is the vertical axis.
Orthogonal decomposition
An orthogonal decomposition is the unique split of a vector into a part in a subspace and a part in its orthogonal complement.
Projection onto the horizontal axis splits (2,7) into (2,0)+(0,7).
Orthogonal matrix
An orthogonal matrix is a square real matrix whose inverse is its transpose, equivalently a square matrix with orthonormal columns.
A planar rotation matrix is orthogonal, so rotating a vector leaves its length unchanged.
Orthogonal projection onto a line
The orthogonal projection onto a line is the unique point on that line whose residual from the input is perpendicular to the line.
Projecting (2,7) onto the horizontal axis gives (2,0) with residual (0,7).
Orthogonal set
An orthogonal set is a set of vectors in which every pair of distinct vectors has zero dot product.
Checking four vectors for an orthogonal set requires six pairwise dot products, not four.
Orthogonal subspaces
Orthogonal subspaces are subspaces for which every vector in one has zero dot product with every vector in the other.
The horizontal and vertical axes are orthogonal subspaces; their only common vector is zero.
Orthogonal vectors
Orthogonal vectors are vectors whose dot product is zero; this definition applies in every real coordinate dimension.
The vectors (2,3) and (−3,2) are orthogonal because −6+6=0.
Orthogonal-column shortcut
The orthogonal-column shortcut computes each least-squares coefficient separately by a dot-product quotient when columns are nonzero and orthogonal.
For a constant column of three ones, its fitted coefficient is the mean of the three responses.
Orthonormal basis
An orthonormal basis is a basis of mutually perpendicular unit vectors in which each coordinate is one dot product.
In an orthonormal basis, the coordinate along 𝐪j is 𝐲⋅𝐪j.
Orthonormal columns
Orthonormal columns are mutually perpendicular unit columns of a matrix, characterized by the identity UTU=I.
A tall matrix can have orthonormal columns while UUT projects onto a proper subspace.
Orthonormal set
An orthonormal set is a set of mutually orthogonal unit vectors, so its pairwise dot products are zero and its self-products are one.
The standard coordinate vectors form an orthonormal set in every real coordinate space.

P

Parameter vector
A parameter vector collects the unknown model coefficients in the same order as the corresponding design-matrix columns.
For columns 1, temperature, and area, use parameter order intercept, temperature slope, area slope.
Perpendicular component
The perpendicular component is the input vector minus its projection onto a line, leaving the part orthogonal to that line.
For input (2,7) and projection (2,0), the perpendicular component is (0,7).
Positive-diagonal convention
The positive-diagonal convention chooses every diagonal entry of the reduced QR factor R to be positive, making the factors unique.
Without that convention, changing one column sign in Q and the matching row sign in R preserves A.
Predictor
A predictor is an input variable or specified input function whose values form a model-design column.
Temperature and floor area can serve as two predictors of a building’s daily heating energy.
Preserved span
A preserved span is an unchanged set of attainable linear combinations after replacing the original spanning vectors.
Gram–Schmidt changes directions but preserves the span of each processed group of inputs.
Projection matrix
A projection matrix for orthogonal projection is a symmetric matrix satisfying P2=P and mapping onto its column space.
For an orthonormal basis matrix U of a plane in three dimensions, P=UUT projects onto that plane.
Pythagorean theorem for vectors
The Pythagorean theorem for vectors states that orthogonal vectors have a squared sum-length equal to the sum of their squared lengths.
For orthogonal vectors of lengths 3 and 4, the sum has length 9+16=5.

Q

QR factorization
A QR factorization expresses a matrix as A=QR, with orthonormal columns in Q and an upper triangular factor R.
For independent columns, QR supplies a convenient orthonormal basis of the original column space.

R

Reduced QR
A reduced QR of an independent-column m×n matrix uses an m×n matrix Q and an invertible n×n matrix R.
A matrix with six rows and two independent columns has a reduced Q with two columns.
Residual vector
A residual vector is the observed or target vector minus the fitted vector, with one signed discrepancy per observation or equation.
A least-squares residual can be nonzero while its product with AT is the zero vector.
Row space
The row space is the span of a matrix’s rows, regarded as coordinate vectors; its orthogonal complement is the matrix’s null space.
If a row is (1,2,0), every null-space vector must satisfy x1+2x2=0.

S

Scalar component
The scalar component along a nonzero direction is the signed projection length, equal to the dot product divided by the direction’s length.
A negative scalar component places the projected point opposite to the chosen positive direction.
Slope
A slope is the change in a line’s predicted response per one-unit increase in its predictor, with units of response per input.
A slope of 1.2 cm per week predicts a 2.4 cm increase across a two-week interval.
Sum of squared residuals
The sum of squared residuals is the residual self-dot-product, measuring squared error without cancellation of positive and negative entries.
Residuals 2 and −2 sum to zero, but their sum of squares is 8, indicating a nonzero error.
Symmetric matrix
A symmetric matrix is a square real matrix equal to its transpose; every orthogonal projection matrix has this property.
The matrix 12[1111] is symmetric and projects onto a line.

T

Triangle inequality
The triangle inequality states that the length of a vector sum cannot exceed the sum of the individual lengths.
Two perpendicular vectors of length 1 have a sum of length 2, which is less than 2.

U

Unit vector
A unit vector is a vector of length 1 that can specify a direction without introducing any additional scale.
The vector (3/5,4/5) has squared length 9/25+16/25=1, so it is a unit vector.
Upper triangular matrix
An upper triangular matrix is a square matrix with every entry below the main diagonal equal to zero.
The last row of an invertible upper triangular system gives the last unknown directly.

About this lesson

By StudeliReport a mistake

Make your own Study Materials

Turn your notes, slides and documents into Study Guides, Practice Questions, Flashcards and 6 more tools.

Get Started