Works on this device
Best Fit Line Physics
Paste the x and y values you measured. The page draws the best fit straight line, gives its slope and intercept with their standard errors, and tells you what the slope stands for in your units.
Enter your values
Check these values
Your values are worked out in this browser. They are not sent to a server.
Your result will show here
Fill in the values, then choose Calculate.
Your result
How it was worked out
How to use this tool
- Choose Best fit line y = mx + b, or Best fit line through the origin when theory says y is 0 at x = 0.
- Paste or type your data: one point on each line, x first, then y, such as
2, 3.9. You can paste two columns from a spreadsheet. - Type the names and units of x and y, and what the slope stands for (for example Speed for distance against time).
- Choose Calculate. Read the slope with its standard error, the table of residuals and the graph.
The method
The best fit line is the line that makes the sum of the squared vertical distances from the points as small as possible (ordinary least squares).
- Slope: m = Sxy ÷ Sxx, with Sxx = Σ(x − x̄)² and Sxy = Σ(x − x̄)(y − ȳ). Intercept: b = ȳ − m x̄.
- Standard errors: SE(m) = s ÷ √Sxx and SE(b) = s × √(1/n + x̄² ÷ Sxx), where s = √(Σ residual² ÷ (n − 2)).
- R² = 1 − Σ residual² ÷ Σ(y − ȳ)². It is 1 when every point lies on the line.
- Through the origin: m = Σxy ÷ Σx², SE(m) = s ÷ √Σx² with s = √(Σ residual² ÷ (n − 1)), and R² is measured from y = 0.
- Unit of the slope = unit of y ÷ unit of x. A distance in m against a time in s gives a slope in m/s.
Worked example
A trolley moves along a track. The distances at 0, 1, 2, 3, 4 and 5 s are 0.0, 2.1, 3.9, 6.2, 7.8 and 10.1 m.
Here x̄ = 2.5 s, ȳ = 5.016667 m, Sxx = 17.5 and Sxy = 34.95. The slope is 34.95 ÷ 17.5 = 1.997143 m/s, and the intercept is 0.0238095 m.
The standard error of the slope is 0.039 m/s, so the speed is 1.997 ± 0.039 m/s. R² = 0.998452.
Limits you should know
- All of the error is taken to be in y. If x has large errors too, the slope is a little too small.
- The standard errors come from the scatter of your points. They do not include the error of your instruments or a systematic error.
- Every point counts the same. The page does not weight points by error bars, and it does not draw steepest and shallowest lines.
- For a curved law, make it straight first: for a pendulum, type T² against L; for decay, type ln(N) against t. The page fits the numbers you type.
- The graph shows the measured points and the points of the line at each measured x.