2

Linear Algebra

Linearity ยท Matrices ยท Discrete models

๐Ÿ“ What Is a Linear Function?
The intuitive picture
A function is linear if it respects two operations:

1. Scaling: if you scale the input by $c$, the output scales by the same $c$
2. Adding: if you add two inputs, the outputs add too

Think of it as: linear functions play nicely with addition and scaling. The graph of a linear function (in multiple variables) is always a flat plane through the origin.
Bennoun's two-property definition (Class 4)
A function $f$ is linear if it satisfies BOTH:

Property 1 โ€” Additivity: $f(\vec{x}_1 + \vec{x}_2) = f(\vec{x}_1) + f(\vec{x}_2)$
Property 2 โ€” Scalar multiplicativity: $f(a\vec{x}) = a\, f(\vec{x})$

You must verify BOTH. If either one fails, the function is NOT linear.

Combined shortcut (equivalent): $f(\alpha\mathbf{x} + \beta\mathbf{y}) = \alpha f(\mathbf{x}) + \beta f(\mathbf{y})$ checks both at once.
๐Ÿ”ฅ The fastest non-linearity checks
Check 1 โ€” f(0) = 0? Every linear function must satisfy $f(\mathbf{0}) = \mathbf{0}$. If $f(0,0) \neq (0,0)$, it's instantly NOT linear.

Check 2 โ€” any of these present? If yes โ†’ NOT linear:
• Constant term: $f(x)=3x+5$ โ€” the $+5$ breaks linearity
• Product of variables: $xy$, $x^2=x\cdot x$, $\sqrt{x}=x^{1/2}$
• Sigmoid or exponential of the variable
โœ๏ธ Proving & Disproving Linearity
Template: Proving f IS linear (always use this structure)
Show $f(X,Y) = (3X - 2Y,\ X + Y)$ is linear.

Let $\mathbf{u}=(X_1,Y_1)$, $\mathbf{v}=(X_2,Y_2)$, scalars $\alpha,\beta$.

Compute the left side $f(\alpha\mathbf{u}+\beta\mathbf{v})$:
$\alpha\mathbf{u}+\beta\mathbf{v} = (\alpha X_1+\beta X_2,\ \alpha Y_1+\beta Y_2)$
$f(\alpha\mathbf{u}+\beta\mathbf{v}) = \big(3(\alpha X_1+\beta X_2)-2(\alpha Y_1+\beta Y_2),\ (\alpha X_1+\beta X_2)+(\alpha Y_1+\beta Y_2)\big)$
$= \big(\alpha(3X_1-2Y_1)+\beta(3X_2-2Y_2),\ \alpha(X_1+Y_1)+\beta(X_2+Y_2)\big)$

Compute the right side $\alpha f(\mathbf{u})+\beta f(\mathbf{v})$:
$= \alpha(3X_1-2Y_1, X_1+Y_1) + \beta(3X_2-2Y_2, X_2+Y_2)$
$= \big(\alpha(3X_1-2Y_1)+\beta(3X_2-2Y_2),\ \alpha(X_1+Y_1)+\beta(X_2+Y_2)\big)$

Left = Right โœ“ โ†’ f is linear.
Disproving โ€” Constant term: $g(x,y) = 2x + y + 3$
Fastest method โ€” check $g(0,0)$:
$g(0,0) = 0 + 0 + 3 = 3 \neq 0$
Every linear function must have $f(\mathbf{0})=\mathbf{0}$. Since $g(0,0)=3\neq 0$ โ†’ NOT linear. Done.
Disproving โ€” Product of variables: $h(x,y) = xy$
Use scalar multiplicativity with a specific counterexample:
Try $c=2$, $x=1$, $y=1$:
$h(2\cdot 1,\ 2\cdot 1) = h(2,2) = 4$
$2\cdot h(1,1) = 2\cdot(1\cdot 1) = 2$
$4 \neq 2$ โ†’ scalar multiplicativity fails โ†’ NOT linear.
Using linearity without the formula โ€” most powerful exam skill
Given that $f$ is linear and you know: $f(\mathbf{u}) = \begin{pmatrix}2\\4\end{pmatrix}$ and $f(\mathbf{v}) = \begin{pmatrix}-1\\3\end{pmatrix}$

