Foundations to FrontierPart VII: Applied mathematics and computationBezhig

A01: Linear systems, vector spaces, and transformations

5 exercises, each with a complete solution. 1 figure. 1 code listing.

On this page
  1. A. Prerequisites and observable goals
  2. B. The central question: which combinations produce the desired output?
  3. C. Span, independence, and bases
  4. D. Elimination preserves the solution set
  5. E. Composition explains matrix multiplication
  6. F. Inverses and determinants: useful but not universal tools
  7. G. Independent practice
  8. H. Complete solutions: A01
  9. I. Retention and readiness

A. Prerequisites and observable goals#

Before

Modules 01–02 for algebra and functions; C01 for the optional Python lab. Vectors from Module 33 are useful but not required.

After

Interpret a matrix as a map, solve and classify linear systems, identify span, independence, basis, rank, and null space, and explain when an inverse or determinant is useful.

Level: Degree-core mathematics; no calculus prerequisite.

B. The central question: which combinations produce the desired output?#

A vector is an ordered collection of coordinates relative to a chosen basis. It can describe displacement, a feature representation, a sampled signal, or a collection of unknowns. The same tuple can have different meanings in different coordinate systems. Addition and scalar multiplication are coordinatewise: (1,2)+(3,−1)=(4,1)(1,2)+(3,-1)=(4,1) and 2(1,2)=(2,4)2(1,2)=(2,4). A linear combination is a sum c1v1+⋯+ckvkc_1v_1+\cdots+c_kv_k. The coefficients cic_i are scalars; the viv_i are vectors. Do not confuse the number of coefficients with the dimension of each vector.

A matrix A∈Rm×nA\in\R^{m\times n} is a rectangular array with mm rows and nn columns. It represents a linear map from Rn\R^n to Rm\R^m. Writing its columns as a1,…,ana_1,\dots,a_n makes multiplication meaningful:

Ax=x1a1+⋯+xnan.Ax=x_1a_1+\cdots+x_na_n.

Thus Ax=bAx=b asks whether the desired output bb can be assembled from the columns of AA, and, if so, with which coefficients. This connects an algebraic system with a geometric image rather than treating multiplication as a mysterious row-by-column ritual.

C. Span, independence, and bases#

The span of a collection is the set of all its linear combinations. A collection is linearly independent when the only coefficients producing the zero vector are all zero. A basis for a vector space is an independent spanning collection; its size is the dimension. For example, (1,0)(1,0) and (0,1)(0,1) form a basis of R2\R^2. So do (1,1)(1,1) and (1,−1)(1,-1). The coordinates of a vector change with the basis, while the represented geometric vector need not.

The null space ker⁡A={x:Ax=0}\ker A=\{x:Ax=0\} describes inputs collapsed to zero. The column space im⁡A={Ax:x∈Rn}\operatorname{im} A=\{Ax:x\in\R^n\} describes achievable outputs. The rank is the dimension of the image. The rank–nullity theorem states

dim⁡ker⁡A+rank⁡A=n,\dim\ker A+\operatorname{rank}A=n,

where nn is the dimension of the input space. One way to understand this is to extend a basis of the null space to a basis of the whole input space. The added basis vectors have images that form a basis of the image: they must span it, and any dependence would contradict the way the original basis was completed. Each lost input direction reduces the number of independent output directions.

D. Elimination preserves the solution set#

Consider

2x+y=5,x−y=1.2x+y=5,\qquad x-y=1.

Add the equations to obtain 3x=63x=6, so x=2x=2; substitute into x−y=1x-y=1 to obtain y=1y=1. The augmented matrix records the same operations:

[2151−11]⟶[1−11033].\left[\begin{array}{cc|c}2&1&5\\1&-1&1\end{array}\right] \longrightarrow \left[\begin{array}{cc|c}1&-1&1\\0&3&3\end{array}\right].

Swapping equations, multiplying an equation by a nonzero scalar, and adding a multiple of one equation to another are reversible operations. They preserve exactly the same solutions. Multiplying a row by zero is not reversible and can erase a constraint. A pivot is a leading nonzero entry used to eliminate a variable from other equations. If a prospective pivot is zero, exchange rows when possible; do not divide by zero and hope a later simplification repairs it.

A row [0 0∣1][0\ 0\mid 1] means 0=10=1: the system is inconsistent. A row of all zeros means one constraint is redundant. A nonpivot input variable is free in a consistent system. For example,

x+2y=3,2x+4y=6x+2y=3,\qquad 2x+4y=6

has (x,y)=(3−2t,t)(x,y)=(3-2t,t) for every real tt, not merely one numerical answer. Changing the second right-hand side to 7 makes the system inconsistent. The coefficient matrix has rank 1 in both cases, but the right-hand side changes consistency.

