PPolySim OS

Least Squares

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

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.

Presets

▶ Run in Python

Data Inspector

R²0.9888
RMSE0.225
Degree1
Data points10
Methodnormal equations
ŷ = 1.03 + 0.804·x

Governing equation

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.

or unlock everything with Pro →
★ Sign in to save this setup
Save 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.

More Linear Algebra simulations

Frequently asked questions

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.