A Feynman-style cheatsheet for math challenges. I-search or grep and rock! In org-mode.

Download org file

#+TITLE: Feynman's Playbook — What To Do When You're Stuck #+AUTHOR: Ara #+STARTUP: overview * How to Evaluate an Ugly Integral ** Differentiating under the integral sign :feynman:leibniz: Feynman's favorite trick. Introduce a parameter, differentiate with respect to it, evaluate the easier integral, then integrate back (or set the parameter to the value you want). *** The rule (Leibniz integral rule) d/dα ∫_{a(α)}^{b(α)} f(x,α) dx = ∫_a^b ∂f/∂α dx + f(b,α)b'(α) - f(a,α)a'(α) Usually the limits are constant so just: d/dα ∫ f(x,α) dx = ∫ ∂f/∂α dx *** Example: ∫_0^∞ sin(x)/x dx Define I(α) = ∫_0^∞ e^{-αx} sin(x)/x dx for α > 0 I'(α) = -∫_0^∞ e^{-αx} sin(x) dx = -1/(1+α²) I(α) = -arctan(α) + C I(∞) = 0 ⟹ C = π/2 I(0) = π/2 - arctan(0) = π/2 ✓ *** Example: ∫_0^∞ e^{-x²} dx (alternate derivation) Let I = ∫_0^∞ e^{-x²} dx. Consider instead: J(t) = (∫_0^∞ e^{-t(1+x²)}/(1+x²) dx) The "trick" here: square I first. I² = ∫∫ e^{-(x²+y²)} dx dy → polar → π/4. So I = √π/2. Sometimes the trick is to multiply two copies together. *** Example: ∫_0^1 (x^a - x^b)/ln(x) dx Call it I(a,b). Differentiate w.r.t. a: ∂I/∂a = ∫_0^1 x^a dx = 1/(a+1) So I(a,b) = ln((a+1)/(b+1)) [since I(a,a)=0] *** When to try it - The integrand has a parameter you can differentiate w.r.t. - You see something like f(x)/x or f(x)/ln(x) — the denominator is often the "scar" of a differentiation - The integral is hard with parameter=specific value but easy for general parameter - You can't find a substitution but the integrand is smooth in some auxiliary variable ** Contour integration tricks :residue:cauchy: *** When to reach for contours - Integrand involves rational functions of trig (∫_0^{2π} R(sinθ,cosθ)dθ) - Integral from -∞ to ∞ of rational × trig (∫ P(x)/Q(x) e^{iax} dx) - You need to close a contour and the "extra piece" vanishes - The integrand has branch cuts (log, fractional powers) *** The residue shortcut ∮ f(z) dz = 2πi Σ Res(f, z_k) (inside contour) Simple pole at z₀: Res = lim_{z→z₀} (z-z₀)f(z) Order-n pole: Res = lim (1/(n-1)!) (d/dz)^{n-1} [(z-z₀)^n f(z)] *** Contour zoo (which contour for which problem) Real line integral, integrand decays: semicircle (upper or lower half-plane, pick by sign of exponential) Trig integral 0 to 2π: unit circle, z=e^{iθ} Branch cut on [0,∞): keyhole contour Branch cut on [-1,1]: dogbone contour Integrand periodic: rectangular contour with offset = period *** Example: ∫_0^∞ dx/(1+x^n) Keyhole or wedge contour with angle 2π/n. Result: π/(n sin(π/n)) *** Jordan's lemma (when the semicircle arc vanishes) If |f(z)| → 0 uniformly on |z|=R as R→∞, and a>0, then ∫_{arc} f(z) e^{iaz} dz → 0 (upper half-plane) Key: e^{iaz} decays in upper half-plane when a > 0 ** Symmetry arguments :symmetry: *** Even/odd decomposition ∫_{-a}^a f(x) dx: split f = f_even + f_odd, odd part integrates to 0 So ∫_{-a}^a f(x) dx = 2∫_0^a f_even(x) dx Saves work and sometimes makes the integral tractable *** Rotation / reflection If integrand is symmetric under x↔y, then ∫∫ f(x,y) dA over symmetric domain: can set x≤y and double (or use the symmetry to reduce dimension) *** The "add it to itself" trick I = ∫_0^π x f(sin x) dx. Substitute u=π-x: I = ∫_0^π (π-u) f(sin u) du. Add: 2I = π∫_0^π f(sin x) dx. Works whenever f(sin x) = f(sin(π-x)). Classic application: ∫_0^π x sin x/(1+cos²x) dx = π²/4 *** King's rule (generalization) ∫_a^b f(x) dx = ∫_a^b f(a+b-x) dx Useful when f(x) + f(a+b-x) simplifies ** Useful substitutions you might not think of :substitution: *** Weierstrass substitution (universal trig sub) t = tan(x/2), then sin x = 2t/(1+t²), cos x = (1-t²)/(1+t²), dx = 2dt/(1+t²) Converts any rational trig integral to rational function of t Last resort — often uglier than necessary, but always works *** Euler substitutions (for √(ax²+bx+c)) √(ax²+bx+c) = t ± x√a (if a > 0) √(ax²+bx+c) = tx ± √c (if c > 0) Rationalizes the square root *** Reciprocal substitution ∫_0^∞ f(x) dx with x ↦ 1/x sometimes splits nicely If f(1/x)/x² relates to f(x), you win *** Hyperbolic substitutions √(x²+1): x = sinh t (cleaner than sec) √(x²-1): x = cosh t These avoid the absolute-value headaches of trig subs ** Integration by "creative bookkeeping" :tricks: *** Complexify and take real/imaginary part ∫ e^{ax} cos(bx) dx: compute ∫ e^{(a+ib)x} dx, take Re Much cleaner than integration by parts twice *** Add zero strategically ∫ 1/(1+tan^n(x)) dx from 0 to π/2: Add to itself with sub x→π/2-x, numerator becomes tan^n/(1+tan^n) Sum = ∫_0^{π/2} 1 dx = π/2, so I = π/4 *** Schwinger parametrization 1/A^n = 1/Γ(n) ∫_0^∞ t^{n-1} e^{-tA} dt Converts denominators to exponentials (then Gaussian integrals) Workhorse in physics but useful anywhere you have products of denominators *** Feynman parametrization 1/(AB) = ∫_0^1 dx / [Ax + B(1-x)]² 1/(ABC) = 2 ∫_0^1 ∫_0^{1-x} dx dy / [Ax + By + C(1-x-y)]³ Combines products of denominators into a single denominator ** When all else fails :lastresort: - Series expand and integrate term by term (check convergence) - Numerical integration as a sanity check (compute it to 6 digits, then guess the closed form: is it a multiple of π²? ratio of small integers?) - Look for a probabilistic interpretation (is this an expectation?) - Mellin/Laplace/Fourier transform to a domain where it's easier - Check if it's a known integral in disguise (substitute, rescale) * How to Estimate Before You Compute ** Fermi estimation :fermi: *** The method 1. Break the quantity into factors you can estimate independently 2. Estimate each factor to within an order of magnitude 3. Multiply (errors tend to partially cancel by CLT-like reasoning) 4. State your answer as a power of 10 *** Why it works If each factor has independent multiplicative error ~3×, product of n factors has error ~3^{√n}× (geometric CLT) 5 factors each off by 3× → total off by ~5× (not 243×) *** Practice template "How many X are there in Y?" = (number of A) × (fraction that are B) × (rate of C per B) × ... Always sanity-check: does the final number pass the smell test? ** Dimensional analysis as problem-solving :dimensions: *** The real power Don't just check dimensions at the end — use them to DERIVE answers. If the answer depends on quantities {m, g, L, t}, and must have dimensions of [length], then the answer is L × f(dimensionless combos). Often there's only one dimensionless combo, fixing the answer up to a constant. *** Example: period of a pendulum Depends on: m, g, L, θ₀ [T] = [time]. From m, g, L: only combo with [time] is √(L/g) So T = C(θ₀) × √(L/g). You get the scaling for free; only C(θ₀) needs work. (And C(θ₀) ≈ 2π for small θ₀.) *** Example: drag force on a sphere Depends on: ρ (fluid density), v, D (diameter), μ (viscosity) [Force] = [M L T⁻²]. Dimensionless group: Re = ρvD/μ So F = ½ρv²A × C_D(Re) where A = πD²/4. The entire physics is in C_D(Re). ** Bounding and squeezing :bounds: *** Upper/lower bound by simpler function Can't evaluate ∫_0^1 e^{-x²} dx exactly? Lower: e^{-x²} ≥ 1-x² on [0,1], so I ≥ ∫(1-x²) = 2/3 ≈ 0.667 Upper: e^{-x²} ≤ 1 on [0,1], so I ≤ 1 Better upper: e^{-x²} ≤ e^{-x} on [0,1]? No, wrong direction. Try: split at x=1, use e^{-x²} ≤ e^{-x} for x>1. Actual value: I ≈ 0.7468 *** Squeeze to known form If you can show f(x) is between two things whose integrals you know, you have a useful range. Tighten by splitting the domain. *** Dominant term analysis In Σ a_n or ∫ f(x)dx, often one term or one region dominates. Identify it, estimate that piece, and check the rest is smaller. "Where is the integrand biggest? That region gives the answer." ** Interpolation between limits :interpolation: *** If you know the answer at two extremes, interpolate Example: f(0) = A, f(∞) = B, and f is monotone. Simplest: f(x) ≈ A + (B-A)(1-e^{-cx}) or f(x) ≈ B - (B-A)/(1+cx) Choose c to match a known derivative or intermediate value. *** Physical intuition version "For very large X, the answer looks like P; for very small X, it looks like Q. The crossover happens around X ~ X₀. For X near X₀, interpolate." Often the interpolation formula is (P·Q)/(P+Q) or √(P²+Q²) depending on whether effects add in series or in quadrature. ** Order-of-magnitude algebra :orderofmag: *** Rules of thumb If a quantity is O(ε), then ε² is negligible (keep only leading order) If two terms are O(1), they might cancel — be careful If a term is O(1/ε), it dominates — handle it first *** Identify the small parameter Every approximation has one. Find it explicitly. Taylor: the small parameter is the argument WKB: 1/k (short wavelength) Perturbation: the coupling constant Stirling: 1/n Once you name it, the expansion writes itself. * How to Solve a Differential Equation You've Never Seen ** Guess the form of the solution :ansatz: *** Power-law ansatz If the equation has scaling symmetry (x → λx, y → λ^α y leaves the equation invariant), try y = Cx^α. Plug in, determine α. This is often the dominant balance. *** Exponential ansatz Linear constant-coefficient → y = e^{rx}, solve characteristic equation Nonlinear but autonomous → look for traveling waves y(x-ct) *** Separation of variables Try y(x,t) = X(x)T(t). If it separates, you get two ODEs. Works more often than you'd expect, even for nonlinear problems. *** Similarity solutions If the PDE has a scaling symmetry, look for solutions that depend on a single combination η = x/t^α (or similar). Reduces PDE to ODE. Choose α by dimensional analysis or by requiring the combination to be dimensionless. ** Recognize a disguised standard equation :disguise: *** Change of dependent variable y = v(x) · w(x) sometimes turns a nasty equation into a standard one. Classic: y = e^{∫ P dx} · v reduces y'' + P(x)y' + Q(x)y = 0 to v'' + [Q - P'/2 - P²/4]v = 0 (no first-derivative term → maybe Airy, Bessel) *** Change of independent variable t = g(x) can straighten out singular points Classic: t = 1/x turns a neighborhood of ∞ into a neighborhood of 0 Classic: t = ln x for Euler-Cauchy equations *** Recognize by singularity structure Regular singular point at x=0 → Frobenius series (think Bessel, Legendre) Two regular singular points → hypergeometric or related Irregular singular point → asymptotic series, WKB *** The "what equation is this really?" checklist 1. Is it linear? → superposition, Green's function 2. Is it autonomous (no explicit t)? → phase plane, reduce order by p=y' 3. Is it exact? → ∃ potential function 4. Is it Bernoulli (y' + P(x)y = Q(x)y^n)? → sub v=y^{1-n} 5. Is it Riccati (y' = P+Qy+Ry²)? → know one solution, reduce to linear 6. Is it equidimensional? → try y=x^m 7. Does it have a Lie symmetry? → systematic reduction ** Boundary behavior and asymptotics :boundary: *** Before solving: what MUST the solution look like? - At infinity: growing, decaying, oscillating? - At the origin: regular or singular? - Physical constraints (positivity, boundedness, normalization) These constrain the solution enormously. Sometimes they determine it. *** Dominant balance (for asymptotic behavior) Near a singular point, assume y ~ x^α or y ~ e^{±f(x)}. Plug in, keep only the largest terms, solve the reduced equation. This tells you the asymptotic form; the rest is perturbative correction. *** Example: Airy equation y'' = xy for large x Try y ~ e^{S(x)}: S'' + (S')² = x Dominant balance: (S')² ≈ x ⟹ S' ≈ ±x^{1/2} ⟹ S ≈ ±(2/3)x^{3/2} So y ~ x^{-1/4} exp(±(2/3)x^{3/2}) — the two Airy asymptotics ** Perturbation methods :perturbation: *** Regular perturbation Equation depends on small ε. Expand: y = y₀ + εy₁ + ε²y₂ + ... Plug in, collect powers of ε, solve order by order. Works when the ε=0 problem has the same "character" as ε≠0. *** When regular perturbation fails (secular terms) If y₁ grows without bound (secular term), the expansion breaks down. Signals: boundary layer, multiple scales, or resonance. *** Singular perturbation / boundary layers ε multiplies the highest derivative → boundary layer of width O(ε^α) Outer solution: set ε=0 (misses boundary condition) Inner solution: rescale x = εξ near boundary, solve inner problem Match: overlap region where both are valid Classic example: εy'' + y' + y = 0, y(0)=0, y(1)=1 *** Multiple scales Introduce slow time T = εt alongside fast time t Treat t and T as independent, require no secular terms Gets amplitude modulation, envelope equations *** WKB approximation (rapidly oscillating/decaying) y'' + Q(x)y = 0 with Q slowly varying y ≈ Q^{-1/4} exp(±i ∫ Q^{1/2} dx) Valid when |Q'/Q^{3/2}| << 1 (i.e., Q varies slowly on wavelength scale) Breaks down at turning points (Q=0) — match via Airy functions * How to Handle a Sum or Series ** Generating functions :genfun: *** The idea Turn a sequence {a_n} into a function: A(x) = Σ a_n x^n Solve for A(x) (often via a functional equation), then extract coefficients. *** When to use - Recurrence relation → translates to algebraic/differential equation for A(x) - Counting problem with a recursive structure - You need a closed form for Σ a_n or a_n itself *** Common generating functions 1/(1-x) generates {1,1,1,...} 1/(1-x)² generates {1,2,3,...} e^x generates {1/n!} -ln(1-x) generates {1/n} 1/(1-x-x²) generates Fibonacci *** Exponential generating functions Â(x) = Σ a_n x^n/n! Product ·B̂ corresponds to "interleaving" (binomial convolution) Use for labeled structures (permutations, set partitions, etc.) ** Recognizing hidden structure in sums :sumtricks: *** Telescoping Σ [f(k) - f(k+1)] = f(1) - f(n+1) Partial fractions often reveal telescoping: 1/(k(k+1)) = 1/k - 1/(k+1) *** Abel summation (summation by parts) Σ a_k b_k = A_n b_n - Σ A_k (b_{k+1} - b_k) where A_k = Σ_{j≤k} a_j Discrete analog of integration by parts. Use when one factor has known partial sums. *** Recognize a derivative or integral Σ n x^n = x d/dx [Σ x^n] = x d/dx [1/(1-x)] = x/(1-x)² Σ x^n/n = -ln(1-x) = ∫ Σ x^{n-1} dx General principle: if the sum is hard, differentiate or integrate w.r.t. a parameter to simplify, then undo. *** Interchange sum and integral Σ ∫ = ∫ Σ (when justified by dominated convergence / Fubini) Often one order is easy, the other is hard. Σ 1/n² = Σ ∫_0^1 ∫_0^1 x^{n-1} y^{n-1} dx dy → leads to ζ(2) = π²/6 proof *** The "what does this sum count?" trick Sometimes a combinatorial sum is easier to evaluate by asking what it's counting, then counting that thing a different way. Double counting / bijective proof. ** Accelerating slow series :acceleration: *** Euler-Maclaurin for slowly converging sums Turn Σ into ∫ plus correction terms (Bernoulli numbers) Good for Σ 1/n^s type sums *** Euler transformation for alternating series Σ (-1)^n a_n = Σ (-1)^n Δ^n a_0 / 2^{n+1} where Δ^n a_0 = Σ (-1)^k C(n,k) a_{n-k} Can dramatically speed up convergence *** Richardson extrapolation (general) If S(h) = S + c₁h^p + c₂h^{2p} + ..., then S* = (2^p S(h/2) - S(h)) / (2^p - 1) eliminates leading error term Apply repeatedly: this is the idea behind Romberg, Aitken Δ², etc. *** Shanks transformation s_n = partial sums: e_1(s_n) = (s_{n+1}s_{n-1} - s_n²)/(s_{n+1} + s_{n-1} - 2s_n) Accelerates geometric-like convergence * How to Do Linear Algebra by Thinking ** Rank-one thinking :rank1: *** Most updates are rank-1 (or low-rank) "I changed one data point" → rank-1 update to a matrix Sherman-Morrison tells you the new inverse without recomputing Matrix determinant lemma tells you the new determinant Think of rank-1 updates as the derivative of matrix operations *** Dyadic (outer product) decomposition Any rank-r matrix = sum of r rank-1 matrices: A = Σ σ_i u_i v_i^T The SVD gives you this decomposition optimally When r is small, everything is cheap ** The trace trick :trace: *** tr(AB) = tr(BA) — use this to reorder ∂/∂A tr(AB) = B^T ∂/∂A tr(A^T B) = B ∂/∂A tr(A^T A) = 2A ∂/∂A ln det(A) = A^{-T} *** Log-determinant via trace ln det(A) = tr(ln A) det(I + εB) ≈ 1 + ε tr(B) *** Expectation of quadratic form E[x^T A x] = tr(A Σ) + μ^T A μ for x ~ N(μ, Σ) ** Think geometrically :geometric: *** What does this matrix DO? Before computing, ask: rotation? scaling? projection? shear? SVD decomposes any matrix into rotate-scale-rotate Eigenvalues tell you the scaling factors (along eigenvectors) *** Projection matrices P = A(A^TA)^{-1}A^T projects onto column space of A P² = P, P^T = P, rank(P) = rank(A) I - P projects onto the orthogonal complement Least squares: x̂ = (A^TA)^{-1}A^Tb ← this IS the projection *** Volume = |det| |det(A)| = volume of parallelepiped spanned by columns of A det(AB) = det(A)det(B): volumes multiply Singular matrix: collapsed volume (dependent columns) ** When to avoid forming the matrix :implicit: *** Matrix-free methods CG and GMRES only need the ACTION of A on a vector (matrix-vector multiply) You never need to store A explicitly if you can compute Ax Huge for PDE discretizations: operator is sparse or structured *** Schur complement Instead of inverting the full block matrix, eliminate one block: [A B; C D]x = f → solve (A - BD⁻¹C)x₁ = f₁ - BD⁻¹f₂ Then x₂ = D⁻¹(f₂ - Cx₁) Reduces an (n+m)×(n+m) solve to an n×n solve *** Woodbury: update cheaply, don't recompute Changing k rows/columns of an n×n matrix? Woodbury costs O(n²k + k³) instead of O(n³) * How to Make a Model (or Simplify One) ** Identify the small parameter :modeling: *** Every approximation has one — name it Pendulum: θ₀ (small angle) Fluid flow: 1/Re (slow flow), or Re (viscous effects small) Quantum: ℏ (semiclassical) Thin plate: h/L (thickness / extent) *** Nondimensionalize first Divide every variable by its characteristic scale The equation will naturally reveal which terms are O(1) and which are O(ε). Drop the small ones. This is not laziness — it's the systematic way to derive approximations. The ε tells you the error. ** Dominant balance revisited :dombal: *** In an equation with several terms, at any point or limit, only 2-3 terms matter. The rest are corrections. Which terms balance which determines the regime. *** Recipe 1. Assume two specific terms dominate 2. Solve the reduced equation 3. Check that the neglected terms are indeed smaller 4. If not, try a different pair *** This is how you derive - Boundary layer thickness (viscous vs convective balance) - WKB validity criterion - Transition points between regimes - Scaling laws ** Symmetry and conservation laws :symmetry:noether: *** Noether's theorem (informal) Every continuous symmetry → conserved quantity Time translation → energy conservation Space translation → momentum conservation Rotation → angular momentum conservation *** Use symmetry BEFORE solving If the problem has rotational symmetry, the answer can't depend on angle. If the equation is translation-invariant, look for traveling wave solutions. If there's a discrete symmetry (reflection), solutions are even or odd. *** Conservation laws reduce order Hamiltonian H(p,q) = const turns a 2nd-order ODE into a 1st-order one. Any first integral reduces the order by one. Two integrals of a 2D system → the solution (quadrature). * How to Think About Probability ** The indicator variable method :indicator: *** Turn counting into summation X = "number of things with property P" = Σ I(thing i has P) E[X] = Σ P(thing i has P) — always valid, no independence needed Var(X) = Σ Var(I_i) + 2 Σ_{i -1, λ → ∞ ** Stationary phase :stationaryphase: ∫ f(x) e^{iλg(x)} dx as λ → ∞ Oscillations cancel everywhere EXCEPT near stationary points g'(x₀)=0 I ~ f(x₀) e^{iλg(x₀)} √(2π/(λ|g''(x₀)|)) e^{±iπ/4} (sign of π/4 depends on sign of g'') ** Steepest descent (saddle point) :saddlepoint: Deform contour in complex plane to pass through saddle of Re(g(z)) Along steepest descent path, Im(g) = const (no oscillation) Reduces to Laplace's method on the deformed contour This is the "professional" version of Laplace's method. ** Matched asymptotic expansions :matching: *** The method 1. Outer expansion: valid away from boundary layer, set ε=0 2. Inner expansion: rescale near boundary (ξ = x/ε^α), solve 3. Matching: require outer(x→0) = inner(ξ→∞) in overlap region 4. Composite: y_composite = y_inner + y_outer - y_match *** How to find the layer thickness Dominant balance: if ε y'' and y' balance, then ε/δ² ~ 1/δ → δ ~ ε If ε y'' and y balance, then ε/δ² ~ 1 → δ ~ √ε The scaling is dictated by which terms must balance. * How to Use a Computer Wisely :numerical: ** Before coding: think *** Paper estimate first If you don't know approximately what the answer should be, you can't tell if the computer is giving you garbage. *** Is there a closed form you're missing? 20 minutes of algebra can save 20 hours of debugging numerical code. Try: Mathematica/Wolfram Alpha / OEIS / DLMF before writing a solver. ** Numerical common sense *** Avoid subtracting nearly equal numbers a - b when a ≈ b: use algebraic rearrangement log(1+x) for small x: use log1p(x) e^x - 1 for small x: use expm1(x) 1 - cos(x) for small x: use 2sin²(x/2) *** Avoid computing things you don't need det(A) for solving Ax=b? Never. Use LU. A^{-1} explicitly? Almost never. Solve the system. A^{-1}B? Solve AX=B instead. *** Choose the right algorithm for the structure Sparse → iterative solver (CG, GMRES), not dense LU Symmetric positive definite → Cholesky, not general LU Banded → banded solver, O(nb²) not O(n³) Low-rank update → Sherman-Morrison, not full re-solve Structured (Toeplitz, circulant) → FFT-based, O(n log n) *** Monte Carlo: when all else fails Expected value of anything: sample and average Variance reduction: importance sampling, antithetic variates, control variates, stratification Error ~ 1/√N regardless of dimension (curse of dimensionality beaten) Good for d > 4 where quadrature needs too many points ** Convergence checks :convergtic: *** Richardson extrapolation (again) Run at h and h/2. If the answers agree to k digits, you have ~k digits. If they don't agree, halve h again. If they STILL don't agree, your method may be wrong (not just underresolved). *** Grid refinement study Plot error vs h on log-log. Slope should match theoretical order. If slope is wrong, look for: bugs, singular solutions, wrong BC. *** Compare two different methods If RK4 and Adams-Bashforth give the same answer, it's probably right. If they disagree, investigate. This is cheap insurance.

Ara / アラ