Type at least 2 letters. Enter opens the first result, Esc closes.

    Quick recap

    The key takeaways of every lesson on one page. Read it in ten minutes to refresh the whole track; open a lesson when a point feels unclear.

    01 Derivatives in one variable

    • The derivative is the limit of difference quotients: f′(x)=lim⁡h→0(f(x+h)−f(x))/hf'(x) = \lim_{h \to 0} \big(f(x+h) - f(x)\big)/h, the slope of the tangent line.
    • Equivalently, f(x+h)=f(x)+f′(x) h+r(h)f(x+h) = f(x) + f'(x)\,h + r(h) with r(h)/h→0r(h)/h \to 0: the tangent line is the best linear approximation.
    • ∣x∣|x| and ReLU have no derivative at 0 (the one-sided slopes differ); frameworks use the subgradient value 00 there.
    • Rules: linearity, (fg)′=f′g+fg′(fg)' = f'g + fg', and the chain rule (f(g(x)))′=f′(g(x)) g′(x)\big(f(g(x))\big)' = f'(g(x))\,g'(x): rates multiply.
    • σ′=σ(1−σ)≤1/4\sigma' = \sigma(1 - \sigma) \le 1/4, tanh⁡′=1−tanh⁡2\tanh' = 1 - \tanh^2, ddxlog⁡(1+ex)=σ(x)\frac{d}{dx}\log(1 + e^x) = \sigma(x).
    • f′′≥0f'' \ge 0 on an interval means convex. At a critical point, f′′>0f'' > 0 gives a strict local minimum, f′′<0f'' < 0 a maximum, and f′′=0f'' = 0 decides nothing.
    • Taylor: f(x0+h)=∑j≤kf(j)(x0)hj/j!+f(k+1)(ξ)hk+1/(k+1)!f(x_0 + h) = \sum_{j \le k} f^{(j)}(x_0) h^j / j! + f^{(k+1)}(\xi) h^{k+1}/(k+1)!; the error has order hk+1h^{k+1}.
    • Gradient descent on a2x2\tfrac a2 x^2 multiplies xx by 1−ηa1 - \eta a per step and converges exactly when 0<η<2/a0 < \eta < 2/a.

    02 Partial derivatives and the gradient

    • A function of two variables can be drawn as a surface z=f(x,y)z = f(x, y) or as a contour plot of level sets {f=c}\{f = c\}; close contour lines mean a steep function.
    • The partial derivative ∂f/∂xi\partial f/\partial x_i is the ordinary derivative in xix_i with all other variables fixed: the slope of a slice.
    • The gradient ∇f(x)=(∂1f,…,∂nf)⊤\nabla f(x) = (\partial_1 f, \dots, \partial_n f)^\top is a column vector in the input space Rn\R^n.
    • ff is differentiable at xx if f(x+h)=f(x)+∇f(x)⊤h+o(∥h∥)f(x + h) = f(x) + \nabla f(x)^\top h + o(\|h\|); then Dvf(x)=∇f(x)⊤vD_v f(x) = \nabla f(x)^\top v.
    • Among unit directions, ∇f/∥∇f∥\nabla f/\|\nabla f\| gives the largest slope ∥∇f∥\|\nabla f\| and −∇f/∥∇f∥-\nabla f/\|\nabla f\| the smallest (Cauchy–Schwarz).
    • The gradient is perpendicular to the level set through its base point.
    • In a stretched bowl x2+κy2x^2 + \kappa y^2, −∇f-\nabla f does not point at the minimum, and gradient descent zig-zags; the best rate per step is (κ−1)/(κ+1)(\kappa - 1)/(\kappa + 1).
    • Existing partial derivatives do not imply differentiability (xy/(x2+y2)xy/(x^2 + y^2) at 0); continuous partial derivatives (C1C^1) do.

    03 Jacobians, Hessians and Taylor

    • The derivative of f:Rn→Rmf:\R^n\to\R^m is the m×nm\times n Jacobian Df(x)Df(x) with f(x+h)=f(x)+Df(x)h+o(∥h∥)f(x+h) = f(x) + Df(x)h + o(\|h\|); its entries are ∂fi/∂xj\partial f_i/\partial x_j.
    • Shapes: Jacobian outputs × inputs; gradient ∇f=Df⊤∈Rn\nabla f = Df^\top \in \R^n (a column here, a row in MML); Hessian n×nn \times n.
    • D(Wx)=WD(Wx) = W; an elementwise map has Dφ=diag⁡(φ′(x))D\varphi = \operatorname{diag}(\varphi'(x)); polar coordinates have det⁡Df=r\det Df = r.
    • If f∈C2f \in C^2, the Hessian is symmetric (Schwarz), and f(x+h)f(x+h) equals f(x)+∇f⊤h+12h⊤∇2f hf(x) + \nabla f^\top h + \tfrac12 h^\top \nabla^2 f\, h up to an error o(∥h∥2)o(\|h\|^2) (Taylor).
    • Minimizing the quadratic model gives the Newton step: solve Hh=−gHh = -g. It is a descent direction when H≻0H \succ 0; with an indefinite HH it goes to the model's saddle.
    • At a critical point: all Hessian eigenvalues >0> 0 gives a strict local minimum, mixed signs a saddle; a zero eigenvalue with no negative one leaves the test undecided.
    • Taylor test: ∣f(x+td)−f(x)−tg~⊤d∣|f(x+td) - f(x) - t\tilde g^\top d| has order 2 if g~\tilde g is the gradient and order 1 if not; use float64, a random dd and the middle range of tt.

    04 Chain rule and computational graphs

    • Chain rule: D(g∘f)(x)=Dg(f(x)) Df(x)D(g\circ f)(x) = Dg(f(x))\,Df(x), shapes (p×m)(m×n)=p×n(p\times m)(m\times n) = p\times n. The map applied first stands on the right; the outer Jacobian is evaluated at f(x)f(x).
    • Entry form: ∂(g∘f)i/∂xj=∑k(∂gi/∂uk)(∂fk/∂xj)\partial(g\circ f)_i/\partial x_j = \sum_k (\partial g_i/\partial u_k)(\partial f_k/\partial x_j), a sum over the intermediate variables.
    • For a scalar loss, the gradient through a map is a vector-Jacobian product: xˉ=Df(x)⊤uˉ\bar x = Df(x)^\top\bar u, where uˉ=∂ℓ/∂u\bar u = \partial\ell/\partial u is the adjoint of u=f(x)u = f(x).
    • The three basic VJPs: xˉ=W⊤zˉ\bar x = W^\top\bar z for z=Wxz = Wx; zˉ=φ′(z)⊙aˉ\bar z = \varphi'(z)\odot\bar a for an elementwise a=φ(z)a = \varphi(z); Wˉ=zˉ x⊤\bar W = \bar z\,x^\top (rank 1 for one sample).
    • Fan-out: when a value is used in several places, the contributions of all paths add, xˉ=Df⊤uˉ+Dg⊤wˉ\bar x = Df^\top\bar u + Dg^\top\bar w. Residual connections and shared weights are fan-out.
    • A computational graph has one node per primitive operation. The backward sweep vˉj=∑children ivˉi ∂vi/∂vj\bar v_j = \sum_{\text{children } i}\bar v_i\,\partial v_i/\partial v_j (seed yˉ=1\bar y = 1) gives all partial derivatives of one output; the forward sweep gives one directional derivative.
    • For f=ln⁡x1+x1x2−sin⁡x2f = \ln x_1 + x_1x_2 - \sin x_2 at (2,5)(2, 5): f=11.652f = 11.652, ∂f/∂x1=5.5\partial f/\partial x_1 = 5.5, ∂f/∂x2=2−cos⁡5=1.716\partial f/\partial x_2 = 2 - \cos 5 = 1.716.

    05 Forward and reverse mode autodiff

    • Automatic differentiation applies the chain rule to the primitive operations of a program at the current numbers. It is exact up to rounding, has no step size, and handles loops and branches (it differentiates the branch that ran).
    • Forward mode carries (value, tangent) pairs; one pass gives a JVP Jx˙J\dot x, one column of JJ for x˙=ej\dot x = e_j. It needs no tape.
    • Dual numbers a+bεa + b\varepsilon with ε2=0\varepsilon^2 = 0 implement forward mode: f(a+bε)=f(a)+f′(a) b εf(a + b\varepsilon) = f(a) + f'(a)\,b\,\varepsilon.
    • Reverse mode records a tape in the forward run, then accumulates vˉj+=vˉi ∂vi/∂vj\bar v_j \mathrel{+}= \bar v_i\,\partial v_i/\partial v_j in reverse order; one pass gives a VJP u⊤Ju^\top J, one row of JJ.
    • One pass of either mode costs at most a small constant times one evaluation (c<6c < 6, typically 2–3). The full Jacobian of Rn→Rm\R^n\to\R^m needs nn JVPs or mm VJPs.
    • Cheap gradient principle: the gradient of a scalar function costs a constant times the function, for any number of inputs. Forward mode wins when inputs are few and outputs are many.
    • Reverse mode stores the values of the forward run, so memory grows with depth and batch. Checkpointing every k≈Lk \approx \sqrt L layers lowers the peak to about 2L2\sqrt L activations for at most one extra forward pass.

    06 Backprop: MLPs, losses, layers

    • Backprop for an MLP with softmax cross-entropy: δL=p−ey\delta^L = p - e_y, δl=φ′(zl)⊙(Wl+1)⊤δl+1\delta^l = \varphi'(z^l)\odot(W^{l+1})^\top\delta^{l+1}, ∂ℓ/∂Wl=δl(al−1)⊤\partial\ell/\partial W^l = \delta^l(a^{l-1})^\top, ∂ℓ/∂bl=δl\partial\ell/\partial b^l = \delta^l.
    • For one sample, the gradient of a weight matrix is an outer product (rank at most 1); for a batch, ∂ℓ/∂Wl=(Δl)⊤Al−1\partial\ell/\partial W^l = (\Delta^l)^\top A^{l-1} has rank at most BB.
    • With a mean loss over a batch, the factor 1/B1/B enters once, in ΔL=(P−Y)/B\Delta^L = (P - Y)/B. The backward pass costs about two forward passes and needs the stored activations.
    • Least squares 12n∥Xw−y∥2\frac1{2n}\|Xw - y\|^2: gradient 1nX⊤(Xw−y)\frac1n X^\top(Xw - y), Hessian 1nX⊤X⪰0\frac1n X^\top X \succeq 0; one Newton step reaches the minimizer.
    • Logistic regression: gradient 1nX⊤(σ(Xw)−y)\frac1n X^\top(\sigma(Xw) - y), Hessian 1nX⊤SX\frac1n X^\top S X with S=diag⁡(σ(1−σ))S = \operatorname{diag}(\sigma(1 - \sigma)); convex, but on separable data no minimizer exists.
    • Softmax cross-entropy ℓ=lse⁡(z)−zy\ell = \operatorname{lse}(z) - z_y has gradient p−eyp - e_y and Hessian diag⁡(p)−pp⊤⪰0\operatorname{diag}(p) - pp^\top \succeq 0. Compute lse⁡(z)=m+log⁡∑kezk−m\operatorname{lse}(z) = m + \log\sum_k e^{z_k - m} with m=max⁡kzkm = \max_k z_k.
    • Layer norm backward: dx=1σ(g^−mean⁡(g^)−x^ mean⁡(g^⊙x^))dx = \frac1\sigma\big(\hat g - \operatorname{mean}(\hat g) - \hat x\,\operatorname{mean}(\hat g\odot\hat x)\big); its entries sum to 0, and it is orthogonal to x^\hat x when ε=0\varepsilon = 0.
    • The input-side error δ1\delta^1 is a product of L−1L - 1 transposed layer Jacobians, so it can vanish or explode exponentially with depth.

    07 Finite differences and gradient checks

    • Forward difference (f(x+h)−f(x))/h(f(x+h) - f(x))/h has truncation error h2f′′\tfrac h2 f'': first order. Central difference (f(x+h)−f(x−h))/(2h)(f(x+h) - f(x-h))/(2h) has h26f′′′\tfrac{h^2}{6}f''': second order.
    • Rounding adds an error of about ε∣f∣/h\varepsilon|f|/h, so the total error against hh is a V on a log–log plot; the best step is not the smallest.
    • Optimal steps in float64: about ε≈10−8\sqrt\varepsilon \approx 10^{-8} for the forward difference (about 8 correct digits) and ε1/3≈10−5\varepsilon^{1/3} \approx 10^{-5} for the central one (about 10–11 digits); scale them by max⁡(1,∣xi∣)\max(1, |x_i|).
    • The complex step Im⁡f(x+ih)/h\operatorname{Im} f(x+ih)/h has error O(h2)O(h^2) and no subtraction, so h=10−20h = 10^{-20} gives machine precision; the code must be analytic and complex-safe.
    • A finite-difference gradient costs nn or 2n2n evaluations of ff; a directional check ∇f⊤v\nabla f^\top v costs 2. Use them to check gradients, never to train.
    • A reliable gradient check uses float64, central differences, the relative error ∥g−gnum∥/max⁡(∥g∥,∥gnum∥)\|g - g_{\text{num}}\|/\max(\|g\|, \|g_{\text{num}}\|), a deterministic ff, a generic point and no kinks within hh.
    • For a smooth function in float64, a relative error below 10−710^{-7} is fine and above 10−310^{-3} is almost surely a bug.

    08 Hessian-vector products

    • A Hessian-vector product is the derivative of the gradient along vv: Hv=ddt∇f(x+tv)∣t=0Hv = \frac{d}{dt}\nabla f(x + tv)\big|_{t=0}.
    • Forward-over-reverse computes HvHv as a JVP of the gradient; reverse-over-reverse as ∇(∇f⊤v)\nabla(\nabla f^\top v). Both are exact because HH is symmetric.
    • One exact HVP costs a small constant times one gradient (about 2–4), for any nn. The full Hessian needs nn HVPs.
    • A central difference of two gradients approximates HvHv with best relative error about ε2/3\varepsilon^{2/3} (about 4×10−114\times10^{-11} in float64).
    • ∇2ℓ(r(θ))=J⊤∇2ℓ J+∑i∂iℓ ∇2ri\nabla^2 \ell(r(\theta)) = J^\top \nabla^2\ell\, J + \sum_i \partial_i\ell\, \nabla^2 r_i. The Gauss-Newton matrix G=J⊤∇2ℓ JG = J^\top \nabla^2\ell\, J keeps the first term.
    • G⪰0G \succeq 0 when ℓ\ell is convex, even where the Hessian is indefinite; G=∇2LG = \nabla^2 L at a perfect fit or for a linear model. Gv=J⊤(∇2ℓ (Jv))Gv = J^\top(\nabla^2\ell\,(Jv)) needs one JVP and one VJP.
    • Hutchinson: E[z⊤Az]=tr⁡A\mathbb E[z^\top A z] = \operatorname{tr} A when E[zz⊤]=I\mathbb E[zz^\top] = I. With Rademacher probes and symmetric AA, the variance is 2∑i≠jAij22\sum_{i\ne j} A_{ij}^2; Gaussian probes give 2∥A∥F22\|A\|_F^2.

    09 Implicit differentiation

    • Implicit function theorem: if F(x0,θ0)=0F(x_0, \theta_0) = 0, FF is C1C^1 and FxF_x is invertible, then near θ0\theta_0 the solution x∗(θ)x^*(\theta) is a unique C1C^1 map with Dx∗=−Fx−1FθDx^* = -F_x^{-1} F_\theta.
    • The derivative comes from differentiating F(x∗(θ),θ)=0F(x^*(\theta), \theta) = 0 with the chain rule; it does not depend on how x∗x^* was computed.
    • Fixed point x∗=f(x∗,θ)x^* = f(x^*, \theta): Dx∗=(I−fx)−1fθDx^* = (I - f_x)^{-1} f_\theta, the sum of the Neumann series ∑jfxjfθ\sum_j f_x^j f_\theta. Argmin of hh: Dx∗=−(∇xx2h)−1∇xθ2hDx^* = -(\nabla^2_{xx}h)^{-1}\nabla^2_{x\theta}h.
    • The gradient of a scalar loss needs one adjoint solve Fx⊤u=xˉF_x^\top u = \bar x and one VJP: ∇θL=∂θℓ−Fθ⊤u\nabla_\theta L = \partial_\theta \ell - F_\theta^\top u. CG (symmetric positive definite FxF_x) or GMRES do it matrix-free.
    • Unrolled backprop stores all KK iterates and has truncation error about ρK\rho^K; the implicit gradient stores only x∗x^* and its error is proportional to the forward error ∥x^−x∗∥\|\hat x - x^*\|.
    • Ridge: dw∗/dλ=−(X⊤X+λI)−1w∗dw^*/d\lambda = -(X^\top X + \lambda I)^{-1} w^*, so ∥w∗∥\|w^*\| decreases in λ\lambda, though single weights can grow.
    • The theorem fails at folds (FxF_x singular), for non-unique or non-smooth solutions, and the gradient is poor when FxF_x is ill-conditioned or the solver has not converged.

    10 Integrals and change of variables

    • The integral ∫abf dx\int_a^b f\,dx is the limit of Riemann sums ∑if(ξi) h\sum_i f(\xi_i)\,h. The fundamental theorem gives ∫abf dx=G(b)−G(a)\int_a^b f\,dx = G(b) - G(a) for any antiderivative GG. The midpoint and trapezoid rules have error O(h2)O(h^2), the left sum O(h)O(h).
    • An expectation is an integral: E[f(X)]=∫f(x) pX(x) dx\mathbb E[f(X)] = \int f(x)\,p_X(x)\,dx. The Monte Carlo average of NN samples is unbiased with standard error σ/N\sigma/\sqrt N, in any dimension.
    • Tonelli (f≥0f \ge 0) and Fubini (∫∣f∣<∞\int|f| < \infty) allow you to integrate one variable at a time, in any order.
    • In polar coordinates dx dy=r dr dθdx\,dy = r\,dr\,d\theta, because det⁡DT(r,θ)=r\det DT(r, \theta) = r.
    • Change of variables: ∫Uf(x) dx=∫Vf(T(y)) ∣det⁡DT(y)∣ dy\int_U f(x)\,dx = \int_V f(T(y))\,|\det DT(y)|\,dy for a diffeomorphism T:V→UT: V \to U. A smooth map scales small volumes by ∣det⁡DT∣|\det DT|.
    • Density of Y=g(X)Y = g(X): pY(y)=pX(x)/∣det⁡Dg(x)∣p_Y(y) = p_X(x)/|\det Dg(x)| with x=g−1(y)x = g^{-1}(y), so log⁡pY(y)=log⁡pX(x)−log⁡∣det⁡Dg(x)∣\log p_Y(y) = \log p_X(x) - \log|\det Dg(x)|. If gg is not one-to-one, add the terms of all branches.
    • For a composition of layers, the log-determinants add. A coupling layer has a triangular Jacobian with log⁡∣det⁡∣=∑isi(xA)\log|\det| = \sum_i s_i(x_A), an O(d)O(d) cost, and an exact inverse.
    • A nonlinear map moves the mode and the mean in a nonobvious way: for X∼N(0,1)X \sim N(0, 1), the mode of eXe^X is e−1e^{-1} and its mean is e1/2e^{1/2}.

    11 Gaussian integrals and Laplace

    • ∫Re−x2dx=π\int_{\R} e^{-x^2}dx = \sqrt\pi: square the integral, use polar coordinates, and the factor rr in r dr dθr\,dr\,d\theta gives an elementary antiderivative. More generally ∫e−ax2/2dx=2π/a\int e^{-ax^2/2}dx = \sqrt{2\pi/a}.
    • For symmetric A≻0A \succ 0: ∫Rde−12x⊤Ax+b⊤xdx=(2π)d/2det⁡(A)−1/2e12b⊤A−1b\int_{\R^d} e^{-\frac12 x^\top A x + b^\top x}dx = (2\pi)^{d/2}\det(A)^{-1/2}e^{\frac12 b^\top A^{-1}b}. Proof: complete the square, shift, rotate to the eigenvectors, factor.
    • The normalized density is N(A−1b,A−1)N(A^{-1}b, A^{-1}): AA is the precision matrix. The gradient of log⁡Z(b)\log Z(b) is the mean and its Hessian is the covariance.
    • The marginal likelihood of Bayesian linear regression is a Gaussian integral over the weights; its −12log⁡det⁡-\tfrac12\log\det term penalizes flexible models.
    • Gauss–Hermite: E[f(X)]≈1π∑kwkf(μ+2 σtk)\mathbb E[f(X)] \approx \frac{1}{\sqrt\pi}\sum_k w_k f(\mu + \sqrt2\,\sigma t_k) for X∼N(μ,σ2)X \sim N(\mu, \sigma^2); KK nodes are exact for polynomials of degree ≤2K−1\le 2K - 1.
    • Laplace's method: ∫e−nφ=e−nφ(x∗)(2π/n)d/2det⁡(∇2φ(x∗))−1/2(1+O(1/n))\int e^{-n\varphi} = e^{-n\varphi(x^*)}(2\pi/n)^{d/2}\det(\nabla^2\varphi(x^*))^{-1/2}(1 + O(1/n)) for a unique, nondegenerate minimum. It gives Stirling's formula n!≈2πn(n/e)nn! \approx \sqrt{2\pi n}(n/e)^n, with relative error ≈1/(12n)\approx 1/(12n).
    • Laplace approximation: p(θ∣D)≈N(θ^MAP,H−1)p(\theta \mid D) \approx N(\hat\theta_{\text{MAP}}, H^{-1}) and log⁡p(D)≈−Ψ(θ^)+d2log⁡2π−12log⁡det⁡H\log p(D) \approx -\Psi(\hat\theta) + \tfrac d2\log 2\pi - \tfrac12\log\det H, with Ψ\Psi the negative log joint and HH its Hessian. Keeping only the terms that grow with nn gives the BIC.
    • The Laplace approximation is exact for linear-Gaussian models. It fails for multimodal, skewed or bounded posteriors, modes on a boundary or at a kink, and singular or indefinite Hessians, and it depends on the parameterization.

    12 Gradients of expectations

    • When θ\theta is in the distribution, F(θ)=Epθ[f(x)]F(\theta) = \mathbb E_{p_\theta}[f(x)] changes because the density moves; autodiff through a plain sample returns 00 or an error.
    • Score-function identity (REINFORCE): ∇θF=E[f(x) ∇θlog⁡pθ(x)]\nabla_\theta F = \mathbb E[f(x)\,\nabla_\theta \log p_\theta(x)]. It needs only values of ff and works for discrete xx, but the support of pθp_\theta must not depend on θ\theta.
    • The score has mean zero, E[∇θlog⁡pθ(x)]=0\mathbb E[\nabla_\theta \log p_\theta(x)] = 0, so a baseline bb that does not depend on xx keeps the estimator unbiased; the best constant is b∗=E[fs2]/E[s2]b^* = \mathbb E[f s^2]/\mathbb E[s^2].
    • Pathwise gradient (reparameterization): with x=g(ϵ,θ)x = g(\epsilon, \theta), ∇θF=Eϵ[(∂g/∂θ)⊤∇xf(x)]\nabla_\theta F = \mathbb E_\epsilon[(\partial g/\partial\theta)^\top \nabla_x f(x)]; for a Gaussian, x=μ+σϵx = \mu + \sigma\epsilon, ∂x/∂μ=1\partial x/\partial\mu = 1, ∂x/∂σ=ϵ\partial x/\partial\sigma = \epsilon.
    • The pathwise estimator needs a differentiable path and an ff without jumps; through a jump it is biased.
    • For x∼N(2,1)x \sim N(2, 1), f=x2f = x^2: per-sample variances 44 (pathwise), 8787 (score), 3838 (score with b∗=7b^* = 7); all means are 44.
    • Score-function variance grows with ∣f∣|f| and with the dimension; pathwise variance follows the slope of ff and can be larger for fast-oscillating ff.
    • VAE encoder: pathwise. Policy gradients, discrete choices, black-box simulators: score function with a baseline.

    13 Calculus of variations

    • A functional J[u]=∫abL(x,u,u′) dxJ[u] = \int_a^b L(x, u, u')\,dx maps a function to a number; on a grid it becomes an ordinary function of the values UiU_i, and ∂Jh/∂Ui≈h δJ/δu(xi)\partial J_h/\partial U_i \approx h\,\delta J/\delta u(x_i).
    • The first variation is δJ[u;η]\delta J[u; \eta] =ddϵJ[u+ϵη]∣ϵ=0= \frac{d}{d\epsilon}J[u + \epsilon\eta]\big|_{\epsilon=0} =∫(Luη+Lpη′) dx= \int (L_u\eta + L_p\eta')\,dx, the directional derivative in the direction of a function η\eta.
    • Integration by parts and the fundamental lemma give the Euler–Lagrange equation Lu−ddxLp=0L_u - \frac{d}{dx}L_p = 0, where ddx\frac{d}{dx} is a total derivative; so δJ/δu=Lu−ddxLp\delta J/\delta u = L_u - \frac{d}{dx}L_p.
    • At a free end the minimizer satisfies the natural boundary condition Lp=0L_p = 0 (for 12u′2\tfrac12u'^2: u′=0u' = 0); prescribed values are essential conditions.
    • Euler–Lagrange is necessary only; if LL is convex in (u,p)(u, p), every solution is a global minimizer.
    • The shortest path is a straight line; the Dirichlet energy ∫(12∣∇u∣2−fu)\int(\tfrac12|\nabla u|^2 - fu) gives the Poisson equation −Δu=f-\Delta u = f.
    • Energy (Ritz) losses need half the derivatives and get natural conditions for free; residual (PINN) losses work for any PDE but have Hessian like A⊤AA^\top A, with condition number κ(A)2\kappa(A)^2.
    • Gradient descent on a discretized functional is an explicit Euler step of the gradient flow ut=−δJ/δuu_t = -\delta J/\delta u; for the Dirichlet energy this is the heat equation, stable only for τ≤h/2\tau \le h/2.