Curve fitting made visible. Drag a cloud of data points and watch the best-fit polynomial re-solve in real time — the workhorse behind every trendline and regression model.
Least Squares StudioLive
polynomial regression via normal equations
Controls
Drag any point to reshape the cloud and watch the best-fit curve re-solve instantly. Pink segments are the residuals least squares minimizes; raise the degree to bend the curve — and to see overfitting.
Reading this result: Least squares picks the coefficients that minimize Σ(yᵢ − ŷᵢ)² — the total squared length of the pink residual segments. Solving the normal equations (XᵀX)β = Xᵀy yields that minimum directly, no iteration. This degree-1 fit explains R² = 0.989 of the variance (RMSE 0.22). Raise the degree to bend the curve — but push it too high and it starts chasing noise instead of the underlying trend.
Runs locally in your browser — free forever. Scale to the cloud when reality gets heavy.
★ Sign in to save this setupSave your tuned setup, or drop this simulation into your own site, docs, or course page.
How it works
Least-squares fitting chooses the polynomial coefficients that minimize the sum of squared vertical residuals between the data and the curve. This studio solves the normal equations (XᵀX)β = Xᵀy directly with Gaussian elimination — the same closed-form linear-algebra route numpy's polyfit and lstsq take. Drag points to reshape the data, raise the degree to bend the curve through more points, and watch R² climb toward 1 while the fit starts chasing noise: a hands-on look at the bias-variance tradeoff and overfitting.
✦
Ask the AI about this model
The math, the assumptions, real-world uses, or a code translation — explained for this exact simulation.
Is this least squares regression fit tool really free?▾
Yes. Least Squares runs entirely in your browser using your device's own compute, so local use is free forever. You only pay Compute Tokens if you scale a job to the cloud.
Do I need to install anything?▾
No. Everything runs client-side in a modern browser — no downloads, no license, no account required to start.
Can I save or share my simulation?▾
Create a free account to save projects, and use a shareable embed or minted DOI to publish a live, interactive version anywhere.
How accurate are the results?▾
The solver uses established numerical methods, but results are for research and educational purposes and should be validated against experiment or professional review before you rely on them.