Math Formula Cheat Sheet
"Source" points to the handouts under 学习路线/阶段/.
输入关键词开始查 —— 多个词用空格隔开(都要命中)。
1 Limits
| What I want to find | Formula | Symbol meaning | When to use | Source | Common mistake | sympy check |
|---|---|---|---|---|---|---|
| Limit of a function at a point | $\lim\limits_{x\to a}f(x)$ | $a$ is the point approached | find the trend, test continuity | Stage 01–02 | plugging in directly is not always the answer (it may be $0/0$) | limit(sin(x)/x, x, 0) → 1 |
| Limit of a sequence (ε-N definition) | $\forall\varepsilon>0,\ \exists N,\ n>N \Rightarrow \lvert a_n-A\rvert<\varepsilon$ | ε arbitrarily small, N is "which term it starts from" | proving a limit, not computing one | Stage 01 | dropping "$\forall\varepsilon$" loses the "arbitrarily small" | limit(1/n, n, oo) → 0 |
| Limit of a function (ε-δ definition) | $\forall\varepsilon>0,\ \exists\delta>0,\ 0<\lvert x-x_0\rvert<\delta \Rightarrow \lvert f(x)-A\rvert<\varepsilon$ | δ is the radius of the neighbourhood of x | prove the limit exists | Stage 02 | throwing away $0<\lvert x-x_0\rvert$ — the point itself may be undefined | — |
| $0/0$-type limit | use equivalent infinitesimals or L'Hôpital | — | direct substitution gives $0/0$ | Stage 05 | if it is not $0/0$ or $\infty/\infty$ you cannot use L'Hôpital | limit((exp(x)-1)/x, x, 0) → 1 |
| $\infty/\infty$-type limit | L'Hôpital, or compare highest powers | — | direct substitution gives $\infty/\infty$ | Stage 05 | L'Hôpital may loop without converging; try something else | limit(x**2/exp(x), x, oo) → 0 |
| Left / right limits | $\lim_{x\to a^-}f$, $\lim_{x\to a^+}f$ | left = from the smaller side, right = from the larger side | piecewise functions, testing whether a limit exists | Stage 02 | left ≠ right ⇒ the limit does not exist | limit(1/x, x, 0, '-') → -oo |
Core identities (equivalent infinitesimals as $x\to0$):
$$\sin x \sim x, \quad \tan x \sim x, \quad 1-\cos x \sim \frac{x^2}{2}, \quad e^x-1 \sim x, \quad \ln(1+x)\sim x$$
⚠️ "Equivalent infinitesimals" may only be substituted inside multiplication and division, never casually inside addition and subtraction.
Work out the order of the $o(x)$ term before substituting.
2 Derivatives and Differentials
| What I want to find | Formula | Symbol meaning | When to use | Source | Common mistake | sympy check |
|---|---|---|---|---|---|---|
| Instantaneous rate of change (definition) | $f'(x)=\lim\limits_{\Delta x\to0}\dfrac{f(x+\Delta x)-f(x)}{\Delta x}$ | Δx is the increment of the independent variable | differentiate from the definition, prove differentiability | Stage 03 | forgetting this is a "limit", thinking you may just set Δx=0 | diff(x**2, x) → 2*x |
| Power function | $(x^n)' = nx^{n-1}$ | n any real number | the most basic rule | Stage 04 | for $n=0$ it is 0, don't forget | diff(x**5, x) → 5*x**4 |
| Product rule | $(uv)' = u'v + uv'$ | — | two functions multiplied | Stage 04 | not $u'v'$ (the classic mistake) | diff(x*sin(x), x) → x*cos(x)+sin(x) |
| Quotient rule | $\left(\dfrac uv\right)' = \dfrac{u'v-uv'}{v^2}$ | v ≠ 0 | two functions divided | Stage 04 | the numerator is $u'v - uv'$; reverse the order and it is wrong | diff(sin(x)/x, x) |
| Chain rule ⭐ | $[f(g(x))]' = f'(g(x))\cdot g'(x)$ | outer derivative × inner derivative | any composite function | Stage 04 | omitting the inner derivative $g'(x)$ | diff(sin(x**2), x) → 2*x*cos(x**2) |
| Trigonometric | $(\sin x)'=\cos x$, $(\cos x)'=-\sin x$ | — | — | Stage 04 | differentiating $\cos$ carries a minus sign | diff(cos(x), x) → -sin(x) |
| Exponential / logarithm | $(e^x)'=e^x$, $(\ln x)'=\dfrac1x$ | x > 0 | — | Stage 04 | the derivative of $\ln\lvert x\rvert$ is also $1/x$ | diff(log(x), x) → 1/x |
| Inverse trig | $(\arctan x)'=\dfrac{1}{1+x^2}$, $(\arcsin x)'=\dfrac{1}{\sqrt{1-x^2}}$ | — | you meet these in reverse when integrating | Stage 04 | don't mix the denominators up with the $\arcsin$ one | diff(atan(x), x) → 1/(x**2+1) |
| Testing monotonicity | $f'(x)>0$ ⇒ increasing; $f'(x)<0$ ⇒ decreasing | — | sketch graphs, find extrema | Stage 06 | a point with $f'=0$ is not necessarily an extremum (e.g. $x^3$ at 0) | solve(diff(x**3-3*x, x), x) |
| Second derivative for concavity | $f''>0$ ⇒ opens upward (concave); $f''<0$ ⇒ opens downward (convex) | — | determine the direction of bending | Stage 07 | ⚠️ the Chinese and English conventions for "concave/convex" are opposite — check your textbook first | diff(x**2, x, 2) → 2 |
| Finding extrema (two steps) | ① solve $f'(x)=0$ for the stationary points ② check the sign of $f''$ | — | optimisation | Stage 06 | when $f''=0$ the test tells you nothing; find another way | diff(x**3-3*x, x, 2).subs(x, 1) → 6 |
| Tangent line equation | $y - f(a) = f'(a)(x-a)$ | a is the x-coordinate of the point of tangency | find tangent / normal lines | Stage 03 | forgetting to compute $f(a)$ first | diff(x**2,x).subs(x,1) → 2 |
3 Mean Value Theorem and L'Hôpital
| What I want to find | Formula | Symbol meaning | When to use | Source | Common mistake | sympy check |
|---|---|---|---|---|---|---|
| Rolle's theorem | $f(a)=f(b)$ ⇒ $\exists\xi,\ f'(\xi)=0$ | ξ lies inside (a,b) | prove "there is a point where the derivative is 0" | Stage 05 | three hypotheses (continuous, differentiable, equal endpoint values) — all are required | — |
| Lagrange mean value theorem | $\dfrac{f(b)-f(a)}{b-a} = f'(\xi)$ | ξ lies inside (a,b) | link the "average rate of change" to the "instantaneous rate of change" | Stage 05 | — | — |
| L'Hôpital's rule | $\lim\dfrac{f}{g} = \lim\dfrac{f'}{g'}$ | only for $0/0$ or $\infty/\infty$ | limits of indeterminate forms | Stage 05 | ⚠️ using it on a non-indeterminate form ⇒ every answer is wrong | limit(sin(x)/x, x, 0) |
| When L'Hôpital fails | when the limit of $f'/g'$ does not exist, the original limit may still exist | — | when one attempt does not converge | Stage 05 | don't hammer at it; switch to equivalent infinitesimals or Taylor | limit((x+sin(x))/x, x, oo) → 1 |
4 Indefinite Integrals
| What I want to find | Formula | Symbol meaning | When to use | Source | Common mistake | sympy check |
|---|---|---|---|---|---|---|
| Antiderivative / indefinite integral | $\int f(x)dx = F(x)+C$, where $F'=f$ | C is an arbitrary constant | the inverse operation of differentiation | Stage 11 | ⚠️ forgetting +C | integrate(2*x, x) → x**2 |
| Power rule for integrals | $\int x^n dx = \dfrac{x^{n+1}}{n+1}+C$ | $n \ne -1$ | the most used | Stage 11 | fails when $n=-1$ (division by 0) | integrate(x**5, x) → x**6/6 |
| Integral of $1/x$ | $\int \dfrac1x dx = \ln\lvert x\rvert+C$ | it is the $n=-1$ case | — | Stage 11 | don't drop the absolute value | integrate(1/x, x) → log(x) |
| Exponential / trig | $\int e^x dx = e^x+C$ $\int \sin x\,dx = -\cos x+C$ |
— | — | Stage 11 | ⚠️ integrating $\sin$ carries a minus sign | integrate(sin(x), x) → -cos(x) |
| Reverse of the inverse-trig derivative | $\int \dfrac{1}{1+x^2}dx = \arctan x+C$ | — | when the denominator is $1+x^2$ | Stage 11 | don't mix it up with the $\arcsin$ one | integrate(1/(1+x**2), x) → atan(x) |
| Substitution (first kind) | $\int f(g(x))g'(x)dx = \int f(u)du$ | let $u=g(x)$ | the integrand contains "the derivative of some function" | Stage 11 | forgetting to substitute back to $x$ | integrate(2*x*cos(x**2), x) → sin(x**2) |
| Integration by parts ⭐ | $\int u\,dv = uv - \int v\,du$ | choose u as the thing that "gets simpler when differentiated" | a product of two different types of function | Stage 11 | the sign is "minus", and the order is easy to reverse | integrate(x*exp(x), x) → (x-1)*exp(x) |
| How to choose $u$ for parts | LIATE: Logarithm > Inverse trig > Algebraic > Trig > Exponential | (Chinese mnemonic: 反对幂指三) | which one to take as $u$ | Stage 11 | choosing wrong makes it more and more complicated | integrate(log(x), x) → x*log(x)-x |
| The "insert a 1" trick | $\int\ln x\,dx = \int \ln x\cdot 1\,dx$ | take $dv=dx$, $v=x$ | when $\ln x$ or $\arctan x$ appears alone | Stage 11 | not thinking to "insert a 1" | integrate(log(x), x) |
| Parts twice, "wrapping back" | $I = \cdots - I$ ⇒ $2I=\cdots$ | treat the original integral as an unknown | things like $\int e^x\sin x\,dx$ | Stage 11 | forgetting that after "wrapping back" you divide by 2 | integrate(exp(x)*sin(x), x) |
| Trigonometric substitution (second kind) | $\sqrt{a^2-x^2} \Rightarrow x=a\sin t$ | — | to remove the square root | Stage 11 | after substituting you must change the limits | integrate(sqrt(1-x**2), x) |
5 Definite Integrals and Applications
| What I want to find | Formula | Symbol meaning | When to use | Source | Common mistake | sympy check |
|---|---|---|---|---|---|---|
| Definite integral (Riemann sum definition) | $\int_a^b f = \lim\limits_{n\to\infty}\sum f(x_i)\Delta x$ | Δx = (b−a)/n | understand the definition, numerical approximation | Stage 12 | confusing it with the indefinite integral | — |
| Newton–Leibniz ⭐ | $\int_a^b f(x)dx = F(b)-F(a)$ | F is any antiderivative | everything for evaluating a definite integral rests on it | Stage 12 | ⚠️ sign errors when plugging in the limits (e.g. $[-\cos x]_0^\pi$) | integrate(x**2, (x,0,1)) → 1/3 |
| Interval additivity / swapping limits | $\int_a^b f = -\int_b^a f$, $\int_a^b=\int_a^c+\int_c^b$ | — | integrating piecewise | Stage 12 | swapping the limits changes the sign | — |
| Odd function on a symmetric interval | $\int_{-a}^{a} f = 0$ (f odd) | — | know it is 0 without computing | Stage 12 | not spotting the parity, wasting half the work | integrate(x**3, (x,-1,1)) → 0 |
| Even function on a symmetric interval | $\int_{-a}^{a} f = 2\int_0^a f$ | — | — | Stage 12 | — | integrate(x**2, (x,-1,1)) → 2/3 |
| Fundamental theorem of calculus | $\dfrac{d}{dx}\int_a^x f(t)dt = f(x)$ | holds even when the antiderivative has no closed form | differentiate a variable-limit integral | Stage 12 | forgetting that a constant lower limit contributes 0 | diff(integrate(exp(-t**2),(t,0,x)), x) → exp(-x**2) |
| Area between two curves | $S=\int_a^b(\text{upper}-\text{lower})dx$ | — | find the area of a figure | Stage 12 | getting "which one is on top" wrong ⇒ a negative answer | integrate(x-x**2, (x,0,1)) → 1/6 |
| Average value of a function | $\bar f = \dfrac{1}{b-a}\int_a^b f\,dx$ | — | average speed, etc. | Stage 12 | forgetting to divide by the interval length | integrate(x**2, (x,0,3))/3 → 3 |
| Volume of a solid of revolution | $V = \pi\int_a^b [f(x)]^2 dx$ | rotate about the x-axis | find a volume | Stage 12 | dropping the π or forgetting to square | pi*integrate(x**4, (x,0,1)) → pi/5 |
| Convergence test for improper integrals | $\int_1^\infty\dfrac{1}{x^p}dx$: $p>1$ converges, $p\le1$ diverges | p is the exponent | integrals over an infinite interval | Stage 12 | ⚠️ $\int_1^\infty 1/x$ diverges | integrate(1/x, (x,1,oo)) → oo |
| Numerical integration (when it cannot be done) | $\int_a^b f \approx$ numerical methods | — | no elementary antiderivative | Stage 12 | — | float(integrate(exp(-x**2),(x,0,1))) |
6 Determinants
| What I want to find | Formula | Symbol meaning | When to use | Source | Common mistake | sympy check |
|---|---|---|---|---|---|---|
| 2×2 determinant | $\begin{vmatrix}a&b\\c&d\end{vmatrix}=ad-bc$ | — | solve a 2-variable system | Stage 08 | forgetting to subtract the anti-diagonal term | Matrix([[2,1],[1,3]]).det() → 5 |
| 3×3 (Sarrus' rule) | add the 3 main-direction terms − add the 3 anti-direction terms | — | valid only for 2×2 and 3×3 | Stage 08 | ⚠️ cannot be used from 4×4 up! also easy to miss one diagonal | Matrix([[1,2,3],[4,5,6],[7,8,10]]).det() → -3 |
| Conditions for determinant = 0 | ① two rows equal ② one row is a multiple of another ③ some row is all 0 | — | know it is 0 without computing | Stage 08 | not spotting it and grinding through the computation | Matrix([[1,2],[2,4]]).det() → 0 |
| Determinant property (row swap flips sign) | swapping two rows ⇒ $\det$ changes sign | — | simplify a computation | Stage 08 | — | — |
| Determinant property (adding a multiple of a row) | $R_i + kR_j$ ⇒ $\det$ unchanged | — | reduce to upper triangular (what a computer does) | Stage 08 | confusing it with "multiply a row by k" (that one multiplies by k) | — |
| Triangular determinant | upper/lower triangular ⟹ $\det$ = product of the diagonal | — | one step to the answer once triangular | Stage 08 | — | Matrix([[1,2,3],[0,4,5],[0,0,6]]).det() → 24 |
| Determinant of a product | $\det(AB)=\det(A)\det(B)$ | — | simplify a computation | Stage 08 | — | (Matrix([[1,2],[3,4]])*Matrix([[0,1],[1,0]])).det() |
| Transpose invariance | $\det(A^T)=\det(A)$ | — | — | Stage 08 | — | — |
| Cramer's rule | $x_i = D_i / D$, $D_i$ is what you get by replacing column i with the constant column | requires $D\ne0$ | solve n equations in n unknowns (theoretical use) | Stage 08 | ⚠️ not used in actual computation ($O(n\cdot n!)$ is too slow) | Matrix([[1,1,1],[2,-1,1],[1,2,-1]]).det() → 7 |
7 Matrix Operations
| What I want to find | Formula | Symbol meaning | When to use | Source | Common mistake | sympy check |
|---|---|---|---|---|---|---|
| Matrix multiplication | $(AB)_{ij}=\sum_k a_{ik}b_{kj}$ (left row × right column) | dimensions must be $(m\times n)(n\times p)$ | composing transformations | Stage 09 | ⚠️ the left column count must equal the right row count | Matrix([[1,2],[3,4]])*Matrix([[0,1],[1,0]]) |
| Multiplication is not commutative | $AB \ne BA$ (in general) | — | at all times | Stage 09 | ⚠️ the classic mistake: assuming you may swap | Matrix([[1,2],[3,4]])*Matrix([[0,1],[1,0]]) == Matrix([[0,1],[1,0]])*Matrix([[1,2],[3,4]]) → False |
| Cancellation fails | $AB=AC \not\Rightarrow B=C$ | — | matrix equations | Stage 09 | also "assuming you can cancel as with numbers" | — |
| Zero divisors | $AB=O$ but $A\ne O,B\ne O$ | — | — | Stage 09 | for numbers "a product of 0 means one factor is 0"; for matrices it does not hold | — |
| Transpose | $(A^T)_{ij}=a_{ji}$ | rows and columns swap | — | Stage 09 | — | Matrix([[1,2,3],[4,5,6]]).T |
| Transpose of a product | $(AB)^T = B^TA^T$ | — | — | Stage 09 | ⚠️⚠️ reverse the order | (A*B).T == B.T*A.T → True |
| Identity matrix | $AI = IA = A$ | all 1s on the diagonal | the "1" of matrices | Stage 09 | — | Matrix([[1,2],[3,4]])*eye(2) |
| Trace | $\text{tr}(A)=\sum_i a_{ii}$ (sum of the main diagonal) | — | equals the sum of the eigenvalues | Stage 13 | — | Matrix([[2,1],[1,2]]).trace() → 4 |
| Rank | $\text{rank}(A)$ = number of independent rows/columns | $\le\min(m,n)$ | determine the number of solutions | Stage 10 | the rank cannot exceed the smaller of the two dimensions | Matrix([[1,2,3],[2,4,6],[1,1,1]]).rank() → 2 |
| Reduced row echelon form (rref) | use row operations to make each column's pivot 1 and the rest 0 | — | the standard way to solve systems / find the rank | Stage 10 | — | Matrix([[1,2],[3,4]]).rref() |
8 Inverse Matrices
| What I want to find | Formula | Symbol meaning | When to use | Source | Common mistake | sympy check |
|---|---|---|---|---|---|---|
| Definition of the inverse | $AA^{-1} = A^{-1}A = I$ | must be square with $\det\ne0$ | "division for matrices" | Stage 09 | a non-square matrix has no inverse; $\det=0$ means no inverse | — |
| 2×2 inverse formula ⭐ | $\begin{pmatrix}a&b\\c&d\end{pmatrix}^{-1}=\dfrac{1}{ad-bc}\begin{pmatrix}d&-b\\-c&a\end{pmatrix}$ | — | by hand for order 2 | Stage 09 | ⚠️ forgetting to divide by the determinant | Matrix([[1,2],[3,4]]).inv() → [[-2,1],[3/2,-1/2]] |
| Mnemonic | swap the main diagonal, flip the sign of the anti-diagonal, divide by the determinant | — | memorise it | Stage 09 | forgetting to flip the sign on the anti-diagonal | — |
| Adjugate method (order 3) | $A^{-1} = \dfrac{1}{\det A}\operatorname{adj}(A)$ | adj = the transpose of the cofactor matrix | by hand for order 3 (very tedious) | Stage 09 | forgetting the transpose step | Matrix([[1,2,3],[0,1,4],[5,6,0]]).adjugate() |
| Inverse of a product | $(AB)^{-1} = B^{-1}A^{-1}$ | — | — | Stage 09 | ⚠️⚠️ reverse the order (the same rule as the transpose) | (A*B).inv() == B.inv()*A.inv() → True |
| Inverse of a transpose | $(A^T)^{-1} = (A^{-1})^T$ | — | the order may be swapped | Stage 09 | — | (A.T).inv() == A.inv().T → True |
| Determinant of an inverse | $\det(A^{-1}) = 1/\det(A)$ | — | — | Stage 09 | — | Matrix([[1,2],[3,4]]).inv().det() → -1/2 |
| Solving a system with the inverse | $AX=b \Rightarrow X=A^{-1}b$ | — | when solving for several b with the same A | Stage 09 | for a single solve, solve is faster |
Matrix([[2,1],[1,-3]]).inv()*Matrix([5,-1]) |
⚠️ In practice use
np.linalg.solve(A, b)— do not invert first and then multiply.
It is faster and numerically more stable.
9 Systems of Linear Equations
| What I want to find | Formula | Symbol meaning | When to use | Source | Common mistake | sympy check |
|---|---|---|---|---|---|---|
| Decision table for solutions ⭐ | $r_A < r_b$ ⇒ no solution $r_A = r_b = n$ ⇒ unique solution $r_A = r_b < n$ ⇒ infinitely many solutions |
$r_A=\text{rank}(A)$, $r_b=\text{rank}([A\mid b])$, $n$=number of unknowns | decide without solving the system | Stage 10 | ⚠️ computing only $\text{rank}(A)$ is not enough; you must also compute the rank of the augmented matrix | see below |
| Homogeneous system has a nonzero solution | $\text{rank}(A) < n$ | — | test "is there a nonzero solution" | Stage 10 | a homogeneous system always has the zero solution; the question is whether there is a nonzero one | Matrix([[1,2,3],[2,4,6],[1,1,1]]).rank() < 3 → True |
| General solution of a homogeneous system | $X = k_1\xi_1 + k_2\xi_2 + \cdots$ | fundamental system of solutions $\xi_i$ | write out all solutions | Stage 10 | number of free variables = $n-\text{rank}$ | Matrix([[1,2,3],[2,4,6],[1,1,1]]).nullspace() |
| General solution of a non-homogeneous system | $X = \eta^* + k_1\xi_1+\cdots$ | η is one particular solution* | write out all solutions | Stage 10 | forgetting to add the homogeneous part | linsolve((A, b), (x,y,z)) |
| Linear dependence / independence | if some $k_i$, not all zero, satisfy $\sum k_i\alpha_i=0$ ⇒ dependent | — | test "are there redundant vectors" | Stage 10 | — | Matrix.hstack(v1,v2,v3).rank() == 3 → independent |
| More than $n$ vectors in $n$ dimensions | always linearly dependent | — | a quick test | Stage 10 | forgetting this wastes the work | — |
Terminal check for the decision table:
# example with no solution (rank(A)=1, rank([A|b])=2)
~/miniconda3/bin/python -c "
from sympy import Matrix
A=Matrix([[1,2],[2,4]]); b=Matrix([1,3])
print('rank(A)=',A.rank(),' rank([A|b])=',A.row_join(b).rank(),' -> not equal => no solution')"
# example with infinitely many solutions (the two ranks are equal and < number of unknowns)
~/miniconda3/bin/python -c "
from sympy import Matrix
A=Matrix([[1,2,3],[2,4,6]]); b=Matrix([1,2])
print('rank(A)=',A.rank(),' rank([A|b])=',A.row_join(b).rank(),' unknowns=3 -> infinitely many solutions')"
10 Eigenvalues and Diagonalisation
| What I want to find | Formula | Symbol meaning | When to use | Source | Common mistake | sympy check |
|---|---|---|---|---|---|---|
| Eigenvalues and eigenvectors | $Av=\lambda v$, $v\ne0$ | λ eigenvalue, v eigenvector | find the "direction that does not turn" | Stage 13 | an eigenvector cannot be the zero vector | Matrix([[2,1],[1,2]]).eigenvects() |
| Characteristic equation ⭐ | $\det(A-\lambda I)=0$ | you must subtract λI | find the eigenvalues | Stage 13 | ⚠️ writing $\det(A-\lambda)$ is completely wrong | Matrix([[2,1],[1,2]]).charpoly(lam) |
| Sum of the eigenvalues | $\sum_i\lambda_i = \text{tr}(A)$ | trace = sum of the main diagonal | a one-second check | Stage 13 | use this to spot an arithmetic error immediately | sum(Matrix([[2,1],[1,2]]).eigenvals()) → 4 |
| Product of the eigenvalues | $\prod_i\lambda_i = \det(A)$ | — | check the result | Stage 13 | — | Matrix([[2,1],[1,2]]).det() → 3 |
| Eigenvalues of a triangular matrix | they are the diagonal entries | — | the fastest case | Stage 13 | — | Matrix([[1,2,3],[0,4,5],[0,0,6]]).eigenvals() |
| Eigenvalues of a symmetric matrix | always real, with eigenvectors mutually orthogonal | — | covariance matrices, etc. | Stage 13 | — | Matrix([[2,1],[1,2]]).eigenvals() → {1:1, 3:1} |
| Diagonalisation | $A = P\Lambda P^{-1}$, or $\Lambda = P^{-1}AP$ | columns of P = eigenvectors, Λ = diagonal of eigenvalues | make a matrix simpler | Stage 15 | ⚠️ the column order of P must match the diagonal order of Λ | Matrix([[2,1],[1,2]]).diagonalize() |
| Condition for diagonalisability | A has $n$ linearly independent eigenvectors | — | decide whether it can be diagonalised | Stage 15 | with a repeated root it may still be diagonalisable | Matrix([[2,1],[0,2]]).is_diagonalizable() → False |
| Matrix power (via diagonalisation) | $A^k = P\Lambda^k P^{-1}$ | Λ^k just raises the diagonal entries to the power | compute a high power | Stage 15 | multiplying out directly is slow | (Matrix([[1,1],[1,0]])**10) → Fibonacci |
| Orthogonal diagonalisation of a real symmetric matrix | $A = Q\Lambda Q^T$, $Q^{-1}=Q^T$ | Q is an orthogonal matrix | PCA, covariance matrices | Stage 15 | only symmetric matrices allow this (for a general matrix $P^{-1}\ne P^T$) | Matrix([[2,1],[1,2]]).diagonalize(normalize=True) |
| Geometric meaning of diagonalisation | switch to the basis of eigenvectors and the transformation becomes independent stretching along each direction | — | build intuition | Stage 15 | — | — |
| Long-term behaviour | $\|\lambda_{\max}\|>1$ diverges; $=1$ stable; $<1$ decays | — | analysing dynamical systems | Stage 15 | — | — |
11 SVD
| What I want to find | Formula | Symbol meaning | When to use | Source | Common mistake | sympy check |
|---|---|---|---|---|---|---|
| Singular value decomposition ⭐ | $A = U\Sigma V^T$ | U ($m\times m$) orthogonal, Σ ($m\times n$) diagonal non-negative, $V^T$ ($n\times n$) orthogonal | every matrix has one | Stage 16 | ⚠️ U and V have different sizes; truncate when reconstructing | U,S,Vt = np.linalg.svd(A) |
| Geometric meaning | rotate → stretch along the coordinate axes → rotate | — | build intuition | Stage 16 | — | — |
| Relation between singular values and eigenvalues | the eigenvalues of $A^TA$ $= \sigma_i^2$ | σ is a singular value | understand where the SVD comes from | Stage 16 | in practice you do not compute it this way (poor accuracy) | np.linalg.eigvalsh(A.T@A) |
| Symmetric matrix | $\sigma_i = \|\lambda_i\|$ | — | the special case of a symmetric matrix | Stage 16 | ⚠️ eigenvalues may be negative; singular values are never negative | np.linalg.svd(C)[1] |
| Low-rank approximation (Eckart–Young) | $A\approx U_k\Sigma_kV_k^T$ (keep only the first k singular values) | — | image compression, dimensionality reduction, denoising | Stage 16 | what is truncated is the "least important" directions | see below |
| Pseudoinverse | $A^+ = V\Sigma^+U^T$ | Σ⁺ = take the reciprocal of the nonzero singular values, then transpose | the fallback when $A$ is not invertible (regression) | Stage 16 | — | np.linalg.pinv(A) |
| The other face of PCA | SVD of centred data ⇒ right singular vectors = principal component directions | singular value² ÷(n−1) = variance of each principal component | dimensionality reduction | Stage 16 | — | — |
A hands-on test of low-rank approximation (the example from the Stage 16 handout):
~/miniconda3/bin/python -c "
import numpy as np
np.random.seed(0)
X = np.outer(np.arange(1,11), np.arange(1,6)) + np.random.normal(0,0.5,(10,5))
U,S,Vt = np.linalg.svd(X)
for k in [1,2,3]:
Xk = U[:,:k] @ np.diag(S[:k]) @ Vt[:k]
print(f'first {k}: relative error {np.linalg.norm(X-Xk)/np.linalg.norm(X):.4f}')"
# first 1: relative error 0.0222 ← 16 numbers reconstruct 50 numbers, error 2%
# first 2: relative error 0.0166
# first 3: relative error 0.0103
12 Common Constants and Equivalent Infinitesimals
| Name | Value / Formula | sympy syntax |
|---|---|---|
| Pi π | $3.14159265\ldots$ | sp.pi |
| Euler's number e | $2.71828182\ldots$ | sp.E |
| Infinity | — | sp.oo |
| Golden ratio φ | $\dfrac{1+\sqrt5}{2}=1.61803398\ldots$ | (1+sp.sqrt(5))/2 |
| Imaginary unit i | $\sqrt{-1}$ | sp.I |
Equivalent infinitesimals ($x\to0$):
| Expression | Equivalent to | sympy check |
|---|---|---|
| $\sin x$ | $x$ | limit(sin(x)/x, x, 0) → 1 |
| $\tan x$ | $x$ | limit(tan(x)/x, x, 0) → 1 |
| $1-\cos x$ | $\dfrac{x^2}{2}$ | limit((1-cos(x))/x**2, x, 0) → 1/2 |
| $e^x-1$ | $x$ | limit((exp(x)-1)/x, x, 0) → 1 |
| $\ln(1+x)$ | $x$ | limit(log(1+x)/x, x, 0) → 1 |
| $(1+x)^\alpha-1$ | $\alpha x$ | limit(((1+x)**0.5-1)/x, x, 0) → 0.5 |
13 High-Frequency Mistakes (must-read before the exam)
These are counted from Stages 01–16, ordered by how often they occur.
| # | Mistake | Correct |
|---|---|---|
| 1 | $\int\sin x\,dx = \cos x$ | it is $-\cos x+C$ |
| 2 | forgetting $+C$ on an indefinite integral | write it every time |
| 3 | $(AB)^{-1} = A^{-1}B^{-1}$ | it is $B^{-1}A^{-1}$, the order is reversed |
| 4 | $(AB)^T = A^TB^T$ | it is $B^TA^T$, the order is reversed |
| 5 | forgetting to change the limits after substitution | once you change to $u$, change the limits |
| 6 | computing $[-\cos x]_0^\pi$ as 0 | $-\cos\pi=+1$, the answer is 2 |
| 7 | forgetting to write $I$ in $\det(A-\lambda I)$ | subtract from the main diagonal only |
| 8 | giving only eigenvalues, not eigenvectors | the two must be paired |
| 9 | forgetting the $D\ne0$ precondition of Cramer's rule | compute $D$ first |
| 10 | computing only $\text{rank}(A)$, not $\text{rank}([A\mid b])$ | compute both |
| 11 | using L'Hôpital on a non-indeterminate form | first confirm it is $0/0$ or $\infty/\infty$ |
| 12 | using == to compare floats |
use math.isclose |
⭐ Items 3 and 4 are the sneakiest — they go wrong exactly when they look right.
Mnemonic: both the inverse and the transpose "turn the order around", like putting socks and shoes on and off.
14 How to use this sheet
| Step | What to do |
|---|---|
| 1 | search here when you get stuck on a problem (Cmd+F the "What I want to find" column) |
| 2 | read "Formula" and "When to use" |
| 3 | when unsure, copy the "sympy check" line into a terminal and run it |
| 4 | read the "Common mistake" column — those are the pits others fell into, and the ones you are about to |
Template command for running sympy:
~/miniconda3/bin/python -c "
import sympy as sp
x, y, z = sp.symbols('x y z')
print(sp.diff(x**2, x))
print(sp.integrate(x**2, x))
print(sp.limit(sp.sin(x)/x, x, 0))
"
💡 Save the few lines you use most as a shortcut, for example in
.zshrc:alias math='~/miniconda3/bin/python -c'Then you can just run
math "import sympy as s;x=s.symbols('x');print(s.diff(x**2,x))".
15 Related
- How to look up code → Code cheat sheet
- Full explanation of every formula →
学习路线/阶段/阶段01.htmlto阶段16.html - Whole-site self-check →
~/miniconda3/bin/python ~/Desktop/大一/验证.py