Curve Fitting: Best-Fit Line & Regression
Drag data points and watch the best-fit line, quadratic and cubic curves and R² update.
Drag the data points around, or click on the graph to add points. The best-fit line or curve updates instantly. Try different fit types and watch the error.
About the Curve Fitting: Best-Fit Line & Regression
Free curve fitting: best-fit line & regression. Drag data points and watch the best-fit line, quadratic and cubic curves and R² update. Drag, change the sliders and see the result live. No sign-up, works on phone and computer. Built for math, the curve fitting: best-fit line & regression runs instantly in your browser: change a setting or drag an object and the result updates at once, so you learn by trying things out rather than only reading about them.
Drag data points and watch the best-fit line, quadratic and cubic curves and R² update. Use it to explore math ideas at your own pace, then check what you found against the key ideas further down this page.
How to use the Curve Fitting: Best-Fit Line & Regression
- Use the controls to change Fit, Residuals, Data set. The simulation reacts instantly.
- Pick an option such as Line, Quadratic, Cubic, Show to switch modes or load an example.
- Press "Remove last point", "Clear" to start, reset or change what is happening.
- Where you see a glowing handle, object, weight or atom, drag it with your mouse or finger. Everything responds in real time.
- Watch the readouts and graphs update as you experiment, and compare what you see with the key ideas below.
Things to try
- Drag one point far away and watch the line move.
- Fit a curved data set with a line and a quadratic.
- Add points by clicking.
Key ideas you can learn
- Least squares finds the curve that makes the total squared error smallest.
- R² close to 1 means a good fit.
- Higher-degree curves can over-fit.
- Outliers pull the fit.
Where this is used in the real world
Scientists, economists and engineers fit curves to data to find trends and predict.
Who is this simulation for?
Algebra, geometry, trigonometry and calculus students, teachers preparing demonstrations, and self-learners who want to see the maths move.
For teachers: project it on the board, let students predict what will happen, then run it together. For students: change one thing at a time and write down what changes.
Frequently asked questions
What is a line of best fit?
The straight line that has the smallest total squared distance from all the points.
What is R²?
The fraction of the variation in the data that the fit explains.
Is the Curve Fitting: Best-Fit Line & Regression free to use?
Yes. It is completely free, with no signup, no download and no ads inside the simulation. It runs in your web browser.
Does the Curve Fitting: Best-Fit Line & Regression work on a phone or tablet?
Yes. It uses touch as well as the mouse, so you can drag objects with your finger. A larger screen makes the controls easier to see.