FireCADCalc

Straight-Line Fit (Least Squares) and Prediction

Least-squares straight line y = a + b x through up to eight points, with the coefficient of determination R² and the predicted y at a chosen x.

Inputs

Examples: Calibration dataTwo points

Point 1

Point 2

Point 3

Point 4

Point 5

Point 6

Point 7

Point 8

Results

Slope0.98900
Intercept21.780
Coefficient of determination99.928%
Predicted y at x₀91.010

Download PDF CSV Link to this result Compare another case

Log in to save calculations to your dashboard.

Worked example

Example: Calibration data. The inputs, in the units selected above:

InputValue
Number of points used5.0000 -
Point 1: x20.000 -
Point 1: y41.500 -
Point 2: x40.000 -
Point 2: y61.000 -
Point 3: x60.000 -
Point 3: y82.300 -
Point 4: x80.000 -
Point 4: y99.800 -
Point 5: x100.00 -
Point 5: y121.00 -
Point 6: x0 -
Point 6: y0 -
Point 7: x0 -
Point 7: y0 -
Point 8: x0 -
Point 8: y0 -
x for prediction70.000 -

Applying the formula below gives:

ResultValue
Slope0.98900
Intercept21.780
Coefficient of determination99.928 %
Predicted y at x₀91.010

Open this example in the calculator and change any input.

Formula

\(b = \frac{\sum(x - \bar x)(y - \bar y)}{\sum(x - \bar x)^2}, \quad a = \bar y - b\bar x, \quad R^2 = \frac{S_{xy}^2}{S_{xx}S_{yy}}\)

Variables

Symbol Meaning SI unit
\(n\) Number of points used -
\(x_{1}\) Point 1: x -
\(y_{1}\) Point 1: y -
\(x_{2}\) Point 2: x -
\(y_{2}\) Point 2: y -
\(x_{3}\) Point 3: x -
\(y_{3}\) Point 3: y -
\(x_{4}\) Point 4: x -
\(y_{4}\) Point 4: y -
\(x_{5}\) Point 5: x -
\(y_{5}\) Point 5: y -
\(x_{6}\) Point 6: x -
\(y_{6}\) Point 6: y -
\(x_{7}\) Point 7: x -
\(y_{7}\) Point 7: y -
\(x_{8}\) Point 8: x -
\(y_{8}\) Point 8: y -
\(x_0\) x for prediction -
\(b\) Slope -
\(a\) Intercept -
\(R^2\) Coefficient of determination -
\(\hat y\) Predicted y at x₀ -

Method and standards

Least squares.

Where it is used

  • Instrument calibration.
  • Willans line and performance curves.

Common mistakes

  • Extrapolating.
  • Fitting a line to curved data.

Assumptions and limits

  • Errors in y only. Extrapolation beyond the data and the trivial two-point fit are flagged.

References

  • Ordinary least squares y = a + bx

Questions and answers

What does the default data fit?

y ≈ 21.78 + 0.9890 x, R² 0.9993.

Calibrations?

Fit instrument readings against standards to find gain and offset.

Extrapolation?

Risky beyond the measured range.

Method and article reviewed by FireCAD engineering on 12 November 2026. Every result is checked against an independent calculation on each release: how we verify our calculators.

Related calculators

Free engineering calculators: every page computes in SI and converts to your units. Results are for engineering estimation; verify critical designs against the referenced standards.

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.