Skip to main content

Fit y = ln(ax + b)

Short answer

Linearize by taking exponentials: Y=e^y = ax+b. Fit with least squares normal equations to get a=1.7665, b=1.5172. The fitted curve is y = ln(1.7665x + 1.5172).

Fit the following data to the curve y = log_e(ax + b).

x0123456
y0.91.01.51.92.12.42.5

Take the exponential of both sides: y = ln(ax + b) → eʸ = ax + b. Put Y = eʸ, so Y = b + ax is a straight line in x.

xyY = eʸx²xY
00.92.459600.0000
112.718312.7183
21.54.481748.9634
31.96.6859920.0577
42.18.16621632.6647
52.411.02322555.1159
62.512.18253673.0950
Σ47.717391192.6149

Normal equations (intercept b, slope a)

ΣY = n·b + a·Σx      →  47.7173 = 7b + 21.0000a
ΣxY = b·Σx + a·Σx²   →  192.6149 = 21.0000b + 91.0000a

Solving: a = (nΣxY − ΣxΣY)/(nΣx² − (Σx)²) = 1.7665, b = (ΣY − aΣx)/n = 1.5172.

Answer: y = ln(1.7665x + 1.5172) (check: x = 6 gives 2.495 against 2.5; x = 0 gives 0.417 against 0.9).

This fits the straight line to eʸ rather than minimising the error in y itself, which is the usual exam method.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Numerical Method chapter 4 questions →