TExcelTAD
Home › Calculus Essentials › Area Under and Between Curves

Area Under and Between Curves

A definite integral gives signed area, which is not always what you want. This lesson shows how to get the real (geometric) area when a curve dips below the axis, and how to find the area trapped between two curves.

Signed area versus total area

∫abf(x) dx\int_a^b f(x)\,dx counts area below the x-axis as negative. To get the total area, integrate the absolute value:

total area=∫ab∣f(x)∣ dx\text{total area} = \int_a^b \lvert f(x) \rvert\,dx

In practice you find where ff crosses zero, split the interval there, and flip the sign of the negative pieces. For f(x)=x2−1f(x) = x^2 - 1 on [0,2][0, 2] (zero at x=1x = 1):

∫01(x2−1) dx=[x3/3−x]01=−2/3(below the axis)∫12(x2−1) dx=[x3/3−x]12=2/3−(−2/3)=4/3signed area=−2/3+4/3=2/3total area=2/3+4/3=2\begin{aligned} \int_0^1 (x^2 - 1)\,dx &= \Big[x^3/3 - x\Big]_0^1 = -2/3 && \text{(below the axis)} \\ \int_1^2 (x^2 - 1)\,dx &= \Big[x^3/3 - x\Big]_1^2 = 2/3 - (-2/3) = 4/3 \\ \text{signed area} &= -2/3 + 4/3 = 2/3 \\ \text{total area} &= 2/3 + 4/3 = 2 \end{aligned}

Area between two curves

If top(x)≥bottom(x)\text{top}(x) \ge \text{bottom}(x) on [a,b][a, b], the area between them is

A=∫ab(top(x)−bottom(x)) dxA = \int_a^b (\text{top}(x) - \text{bottom}(x))\,dx

It does not matter whether the curves are above or below the axis; only the vertical gap counts. The usual recipe:

  1. Find where the curves meet: solve f(x)=g(x)f(x) = g(x). These are often the limits.
  2. Decide which curve is on top between those points (test one xx value).
  3. Integrate top minus bottom.

Example. The parabola y=4−x2y = 4 - x^2 and the line y=x+2y = x + 2.

4−x2=x+2  ⇒  x2+x−2=0  ⇒  (x+2)(x−1)=0  ⇒  x=−2, x=1at x=0: parabola 4, line 2  →  parabola is on topA=∫−21(4−x2−x−2) dx=∫−21(2−x−x2) dx=[2x−x2/2−x3/3]−21=(2−1/2−1/3)−(−4−2+8/3)=7/6+10/3=9/2\begin{aligned} &4 - x^2 = x + 2 \;\Rightarrow\; x^2 + x - 2 = 0 \;\Rightarrow\; (x + 2)(x - 1) = 0 \;\Rightarrow\; x = -2,\ x = 1 \\ &\text{at } x = 0\text{: parabola } 4, \text{ line } 2 \;\to\; \text{parabola is on top} \\[1ex] A &= \int_{-2}^{1} (4 - x^2 - x - 2)\,dx = \int_{-2}^{1} (2 - x - x^2)\,dx \\ &= \Big[2x - x^2/2 - x^3/3\Big]_{-2}^{1} = (2 - 1/2 - 1/3) - (-4 - 2 + 8/3) = 7/6 + 10/3 = 9/2 \end{aligned}
python · try it yourself
import sympy as sp

x = sp.symbols("x")
top, bottom = 4 - x**2, x + 2
a, b = sorted(sp.solve(sp.Eq(top, bottom), x))
print("curves meet at x =", a, "and", b)
print("area =", sp.integrate(top - bottom, (x, a, b)))

f = x**2 - 1
print("signed area of x^2-1 on [0,2]:", sp.integrate(f, (x, 0, 2)))
print("total  area of x^2-1 on [0,2]:", -sp.integrate(f, (x, 0, 1)) + sp.integrate(f, (x, 1, 2)))
curves meet at x = -2 and 1
area = 9/2
signed area of x^2-1 on [0,2]: 2/3
total  area of x^2-1 on [0,2]: 2
python · try it yourself
import numpy as np
import matplotlib.pyplot as plt

xs = np.linspace(-2.5, 1.5, 300)
top, bottom = 4 - xs ** 2, xs + 2
inside = (xs >= -2) & (xs <= 1)

plt.figure(figsize=(6, 4))
plt.plot(xs, top, label="y = 4 − x²")
plt.plot(xs, bottom, label="y = x + 2")
plt.fill_between(xs, bottom, top, where=inside, alpha=0.3, label="area = 4.5")
plt.axhline(0, color="gray", linewidth=0.8)
plt.legend()
print("numerical check:", round(float(np.trapezoid((top - bottom)[inside], xs[inside])), 3))
numerical check: 4.5

The trapezoid rule on 300 sample points agrees with the exact 9/29/2 to three decimals.

Tip: If the curves cross inside the interval, the "top" curve changes. Split at every crossing, or integrate ∣f−g∣\lvert f - g \rvert.

Integrating with respect to y

