Can you add up infinitely many numbers and get a finite total? Sometimes — and when you can, the result is one of the most powerful tools in mathematics: the ability to represent complicated functions as infinite polynomials. Taylor series let us approximate any smooth function by polynomials, which is the basis of linearization, of numerical methods, and of the second-order analysis of optimization.
Sequences and their limits
A sequence \(a_1,a_2,a_3,\dots\) is an ordered list; it converges to \(L\) if \(a_n\to L\) as \(n\to\infty\) (the limit idea of Chapter [ch:limits], on the integers). For example \(a_n=1/n\to0\), while \(a_n=(-1)^n\) does not converge. Convergence of sequences is the foundation for everything that follows — and for the convergence of training algorithms, whose iterates form a sequence we hope settles down.
Infinite series
A series \(\sum_{n=1}^{\infty} a_n\) is the limit of its partial sums \(s_N=\sum_{n=1}^{N}a_n\). If \(s_N\to S\) (finite), the series converges to \(S\); otherwise it diverges.
The most important series of all: \[\sum_{n=0}^{\infty} r^n = \frac{1}{1-r}\quad\text{for }|r|<1,\qquad\text{diverges for }|r|\ge1.\] It models compound discounting — and the discounted sum of future rewards in reinforcement learning, \(\sum_t \gamma^t r_t\), converges precisely because \(0<\gamma<1\).
\(n\)-th term test: if \(a_n\not\to0\), the series diverges.
\(p\)-series: \(\sum 1/n^p\) converges iff \(p>1\) (so \(\sum1/n\) diverges, \(\sum1/n^2\) converges).
Ratio test: if \(\lim|a_{n+1}/a_n|=L<1\) it converges, \(>1\) diverges.
The terms going to zero is necessary but not sufficient for convergence: the harmonic series \(\sum 1/n\) has terms \(\to0\) yet diverges (to \(\infty\)). Convergence is about how fast the terms shrink. The same distinction matters for the discount factor and learning-rate schedules: \(\sum\eta_t=\infty\) but \(\sum\eta_t^2<\infty\) is the classic condition guaranteeing stochastic gradient descent converges.
Power series
A power series \(\sum_{n=0}^{\infty}c_n(x-a)^n\) is a “polynomial of infinite degree.” It converges for \(x\) within some radius of convergence \(R\) of the center \(a\), and inside that interval it defines a function that can be differentiated and integrated term by term — as if it were an ordinary polynomial.
Taylor and Maclaurin series
If \(f\) is infinitely differentiable near \(a\), then near \(a\) \[f(x)=\sum_{n=0}^{\infty}\frac{f^{(n)}(a)}{n!}(x-a)^n = f(a)+f'(a)(x-a)+\frac{f''(a)}{2}(x-a)^2+\cdots.\] Centered at \(a=0\) it is the Maclaurin series.
A Taylor series rebuilds a function from its derivatives at a single point. Truncating it gives polynomial approximations of increasing accuracy: the degree-1 truncation is the tangent-line linearization (Chapter [ch:appderiv]); the degree-2 truncation adds curvature. This “replace a hard function by its low-order polynomial” move is everywhere — it is how calculators evaluate \(e^x\) and \(\sin x\), how Newton’s method and gradient descent are analyzed, and how the Laplace approximation models a posterior as a Gaussian.
\[e^x=\sum_{n=0}^\infty\frac{x^n}{n!},\qquad \sin x=\sum_{n=0}^\infty\frac{(-1)^n x^{2n+1}}{(2n+1)!},\qquad \frac{1}{1-x}=\sum_{n=0}^\infty x^n\ (|x|<1).\]
Watch the picture: degree 1 matches the slope at the origin, degree 3 hugs the curve over a wider stretch, degree 5 wider still. Each extra term cancels the next derivative’s error. The multivariable Taylor expansion (Chapter [ch:multivariable]) does the same with a gradient (linear term) and a Hessian (quadratic term) — and that quadratic model is exactly what second-order optimizers minimize at each step.
Taylor expansion is the analytic lens on optimization. The second-order Taylor model \(f(\vtheta+\Delta)\approx f+\grad f^\top\Delta+\tfrac12\Delta^\top \mathbf{H}\Delta\) explains gradient descent (use the linear term), Newton’s method (minimize the quadratic exactly), and trust-region methods. Series also appear directly: the discounted return \(\sum\gamma^t r_t\) in RL is geometric; the logistic and softmax expansions inform numerically stable implementations; positional encodings use \(\sin/\cos\); and the convergence conditions \(\sum\eta_t=\infty,\ \sum\eta_t^2<\infty\) for SGD are series statements.
import numpy as np
from math import factorial
# Maclaurin series for e^x converges fast
def exp_series(x, terms=12):
return sum(x**n/factorial(n) for n in range(terms))
print(exp_series(1.0), np.e) # ~2.71828
# geometric series sum 1 + r + r^2 + ... = 1/(1-r) for |r|<1
r = 0.9
print(sum(r**n for n in range(1000)), 1/(1-r)) # ~10, 10Chapter summary
A series converges if its partial sums have a finite limit; the geometric series \(\sum r^n=\tfrac{1}{1-r}\) (\(|r|<1\)) is the prototype.
Terms \(\to0\) is necessary, not sufficient (\(\sum1/n\) diverges); use \(p\)-series and ratio tests.
Taylor series rebuild a function from its derivatives; truncations give polynomial approximations (degree 1 = linearization).
Know \(e^x,\sin x,\tfrac{1}{1-x}\) series; the multivariable version uses gradient + Hessian.
Series underlie SGD convergence conditions, RL discounted returns, and second-order optimization.