Skip to content

Linear algebra practice

Try a new question, then work through the fixed examples below. If you get stuck, check one step and retry.

Use A=[102131]A=\begin{bmatrix}1&0\\2&1\\3&1\end{bmatrix} and y=[2,5,8]Ty=[2,5,8]^\mathsf T where specified. Try each question before opening its answer.

Given AR3×2A\in\mathbb R^{3\times2}, find A32A_{32} and explain its meaning.

Answer

A32=1A_{32}=1: record 3 has one practice set. The first index selects a row; the second selects a column.

Find x3x1x_3-x_1.

Answer

[3,1]T[1,0]T=[2,1]T[3,1]^\mathsf T-[1,0]^\mathsf T=[2,1]^\mathsf T. The third record has two more study hours and one more set.

Evaluate j=12wjxj\sum_{j=1}^{2}w_jx_j for w=[1,3]Tw=[-1,3]^\mathsf T and x=[2,1]Tx=[2,1]^\mathsf T.

Answer

(1)(2)+(3)(1)=1(-1)(2)+(3)(1)=1. The answer is a scalar, not a two-entry vector.

If BB has shape 2×42\times4, which of ABAB and BABA are defined? Give each defined product’s shape.

Answer

ABAB is defined and has shape 3×43\times4. BABA is undefined because its inner dimensions are 4 and 3.

Find ww satisfying Aw=[3,5,8]TAw=[3,5,8]^\mathsf T, or explain why none exists.

Answer

Row 1 gives w1=3w_1=3. Row 2 gives 6+w2=56+w_2=5, so w2=1w_2=-1. Row 3 then gives 91=89-1=8. The solution is [3,1]T[3,-1]^\mathsf T.

Does [2,5,8]T[2,5,8]^\mathsf T lie in the column space of AA?

Answer

No. Every vector AwAw has its third entry equal to the sum of its first two; 82+58\ne2+5. Equivalently, the first two equations require w=[2,1]Tw=[2,1]^\mathsf T, which predicts 7 in the third row.

7. Distinguish two meanings of independence

Section titled “7. Distinguish two meanings of independence”

The columns of CC are a=[1,2,3]Ta=[1,2,3]^\mathsf T and 2a2a. Are they linearly independent? Is this a question about probabilistic independence?

Answer

They are linearly dependent because 2a1(2a)=02a-1(2a)=0 uses coefficients that are not all zero. This is a relationship between fixed vectors, not a claim about independent random events.

For a=[1,2]Ta=[1,2]^\mathsf T and r=[2/5,1/5]Tr=[-2/5,1/5]^\mathsf T, compute aTra^\mathsf Tr.

Answer

2/5+2/5=0-2/5+2/5=0, so the vectors are perpendicular in Euclidean geometry.

9. Distinguish a coefficient from a projection

Section titled “9. Distinguish a coefficient from a projection”

Project y0=[2,5]Ty_0=[2,5]^\mathsf T onto the span of a=[1,2]Ta=[1,2]^\mathsf T. Report both the coefficient and the projected vector.

Answer

The coefficient is t=(aTy0)/(aTa)=12/5t=(a^\mathsf Ty_0)/(a^\mathsf Ta)=12/5. The projected vector is ta=[12/5,24/5]Tta=[12/5,24/5]^\mathsf T. A scalar coefficient and a vector prediction are different answers.

For minwyAw2\min_w\lVert y-Aw\rVert^2, report the minimum value and one minimizing weight vector.

Answer

The minimum value is 1/31/3. The minimizing vector is [7/3,2/3]T[7/3,2/3]^\mathsf T. If the objective were MSE, dividing by three would change the minimum to 1/91/9 but leave the weights unchanged.

We want predictions b+w1hi+w2sib+w_1h_i+w_2s_i. Write the new design matrix and its shape, placing the intercept coefficient first.

Answer

The coefficient vector is [b,w1,w2]T[b,w_1,w_2]^\mathsf T, and the matrix is [110121131]\begin{bmatrix}1&1&0\\1&2&1\\1&3&1\end{bmatrix}, of shape 3×33\times3. The first column multiplies the same intercept into every record. Changing the feature set changes the fitting problem.

A model has training MSE 1/91/9. What is its MSE on future records?

Answer

The training score does not determine it. We need new-data evidence, such as evaluation on an appropriate held-out set. Least squares solves the stated training objective, not the separate question of future performance.

Definition

Read the full glossary entry →