One system, two pictures. Left, the row picture: each equation is a line, and the solution (2,1)(2,1) is where they cross. Right, the column picture: the same numbers ask which combination of the columns (2,1)(2,1) and (1,−1)(1,-1) reaches (5,1)(5,1), and the answer is 22 of the first plus 11 of the second.

E. Composition explains matrix multiplication#

Suppose B:Rp→RnB:\R^p\to\R^n and A:Rn→RmA:\R^n\to\R^m. The composition x↦A(Bx)x\mapsto A(Bx) has matrix AB∈Rm×pAB\in\R^{m\times p}. Column jj of ABAB is AA applied to column jj of BB. Dimensions enforce which multiplication is meaningful; the order follows the function composition. In general AB≠BAAB\ne BA, even when both products exist.

A planar rotation and nonuniform scaling demonstrate the difference. With

R=(0−110),S=(2001),R=\begin{pmatrix}0&-1\\1&0\end{pmatrix},\qquad S=\begin{pmatrix}2&0\\0&1\end{pmatrix},

RS(1,0)T=(0,2)TRS(1,0)^T=(0,2)^T, whereas SR(1,0)T=(0,1)TSR(1,0)^T=(0,1)^T. Applying local scale before world rotation is not the same as scaling along world axes afterward. Translation x↦Ax+tx\mapsto Ax+t is affine, not linear when t≠0t\ne0, because it does not send zero to zero. Homogeneous coordinates encode an affine map in a larger matrix, but they do not make the original translation a linear map on the original vector space.

F. Inverses and determinants: useful but not universal tools#

For a square matrix, invertibility, full rank, trivial null space, independent columns, and nonzero determinant are equivalent. The inverse undoes the map. To solve one numerical system, elimination or a factorization is generally preferable to explicitly forming an inverse: the inverse computes more information than the requested solution and can introduce avoidable work or error. [LA]

In two dimensions, det⁡(abcd)=ad−bc\det\begin{pmatrix}a&b\\c&d\end{pmatrix}=ad-bc is an oriented area scale factor. Its absolute value describes area scaling; its sign distinguishes orientation preservation from reversal. A zero determinant identifies dimension collapse. It is not a general measure of numerical quality: diag⁡(1012,10−12)\operatorname{diag}(10^{12},10^{-12}) has determinant 1 but stretches different directions by vastly different amounts. Conditioning in A05 and singular values in A02 explain that problem more accurately.

G. Independent practice#

F foundation C standard course work T transfer S optional stretch L runnable lab or project. Attempt the complete set before opening its solutions.

A01.01FSolution

Solve 2x+y=52x+y=5, x−y=1x-y=1 by a different elimination order than the worked example. Substitute the answer into both original equations. Identify the two column vectors whose combination equals (5,1)T(5,1)^T.

A01.02CSolution

For A=(123011)A=\begin{pmatrix}1&2&3\\0&1&1\end{pmatrix}, find its rank, a basis for its null space, and one solution to Ax=(4,1)TAx=(4,1)^T. Explain why the solution is not unique.

A01.03CSolution

Find the coordinates of (3,1)(3,1) in the basis v1=(1,1)v_1=(1,1), v2=(1,−1)v_2=(1,-1). Prove these two vectors are a basis, and distinguish coordinates from the geometric vector.

A01.04TSolution

Compute RSRS and SRSR for the matrices above. Give a vector witnessing their difference. Explain why the determinant alone cannot distinguish all different transformations.

A01.05LabSolution

Implement exact elimination with Fraction in linear_lab.py. Support nonempty square systems with a unique solution, pivot by swapping to a nonzero row, copy the inputs, and reject a singular system or incompatible dimensions. Test a system requiring a row swap and compare generated solutions by substitution. State why this exact rational lab is not a high-performance floating-point solver.

Optional small hints

A01.02: use the third unknown as a free parameter. A01.03: solve c1v1+c2v2=(3,1)c_1v_1+c_2v_2=(3,1). A01.05: a nonzero pivot is enough over exact rationals; floating-point pivot quality is a separate issue.

H. Complete solutions: A01#

Compare the first step where your work differs. A corrected answer is not yet an independent success.

A01.01Show solution

Eliminate the other variable first

Subtract twice the second equation from the first: (2x+y)−2(x−y)=5−2(2x+y)-2(x-y)=5-2, so 3y=33y=3 and y=1y=1. The second equation then gives x=2x=2. Verification: 2(2)+1=52(2)+1=5 and 2−1=12-1=1. The columns are (2,1)T(2,1)^T and (1,−1)T(1,-1)^T; the output is 2(2,1)T+1(1,−1)T=(5,1)T2(2,1)^T+1(1,-1)^T=(5,1)^T. This vector equation and the two scalar equations describe the same constraints.