Find $f(3\mathbf{u} - 2\mathbf{v})$.

Since $f$ is linear: $f(3\mathbf{u}-2\mathbf{v}) = 3f(\mathbf{u}) - 2f(\mathbf{v}) = 3\begin{pmatrix}2\\4\end{pmatrix} - 2\begin{pmatrix}-1\\3\end{pmatrix} = \begin{pmatrix}6\\12\end{pmatrix} - \begin{pmatrix}-2\\6\end{pmatrix} = \begin{pmatrix}8\\6\end{pmatrix}$

You never need the actual formula for $f$ โ€” just linearity and the known outputs.
๐Ÿ”ข Linear Combinations & Basis Vectors
Linear combination
A linear combination of vectors $\mathbf{v}_1, \mathbf{v}_2$ is any expression $\alpha\mathbf{v}_1 + \beta\mathbf{v}_2$ for scalars $\alpha,\beta$.

Standard basis vectors in $\mathbb{R}^2$: $\mathbf{e}_1=\begin{pmatrix}1\\0\end{pmatrix}$, $\mathbf{e}_2=\begin{pmatrix}0\\1\end{pmatrix}$. Every 2D vector is a linear combination: $\begin{pmatrix}a\\b\end{pmatrix}=a\mathbf{e}_1+b\mathbf{e}_2$.
Writing a vector as a linear combination โ€” solving the system
Write $\begin{pmatrix}3\\6\end{pmatrix}$ as a linear combination of $\mathbf{u}=\begin{pmatrix}1\\1\end{pmatrix}$ and $\mathbf{v}=\begin{pmatrix}-2\\1\end{pmatrix}$.

Set up: $\alpha\begin{pmatrix}1\\1\end{pmatrix}+\beta\begin{pmatrix}-2\\1\end{pmatrix}=\begin{pmatrix}3\\6\end{pmatrix}$

This gives the system: $\alpha - 2\beta = 3$ and $\alpha + \beta = 6$
Subtract equation 1 from equation 2: $3\beta = 3$ โ†’ $\beta=1$, $\alpha=5$

$\begin{pmatrix}3\\6\end{pmatrix} = 5\begin{pmatrix}1\\1\end{pmatrix} + 1\begin{pmatrix}-2\\1\end{pmatrix}$ โœ“   Check: $(5-2, 5+1) = (3,6)$ โœ“
๐Ÿงฎ Matrix Representation of Linear Functions
Every linear function = a matrix
Any linear $f:\mathbb{R}^m\to\mathbb{R}^n$ can be written as matrix multiplication: $f(\mathbf{x}) = A\mathbf{x}$.

To build the matrix: apply $f$ to each standard basis vector. The results become the columns of $A$:
$$A = \Big[\; f(\mathbf{e}_1) \;\Big|\; f(\mathbf{e}_2) \;\Big|\; \cdots \Big]$$
Build the matrix from two images
Given: $f\begin{pmatrix}1\\0\end{pmatrix}=\begin{pmatrix}3\\-1\end{pmatrix}$ and $f\begin{pmatrix}0\\1\end{pmatrix}=\begin{pmatrix}2\\4\end{pmatrix}$

The matrix is: $A=\begin{pmatrix}3&2\\-1&4\end{pmatrix}$ (first image = first column, second image = second column)