Sometimes a region is easier to describe sideways, as x=right(y)x = \text{right}(y) and x=left(y)x = \text{left}(y). Then A=∫(right(y)−left(y)) dyA = \int (\text{right}(y) - \text{left}(y))\,dy between the yy-limits. Example: the region between x=y2x = y^2 and x=2yx = 2y has A=∫02(2y−y2) dy=4−8/3=4/3A = \int_0^2 (2y - y^2)\,dy = 4 - 8/3 = 4/3.

In software

  • ML model evaluation: the AUC in AUC – ROC Curve is the area under the ROC curve, computed from points with the trapezoid rule.
  • Probability: the chance that a value falls in a range is the area under its density (see The Definite Integral).
  • Performance testing: the area between a "before" and an "after" latency curve over time measures total time saved.
  • Graphics: filled shapes in vector graphics and font rendering use signed area (the shoelace formula is a discrete version) to decide winding and coverage.

Exercises

Exercise 1: Total area

Find the total area between y=x3y = x^3 and the x-axis on [−1,2][-1, 2].

Answer

17/4=4.2517/4 = 4.25

Solution
x3<0 on [−1,0],>0 on [0,2]∫−10x3 dx=[x4/4]−10=−1/4→contributes 1/4∫02x3 dx=16/4=4total=1/4+4=17/4(signed area would be 15/4)\begin{aligned} &x^3 < 0 \text{ on } [-1, 0], \quad {} > 0 \text{ on } [0, 2] \\ \int_{-1}^{0} x^3\,dx &= \Big[x^4/4\Big]_{-1}^{0} = -1/4 && \to \text{contributes } 1/4 \\ \int_0^2 x^3\,dx &= 16/4 = 4 \\ \text{total} &= 1/4 + 4 = 17/4 && \text{(signed area would be } 15/4\text{)} \end{aligned}

Exercise 2: Line and parabola

Find the area between y=xy = x and y=x2y = x^2.

Answer

1/61/6

Solution
x=x2  ⇒  x=0,1;at x=0.5 the line (0.5) is above the parabola (0.25)A=∫01(x−x2) dx=1/2−1/3=1/6\begin{aligned} &x = x^2 \;\Rightarrow\; x = 0, 1; \quad \text{at } x = 0.5 \text{ the line (0.5) is above the parabola (0.25)} \\ A &= \int_0^1 (x - x^2)\,dx = 1/2 - 1/3 = 1/6 \end{aligned}

Exercise 3: Sine and cosine

Find the area between y=sin⁡xy = \sin x and y=cos⁡xy = \cos x from x=0x = 0 to x=π/2x = \pi/2.

Answer

22−2≈0.82842\sqrt{2} - 2 \approx 0.8284

Solution

The curves cross at x=π/4x = \pi/4, so split there:

∫0π/4(cos⁡x−sin⁡x) dx=[sin⁡x+cos⁡x]0π/4=2−1∫π/4π/2(sin⁡x−cos⁡x) dx=[−cos⁡x−sin⁡x]π/4π/2=−1+2total=22−2\begin{aligned} \int_0^{\pi/4} (\cos x - \sin x)\,dx &= \Big[\sin x + \cos x\Big]_0^{\pi/4} = \sqrt{2} - 1 \\ \int_{\pi/4}^{\pi/2} (\sin x - \cos x)\,dx &= \Big[-\cos x - \sin x\Big]_{\pi/4}^{\pi/2} = -1 + \sqrt{2} \\ \text{total} &= 2\sqrt{2} - 2 \end{aligned}
python · try it yourself
import sympy as sp

x = sp.symbols("x")
A = sp.integrate(sp.Abs(sp.sin(x) - sp.cos(x)), (x, 0, sp.pi / 2))
print(sp.nsimplify(sp.simplify(A)), "≈", round(float(A), 4))
-2 + 2*sqrt(2) ≈ 0.8284

Exercise 4: Area from samples

Two curves are only known as samples at x=0,0.5,…,3x = 0, 0.5, \ldots, 3: f = [5, 5.2, 5.5, 5.3, 5, 4.6, 4.4] and g = [1, 1.5, 2.2, 2.6, 3, 3.1, 3.4]. Estimate the area between them with the trapezoid rule.

Answer

7.85

Solution
python · try it yourself
import numpy as np

x = np.arange(0, 3.01, 0.5)
f = np.array([5, 5.2, 5.5, 5.3, 5, 4.6, 4.4])
g = np.array([1, 1.5, 2.2, 2.6, 3, 3.1, 3.4])
print(round(float(np.trapezoid(f - g, x)), 4))
7.85

Test yourself

What is the area between y=2xy = 2x and y=x2y = x^2 for 0≤x≤20 \le x \le 2?

  1. 4/34/3
  2. 8/38/3
  3. 4
  4. 2

∫−11x dx=0\int_{-1}^{1} x\,dx = 0. What is the total area between y=xy = x and the x-axis on [−1,1][-1, 1]?

  1. 0
  2. 2
  3. 1/21/2
  4. 1

What is the first step when finding the area between two curves without given limits?

  1. Differentiate both curves
  2. Solve f(x)=g(x)f(x) = g(x) to find where they meet
  3. Integrate each curve from 0
  4. Take the absolute value of each