Linear Regression: Line of Best Fit
Problem
Fit a line to data: (1,2), (2,4), (3,5), (4,4), (5,5). Show residual squares minimized.
Explanation
What is linear regression?
Linear regression finds the line that minimizes the sum of squared residuals — the squared vertical distances from each point to the line.
Step-by-step: {(1,2), (2,4), (3,5), (4,4), (5,5)}
Step 1 — Compute sums. , , , , .
Step 2 — Slope:
Step 3 — Intercept:
Result:
Step 4 — : Measures how well the line fits. is perfect; means the line explains nothing.
Residuals
A residual is (actual minus predicted). The regression line minimizes .
Try it in the visualization
Scatter plot with the regression line. Residual lines connect each point to the line. Toggle "squared residuals" to see them as literal squares — the line minimizes total square area.
Interactive Visualization
Parameters
Got your own math or physics problem?
Turn any problem into an interactive visualization like this one — powered by AI, generated in seconds. Free to try, no credit card required.