Courses / Computer Science I
Calculus

Taylor Series and Approximation

Computers cannot directly evaluate x, e^x, or x — these are defined by limits, not arithmetic.

Computer Science I 333 words Free to read

Turning Functions into Polynomials

Computers cannot directly evaluate sinx\sin x, exe^x, or lnx\ln x — these are defined by limits, not arithmetic. The resolution is Taylor series: any smooth function can be approximated (often exactly represented) by a polynomial built from its derivatives at a single point. Since polynomials need only addition and multiplication, this is how calculators and libraries actually compute these functions.

The Taylor series of ff about a point aa is f(x)=f(a)+f(a)(xa)+f(a)2!(xa)2+f(a)3!(xa)3+f(x) = f(a) + f'(a)(x - a) + \frac{f''(a)}{2!}(x - a)^2 + \frac{f'''(a)}{3!}(x - a)^3 + \dots Each term uses a higher derivative and a higher power. Intuitively: the constant term matches the function's value, the linear term matches its slope, the quadratic term matches its curvature, and so on — each term correcting the approximation a little more. Truncating after a few terms gives a Taylor polynomial that hugs the function near aa.

The special case a=0a = 0 (a Maclaurin series) gives famously clean expansions: ex=1+x+x22!+x33!+e^x = 1 + x + \frac{x^2}{2!} + \frac{x^3}{3!} + \dots and similar series for sinx\sin x and cosx\cos x. Keeping more terms improves accuracy; the linear approximation f(x)f(a)+f(a)(xa)f(x) \approx f(a) + f'(a)(x-a) (just the first two terms) is the simplest and is the basis of Newton's method and many numerical algorithms.

The key idea for computing: replace a hard function by an easy polynomial that matches it locally. The approximation is best near the expansion point aa and generally degrades as you move away — so choosing a good center, and enough terms, is a practical trade-off between accuracy and cost.

Common pitfall: expecting a truncated Taylor polynomial to be accurate far from the expansion point. A Taylor polynomial matches the function best near the center aa and its error typically grows as xa|x - a| increases — a few terms good near aa can be wildly wrong far away. More terms extend the accurate region but never make a finite polynomial match everywhere; the approximation is fundamentally local.

Practise this lesson

The explanation above is free to read. The graded practice for this lesson lives in the Tryals app.

11practice questions
2interactive scenes
Start Computer Science I free

Calculus