Correlation tells you two variables are related; regression gives you the equation of the line that best describes exactly how — and lets you predict y for a new x.
Level 4 HN Engineering MathsInteractive ToolsVisual DiagramsGraded Practice
2Topics
8Worked Examples
4Eng. Cases
12Practice Qs
📏Least-Squares LineFinding y = a + bx
🔮PredictionInterpolation vs extrapolation
⚙️ApplicationsReal engineering
🎮Quick-Fire GameTest your speed
📝PracticeGraded questions
🎯What you will learn
Derive and use the least-squares regression line y = a + bx; interpret the gradient and intercept in engineering terms; and use the line to predict values, understanding the danger of extrapolating beyond your data.
💡 "Least squares" means the line minimises the sum of the squared vertical distances from each point to the line — squaring stops positive and negative errors from cancelling out.
🧭How to use this resource
1. Read the rules banner at the top of each tab
2. Experiment with the interactive tool
3. Check the key vocabulary panel
4. Study the visual diagram, then the worked examples
📏
The Least-Squares Line
The unique straight line that minimises the total squared vertical distance to every data point.
📏 The Rules — Least-Squares Regression
y = a + bx
a = intercept, b = gradient of the best-fit line
b = Sxy / Sxx
Same Sxy, Sxx as Pearson's r — reuse the calculation
a = ȳ − b·x̄
The line always passes through the point (x̄, ȳ)
🔧Least-Squares Line CalculatorEnter matching x,y data
Enter matching x and y values, then press Calculate to find the gradient, intercept and the regression equation…
📖 Key Vocabulary
Regression line — the straight line that best fits a set of bivariate data.
Gradient (b) — the rate of change of y per unit increase in x.
Intercept (a) — the value of y predicted when x = 0 (only meaningful if x=0 makes physical sense).
Residual — the vertical distance between an actual data point and the regression line.
👁️ Visual aid: each point's vertical gap to the line is a residual — the regression line is chosen to make the sum of squared residuals as small as possible.
✏️Worked Example 1 — Finding the regression lineType: Full calculation
Question Find the regression line for x: 1,2,3,4,5 and y: 3,5,6,9,11.
Meansx̄=3, ȳ=6.8
Sxy, SxxSxy=20, Sxx=10
Gradientb = 20/10 = 2
Intercepta = 6.8 − 2(3) = 6.8−6 = 0.8
Answer y = 0.8 + 2x
🔍Worked Example 2 — Interpreting gradient and interceptType: Interpretation
Question For y = 0.8 + 2x, where x = furnace temperature rise (°C) and y = expansion (mm), interpret a and b physically.
Gradient b=2 Each 1°C rise adds 2 mm of expansion
Intercept a=0.8 Predicted expansion at 0°C rise (a baseline/offset — may or may not be physically meaningful)
Answer The gradient carries the real engineering meaning here; the intercept is just where the fitted line crosses x=0.
📐Worked Example 3 — Regression line through negative correlationType: Negative gradient
Question Find the regression line for x: 2,4,6,8 (mean=5) and y: 20,14,10,4 (mean=12).
Answer b=96/500=0.192, a=3.15−0.192(15)=3.15−2.88=0.27 → V = 0.27 + 0.192×Load — this equation becomes the sensor's working calibration formula.
🧠 Common slip: swapping the roles of Sxy and Sxx in the gradient formula — always b = Sxy/Sxx, never the other way round.
🔮
Prediction, Interpolation & Extrapolation
Using the regression line to estimate y — and knowing when that estimate can be trusted.
📏 The Rules — Using the Regression Line
Substitute x into y = a + bx
Gives the predicted (fitted) value of y
Interpolation = inside the data range
Generally reliable — the line is well-supported by nearby data
Extrapolation = outside the data range
Risky — the relationship may not continue in the same way
🔧Prediction CalculatorEnter the regression line and an x-value to predict
Enter a, b, the x-value to predict, and the original data's x-range, then press Predict — the tool will flag whether this is interpolation or extrapolation…
📖 Key Vocabulary
Interpolation — predicting y for an x-value within the range of the original data.
Extrapolation — predicting y for an x-value outside the original data range; increasingly unreliable the further outside you go.
Fitted value — the y-value the regression line predicts for a given x, whether or not that x was in the original data.
Line validity range — the interval of x over which the linear model is a reasonable approximation.
👁️ Visual aid: the solid section is backed by real data; the dashed sections are a guess that the same straight-line trend continues, which isn't guaranteed.
✏️Worked Example 1 — Predicting within the data range (interpolation)Type: Interpolation
Question Using y = 0.8 + 2x (data range x: 1 to 5), predict y when x = 3.5.
Check range 3.5 is within [1,5] — interpolation, generally reliable
Substitutey = 0.8 + 2(3.5) = 0.8 + 7
Answer y = 7.8
⚠️Worked Example 2 — Predicting outside the data range (extrapolation)Type: Extrapolation
Question Using the same line, predict y when x = 20, and comment on reliability.
Check range 20 is far outside [1,5] — this is extrapolation
Substitutey = 0.8 + 2(20) = 0.8 + 40 = 40.8
Answer The arithmetic gives 40.8, but this prediction should be treated with real caution — nothing guarantees the relationship stays linear that far beyond the tested range.
🎯Worked Example 3 — Comparing predicted vs actual (residual)Type: Residual
Question The line y = 0.8+2x predicts y=9.8 at x=4.5, but the actual measured value was 9.9. Find the residual.
Formularesidual = actual − predicted
Substitute9.9 − 9.8
Answer Residual = 0.1 — the actual point lies slightly above the fitted line.
⚙️Worked Example 4 — Engineering context (using a calibration line safely)Type: Engineering
Question A load cell's calibration line V = 0.27 + 0.192×Load (kg) was fitted using loads from 0 to 30 kg. An operator wants to estimate the voltage at 45 kg. Should they trust the result?
Check range 45 kg exceeds the tested range (0–30 kg)
Answer The number 8.91 mV can be calculated, but it is an extrapolation — the load cell might saturate or behave non-linearly above its tested range, so this estimate should not be used for safety-critical decisions without further testing.
🧠 Common slip: treating every regression prediction as equally trustworthy. Always state whether a prediction is interpolation or extrapolation — it fundamentally changes how much confidence to place in the answer.
⚙️
Engineering Applications
Four live scenarios — each with its own calculator. Enter your own numbers.
⚖️ Sensor Calibration Line
Fitting a straight line between known inputs and sensor outputs gives the working calibration equation for that device.
Output = a + b × Input
📟 Try it — Calibration Line Calculator
Enter input and output values, then press Calculate…
🔩 Tool Wear Prediction
A regression line between machining time and tool wear lets engineers predict when a tool will need replacing.
Wear = a + b × Time
📟 Try it — Wear Prediction Calculator
Enter time/wear data and a time to predict, then press Calculate…
🌡️ Material Expansion Model
A regression line relating temperature rise to linear expansion supports thermal design calculations.
Expansion = a + b × ΔT
📟 Try it — Expansion Model Calculator
Enter ΔT/expansion data and a ΔT to predict, then press Calculate…
🚧 Extrapolation Risk Checker
Before trusting any prediction, checking how far outside the tested range it falls quantifies the risk involved.
% beyond range = distance outside range ÷ range width × 100
📟 Try it — Extrapolation Risk Checker
Enter the data range and requested x, then press Calculate…
🎮
Quick-Fire Regression Game
12 questions on the regression line and prediction. How many can you get?
⚡ Regression Challenge
Score: 0Question: 1/12Streak: 0🔥
Press Start to begin!
📝
Practice Questions
Graded from warm-up to challenge. Attempt fully before revealing the working.
🥉 Q1–4 Warm-up🥈 Q5–8 Standard🥇 Q9–12 Challenge
Question 1 🥉2 marks
In y = a + bx, what does b represent?
The gradient — change in y per unit change in x
Question 2 🥉2 marks
If Sxy=30 and Sxx=6, find the gradient b.
30/6 = 5
Question 3 🥉2 marks
If x̄=4, ȳ=10, b=2, find the intercept a.
a = 10 − 2(4) = 10−8 = 2
Question 4 🥉2 marks
For y = 2 + 5x, predict y when x = 3.
2 + 5(3) = 2+15 = 17
Question 5 🥈4 marks
Find the regression line for x: 1,2,3,4 (mean=2.5) and y: 4,7,9,14 (mean=8.5).
Dev x: −1.5,−0.5,0.5,1.5; Dev y: −4.5,−1.5,0.5,5.5 Sxy=6.75+0.75+0.25+8.25=16 Sxx=2.25+0.25+0.25+2.25=5 b=16/5=3.2 a=8.5−3.2(2.5)=8.5−8=0.5 y = 0.5 + 3.2x
Question 6 🥈3 marks
Using y=0.5+3.2x from Q5, predict y at x=2.5 and state if this is interpolation or extrapolation (data range 1 to 4).
y=0.5+3.2(2.5)=0.5+8=8.5 Interpolation (2.5 is within [1,4])
Question 7 🥈3 marks
Using y=0.5+3.2x, predict y at x=20 and comment on reliability (data range 1 to 4).
y=0.5+3.2(20)=0.5+64=64.5 Extrapolation — far beyond tested range, unreliable
Question 8 🥈4 marks
A line predicts y=15.2 at a given x; the actual measured value is 14.7. Find the residual and state its sign meaning.
Residual = actual − predicted = 14.7−15.2 = −0.5 (actual point lies below the line)
Question 9 🥇5 marks
A load cell test: Load(kg) 0,15,30,45; Voltage(mV) 0.1,1.6,3.0,4.6. Find the calibration line.
x̄=22.5, ȳ=2.325 Dev x: −22.5,−7.5,7.5,22.5; Dev y: −2.225,−0.725,0.675,2.275 Sxy=50.0625+5.4375+5.0625+51.1875=111.75 Sxx=506.25+56.25+56.25+506.25=1125 b=111.75/1125=0.0993 a=2.325−0.0993(22.5)=2.325−2.235=0.090 V ≈ 0.090+0.0993×Load
Question 10 🥇5 marks
Using the calibration line from Q9, predict the voltage at 60 kg and discuss the risk in trusting this value.
V = 0.090+0.0993(60) = 0.090+5.958 = ≈6.05 mV 60 kg is outside the tested range (0–45 kg) — this is extrapolation; the sensor may saturate or behave non-linearly beyond its calibrated range.
Question 11 🥇5 marks
Find the regression line for x: 5,10,15,20 (mean=12.5) and y: 40,32,25,18 (mean=28.75), and interpret the gradient's sign.
Dev x: −7.5,−2.5,2.5,7.5; Dev y: 11.25,3.25,−3.75,−10.75 Sxy=−84.375−8.125−9.375−80.625=−182.5 Sxx=56.25+6.25+6.25+56.25=125 b=−182.5/125=−1.46 a=28.75−(−1.46)(12.5)=28.75+18.25=47 y = 47 − 1.46x — negative gradient confirms y decreases as x increases
Question 12 🥇5 marks
A regression line y=3+0.8x was fitted using x from 0 to 50. An operator needs a prediction at x=52. Calculate the prediction and explain in engineering terms why this is a low-risk extrapolation compared to predicting at x=200.
y = 3+0.8(52) = 3+41.6 = 44.6 x=52 is only slightly beyond the tested range (0–50), a 4% extension — the underlying relationship is very unlikely to have changed meaningfully in such a small step, unlike extrapolating to x=200 (a 300% extension), where the risk of the line no longer applying is much higher.
SkillLondon · Unit 4002 Engineering Mathematics · Linear Regression · Level 4 HN Engineering Maths