Chapter 10
18 min read
Section 90 of 353

Area Between Curves

Applications of Integration

Learning Objectives

By the end of this section, you will be able to:

  1. Visualize and interpret the area between two curves as a geometric quantity
  2. Set up definite integrals to compute areas between curves, identifying the correct bounds and integrand
  3. Handle curves that intersect within the integration interval by splitting the integral appropriately
  4. Choose between vertical and horizontal integration based on the geometry of the problem
  5. Apply these techniques to real-world problems in physics, economics, and engineering
  6. Connect these ideas to probability distributions and machine learning metrics
Why This Matters: Computing the area between curves is one of the most practical applications of integration. It appears everywhere: in calculating consumer surplus in economics, work done by variable forces in physics, probabilities in statistics, and evaluation metrics in machine learning. Mastering this technique opens doors to understanding how calculus models the real world.

The Big Picture

In Chapter 8, we learned that the definite integral abf(x)dx\int_a^b f(x)\,dx computes the signed area between a curve y=f(x)y = f(x) and the x-axis. But what if we want to find the area trapped between two curves? This is not just an abstract mathematical exercise—it's a question that arises naturally in many contexts.

Historical Context

The problem of finding areas between curves was central to the development of calculus in the 17th century. Isaac Newton and Gottfried Wilhelm Leibniz independently developed techniques to solve such problems. Earlier, mathematicians like Bonaventura Cavalieri (1598–1647) had used the method of indivisibles—thinking of areas as composed of infinitely thin strips—which directly anticipates our modern approach.