Back to A01.01
A01.02Show solution

Free variables are lost input directions

The second row gives x2+x3=0x_2+x_3=0 in the homogeneous system. Let x3=tx_3=t; then x2=−tx_2=-t, and the first row gives x1+2(−t)+3t=0x_1+2(-t)+3t=0, so x1=−tx_1=-t. A null-space basis is (−1,−1,1)T(-1,-1,1)^T. The two rows have distinct pivot positions, so rank is 2 and nullity is 3−2=13-2=1. For the stated right-hand side, taking x3=0x_3=0 gives x2=1x_2=1, x1=2x_1=2. Every solution is (2,1,0)T+t(−1,−1,1)T(2,1,0)^T+t(-1,-1,1)^T. Substitution gives (4,1)T(4,1)^T for all tt. The nonzero null direction proves nonuniqueness.

Back to A01.02
A01.03Show solution

Coordinates depend on the chosen basis

The equations are c1+c2=3c_1+c_2=3 and c1−c2=1c_1-c_2=1. Adding yields 2c1=42c_1=4, so c1=2c_1=2 and c2=1c_2=1. The homogeneous equations yield c1=c2=0c_1=c_2=0, proving independence. Two independent vectors in R2\R^2 form a basis, or directly solve the same system for arbitrary target (a,b)(a,b) to obtain ((a+b)/2,(a−b)/2)((a+b)/2,(a-b)/2). The coordinate tuple (2,1)(2,1) in this basis represents the vector with standard coordinates (3,1)(3,1); it is not a contradiction or a change in the physical displacement.

Back to A01.03
A01.04Show solution

Order is part of the operation

RS=(0−120),SR=(0−210).RS=\begin{pmatrix}0&-1\\2&0\end{pmatrix},\qquad SR=\begin{pmatrix}0&-2\\1&0\end{pmatrix}.

The vector (1,0)T(1,0)^T gives outputs (0,2)T(0,2)^T and (0,1)T(0,1)^T. Both determinants equal 2, since both compositions multiply oriented area by 2. A determinant records only one scalar summary of a transformation, not its complete action on every direction. Equal determinants do not imply equal maps or equal conditioning.

Back to A01.04
A01.05Show solution

Reference implementation and exactness boundary

code/solutions/linear_lab.pyPython
"""A01.05: exact Gaussian elimination on small rational systems."""
from fractions import Fraction

def solve_exact(a: list[list], b: list) -> list[Fraction]:
    n = len(a)
    if n == 0 or len(b) != n or any(len(row) != n for row in a):
        raise ValueError("nonempty square system required")
    m = [[Fraction(v) for v in row] + [Fraction(rhs)]
         for row, rhs in zip(a, b)]
    for k in range(n):
        pivot = next((i for i in range(k, n) if m[i][k] != 0), None)
        if pivot is None:
            raise ValueError("system is not uniquely solvable")
        m[k], m[pivot] = m[pivot], m[k]
        for i in range(k + 1, n):
            factor = m[i][k] / m[k][k]
            for j in range(k, n + 1):
                m[i][j] -= factor * m[k][j]
    x = [Fraction(0)] * n
    for i in range(n - 1, -1, -1):
        x[i] = (m[i][n] - sum(m[i][j] * x[j]
                             for j in range(i + 1, n))) / m[i][i]
    return x

if __name__ == "__main__":
    print(solve_exact([[2, 1], [1, -1]], [5, 1]))

A row swap preserves the equations. Dividing the pivot row by its nonzero pivot and eliminating that column from other rows preserves the solution set while fixing a variable’s coefficient. After all columns, the coefficient matrix is the identity, so the augmented column is the unique solution. Failure to find a pivot in a square coefficient matrix means it is singular; this bounded interface rejects it rather than classifying all consistent and inconsistent singular cases. Rational arithmetic avoids rounding, but numerator and denominator sizes can grow substantially. The nested elimination work is cubic in matrix dimension when individual arithmetic operations are treated as unit cost; exact bit complexity is larger. Test generated systems with known xx, form b=Axb=Ax, solve, and substitute back. The tests are independent numerical evidence in addition to the reversible-row-operation argument.

Back to A01.05

I. Retention and readiness#

Retrieve function composition from Module 03 and the difference between a factor and an additive term from Module 01. Advance when you can explain Ax=bAx=b both as equations and as a column combination, and can recognize a free variable without treating it as a missing calculation.