Check: $A\begin{pmatrix}1\\0\end{pmatrix}=\begin{pmatrix}3\\-1\end{pmatrix}$ โœ“ and $A\begin{pmatrix}0\\1\end{pmatrix}=\begin{pmatrix}2\\4\end{pmatrix}$ โœ“
โœ–๏ธ Matrix Multiplication
Dimension rule and how to multiply
$[R_1 \times C_1][C_1 \times C_2] = [R_1 \times C_2]$  โ€” inner dimensions must match; output = outer dimensions

$(AB)_{ij}$ = (row $i$ of $A$) ยท (column $j$ of $B$) = dot product

$$\begin{pmatrix}a&b\\c&d\end{pmatrix}\begin{pmatrix}e&f\\g&h\end{pmatrix}=\begin{pmatrix}ae+bg&af+bh\\ce+dg&cf+dh\end{pmatrix}$$ NOT commutative: $AB \neq BA$ in general.
Composition order matters
$f\circ g$ means "apply $g$ first, then $f$". Matrix: $(f\circ g)(\mathbf{x}) = M_f(M_g \mathbf{x}) = (M_f M_g)\mathbf{x}$.
So the matrix for $f\circ g$ is $M_f M_g$ (multiply in that order, NOT $M_g M_f$).
๐Ÿ”ข Discrete-Time Matrix Models
What a discrete-time model is
Instead of $X'(t)$ (rate of change), we track $X_N$ at each time step $N=0,1,2,\ldots$ and compute $X_{N+1}$.

$$\mathbf{x}_{N+1} = M\mathbf{x}_N$$ The equilibrium point of a linear discrete-time model is always $\mathbf{0}$ (setting $\mathbf{x}_{N+1}=\mathbf{x}_N$ in $M\mathbf{x}=\mathbf{x}$ means $\mathbf{x}=0$ for a linear map with no eigenvalue=1).
๐Ÿ”ฅ Building a stage-structured matrix
A frog population has Tadpoles (T) and Adults (A).
• Each adult produces 4 tadpoles per month
• 50% of tadpoles survive to become adults
• 80% of adults survive each month

Write the equations first:
$T_{N+1} = 4A_N$  (only adults produce tadpoles)
$A_{N+1} = 0.5T_N + 0.8A_N$  (tadpoles mature + adults survive)

Matrix form (order matters โ€” rows match LHS variable, columns match RHS variable):
$$M=\begin{pmatrix}0&4\\0.5&0.8\end{pmatrix}$$ Column 1 = what tadpoles contribute: $T\to T$: 0, $T\to A$: 0.5
Column 2 = what adults contribute: $A\to T$: 4, $A\to A$: 0.8
Bennoun's own class example โ€” Ghost Orchid (Class 10)
Three stages: Dormant Seeds (D), Small Rosettes (S), Flowering Adults (F)

• 60% of seeds die โ†’ 40% survive as seeds
• 30% of seeds germinate โ†’ become rosettes
• Rosettes produce 5 seeds/yr; adults produce 80 seeds/yr
• 20% of rosettes survive and stay rosettes; 50% grow into adults
• 15% of adults lose stalks โ†’ revert to rosettes; 95% of adults survive

$$M = \begin{pmatrix}0.4 & 5 & 80 \\ 0.3 & 0.2 & 0.15 \\ 0 & 0.5 & 0.95\end{pmatrix} \begin{pmatrix}D_N \\ S_N \\ F_N\end{pmatrix}$$ Columns = what each stage contributes. Column 1 (D): 0.4 survive as seeds, 0.3 germinate. Column 2 (S): 5 seeds produced, 0.2 stay rosettes, 0.5 grow to adults. Column 3 (F): 80 seeds, 0.15 revert to rosettes, 0.95 survive as adults.
Is the model linear?
A discrete-time model is linear if ALL terms are linear combinations of the state variables (no products like $T\cdot A$, no squares, no constants).
If linear โ†’ write as $\mathbf{x}_{N+1} = M\mathbf{x}_N$.
If nonlinear โ†’ cannot write as a matrix (the Jacobian is used instead for local analysis).
PLF Final Review โ€” Is this discrete model linear?
Given: $G_{t+1} = G_t + 0.05S_t - 0.2C_t - 1.7G_t^2$,   $S_{t+1} = S_t$,   $C_{t+1} = C_t + 3.5G_t - 0.09S_tC_t$