The applications were immediately practical. Newton himself used these techniques to analyze planetary orbits, where the area swept out by a planet relates to its speed (Kepler's second law). Economists later adopted the same mathematics to compute consumer and producer surplus, and statisticians used it to work with probability distributions.

The Core Insight

The key insight is simple: the area between two curves equals the integral of the vertical distance between them. If f(x)g(x)f(x) \geq g(x) on an interval [a,b][a, b], then at each x-value, the vertical distance between the curves is f(x)g(x)f(x) - g(x). Summing these infinitesimally thin vertical strips from x=ax = a to x=bx = b gives the total area.


From a Single Curve to Two Curves

Let's build intuition by connecting what we already know about definite integrals to this new problem.

Area Under a Single Curve

Recall that abf(x)dx\int_a^b f(x)\,dx computes the signed area between y=f(x)y = f(x) and the x-axis (where y=0y = 0). We can think of this as the area between two curves:

  • The top curve: y=f(x)y = f(x)
  • The bottom curve: y=0y = 0 (the x-axis)

The integrand f(x)f(x) is precisely the vertical distance between these two curves: f(x)0=f(x)f(x) - 0 = f(x).

Generalizing to Two Curves

Now suppose we have two functions f(x)f(x) and g(x)g(x) where f(x)g(x)f(x) \geq g(x) for all xx in [a,b][a, b]. The vertical distance between the curves at any point xx is:

vertical distance=f(x)g(x)\text{vertical distance} = f(x) - g(x)

Think of the region between the curves as being filled with infinitely many thin vertical rectangles. Each rectangle has:

  • Width: dxdx (an infinitesimally small change in x)
  • Height: f(x)g(x)f(x) - g(x) (the vertical distance between the curves)
  • Area: [f(x)g(x)]dx[f(x) - g(x)]\,dx

Summing all these infinitesimal rectangles from x=ax = a to x=bx = b gives the total area.


The Mathematical Framework

Area Between Two Curves (Vertical Rectangles): If f(x)g(x)f(x) \geq g(x) for all xx in [a,b][a, b], then the area AA of the region bounded above by y=f(x)y = f(x), below by y=g(x)y = g(x), and on the sides by x=ax = a and x=bx = b is:
A=ab[f(x)g(x)]dxA = \int_a^b [f(x) - g(x)]\,dx

Understanding Each Component

ComponentMeaningHow to Find It
a and b (bounds)The x-values where the region starts and endsOften the intersection points of the curves
f(x) (top curve)The function that lies above in the regionCompare function values at a test point
g(x) (bottom curve)The function that lies below in the regionThe other function at the same test point
f(x) - g(x) (integrand)The height of each vertical stripTop minus bottom (always positive)
dxInfinitesimal width of each stripIndicates integration with respect to x

Why Subtract (and Why Order Matters)

The formula ab[f(x)g(x)]dx\int_a^b [f(x) - g(x)]\,dx requires that f(x)g(x)f(x) \geq g(x) throughout the interval. This ensures that f(x)g(x)0f(x) - g(x) \geq 0, so we're integrating a non-negative function and getting a positive area.

If the curves switch positions (one goes above the other at some point), we need to handle this carefully—a topic we'll address in the "When Curves Cross" section below.


Finding Intersection Points

Often, the integration bounds aa and bb are the x-coordinates where the two curves intersect. Finding these points is a crucial first step.

The Algebraic Approach

Two curves y=f(x)y = f(x) and y=g(x)y = g(x) intersect where they have the same y-value for the same x-value. This means:

f(x)=g(x)f(x) = g(x)

Solving this equation gives the x-coordinates of intersection. Let's see some examples:

Example: Parabola and Line

Find where y=x2y = x^2 and y=x+2y = x + 2 intersect.

Solution: Set x2=x+2x^2 = x + 2. Rearranging: x2x2=0x^2 - x - 2 = 0. Factoring: (x2)(x+1)=0(x-2)(x+1) = 0. So x=2x = 2 or x=1x = -1.

The curves intersect at x=1x = -1 (where y=1y = 1) and x=2x = 2 (where y=4y = 4).

Example: Two Parabolas

Find where y=x2y = x^2 and y=2xx2y = 2x - x^2 intersect.

Solution: Set x2=2xx2x^2 = 2x - x^2. Rearranging: 2x22x=02x^2 - 2x = 0, so 2x(x1)=02x(x - 1) = 0. Thus x=0x = 0 or x=1x = 1.


Interactive: Area Between Curves Explorer

Use this interactive visualization to explore how the area between curves is computed. You can:

  • Select different pairs of functions to see various curve shapes
  • Adjust the number of rectangles in the Riemann sum approximation
  • See how the approximation improves as you add more rectangles
  • Identify intersection points where the curves meet

Interactive: Area Between Curves Explorer

A downward parabola intersecting a line

f(x) = -x² + 4g(x) = xx-3.03.0a = -3.00b = 3.00
Exact Area (numerical)
17.3643
Riemann Sum (20 rectangles)
17.2860
Approximation Error
0.078261
Intersection Points (yellow dots):
x = -2.562, x = 1.562

How to read this visualization:

  • The purple shaded region shows the area between the two curves
  • The blue rectangles approximate this area using a Riemann sum
  • Yellow dots mark where the curves intersect
  • Red dashed lines show the integration bounds [a, b]
  • Increase the number of rectangles to see the approximation improve!

Worked Examples

Example 1: Parabola and Line

Problem: Find the area of the region bounded by y=x2y = x^2 and y=x+2y = x + 2.

Step 1: Find intersection points. We already found these: x=1x = -1 and x=2x = 2.

Step 2: Determine which curve is on top. Pick a test point in the interval, say x=0x = 0:

  • y=x2y = x^2 gives y=0y = 0
  • y=x+2y = x + 2 gives y=2y = 2

Since 2>02 > 0, the line y=x+2y = x + 2 is on top in this interval.

Step 3: Set up and evaluate the integral.

A=12[(x+2)x2]dx=12(x+2x2)dxA = \int_{-1}^{2} [(x + 2) - x^2]\,dx = \int_{-1}^{2} (x + 2 - x^2)\,dx

Find the antiderivative: x22+2xx33\frac{x^2}{2} + 2x - \frac{x^3}{3}

Evaluate at the bounds:

[x22+2xx33]12=(42+483)(122+13)\left[\frac{x^2}{2} + 2x - \frac{x^3}{3}\right]_{-1}^{2} = \left(\frac{4}{2} + 4 - \frac{8}{3}\right) - \left(\frac{1}{2} - 2 + \frac{1}{3}\right)
=(2+483)(122+13)=103(76)=103+76=206+76=276=92= \left(2 + 4 - \frac{8}{3}\right) - \left(\frac{1}{2} - 2 + \frac{1}{3}\right) = \frac{10}{3} - \left(-\frac{7}{6}\right) = \frac{10}{3} + \frac{7}{6} = \frac{20}{6} + \frac{7}{6} = \frac{27}{6} = \frac{9}{2}

Answer: The area is 92\frac{9}{2} or 4.54.5 square units.

Example 2: Trigonometric Curves

Problem: Find the area between y=sinxy = \sin x and y=cosxy = \cos x from x=0x = 0 to x=π2x = \frac{\pi}{2}.

Step 1: Find where they intersect. Set sinx=cosx\sin x = \cos x, which gives tanx=1\tan x = 1, so x=π4x = \frac{\pi}{4} in this interval.

Step 2: Determine which is on top in each region.

  • On [0,π4][0, \frac{\pi}{4}]: At x=0x = 0, cos0=1>0=sin0\cos 0 = 1 > 0 = \sin 0, so cosine is on top
  • On [π4,π2][\frac{\pi}{4}, \frac{\pi}{2}]: At x=π2x = \frac{\pi}{2}, sinπ2=1>0=cosπ2\sin \frac{\pi}{2} = 1 > 0 = \cos \frac{\pi}{2}, so sine is on top

Step 3: Split and evaluate.

A=0π/4(cosxsinx)dx+π/4π/2(sinxcosx)dxA = \int_0^{\pi/4} (\cos x - \sin x)\,dx + \int_{\pi/4}^{\pi/2} (\sin x - \cos x)\,dx
=[sinx+cosx]0π/4+[cosxsinx]π/4π/2= [\sin x + \cos x]_0^{\pi/4} + [-\cos x - \sin x]_{\pi/4}^{\pi/2}
=(22+2201)+(01+22+22)= \left(\frac{\sqrt{2}}{2} + \frac{\sqrt{2}}{2} - 0 - 1\right) + \left(0 - 1 + \frac{\sqrt{2}}{2} + \frac{\sqrt{2}}{2}\right)
=(21)+(21)=222=2(21)= (\sqrt{2} - 1) + (\sqrt{2} - 1) = 2\sqrt{2} - 2 = 2(\sqrt{2} - 1)

Answer: The area is 2(21)0.8282(\sqrt{2} - 1) \approx 0.828 square units.


When Curves Cross

When two curves intersect within your integration interval, you cannot simply use one integral. The "top" and "bottom" curves switch at each intersection point.

The General Strategy

  1. Find all intersection points within your interval of interest
  2. Split the interval at each intersection point
  3. Determine which curve is on top in each subinterval (use a test point)
  4. Set up separate integrals for each subinterval
  5. Add the results

Alternative: Using Absolute Value

If you don't want to split the integral, you can use:

A=abf(x)g(x)dxA = \int_a^b |f(x) - g(x)|\,dx

This automatically handles sign changes. However, to evaluate this integral by hand, you'll typically still need to split at the points where f(x)g(x)=0f(x) - g(x) = 0. The absolute value approach is particularly useful for numerical computation.


Integrating with Respect to y

Sometimes it's easier (or necessary) to integrate horizontally rather than vertically. This is especially true when:

  • The curves are more naturally expressed as x=f(y)x = f(y) rather than y=f(x)y = f(x)
  • The "top" and "bottom" would switch many times with vertical rectangles
  • The region's left and right boundaries are simpler than top and bottom
Area Between Two Curves (Horizontal Rectangles): If x=f(y)x = f(y) lies to the right of x=g(y)x = g(y) for all yy in [c,d][c, d], then:
A=cd[f(y)g(y)]dyA = \int_c^d [f(y) - g(y)]\,dy
Here, f(y)f(y) is the "right curve" and g(y)g(y) is the "left curve."

Example: Horizontal Integration

Problem: Find the area enclosed by x=y2x = y^2 and x=y+2x = y + 2.

Step 1: Find intersections. Set y2=y+2y^2 = y + 2, giving y2y2=0y^2 - y - 2 = 0, so (y2)(y+1)=0(y-2)(y+1) = 0. Thus y=1y = -1 or y=2y = 2.

Step 2: Determine right vs. left. At y=0y = 0: the parabola gives x=0x = 0, the line gives x=2x = 2. So the line is on the right.

Step 3: Set up and evaluate.

A=12[(y+2)y2]dy=12(y+2y2)dyA = \int_{-1}^{2} [(y + 2) - y^2]\,dy = \int_{-1}^{2} (y + 2 - y^2)\,dy

This is the same integral as Example 1! The answer is 92\frac{9}{2}.


Practice: Setting Up Integrals

Practice identifying the correct bounds, which curve is on top, and setting up the integral correctly. Try to solve each problem before revealing the solution.

Practice: Setting Up Area Integrals

Problem 1 of 4
f(x) g(x)

Find the area between:

  • f(x) = 4 - x² (green)
  • g(x) = 0 (x-axis) (orange)
Where does the parabola cross the x-axis? Set 4 - x² = 0

Real-World Applications

1. Consumer and Producer Surplus (Economics)

In microeconomics, the demand curve P=D(q)P = D(q) shows how much consumers are willing to pay for quantity qq, and the supply curve P=S(q)P = S(q) shows what producers need. At market equilibrium (q,P)(q^*, P^*):

  • Consumer Surplus = Area between demand curve and price line = 0q[D(q)P]dq\int_0^{q^*} [D(q) - P^*]\,dq
  • Producer Surplus = Area between price line and supply curve = 0q[PS(q)]dq\int_0^{q^*} [P^* - S(q)]\,dq

These surpluses measure the total benefit to consumers and producers from participating in the market.

2. Work Done by Variable Forces (Physics)

If two forces F1(x)F_1(x) and F2(x)F_2(x) act on an object, the net work done as the object moves from x=ax = a to x=bx = b is:

Wnet=ab[F1(x)F2(x)]dxW_{\text{net}} = \int_a^b [F_1(x) - F_2(x)]\,dx

This is exactly the area between the force curves!

3. Gini Coefficient (Inequality Measurement)

The Lorenz curve L(x)L(x) shows the proportion of total income earned by the bottom xx proportion of the population. Perfect equality would give y=xy = x (the line of equality). The Gini coefficient is:

G=201[xL(x)]dxG = 2\int_0^1 [x - L(x)]\,dx

This is twice the area between the line of equality and the Lorenz curve. Values range from 0 (perfect equality) to 1 (maximum inequality).

4. Probability Between Distributions (Statistics)

Given two probability density functions f(x)f(x) and g(x)g(x), the area between them (the total variation distance) measures how different the distributions are:

TV(f,g)=12f(x)g(x)dx\text{TV}(f, g) = \frac{1}{2}\int_{-\infty}^{\infty} |f(x) - g(x)|\,dx

Connection to Machine Learning

The concept of area between curves appears in several important machine learning contexts:

1. ROC-AUC (Receiver Operating Characteristic - Area Under Curve)

The ROC curve plots True Positive Rate vs. False Positive Rate for a binary classifier at different thresholds. The AUC (Area Under the ROC Curve) measures the classifier's performance. An AUC of 1.0 is perfect; 0.5 is random guessing. Computing AUC is essentially computing the area between the ROC curve and the x-axis!

2. Precision-Recall Curves

Similar to ROC, the Precision-Recall curve shows the tradeoff between precision and recall. The area under this curve (AUC-PR) is particularly useful for imbalanced datasets.

3. Probability Calibration

A calibration curve plots predicted probability vs. actual frequency. The area between a model's calibration curve and the perfect diagonal line measures calibration error.

4. KL Divergence and Cross-Entropy

The Kullback-Leibler divergence DKL(PQ)D_{KL}(P \| Q) measures how one probability distribution differs from another. For continuous distributions:

DKL(PQ)=p(x)logp(x)q(x)dxD_{KL}(P \| Q) = \int_{-\infty}^{\infty} p(x) \log\frac{p(x)}{q(x)}\,dx

While not a simple area between curves, KL divergence involves integration over the ratio of two density functions—a related concept.


Python Implementation

Here's how to compute and visualize the area between curves using Python:

Computing Area Between Curves with Python
🐍python
1

Import NumPy for arrays, Matplotlib for plotting, and SciPy for numerical integration.

6

Define the first curve as a Python function: the line y = x + 2.

10

Define the second curve: the parabola y = x².

14

The intersection points were found algebraically: x = -1 and x = 2 where the curves meet.

17

The integrand is the vertical distance: top minus bottom = f(x) - g(x).

19

scipy.integrate.quad computes the definite integral numerically. It returns both the result and an error estimate.

29

fill_between is the key Matplotlib function for shading the area between two curves. The alpha parameter makes it semi-transparent.

47

Compare the numerical result to the exact analytical answer (9/2 = 4.5) to verify accuracy.

50 lines without explanation
1import numpy as np
2import matplotlib.pyplot as plt
3from scipy import integrate
4
5# Define the two curves
6def f(x):
7    return x + 2  # Line: y = x + 2
8
9def g(x):
10    return x**2   # Parabola: y = x^2
11
12# Find intersection points (solve x^2 = x + 2)
13# x^2 - x - 2 = 0 => (x-2)(x+1) = 0
14a, b = -1, 2  # Intersection points
15
16# Compute the area numerically
17def integrand(x):
18    return f(x) - g(x)
19
20area, error = integrate.quad(integrand, a, b)
21print(f"Area between curves: {area:.4f}")
22print(f"Numerical error estimate: {error:.2e}")
23
24# Visualize the region
25x = np.linspace(-2, 3, 500)
26y_f = f(x)
27y_g = g(x)
28
29plt.figure(figsize=(10, 6))
30plt.plot(x, y_f, 'b-', linewidth=2, label='y = x + 2')
31plt.plot(x, y_g, 'r-', linewidth=2, label='y = x²')
32
33# Fill the area between curves
34x_fill = np.linspace(a, b, 100)
35y_f_fill = f(x_fill)
36y_g_fill = g(x_fill)
37plt.fill_between(x_fill, y_g_fill, y_f_fill,
38                 alpha=0.3, color='purple',
39                 label=f'Area = {area:.3f}')
40
41# Mark intersection points
42plt.scatter([a, b], [g(a), g(b)], color='green',
43            s=100, zorder=5, label='Intersections')
44
45plt.xlabel('x')
46plt.ylabel('y')
47plt.title('Area Between Curves')
48plt.legend()
49plt.grid(True, alpha=0.3)
50plt.axhline(y=0, color='k', linewidth=0.5)
51plt.axvline(x=0, color='k', linewidth=0.5)
52plt.show()
53
54# For comparison: exact analytical result
55exact_area = 9/2
56print(f"\nExact area (analytical): {exact_area}")
57print(f"Numerical approximation: {area:.6f}")
58print(f"Absolute error: {abs(exact_area - area):.2e}")

Common Pitfalls

PitfallWhat Goes WrongHow to Avoid It
Wrong order of subtractionGetting a negative areaAlways subtract bottom from top: f(x) - g(x) where f ≥ g
Ignoring curve crossingsUnder- or over-counting areaFind ALL intersection points and split the integral
Using wrong boundsIncluding or excluding regionsDouble-check that bounds match the problem statement
Forgetting absolute valueCancellation when curves crossUse |f(x) - g(x)| or split the integral correctly
Not testing which is on topSubtracting in the wrong orderPick a test point in each subinterval to verify
Mixing up x and y integrationWrong setup entirelyMatch your rectangles (vertical or horizontal) to your variable
Pro Tip: Always sketch the curves first! A quick sketch helps you identify intersection points, see which curve is on top, and catch errors before they happen.

Summary

In this section, we learned how to compute the area between two curves using definite integrals.

Key Formulas

SituationFormula
Vertical rectangles (integrate w.r.t. x)A = ∫[a to b] [f(x) - g(x)] dx where f(x) ≥ g(x)
Horizontal rectangles (integrate w.r.t. y)A = ∫[c to d] [f(y) - g(y)] dy where f(y) ≥ g(y) (right vs left)
When curves crossSplit at intersection points and handle each piece separately
General formulaA = ∫[a to b] |f(x) - g(x)| dx

Problem-Solving Strategy

  1. Sketch the curves to visualize the region
  2. Find intersection points by setting f(x) = g(x)
  3. Determine top/bottom (or right/left) in each subinterval
  4. Set up the integral(s) with correct bounds and integrand
  5. Evaluate using antiderivatives or numerical methods
  6. Check your answer makes sense (positive area, reasonable magnitude)

Knowledge Check

Test your understanding of area between curves with this quiz:

Knowledge Check

Question 1 of 8

When finding the area between two curves f(x) and g(x) where f(x) ≥ g(x) on [a,b], which integral gives the area?

Loading comments...