What is the second-order Taylor expansion of log(1 + x) about x = 0?
answer
- match value, slope, and bend at zero
- first derivative is 1/(1 + x)
- second derivative is negative
- leading term is x, correction is negative
- remainder starts at the cubic
basics
~10 slog(1 + x) is approximately x - x^2/2 near x = 0. The dropped remainder starts at the cubic term x^3/3, so the error shrinks roughly eightfold each time x is halved.
solid answer
~40 sA second-order Taylor expansion about a point uses the value, the first derivative and the second derivative there: `f(x) ~ f(0) + f'(0)*x + f''(0)*x^2/2`. For `f(x) = log(1 + x)`: `f(0) = 0`, `f'(x) = 1/(1 + x)` so `f'(0) = 1`, and `f''(x) = -1/(1 + x)^2` so `f''(0) = -1`. That gives `log(1 + x) ~ x - x^2/2`. The first-order version, `log(1 + x) ~ x`, is the one people quote most, and the quadratic term is the leading correction for the fact that the logarithm bends downward. The remainder begins at `x^3/3`, so accuracy is governed by a cubic: at `x = 0.1` the true value is about `0.09531` and the quadratic model gives `0.095`, an error near `0.0003`, matching `x^3/3`.
go deeper
Recall the expansion x - x^2/2 and be able to derive it on the spot from f(0) = 0, f'(0) = 1 and f''(0) = -1, remembering the 1/2 on the quadratic term.
Explain where each coefficient comes from and quantify the remainder: the leading dropped term is x^3/3, so error scales cubically and shrinks eightfold each time the displacement halves.
Turn the expansion into a decision: state the displacement at which the linear shortcut stops meeting your tolerance, and use the size of the quadratic term as the running estimate of the error you are accepting.
Frame local expansions as a general modelling discipline — every low-order surrogate carries an explicit validity radius, and the team's habit should be to state that radius alongside the approximation rather than discover it in production.
## The general recipe A Taylor expansion approximates a function near a chosen base point by a polynomial that matches the function's value and its first few derivatives there. Around `x = 0` (the Maclaurin case), the second-order expansion is ``` f(x) ~ f(0) + f'(0)*x + (1/2)*f''(0)*x^2 ``` The logic is simple: the constant term makes the polynomial pass through the right height, the linear term makes it leave at the right slope, and the quadratic term makes it bend at the right rate. Each extra term buys one more derivative of agreement. ## Applying it to log(1 + x) Take `f(x) = log(1 + x)`, the natural logarithm. - `f(0) = log(1) = 0` - `f'(x) = 1/(1 + x)`, so `f'(0) = 1` - `f''(x) = -1/(1 + x)^2`, so `f''(0) = -1` Substituting: ``` log(1 + x) ~ 0 + 1*x + (1/2)*(-1)*x^2 = x - x^2/2 ``` The full series continues `x - x^2/2 + x^3/3 - x^4/4 + ...`, converging for `-1 < x <= 1`. Truncating after the quadratic term leaves a remainder whose leading piece is `+x^3/3`. ## How good is it? Numbers make the error scale concrete. At `x = 0.1`, `log(1.1) = 0.0953102...`; the linear model gives `0.1` (error about `0.0047`) and the quadratic model gives `0.095` (error about `0.00031`). The quadratic term removed roughly 94% of the error. Now halve the displacement: at `x = 0.05`, `log(1.05) = 0.0487902...` and the quadratic model gives `0.048750`, an error near `0.00004` — about one eighth of the error at `x = 0.1`. That eightfold shrink is the signature of a **cubic** leading error: halve `x` and `x^3` falls by `2^3 = 8`. This is the single most useful thing to take away. A first-order model has error of order `x^2` (halving `x` quarters the error); a second-order model has error of order `x^3` (halving `x` cuts it eightfold). Bigger displacements degrade a second-order model fast in the other direction too: at `x = 0.5` the quadratic model gives `0.375` against a true `0.405`, an error of `0.03` — two orders of magnitude worse than at `x = 0.05`. Taylor accuracy is a *local* promise. ## The companion expansion for e^x The exponential is the other expansion worth knowing cold. With `f(x) = e^x`, every derivative is `e^x`, and every derivative at `0` equals `1`, so ``` e^x ~ 1 + x + x^2/2 ``` with the series continuing `+ x^3/6 + x^4/24 + ...`. Note the constant term: unlike `log(1 + x)`, which vanishes at `0`, the exponential starts at `1`. A frequent slip is to write `e^x ~ x + x^2/2`, dropping the constant, or to give `log(1 + x)` a leading `1` it does not have. The two are near-inverses of each other around zero, which is a quick sanity check: substituting the quadratic model for `x` in the other and keeping terms up to `x^2` returns `x` in both directions. ## Why this appears in interviews Three reasons. First, it is a check that you can actually differentiate and assemble a Taylor polynomial rather than recite one. Second, `log(1 + x) ~ x` is the workhorse behind small-change approximations — small log-returns approximating percentage changes, small log-likelihood differences, small-`x` reasoning in derivations — and knowing the next term tells you when the shortcut starts to lie. Third, the error-scaling argument generalises directly: the same reasoning explains why any second-order model of a multivariable surface is trustworthy only within a small displacement of its base point, with error growing like the cube of that displacement. ## Things to state carefully Say *about which point* the expansion is taken; `x - x^2/2` is specific to a base point of `0` and says nothing about the behaviour near, say, `x = 3`. Say which logarithm: this is the natural log, and a base-10 version would carry an extra factor `1/log(10)`. And note the domain: `log(1 + x)` is undefined for `x <= -1`, and the series only converges on `-1 < x <= 1`, so the expansion is not an approximation you can push arbitrarily far in the negative direction.
- What is the second-order expansion of e^x about 0, and what is the most common mistake in writing it?e^x ~ 1 + x + x^2/2, since every derivative of e^x equals 1 at x = 0. The usual mistake is dropping the constant term and writing x + x^2/2, or mirroring the log expansion's sign and writing 1 + x - x^2/2. Unlike log(1 + x), the exponential does not vanish at zero.
- By how much does the second-order error change if you halve the displacement x?It falls by roughly a factor of eight. The leading dropped term is cubic in x, so error scales like x^3 and halving x divides it by 2^3. For contrast, a first-order model's error scales like x^2 and only quarters. That ratio is a fast way to check empirically which order of model you are actually using.
- When does the approximation log(1 + x) ~ x become unsafe?Once |x| is no longer small. At x = 0.1 the linear model is off by about 0.005 (roughly 5% relative); at x = 0.5 it is off by about 0.095, nearly a quarter of the true value. The quadratic term x^2/2 is exactly the size of the leading error, so compute it and check whether it is negligible for your tolerance.
saying these in an interview costs you the question
- Writes log(1 + x) ~ x + x^2/2 with the wrong sign
- Forgets the 1/2 factor on the quadratic term
- Gives e^x ~ x + x^2/2, dropping the constant 1
- Claims the approximation holds for any x, ignoring locality
- Says the error halves when x halves, not eighths