Shows a set of data points with a line model ŷ = β₀ + β₁x. The line smoothly morphs from a poor initial guess to the least-squares fit while residuals and their squared-error “blocks” visualize SSE = Σ(y−ŷ)². A matrix panel depicts X (with a column of ones for the intercept), β, and y, then highlights the normal equations (XᵀX)β = Xᵀy as the condition ∇β SSE = 0.
Self-contained Canvas 2D draw function. Uses deterministic synthetic data, precomputes the closed-form normal-equation solution for 1D + intercept, and animates β by easing between a start vector and β̂. Residuals are drawn as vertical lines plus blocky squares proportional to |residual| to emphasize SSE minimization. Responsive scaling via scale=Math.min(w,h)/240 and grid snapping for a retro aesthetic.