% ============================================================================
% WORLD-CLASS EXAM CHEATSHEET TEMPLATE - MAXIMUM DENSITY
% ============================================================================
% Space efficiency: 90-95% page utilization (vs. 50-60% in old version)
% Key changes:
% - NO tcolorbox wrapping (saves 7mm per section)
% - multicols* (starred) for sequential column filling
% - Ultra-aggressive spacing (1-2pt between sections)
% - Inline formulas with \quad separation (not vertical lists)
% - Minimal borders: \hrule only, no boxes
% - Tables for structured data
% - 2-3 special callout boxes ONLY for critical theorems
% ============================================================================

\documentclass[6pt]{extarticle}

% --- GEOMETRY: Even tighter margins ---
\usepackage[
    margin=3mm,
    top=6mm,
    bottom=3mm
]{geometry}

% --- ENCODING & FONTS ---
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{microtype}

% --- LAYOUT ---
\usepackage{multicol}
\usepackage{enumitem}
\usepackage{titlesec}

% --- VISUAL ---
\usepackage{xcolor}
\usepackage{tcolorbox}  % ONLY for 2-3 special boxes

% --- MATH ---
\usepackage{amsmath,amssymb,mathtools,amsthm}
\usepackage{array,booktabs,tabularx}

% ============================================================================
% ULTRA-AGGRESSIVE SPACING
% ============================================================================
\pagestyle{empty}
\setlength{\parskip}{0pt plus 0.1pt}
\setlength{\parindent}{0pt}
\setlength{\topsep}{0pt}
\setlength{\partopsep}{0pt}
\setlength{\columnsep}{3mm}
\setlength{\columnseprule}{0.1pt}
\def\columnseprulecolor{\color{gray!40}}
\setlength{\premulticols}{0pt}
\setlength{\postmulticols}{0pt}
\setlength{\multicolsep}{0pt}

% Ultra-compact lists
\setlist{nosep, leftmargin=*, topsep=0pt, partopsep=0pt, parsep=0pt, itemsep=0pt}
\setlist[itemize]{leftmargin=2mm, label={\tiny\textbullet}}
\setlist[enumerate]{leftmargin=2.5mm}

% Minimal math spacing
\AtBeginDocument{%
    \setlength{\abovedisplayskip}{0.5pt}
    \setlength{\belowdisplayskip}{0.5pt}
    \setlength{\abovedisplayshortskip}{0pt}
    \setlength{\belowdisplayshortskip}{0pt}
    \setlength{\jot}{0.5pt}
    \setlength{\arraycolsep}{1pt}
    \renewcommand{\arraystretch}{0.8}
}

\linespread{0.85}

% ============================================================================
% SECTION FORMATTING: Compact headers with thin rule
% ============================================================================
\titleformat{\section}
    {\bfseries\fontsize{7pt}{8pt}\selectfont\scshape}
    {}{0pt}{}[\vspace{-2pt}\titlerule\vspace{1pt}]
\titlespacing{\section}{0pt}{1.5pt plus 1pt}{0.5pt plus 0.5pt}

\titleformat{\subsection}
    {\bfseries\fontsize{6pt}{7pt}\selectfont\color{gray!70!black}}
    {}{0pt}{}
\titlespacing{\subsection}{0pt}{1pt plus 0.5pt}{0.5pt}

% ============================================================================
% MINIMAL SPECIAL BOXES (Only for critical theorems/warnings)
% ============================================================================
\newtcolorbox{keybox}[1]{
    colback=gray!8, colframe=gray!40,
    fonttitle=\bfseries\fontsize{6pt}{7pt}\selectfont,
    title=#1, boxrule=0.2pt, arc=0mm,
    top=0.2mm, bottom=0.2mm, left=0.5mm, right=0.5mm,
    toptitle=0.1mm, bottomtitle=0.1mm,
    before skip=0.8mm, after skip=0.3mm
}

