Visualizes how the Lagrangian L(x,λ)=f(x)+λg(x) combines objective and constraints, how the dual function d(λ)=inf_x L(x,λ) produces a lower bound on the primal optimum (weak duality), and how dual ascent updates λ using the constraint residual g(x*(λ)) to maximize d(λ). The left plot shows f(x) and L(x,λ) for a changing multiplier, with horizontal lines for d(λ) and p*. The right panel displays the key equations and live values.
Uses a 1D convex quadratic objective with a single inequality constraint so L(x,λ) and d(λ) are explicit. The animation cycles through three stages and, in the final stage, runs a projected dual-ascent update λ←max(0,λ+α g(x*(λ)) dt). Rendering is grid-snapped for a blocky aesthetic and scaled via scale=Math.min(w,h)/baseSize.