---
title: "Least squares: y = ax + b + c/x"
subject: "Numerical Method"
chapter: 4
key: "semester_4/numerical_method:least-squares-ax-b-c-over-x"
source: https://www.bctengineer.com/q/semester_4/numerical_method/least-squares-ax-b-c-over-x
site: BCT Engineering
---

# Least squares: y = ax + b + c/x

Numerical Method · Chapter 4: Interpolation

- Asked in: 2074 Bhadra, 8 marks
- Video: [Curve fitting method by the method of Least square | Curve Fitting parabola](https://www.youtube.com/watch?v=-UJr1XjyfME) — Civil learning online
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_4/numerical_method/least-squares-ax-b-c-over-x
- Whole chapter: https://www.bctengineer.com/md/semester_4/numerical_method/chapter-4

## Question

The following data are provided; use least-squares method to fit these data with the following model, y = ax + b + c/x. [The data table is not given in the printed paper.]

## Short answer

Minimize S = sum(y_i - a x_i - b - c/x_i)^2. The normal equations are a sum x^2 + b sum x + cn = sum xy, a sum x + bn + c sum(1/x) = sum y, and an + b sum(1/x) + c sum(1/x^2) = sum(y/x). Solve for a, b, c; the illustration gives y = 1.9304x + 3.3318 + 0.6507/x.

## Answer

The data table is not printed in the question, so the method is given in general form and then applied to an assumed data set to show the numbers.

#### Normal equations for y = ax + b + c/x

The model is linear in the unknowns a, b, c. Minimise

```text
S = Σ (yᵢ − a xᵢ − b − c/xᵢ)²
```

Setting ∂S/∂a = ∂S/∂b = ∂S/∂c = 0:

```text
a Σx²  + b Σx    + c·n     = Σxy        ... (1)
a Σx   + b·n     + c Σ(1/x) = Σy        ... (2)
a·n    + b Σ(1/x) + c Σ(1/x²) = Σ(y/x)  ... (3)
```

(Here x·(1/x) = 1, so the Σ of that cross term is n.)

#### Procedure

1. Tabulate x, y, 1/x, 1/x², x², xy, y/x and find the sums.
2. Substitute the sums in (1), (2), (3).
3. Solve the three equations by Gauss elimination for a, b, c.

#### Illustration with assumed data (n = 5)

| x | y | 1/x | 1/x² | x² | xy | y/x |
|---|---|---|---|---|---|---|
| 1 | 5.9 | 1.0000 | 1.0000 | 1 | 5.90 | 5.9000 |
| 2 | 7.6 | 0.5000 | 0.2500 | 4 | 15.20 | 3.8000 |
| 3 | 9.2 | 0.3333 | 0.1111 | 9 | 27.60 | 3.0667 |
| 4 | 11.3 | 0.2500 | 0.0625 | 16 | 45.20 | 2.8250 |
| 5 | 13.1 | 0.2000 | 0.0400 | 25 | 65.50 | 2.6200 |
| Σ=15 | 47.1 | 2.2833 | 1.4636 | 55 | 159.4 | 18.2117 |

```text
55a     + 15b      + 5c      = 159.4
15a     + 5b       + 2.2833c = 47.1
5a      + 2.2833b + 1.4636c = 18.2117
```

Solving: a = 1.9304, b = 3.3318, c = 0.6507.

**Answer: y = 1.9304x + 3.3318 + 0.6507/x** for the assumed data; for the actual paper, insert its own x, y values in the same sums.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. Why can ordinary least squares be used for y = ax + b + c/x?
   A. The model is linear in the unknowns a, b, c
   B. It is linear in x
   C. It has exactly three data points
   D. c/x is constant
   Answer: A. Linearity in the parameters makes the normal equations linear. (Key point: Linear in parameters)

2. Which is the third normal equation (from ∂S/∂c = 0)?
   A. a Σx² + b Σx + c n = Σxy
   B. a·n + b Σ(1/x) + c Σ(1/x²) = Σ(y/x)
   C. a Σx + b n + c Σ(1/x) = Σy
   D. a·n + b·n + c·n = Σy
   Answer: B. Multiplying the residual by 1/x gives this equation; x·(1/x) = 1 so its sum is n. (Key point: Normal equation)

## Related in Numerical Method

- [Quadratic least squares fit](https://www.bctengineer.com/question.md?key=semester_4%2Fnumerical_method%3Aquadratic-fit-least-squares) — Numerical Method, chapter 4
- [Least squares significance, normal equations](https://www.bctengineer.com/question.md?key=semester_4%2Fnumerical_method%3Aleast-squares-significance-normal) — Numerical Method, chapter 4
- [Fit y = ln(ax + b)](https://www.bctengineer.com/question.md?key=semester_4%2Fnumerical_method%3Afit-log-ax-b) — Numerical Method, chapter 4, asked 2×
- [Fit y = ax/(b + x)](https://www.bctengineer.com/question.md?key=semester_4%2Fnumerical_method%3Afit-y-ax-over-b-plus-x) — Numerical Method, chapter 4, asked 2×
- [Derive linear least squares](https://www.bctengineer.com/question.md?key=semester_4%2Fnumerical_method%3Aleast-squares-linear-derive) — Numerical Method, chapter 4
- [Fit curve y = a b^x (decay data)](https://www.bctengineer.com/question.md?key=semester_4%2Fnumerical_method%3Afit-y-abx-d) — Numerical Method, chapter 4, asked 3×

## Related in other subjects

- [Least squares fit for calibration data](https://www.bctengineer.com/question.md?key=semester_3%2Fmetrology%3Aleast-squares-calibration-line) — Metrology, chapter 2
- [Wire-frame model and polygon table](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_graphics%3Awireframe-model-polygon-table) — Computer Graphics, chapter 6
- [1D implicit river stage - water table model](https://www.bctengineer.com/question.md?key=semester_8%2Fcomputational_techniques_in_civil_engineering%3Aone-d-implicit-river-stage-model) — Computational Techniques in Civil Engineering, chapter 7, asked 2×
- [Fit straight line: humidity and moisture](https://www.bctengineer.com/question.md?key=semester_5%2Fprobability_and_statistics%3Ahumidity-moisture-straight-line-fit) — Probability and Statistics, chapter 5