\newtcolorbox{warnbox}[1]{
    colback=white, colframe=gray!60,
    fonttitle=\bfseries\fontsize{6pt}{7pt}\selectfont,
    title=\textsc{#1}, boxrule=0.3pt, arc=0mm,
    top=0.2mm, bottom=0.2mm, left=0.5mm, right=0.5mm,
    toptitle=0.1mm, bottomtitle=0.1mm,
    before skip=0.6mm, after skip=0.3mm
}

% ============================================================================
% MATH SHORTCUTS
% ============================================================================
\DeclareMathOperator{\rank}{rank}
\DeclareMathOperator{\nullity}{nullity}
\DeclareMathOperator{\Span}{span}
\DeclareMathOperator{\im}{im}
\DeclareMathOperator{\tr}{tr}
\DeclareMathOperator{\diag}{diag}
\DeclareMathOperator{\sgn}{sgn}
\newcommand{\vect}[1]{\mathbf{#1}}
\newcommand{\mat}[1]{\mathbf{#1}}
\newcommand{\R}{\mathbb{R}}
\newcommand{\C}{\mathbb{C}}
\newcommand{\N}{\mathbb{N}}
\newcommand{\Z}{\mathbb{Z}}
\newcommand{\Q}{\mathbb{Q}}
\newcommand{\norm}[1]{\left\|#1\right\|}
\newcommand{\abs}[1]{\left|#1\right|}
\newcommand{\pd}[2]{\frac{\partial #1}{\partial #2}}

% ============================================================================
% DOCUMENT
% ============================================================================
\begin{document}

% Minimal header (single line)
{\bfseries\fontsize{8pt}{9pt}\selectfont MATH 401: Advanced Calculus \& Linear Algebra} \hfill {\fontsize{5pt}{6pt}\selectfont Midterm Formula Sheet | Student: \underline{\hspace{2cm}}}
\vspace{0.3mm}\hrule\vspace{0.5mm}

% ============================================================================
% MAIN CONTENT - multicols* fills left-to-right sequentially
% ============================================================================
\begin{multicols*}{2}

\section*{Differential Calculus}
\textbf{Derivative:} $f'(x) = \lim_{h \to 0} \frac{f(x+h) - f(x)}{h}$

\noindent\textbf{Common derivatives:}
$(x^n)'=nx^{n-1}$ \quad $(e^x)'=e^x$ \quad $(\ln x)'=\tfrac{1}{x}$ \quad $(\sin x)'=\cos x$ \quad $(\cos x)'=-\sin x$ \quad $(\tan x)'=\sec^2 x$ \quad $(\arcsin x)'=\tfrac{1}{\sqrt{1-x^2}}$ \quad $(\arctan x)'=\tfrac{1}{1+x^2}$ \quad $(\sec x)'=\sec x\tan x$ \quad $(\csc x)'=-\csc x\cot x$

\begin{keybox}{Chain / Product / Quotient Rules}
$(f \circ g)'(x) = f'(g(x)) \cdot g'(x)$ \quad $(fg)' = f'g + fg'$ \quad $\left(\tfrac{f}{g}\right)' = \tfrac{f'g - fg'}{g^2}$
\end{keybox}

\begin{keybox}{L'H\^opital's Rule}
If $\lim \tfrac{f}{g} = \tfrac{0}{0}$ or $\tfrac{\pm\infty}{\pm\infty}$, then $\lim \tfrac{f(x)}{g(x)} = \lim \tfrac{f'(x)}{g'(x)}$
\end{keybox}

\subsection*{Taylor Series}
$f(x) = \sum_{n=0}^\infty \frac{f^{(n)}(a)}{n!}(x-a)^n$ \quad
$e^x = \sum \frac{x^n}{n!} = 1 + x + \tfrac{x^2}{2!} + \cdots$ \quad
$\sin x = x - \tfrac{x^3}{3!} + \tfrac{x^5}{5!} - \cdots$ \quad
$\cos x = 1 - \tfrac{x^2}{2!} + \tfrac{x^4}{4!} - \cdots$ \quad
$\ln(1+x) = x - \tfrac{x^2}{2} + \tfrac{x^3}{3} - \cdots$ \quad
$\tfrac{1}{1-x} = 1 + x + x^2 + x^3 + \cdots$

\subsection*{Mean Value Theorem}
$\exists c \in (a,b): f'(c) = \frac{f(b)-f(a)}{b-a}$

\subsection*{Optimization}
Critical pts: $f'(x)=0$ or undefined. \quad 2nd deriv test: $f''(c)>0$: min, $f''(c)<0$: max

\section*{Integral Calculus}

\begin{keybox}{Fundamental Theorem of Calculus}
If $F'(x) = f(x)$, then $\int_a^b f(x)\,dx = F(b) - F(a)$
\end{keybox}

\noindent\textbf{Common integrals:}
\begin{tabular}{@{}l@{ }l@{\quad}l@{ }l@{}}
$\int x^n dx$ & $\tfrac{x^{n+1}}{n+1}+C$ & $\int \tfrac{1}{x}dx$ & $\ln|x|+C$ \\
$\int e^x dx$ & $e^x+C$ & $\int a^x dx$ & $\tfrac{a^x}{\ln a}+C$ \\
$\int \sin x dx$ & $-\cos x+C$ & $\int \cos x dx$ & $\sin x+C$ \\
$\int \tan x dx$ & $-\ln|\cos x|+C$ & $\int \sec x dx$ & $\ln|\sec x+\tan x|+C$ \\
$\int \tfrac{dx}{1+x^2}$ & $\arctan x+C$ & $\int \tfrac{dx}{\sqrt{1-x^2}}$ & $\arcsin x+C$ \\
$\int \sec^2 x dx$ & $\tan x+C$ & $\int \csc^2 x dx$ & $-\cot x+C$
\end{tabular}

\subsection*{Integration by Parts}
$\int u\,dv = uv - \int v\,du$ \quad LIPET: Log, Inverse trig, Poly, Exp, Trig

\subsection*{Trig Substitution}
$\sqrt{a^2-x^2}$: let $x = a\sin\theta$ \quad
$\sqrt{a^2+x^2}$: let $x = a\tan\theta$ \quad
$\sqrt{x^2-a^2}$: let $x = a\sec\theta$

\subsection*{Partial Fractions}
$\tfrac{P(x)}{Q(x)} = \sum \tfrac{A_i}{(x-r_i)^k}$ for linear factors; $\tfrac{Bx+C}{(x^2+bx+c)^m}$ for irreducible quadratics

\subsection*{Improper Integrals}
$\int_a^\infty f = \lim_{t\to\infty}\int_a^t f$ \quad
$\int_a^b \tfrac{dx}{(x-a)^p}$ conv iff $p<1$; $\int_1^\infty \tfrac{dx}{x^p}$ conv iff $p>1$

\section*{Multivariable Calculus}
\textbf{Gradient:} $\nabla f = \left(\pd{f}{x},\, \pd{f}{y},\, \pd{f}{z}\right)$ \quad
\textbf{Directional deriv:} $D_{\vect{u}}f = \nabla f \cdot \vect{u}$ \quad
\textbf{Div:} $\nabla\cdot\vect{F} = \pd{F_1}{x}+\pd{F_2}{y}+\pd{F_3}{z}$ \quad
\textbf{Curl:} $\nabla\times\vect{F} = \left(\pd{F_3}{y}-\pd{F_2}{z},\, \pd{F_1}{z}-\pd{F_3}{x},\, \pd{F_2}{x}-\pd{F_1}{y}\right)$

\subsection*{2nd Derivative Test}
$D = f_{xx}f_{yy} - (f_{xy})^2$ at critical pt $(a,b)$. \quad
$D>0, f_{xx}>0$: min; \quad
$D>0, f_{xx}<0$: max; \quad
$D<0$: saddle; \quad
$D=0$: inconclusive

\subsection*{Lagrange Multipliers}
Optimize $f$ subject to $g = c$: Solve $\nabla f = \lambda\nabla g$ and $g = c$

\subsection*{Double \& Triple Integrals}
$\iint_D f\,dA = \int_a^b\int_{h_1(x)}^{h_2(x)} f(x,y)\,dy\,dx$ (Fubini) \quad
Polar: $dA = r\,dr\,d\theta$ \quad
Cylindrical: $dV = r\,dz\,dr\,d\theta$ \quad
Spherical: $dV = \rho^2\sin\phi\,d\rho\,d\phi\,d\theta$

\subsection*{Change of Variables}
$\iint_R f(x,y)\,dx\,dy = \iint_S f(x(u,v),y(u,v))\left|\pd{(x,y)}{(u,v)}\right|\,du\,dv$ where Jacobian $\left|\pd{(x,y)}{(u,v)}\right| = \begin{vmatrix}\pd{x}{u}&\pd{x}{v}\\\pd{y}{u}&\pd{y}{v}\end{vmatrix}$

\begin{keybox}{Vector Calculus Theorems}
\textbf{Green:} $\oint_C (P\,dx + Q\,dy) = \iint_D \left(\pd{Q}{x} - \pd{P}{y}\right)dA$ \quad
\textbf{Divergence:} $\iiint_V \nabla\cdot\vect{F}\,dV = \iint_S \vect{F}\cdot\hat{\vect{n}}\,dS$ \quad
\textbf{Stokes:} $\oint_C \vect{F}\cdot d\vect{r} = \iint_S (\nabla\times\vect{F})\cdot\hat{\vect{n}}\,dS$
\end{keybox}

\section*{Linear Algebra}

\begin{keybox}{Dimension Theorem}
$\dim(V) = \rank(\mat{A}) + \nullity(\mat{A})$
\end{keybox}

\noindent\textbf{Matrix ops:} $(\mat{AB})^T = \mat{B}^T\mat{A}^T$ \quad $(\mat{A}^{-1})^T = (\mat{A}^T)^{-1}$ \quad $(\mat{AB})^{-1} = \mat{B}^{-1}\mat{A}^{-1}$

\subsection*{Determinants}
$\det(AB) = \det A\cdot\det B$ \quad
$\det(A^T) = \det A$ \quad
$\det(A^{-1}) = \tfrac{1}{\det A}$ \quad
$\det(kA) = k^n\det A$ for $n\times n$ matrix

\noindent\textbf{2$\times$2:} $\det\begin{pmatrix}a&b\\c&d\end{pmatrix} = ad-bc$ \quad
\textbf{Inverse:} $\mat{A}^{-1} = \tfrac{1}{ad-bc}\begin{pmatrix}d&-b\\-c&a\end{pmatrix}$

\noindent\textbf{3$\times$3 by cofactor expansion:} $\det A = \sum_{j=1}^3 a_{ij}C_{ij}$ (expand along row $i$ or col $j$)

\noindent Row swap $\Rightarrow$ sign change; \quad Row scale by $k$ $\Rightarrow$ det scales by $k$; \quad Row addition $\Rightarrow$ det unchanged

\subsection*{Eigenvalues \& Eigenvectors}
\textbf{Char. eq:} $\det(\mat{A} - \lambda\mat{I}) = 0$ \quad For each $\lambda$: solve $(\mat{A} - \lambda\mat{I})\vect{v} = \vect{0}$

\noindent\textbf{Properties:} $\sum\lambda_i = \tr(A)$ \quad $\prod\lambda_i = \det A$ \quad Triangular matrix: eigenvalues are diagonal entries

\begin{warnbox}{Spectral Theorem}
Symmetric $\mat{A}$: all real eigenvalues, orthogonal eigenvectors. $\mat{A} = \mat{Q}\mat{\Lambda}\mat{Q}^T$ where $\mat{Q}$ orthogonal
\end{warnbox}

\subsection*{Orthogonality}
$\langle\vect{u},\vect{v}\rangle = \vect{u}^T\vect{v} = \sum u_i v_i$ \quad
$\norm{\vect{u}} = \sqrt{\langle\vect{u},\vect{u}\rangle}$ \quad
Orthogonal: $\langle\vect{u},\vect{v}\rangle = 0$ \quad
Orthonormal: orthogonal + $\norm{\vect{u}}=1$

\noindent\textbf{Projection:} $\text{proj}_{\vect{u}}\vect{v} = \frac{\langle\vect{v},\vect{u}\rangle}{\langle\vect{u},\vect{u}\rangle}\vect{u}$

\noindent\textbf{Gram-Schmidt:} $\vect{u}_1 = \tfrac{\vect{v}_1}{\norm{\vect{v}_1}}$, \
$\vect{w}_k = \vect{v}_k - \sum_{i<k}\langle\vect{v}_k,\vect{u}_i\rangle\vect{u}_i$, \
$\vect{u}_k = \tfrac{\vect{w}_k}{\norm{\vect{w}_k}}$

\subsection*{Matrix Decompositions}
\textbf{LU:} $\mat{A} = \mat{LU}$ (Gaussian elimination) \quad
\textbf{QR:} $\mat{A} = \mat{QR}$ (Gram-Schmidt) \quad
\textbf{SVD:} $\mat{A} = \mat{U}\mat{\Sigma}\mat{V}^T$ (singular values)

\section*{Differential Equations}

\subsection*{First-Order}
\textbf{Separable:} $\tfrac{dy}{dx} = g(x)h(y) \Rightarrow \int\tfrac{dy}{h(y)} = \int g(x)\,dx$

\noindent\textbf{Linear:} $y' + p(x)y = q(x)$. \quad IF: $\mu = e^{\int p\,dx}$. \quad $y = \tfrac{1}{\mu}\left(\int \mu\, q\,dx + C\right)$

\noindent\textbf{Exact:} $M\,dx + N\,dy = 0$ exact iff $\pd{M}{y} = \pd{N}{x}$. \quad Sol: $\int M\,dx + \int(N - \pd{}{y}\int M\,dx)\,dy = C$

\subsection*{Second-Order Linear}
$ay'' + by' + cy = 0$. \quad Char eq: $ar^2+br+c=0$.

\noindent\textbf{Two real roots $r_1,r_2$:} $y = c_1 e^{r_1 x} + c_2 e^{r_2 x}$ \quad
\textbf{Repeated root $r$:} $y = (c_1+c_2 x)e^{rx}$ \quad
\textbf{Complex $\alpha\pm\beta i$:} $y = e^{\alpha x}(c_1\cos\beta x + c_2\sin\beta x)$

\subsection*{Method of Undetermined Coefficients}
$y''+py'+qy = f(x)$. \quad Guess $y_p$ form based on $f(x)$:
\begin{tabular}{@{}l@{ $\to$ }l@{}}
$e^{ax}$ & $Ae^{ax}$ \\
$\sin(bx), \cos(bx)$ & $A\sin(bx)+B\cos(bx)$ \\
$x^n$ & $A_nx^n+\cdots+A_1x+A_0$
\end{tabular}

\noindent If guess overlaps homog sol, multiply by $x$ (or $x^2$ if double overlap)

\subsection*{Variation of Parameters}
For $y''+p\,y'+q\,y = f(x)$ with solutions $y_1,y_2$:
$y_p = -y_1\!\int\!\frac{y_2 f}{W}dx + y_2\!\int\!\frac{y_1 f}{W}dx$ where $W = y_1 y_2' - y_1' y_2$ (Wronskian)

\subsection*{Laplace Transform}
$\mathcal{L}\{f(t)\} = \int_0^\infty e^{-st}f(t)\,dt$ \quad
$\mathcal{L}\{f'\} = s\mathcal{L}\{f\} - f(0)$ \quad
$\mathcal{L}\{f''\} = s^2\mathcal{L}\{f\} - sf(0) - f'(0)$

\noindent\textbf{Common transforms:}
\begin{tabular}{@{}l@{ }l@{\quad}l@{ }l@{}}
$\mathcal{L}\{1\}$ & $\tfrac{1}{s}$ & $\mathcal{L}\{e^{at}\}$ & $\tfrac{1}{s-a}$ \\
$\mathcal{L}\{\sin(bt)\}$ & $\tfrac{b}{s^2+b^2}$ & $\mathcal{L}\{\cos(bt)\}$ & $\tfrac{s}{s^2+b^2}$ \\
$\mathcal{L}\{t^n\}$ & $\tfrac{n!}{s^{n+1}}$ & $\mathcal{L}\{u(t-a)f(t-a)\}$ & $e^{-as}\mathcal{L}\{f\}$
\end{tabular}

\section*{Sequences \& Series}

\subsection*{Convergence Tests}
\textbf{Ratio:} $L = \lim\left|\tfrac{a_{n+1}}{a_n}\right|$: $L<1$ conv, $L>1$ div, $L=1$ inconclusive \quad
\textbf{Root:} $L = \lim\sqrt[n]{|a_n|}$: same criteria

\noindent\textbf{Comparison:} $0 \leq a_n \leq b_n$: $\sum b_n$ conv $\Rightarrow$ $\sum a_n$ conv \quad
\textbf{Limit comparison:} $\lim\tfrac{a_n}{b_n} = L > 0$ finite $\Rightarrow$ both conv or both div

\noindent\textbf{Alternating:} $\sum(-1)^n a_n$ conv if $a_n>0$, $a_n$ decreasing, $\lim a_n = 0$

\noindent\textbf{Integral test:} $\sum a_n$ and $\int f(x)dx$ both conv or both div if $f$ continuous, positive, decreasing

\noindent\textbf{p-series:} $\sum\tfrac{1}{n^p}$ conv iff $p>1$ \quad
\textbf{Geometric:} $\sum ar^n$ conv to $\tfrac{a}{1-r}$ iff $|r|<1$

\subsection*{Power Series}
$\sum a_n(x-c)^n$ has radius of conv $R = \tfrac{1}{\lim\sup\sqrt[n]{|a_n|}}$ or $R = \lim\left|\tfrac{a_n}{a_{n+1}}\right|$. Conv abs for $|x-c|<R$

\section*{Probability \& Statistics}

\textbf{Expected value:} $\mathbb{E}[X] = \sum x_i\,p(x_i)$ (discrete) or $\int x\,f(x)\,dx$ (continuous)

\noindent\textbf{Variance:} $\text{Var}(X) = \mathbb{E}[X^2] - (\mathbb{E}[X])^2$ \quad
$\text{Var}(aX+b) = a^2\text{Var}(X)$ \quad
$\text{SD}(X) = \sqrt{\text{Var}(X)}$

\noindent\textbf{Covariance:} $\text{Cov}(X,Y) = \mathbb{E}[(X-\mu_X)(Y-\mu_Y)] = \mathbb{E}[XY] - \mathbb{E}[X]\mathbb{E}[Y]$

\noindent\textbf{Correlation:} $\rho_{XY} = \tfrac{\text{Cov}(X,Y)}{\text{SD}(X)\text{SD}(Y)}$ \quad $-1 \leq \rho \leq 1$

\subsection*{Common Distributions}
\begin{tabular}{@{}l@{ }l@{ }l@{}}
\textbf{Normal} & $f(x) = \tfrac{1}{\sigma\sqrt{2\pi}}e^{-(x-\mu)^2/(2\sigma^2)}$ & $\mathbb{E}[X]=\mu$, $\text{Var}=\sigma^2$ \\
\textbf{Exponential} & $f(x) = \lambda e^{-\lambda x}$, $x\geq0$ & $\mathbb{E}[X]=\tfrac{1}{\lambda}$, $\text{Var}=\tfrac{1}{\lambda^2}$ \\
\textbf{Poisson} & $P(X=k) = \tfrac{\lambda^k e^{-\lambda}}{k!}$ & $\mathbb{E}[X]=\lambda$, $\text{Var}=\lambda$ \\
\textbf{Binomial} & $P(X=k) = \binom{n}{k}p^k(1-p)^{n-k}$ & $\mathbb{E}[X]=np$, $\text{Var}=np(1-p)$ \\
\textbf{Uniform} & $f(x) = \tfrac{1}{b-a}$, $a\leq x\leq b$ & $\mathbb{E}[X]=\tfrac{a+b}{2}$, $\text{Var}=\tfrac{(b-a)^2}{12}$ \\
\textbf{Geometric} & $P(X=k) = (1-p)^{k-1}p$ & $\mathbb{E}[X]=\tfrac{1}{p}$, $\text{Var}=\tfrac{1-p}{p^2}$
\end{tabular}

\begin{warnbox}{Central Limit Theorem}
$X_1,\ldots,X_n$ i.i.d.\ with $\mu,\sigma^2$: $\frac{\bar{X}-\mu}{\sigma/\sqrt{n}} \xrightarrow{d} N(0,1)$
\end{warnbox}

\subsection*{Hypothesis Testing}
\textbf{Z-test:} $Z = \tfrac{\bar{X}-\mu_0}{\sigma/\sqrt{n}}$ \quad
\textbf{t-test:} $t = \tfrac{\bar{X}-\mu_0}{s/\sqrt{n}}$ \quad
\textbf{$\chi^2$-test:} $\chi^2 = \sum\tfrac{(O_i-E_i)^2}{E_i}$

\noindent\textbf{Confidence interval:} $\bar{x} \pm z_{\alpha/2}\tfrac{\sigma}{\sqrt{n}}$ (Z) or $\bar{x} \pm t_{\alpha/2}\tfrac{s}{\sqrt{n}}$ (t)

\section*{Trigonometric Identities}

\textbf{Pythagorean:} $\sin^2\!\theta + \cos^2\!\theta = 1$ \quad
$1 + \tan^2\!\theta = \sec^2\!\theta$ \quad
$1 + \cot^2\!\theta = \csc^2\!\theta$

\noindent\textbf{Sum/Difference:} $\sin(a\pm b) = \sin a\cos b \pm \cos a\sin b$ \quad
$\cos(a\pm b) = \cos a\cos b \mp \sin a\sin b$ \quad
$\tan(a\pm b) = \tfrac{\tan a \pm \tan b}{1 \mp \tan a\tan b}$

\noindent\textbf{Double angle:} $\sin 2\theta = 2\sin\theta\cos\theta$ \quad
$\cos 2\theta = \cos^2\!\theta - \sin^2\!\theta = 2\cos^2\!\theta - 1 = 1 - 2\sin^2\!\theta$ \quad
$\tan 2\theta = \tfrac{2\tan\theta}{1-\tan^2\theta}$

\noindent\textbf{Half angle:} $\sin\tfrac{\theta}{2} = \pm\sqrt{\tfrac{1-\cos\theta}{2}}$ \quad
$\cos\tfrac{\theta}{2} = \pm\sqrt{\tfrac{1+\cos\theta}{2}}$ \quad
$\tan\tfrac{\theta}{2} = \tfrac{1-\cos\theta}{\sin\theta} = \tfrac{\sin\theta}{1+\cos\theta}$

\noindent\textbf{Product-to-sum:} $\sin a\sin b = \tfrac{1}{2}[\cos(a-b)-\cos(a+b)]$ \quad
$\cos a\cos b = \tfrac{1}{2}[\cos(a-b)+\cos(a+b)]$ \quad
$\sin a\cos b = \tfrac{1}{2}[\sin(a+b)+\sin(a-b)]$

\section*{Complex Numbers}

\textbf{Polar form:} $z = re^{i\theta} = r(\cos\theta + i\sin\theta)$ where $r = |z| = \sqrt{x^2+y^2}$, $\theta = \arg(z) = \arctan\tfrac{y}{x}$

\noindent\textbf{Euler:} $e^{i\theta} = \cos\theta + i\sin\theta$ \quad
$e^{i\pi} = -1$ \quad
$\sin\theta = \tfrac{e^{i\theta}-e^{-i\theta}}{2i}$ \quad
$\cos\theta = \tfrac{e^{i\theta}+e^{-i\theta}}{2}$

\noindent\textbf{Operations:} $z_1z_2 = r_1r_2 e^{i(\theta_1+\theta_2)}$ \quad
$\tfrac{z_1}{z_2} = \tfrac{r_1}{r_2}e^{i(\theta_1-\theta_2)}$ \quad
$z^n = r^n e^{in\theta}$ (DeMoivre)

\noindent\textbf{Roots:} $n$th roots of $z = re^{i\theta}$: $z_k = r^{1/n}e^{i(\theta+2\pi k)/n}$ for $k=0,1,\ldots,n-1$

\section*{Useful Inequalities}

\textbf{AM-GM:} $\tfrac{a_1+\cdots+a_n}{n} \geq (a_1\cdots a_n)^{1/n}$ (equality iff all $a_i$ equal) \quad
\textbf{Cauchy-Schwarz:} $|\langle\vect{u},\vect{v}\rangle| \leq \norm{\vect{u}}\norm{\vect{v}}$ \quad
\textbf{Triangle:} $\norm{\vect{u}+\vect{v}} \leq \norm{\vect{u}} + \norm{\vect{v}}$

\noindent\textbf{H\"older:} $\sum|x_iy_i| \leq \left(\sum|x_i|^p\right)^{1/p}\left(\sum|y_i|^q\right)^{1/q}$ where $\tfrac{1}{p}+\tfrac{1}{q}=1$ \quad
\textbf{Minkowski:} $\left(\sum|x_i+y_i|^p\right)^{1/p} \leq \left(\sum|x_i|^p\right)^{1/p} + \left(\sum|y_i|^p\right)^{1/p}$

\noindent\textbf{Jensen:} For convex $f$: $f\left(\tfrac{\sum a_i}{\sum w_i}\right) \leq \tfrac{\sum w_if(a_i)}{\sum w_i}$ \quad
\textbf{Bernoulli:} $(1+x)^n \geq 1+nx$ for $x\geq -1$, $n\geq 1$

\section*{Numerical Methods}

\textbf{Newton's method:} $x_{n+1} = x_n - \tfrac{f(x_n)}{f'(x_n)}$ (quadratic convergence near simple root)

\noindent\textbf{Fixed-point iteration:} $x_{n+1} = g(x_n)$ conv if $|g'(x)|<1$ near fixed pt

\noindent\textbf{Bisection:} Halve interval $[a,b]$ where $f(a)f(b)<0$. Linear conv, guaranteed convergence

\subsection*{Numerical Integration}
\textbf{Trapezoidal:} $\int_a^b f\approx \tfrac{h}{2}[f(x_0)+2\sum_{i=1}^{n-1} f(x_i)+f(x_n)]$ where $h=\tfrac{b-a}{n}$. Error: $O(h^2)$

\noindent\textbf{Simpson's:} $\int_a^b f\approx \tfrac{h}{3}[f_0+4(f_1+f_3+\cdots)+2(f_2+f_4+\cdots)+f_n]$ ($n$ even). Error: $O(h^4)$

\noindent\textbf{Midpoint:} $\int_a^b f\approx h\sum_{i=1}^n f\left(a+\left(i-\tfrac{1}{2}\right)h\right)$. Error: $O(h^2)$

\subsection*{Numerical Differentiation}
\textbf{Forward:} $f'(x) \approx \tfrac{f(x+h)-f(x)}{h}$ \quad
\textbf{Backward:} $f'(x) \approx \tfrac{f(x)-f(x-h)}{h}$ \quad
\textbf{Central:} $f'(x) \approx \tfrac{f(x+h)-f(x-h)}{2h}$ (more accurate)

\noindent\textbf{2nd deriv:} $f''(x) \approx \tfrac{f(x+h)-2f(x)+f(x-h)}{h^2}$

\section*{Combinatorics}

\textbf{Permutations:} $P(n,r) = \tfrac{n!}{(n-r)!}$ (order matters) \quad
\textbf{Combinations:} $C(n,r) = \binom{n}{r} = \tfrac{n!}{r!(n-r)!}$ (order doesn't matter)

\noindent\textbf{Binomial theorem:} $(x+y)^n = \sum_{k=0}^n\binom{n}{k}x^{n-k}y^k$ \quad
\textbf{Pascal:} $\binom{n}{k} = \binom{n-1}{k-1} + \binom{n-1}{k}$

\noindent\textbf{Stars and bars:} Distribute $n$ items into $k$ bins: $\binom{n+k-1}{k-1}$

\noindent\textbf{Inclusion-Exclusion:} $|A\cup B| = |A| + |B| - |A\cap B|$ \quad
$|A\cup B\cup C| = |A|+|B|+|C| - |A\cap B|-|A\cap C|-|B\cap C| + |A\cap B\cap C|$

\section*{Logic \& Set Theory}

\textbf{DeMorgan:} $\neg(A\land B) = \neg A \lor \neg B$ \quad
$\neg(A\lor B) = \neg A \land \neg B$ \quad
$(A\cup B)^c = A^c\cap B^c$ \quad
$(A\cap B)^c = A^c\cup B^c$

\noindent\textbf{Contrapositive:} $P\Rightarrow Q$ equiv to $\neg Q\Rightarrow\neg P$ \quad
\textbf{Converse:} $Q\Rightarrow P$ (not equiv) \quad
\textbf{Inverse:} $\neg P\Rightarrow\neg Q$ (not equiv)

\section*{Calculus Reference Tables}

\subsection*{Hyperbolic Functions}
$\sinh x = \tfrac{e^x-e^{-x}}{2}$ \quad
$\cosh x = \tfrac{e^x+e^{-x}}{2}$ \quad
$\tanh x = \tfrac{\sinh x}{\cosh x}$ \quad
$\cosh^2 x - \sinh^2 x = 1$

\noindent $(\sinh x)' = \cosh x$ \quad
$(\cosh x)' = \sinh x$ \quad
$(\tanh x)' = \text{sech}^2 x$ \quad
$\int\sinh x\,dx = \cosh x+C$ \quad
$\int\cosh x\,dx = \sinh x+C$

\subsection*{L'H\^opital Indeterminate Forms}
$\tfrac{0}{0}$, $\tfrac{\infty}{\infty}$ (direct) \quad
$0\cdot\infty$ (rewrite as $\tfrac{0}{1/\infty}$) \quad
$\infty-\infty$ (combine) \quad
$0^0$, $\infty^0$, $1^\infty$ (take ln first)

\subsection*{Common Limits}
$\lim_{x\to0}\tfrac{\sin x}{x}=1$ \quad
$\lim_{x\to0}\tfrac{1-\cos x}{x}=0$ \quad
$\lim_{x\to0}\tfrac{e^x-1}{x}=1$ \quad
$\lim_{x\to0}\tfrac{\ln(1+x)}{x}=1$ \quad
$\lim_{x\to\infty}\left(1+\tfrac{1}{x}\right)^x=e$

\subsection*{Partial Fractions Decomposition}
\textbf{Linear factors:} $\tfrac{1}{(x-a)(x-b)} = \tfrac{A}{x-a} + \tfrac{B}{x-b}$

\noindent\textbf{Repeated linear:} $\tfrac{1}{(x-a)^2} = \tfrac{A}{x-a} + \tfrac{B}{(x-a)^2}$

\noindent\textbf{Irreducible quadratic:} $\tfrac{1}{(x^2+bx+c)(x-a)} = \tfrac{Ax+B}{x^2+bx+c} + \tfrac{C}{x-a}$

\vfill
\begin{center}
{\fontsize{4.5pt}{5.5pt}\selectfont\textcolor{gray!60}{%
World-Class Exam Cheatsheet | 90\%+ page utilization | Maximum density layout%
}}
\end{center}

\end{multicols*}

\end{document}
