Learn

Learning preferences

Make learning more comfortable. Changes apply immediately.

Enlarges page content, including diagrams and their labels. You can also use your browser’s zoom.

Choose the colours that are easiest for you to distinguish. Applies to lesson diagrams and lab plots. Labels, shapes, hatching and line patterns also distinguish meanings. Source photographs and raw image brightness stay unchanged; mask-only views are available for image overlays.

ExampleComparisonSample link

Saved in this browser on this device. Preferences are separate from progress backups.

Learn through experiments

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.

1 · Try

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

2 · Predict

What do you expect?

Predict before calculating: Which line minimizes the squared residuals of three observations?

3 · Experiment

Change one thing. Inspect what happens.

  1. Compute each residual and its square.
  2. Move the middle point and see why an exact fit may not exist.
  3. Compare the candidate with the fit that may adjust both slope and intercept.
  4. Check that optimum residuals sum to zero, then explain what that does not prove.
Experiment inputs
Inputs
Your settings
Mechanism
Calculation below
Evidence
Compare outcomes
Candidate squared residual sum0 squared units
Best squared residual sum0 squared units
Best slope1 y units per x
Best intercept1 y units

Observed points, candidate and least-squares line

Horizontal: x (input units). Vertical: y (output units).

-1-21338observations: (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)
  • 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
Seriesx (input units)y (output units)
observations01
observations12
observations23
candidate intercept 101
candidate intercept 123
least-squares fit01
least-squares fit23
candidate residual at x=001
candidate residual at x=001
candidate residual at x=112
candidate residual at x=112
candidate residual at x=223
candidate residual at x=223

Follow the calculation

  1. Point (0,1); candidate 1; residual observed−predicted=0.
  2. Point (1,2); candidate 2; residual observed−predicted=0.
  3. Point (2,3); candidate 3; residual observed−predicted=0.
  4. Mean x=1; mean y=2. Sum (x−mean x)²=2; sum (x−mean x)(y−mean y)=2.
  5. Best slope=2/2=1; intercept=mean y−1=1.
  6. 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.

4 · Understand

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

  1. Compute each residual and its square.

  2. Move the middle point and see why an exact fit may not exist.

  3. Compare the candidate with the fit that may adjust both slope and intercept.

  4. 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.
5 · Apply

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.

6 · Continue

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.