Fit a line when equations disagree
Which line minimizes the squared residuals of three observations?
Entering midway? A residual is observed minus predicted. Squaring makes either sign contribute nonnegative error.
Start with a concrete question
Observe (0,1), (1,middle), (2,3). Compare an adjustable line with intercept 1 against the full least-squares fit.
Try the initial inputs, then write a prediction before changing one setting. All calculations run locally on your CPU.
Go directly to the experiment · Review prerequisite mathematics and return here
What do you expect?
Predict before calculating: Which line minimizes the squared residuals of three observations?
Change one thing. Inspect what happens.
- Compute each residual and its square.
- Move the middle point and see why an exact fit may not exist.
- Compare the candidate with the fit that may adjust both slope and intercept.
- Check that optimum residuals sum to zero, then explain what that does not prove.
Your settingsMechanism
Calculation belowEvidence
Compare outcomes
Observed points, candidate and least-squares line
Horizontal: x (input units). Vertical: y (output units).
- 1. observations (points)
- 2. candidate intercept 1 (dashed line)
- 3. least-squares fit (dashed line)
- 4. candidate residual at x=0 (dashed line)
- 5. candidate residual at x=1 (dashed line)
- 6. candidate residual at x=2 (dashed line)
Axes use the displayed ranges.
Read plotted values as a table
| Series | x (input units) | y (output units) |
|---|---|---|
| observations | 0 | 1 |
| observations | 1 | 2 |
| observations | 2 | 3 |
| candidate intercept 1 | 0 | 1 |
| candidate intercept 1 | 2 | 3 |
| least-squares fit | 0 | 1 |
| least-squares fit | 2 | 3 |
| candidate residual at x=0 | 0 | 1 |
| candidate residual at x=0 | 0 | 1 |
| candidate residual at x=1 | 1 | 2 |
| candidate residual at x=1 | 1 | 2 |
| candidate residual at x=2 | 2 | 3 |
| candidate residual at x=2 | 2 | 3 |
Follow the calculation
- Point (0,1); candidate 1; residual observed−predicted=0.
- Point (1,2); candidate 2; residual observed−predicted=0.
- Point (2,3); candidate 3; residual observed−predicted=0.
- Mean x=1; mean y=2. Sum (x−mean x)²=2; sum (x−mean x)(y−mean y)=2.
- Best slope=2/2=1; intercept=mean y−1=1.
- Sum squared residuals=0; least-squares fit=0. Residuals at the optimum sum to 0.0000000000 (rounding shown).
Least squares chooses a line that minimizes squared vertical errors. It does not make every point fit, prove a causal relationship or guarantee accurate extrapolation.
Captures keep your inputs, prediction and observation. Results are recalculated from those inputs. Resetting inputs keeps your captures and challenge history.
Explain the mechanism
Fit a line when equations disagree
Observe (0,1), (1,middle), (2,3). Compare an adjustable line with intercept 1 against the full least-squares fit.
Concepts to recall
A residual is observed minus predicted. Squaring makes either sign contribute nonnegative error.
Understand the mechanism
At middle=2, y=x+1 fits all three points exactly.
At middle=4, mean y=8/3 and mean x=1. The best slope remains 1 while intercept becomes 5/3.
The normal equations make residuals orthogonal to the constant and x columns. Here their sum and x-weighted sum vanish up to floating-point rounding. This is a projection onto the span of those design columns.
Symbols and calculation
m=Σ(x−x̄)(y−ȳ)/Σ(x−x̄)²; b=ȳ−m x̄; SSE=Σ[y−(mx+b)]². m is slope, b intercept, bars are means.
Worked example
Point (0,1); candidate 1; residual observed−predicted=0.
Point (1,2); candidate 2; residual observed−predicted=0.
Point (2,3); candidate 3; residual observed−predicted=0.
Mean x=1; mean y=2. Sum (x−mean x)²=2; sum (x−mean x)(y−mean y)=2.
Best slope=2/2=1; intercept=mean y−1=1.
Sum squared residuals=0; least-squares fit=0. Residuals at the optimum sum to 0.0000000000 (rounding shown).
Your investigation
Compute each residual and its square.
Move the middle point and see why an exact fit may not exist.
Compare the candidate with the fit that may adjust both slope and intercept.
Check that optimum residuals sum to zero, then explain what that does not prove.
Limits and interpretation
- These are bounded teaching models with explicit assumptions, not evidence of a real-world intervention.
Try a fresh case
Observed values are 2,4,5; predictions are 1,4,7. What is the sum of squared residuals?
This is a public practice check. Retries support learning; matching a number does not certify independent proficiency.
Take the investigation further
Choose any extension. These are project prompts for you to carry out; they are not automatically assessed.
School investigation
Explain a fresh small numerical case with a diagram or table and an argument.
College investigation
Implement the method, test a boundary or counterexample, and justify its assumptions.
Workplace investigation
Use a small decision scenario, state units and constraints, and test how the recommendation changes.
Keep the evidence, choose your next step
Completion records your own decision that you have worked through this investigation. Practice checks and independent project evidence are separate.