Is it linear? NO.
Two non-linear terms: $-1.7G_t^2$ (a variable squared) and $-0.09S_tC_t$ (product of two variables).
Cannot write as $ ec{x}_{N+1} = M ec{x}_N$ because linear matrix models can only have terms proportional to one variable at a time.

Shortcut test: scan every term. If you see any $X^2$, $XY$, $X^{1/2}$, or $e^X$ โ†’ NOT linear, done.
PLF Final Review โ€” When does fโˆ˜g NOT exist?
$f$ is represented by $M = \begin{pmatrix}8&-3\\10&-3\end{pmatrix}$ ($2\times 2$ matrix, so $f: \mathbb{R}^2 \to \mathbb{R}^2$)
$g$ is represented by $N = \begin{pmatrix}1&2\\3&4\\5&6\end{pmatrix}$ ($3\times 2$ matrix, so $g: \mathbb{R}^2 \to \mathbb{R}^3$)

For $f \circ g$ (apply $g$ first, then $f$): codomain of $g$ must equal domain of $f$.
Codomain of $g = \mathbb{R}^3$, but domain of $f = \mathbb{R}^2$. Since $3 \neq 2$ โ†’ $f \circ g$ does not exist.

Quick rule: For $f \circ g$ to exist, the number of rows of M for $g$ must equal the number of columns of M for $f$.
โœฆ Unit 2 Practice Quiz

โœฆ Quiz โ€” Linear Algebra

Q1. Which of the following is linear?

A) $f(x,y) = (3x - 2y,\ x + y)$
B) $f(x,y) = (xy,\ x+y)$
C) $f(x,y) = (x+y+1,\ x)$
D) $f(x,y) = (x^2,\ y)$

Q2. You know $f$ is linear, $f(\mathbf{u})=\begin{pmatrix}1\\2\end{pmatrix}$, $f(\mathbf{v})=\begin{pmatrix}3\\0\end{pmatrix}$. Find $f(2\mathbf{u}+\mathbf{v})$.

A) $\begin{pmatrix}4\\2\end{pmatrix}$
B) $\begin{pmatrix}5\\4\end{pmatrix}$
C) $\begin{pmatrix}8\\2\end{pmatrix}$
D) Cannot compute without the formula for $f$

Q3. Matrices $A$ is $3\times 2$ and $B$ is $2\times 4$. The product $AB$ has dimensions:

A) $2\times 2$
B) $3\times 4$
C) $3\times 2$
D) Not defined โ€” dimensions incompatible

Q4. Write $\begin{pmatrix}3\\6\end{pmatrix}$ as a combination of $\mathbf{u}=\begin{pmatrix}1\\1\end{pmatrix}$ and $\mathbf{v}=\begin{pmatrix}-2\\1\end{pmatrix}$. What are $\alpha,\beta$?

A) $\alpha=5,\beta=1$
B) $\alpha=3,\beta=6$
C) $\alpha=1,\beta=-1$
D) $\alpha=2,\beta=0.5$

Q5. A model of bears has: $J_{N+1}=0.4B_N$ (young from adults) and $B_{N+1}=0.3J_N+0.9B_N$ (young mature + adults survive). The matrix $M$ is:

A) $\begin{pmatrix}0&0.4\\0.3&0.9\end{pmatrix}$
B) $\begin{pmatrix}0.4&0\\0.9&0.3\end{pmatrix}$
C) $\begin{pmatrix}0.3&0.9\\0&0.4\end{pmatrix}$
D) $\begin{pmatrix}0.4&0.3\\0&0.9\end{pmatrix}$