Chapter 8: Calculus 2
Second-semester calculus extends integration to harder problems and then pivots to a deep idea: a function can be represented as an infinite sum. That idea is not a curiosity. It is how computers approximate transcendental functions such as , , and , and it is how you analyze the long-run behavior of algorithms and iterative methods, from the average cost of hashing to the smoothed loss curve of a training run.
Concepts from other sections (11)
This section uses these ideas. Each has a short definition and a link to the section that explains it in full. Tap a dotted term in the text to preview it.
- Range reduction: rewriting so the polynomial only ever sees a small argument . Read more: 8.1 Taylor series, remainder bounds, and range reduction
- Catastrophic cancellation: loss of significant digits when large terms of opposite sign nearly cancel. Read more: 8.1 Taylor series, remainder bounds, and range reduction
- Geometric series: , with partial sum and limit for . Read more: 8.2 Series convergence, the EMA as a geometric series, and bias correction
- Exponential moving average (EMA): the recursion , a weighted sum with geometric weights. Read more: 8.2 Series convergence, the EMA as a geometric series, and bias correction
- Taylor polynomial: the degree- polynomial whose value and first derivatives at a point match those of . Read more: 8.1 Taylor series, remainder bounds, and range reduction
- Lagrange remainder: the exact error of a Taylor polynomial, for some unknown between and . Read more: 8.1 Taylor series, remainder bounds, and range reduction
- Bias correction: dividing by its weight total so the zero start no longer pulls the average toward 0. Read more: 8.2 Series convergence, the EMA as a geometric series, and bias correction
- definite integral: the limit of Riemann sums, the signed area between and the axis. Read more: 7.4 Definite Integrals: Trapezoid and Simpson
- Cody-Waite reduction: subtracting as two pieces, a short exact high part and a tiny low part, so is accurate to the last bit. Read more: 8.1 Taylor series, remainder bounds, and range reduction
- GELU: , the input weighted by the standard normal CDF; its tanh approximation is a different function. Read more: 7.3 Activation Functions and Their Derivatives
- Ratio test: if successive term ratios eventually stay below some , the series converges. Read more: 8.2 Series convergence, the EMA as a geometric series, and bias correction
This chapter follows that arc in two built sections and one problem set. The first section turns Taylor series into working code: a polynomial for with a proven error bound, range reduction so the bound holds for every input, and a series for erf that avoids catastrophic cancellation. The second section develops convergence of series and the geometric series, and uses them to explain why an exponential moving average starts out biased toward zero and how to correct it, the same correction Adam applies to its moments. The problem set then practises the hand techniques behind both: integration by parts and substitution, the Gaussian integral, convergence tests, Taylor remainders, polar curves, and first-order differential equations.
Learning objectives
- Choose an integration technique (parts, substitution, partial fractions, trigonometric substitution) and carry it out.
- Decide whether a series converges using the divergence, geometric, -series, integral, comparison, ratio, root, and alternating series tests.
- Approximate a function with a Taylor polynomial, bound the error with the Lagrange remainder, and use range reduction to keep that error small.
- Explain the exponential moving average as a geometric series and derive its bias correction.
- Solve separable and first-order linear differential equations, and recognize gradient descent as Euler’s method.
Before you begin
Section titled “Before you begin”You should be comfortable with limits, derivatives, and definite integrals from Calculus 1, in particular Derivatives and finite differences. The code sections also call two helpers from Precalculus: horner from Polynomials, Horner, and stable quadratic roots and the geometric-sequence helpers from Sequences, geometric series, and frequency ladders. The companion textbook is OpenStax, Calculus Volume 2 (free, CC BY-NC-SA 4.0).
In this chapter
Section titled “In this chapter”- Taylor series, remainder bounds, and range reduction: derives Taylor polynomials and the Lagrange remainder, then builds
exp_range_reduced( with a Cody-Waite reduction) and a cancellation-freeerf_series, the float64 references for the exact GELU and the Cexpf. - Series convergence, the EMA as a geometric series, and bias correction: defines convergence, sums the geometric series exactly, and builds an
EMAclass whose debiased value is exact for a constant input, the correction behind Adam. - Calculus 2 problem set: 52 pen-and-paper problems with worked answers on integration techniques, the Gaussian, series, Taylor polynomials, polar curves, and ODEs.
The mathematics at a glance
Section titled “The mathematics at a glance”The sections above go deep on Taylor series and the geometric series. The rest of second-semester calculus is summarized here, with a worked example for each topic, so that you have the whole toolkit in view. The OpenStax chapter numbers point to fuller treatments and exercise sets.
Integration techniques
Section titled “Integration techniques”Calculus Volume 2, sections 1.1 to 1.5, covers four techniques. Integration by parts, , handles products of two kinds of function; a common heuristic for choosing is LIATE (logarithmic, inverse trigonometric, algebraic, trigonometric, exponential), taking the earliest kind present. Trigonometric integrals reduce powers with identities like . Trigonometric substitution removes square roots: for let , for let , and for let . Partial fractions decompose into simpler fractions when .
Two short examples show the first and last of these. For , take and , so and ; the result is . For , write ; solving gives , , and the integral is .
Applications of integration
Section titled “Applications of integration”Integrals measure more than area (sections 2.1 to 2.4). The arc length of on is ; the surface area of revolution is ; and the center of mass of a lamina is with .
For example, the arc length of from to uses , so . With , , this is .
Parametric curves and polar coordinates
Section titled “Parametric curves and polar coordinates”A parametric curve , has slope and arc length : at each instant the speed is the hypotenuse of the two velocity components (sections 3.1 to 3.4). Polar coordinates use , , and the area swept by from to is .
For example, one petal of spans , so its area is .
Sequences and series
Section titled “Sequences and series”A sequence converges if exists and is finite; a series converges if its sequence of partial sums does (sections 5.1 to 5.6). A power series has a radius of convergence , and the Taylor series is the power series built from derivatives.
The convergence tests form a decision tree, and each has a one-line intuition:
- Divergence test: if , the series diverges. Terms must shrink to zero, but that is necessary, not sufficient.
- Ratio test: if the series converges absolutely; if it diverges. It compares the series to a geometric one.
- Root test: if , the same conclusions hold as for the ratio test.
- Integral test: if is positive, continuous, and decreasing with , then and converge or diverge together.
- Comparison test: bound the series by a known geometric or -series.
- Alternating series test: if decreases to 0, the alternating series converges.
A few series are worth knowing by heart. The geometric series for ; the -series converges if and only if ; the harmonic series diverges (); and , , .
For example, yields to the ratio test: , so the series converges.
Introduction to differential equations
Section titled “Introduction to differential equations”An ordinary differential equation relates a function to its derivatives (sections 4.1 to 4.3). A separable equation is solved by separating the variables and integrating both sides. A first-order linear equation is solved with the integrating factor .
For example, with separates to ; integrating gives , the initial condition gives , and the solution is .
Choosing a technique
Section titled “Choosing a technique”When you face a new problem, the first decision is which tool to reach for. This table collects the cues:
| Technique | When to use | Key formula or idea |
|---|---|---|
| Integration by parts | product of two kinds of function | LIATE priority for choosing |
| Trigonometric substitution | or | substitute , , or |
| Partial fractions | rational functions | factor the denominator, decompose |
| Ratio test | series with factorials or exponentials | compute |
| Comparison test | series similar to a known -series or geometric series | bound by a known convergent or divergent series |
| Taylor expansion | approximating near a point | |
| Separable ODE | separate and integrate both sides |
Where this shows up in computing
Section titled “Where this shows up in computing”These ideas recur well beyond this book. The harmonic series appears in average-case hashing analysis and the coupon-collector problem. Taylor series are how libraries compute , , and in floating point. The radius of convergence of a power series governs whether iterative algorithms converge, and convergence tests in general tell you whether an iterative method terminates. Differential equations model dynamic systems, from PID controllers to epidemics, and Fourier series in signal processing build on the same foundations.
Key terms
Section titled “Key terms”- Integration by parts: , the product rule in reverse; it integrates products of two kinds of function, such as , and LIATE is a heuristic for choosing .
- Trigonometric substitution: replacing by , , or to remove a square root of the form , , or from an integrand.
- Partial fractions: decomposing a rational function with into a sum of simpler fractions over the factors of , each of which integrates to a logarithm or an arctangent.
- Arc length: the length of a curve, for , or for a parametric curve: the integral of speed.
- Parametric curve: a curve given by , in terms of a parameter , with slope ; it describes paths that are not graphs of a function.
- Polar coordinates: describing a point by its distance from the origin and angle , with and ; a polar curve sweeps area .
- Power series: a series in powers of ; it converges for less than its radius of convergence and can diverge beyond it.
- Taylor series: the power series built from the derivatives of at ; truncating it gives the polynomials that libraries use to compute , , and .
- Divergence test: if , then diverges; terms shrinking to zero is necessary for convergence but not sufficient.
- Integral test: if is positive, continuous, and decreasing with , then and converge or diverge together.
- Comparison test: a series of nonnegative terms converges if it is bounded term by term by a known convergent series, such as a geometric or -series, and diverges if it bounds a known divergent one.
- Alternating series test: if decreases to 0, the series converges, even when does not.
- p-series / harmonic series: , which converges if and only if ; the harmonic series is the case and diverges, growing like , which is why it appears in hashing and coupon-collector analyses.
- Ordinary differential equation (ODE): an equation relating a function of one variable to its derivatives, such as ; it models how a system changes, and gradient descent is Euler’s method applied to one.
- Separable differential equation: an ODE of the form , solved by moving all terms to one side, , and integrating both sides.
- Integrating factor: the multiplier that turns the first-order linear ODE into , which can be integrated directly.
Further reading
Section titled “Further reading”- OpenStax, Calculus Volume 2 (free). Good exercise sets for each topic above: integration techniques, sections 1.1 (exercises 1 to 15), 1.3 (115 to 128), 1.4 (155 to 170), with challenge problems in 1.5 (200 to 210); applications, 2.1 (1 to 10), 2.2 (50 to 60), 2.4 (100 to 110, challenge 115 to 120); parametric and polar, 3.1 (1 to 12), 3.3 (110 to 122), 3.4 (150 to 162, challenge 168 to 175); series, 5.1 (1 to 14), 5.3 (120 to 138), 5.4 (175 to 190), 5.6 (260 to 275, challenge 280 to 288); differential equations, 4.1 (1 to 10), 4.3 (100 to 115, challenge 120 to 125).
- Paul’s Online Math Notes, for worked examples of every technique.
- 3Blue1Brown, calculus, for geometric intuition about series and Taylor polynomials.