f <- function(x) x^2
integrate(f, lower = 1, upper = 2)2.333333 with absolute error < 2.6e-14
If derivatives describe the rate of change of a function, integrals do the opposite—they accumulate values over an interval.
Definition D.1 The definite integral of a function \(f(x)\) from \(a\) to \(b\) is defined as:
\[ \int_a^b f(x)\, dx = \lim_{n \to \infty} \sum_{i=1}^n f(x_i^*) \Delta x \]
where the interval \([a, b]\) is divided into \(n\) subintervals of width \(\Delta x = \frac{b - a}{n}\) and \(x_i^*\) is a sample point in the \(i\)th subinterval.
This limit represents the total area under the curve \(f(x)\) from \(a\) to \(b\).
An indefinite integral (or antiderivative) is a function whose derivative is the original function.
Definition D.2 If \(F'(x) = f(x)\), then \(F(x)\) is an antiderivative of \(f(x)\), and we write:
\[ \int f(x)\, dx = F(x) + C \]
where \(C\) is an arbitrary constant.
Suppose your car is moving at a velocity \(f(x)\), where \(x\) is time and \(f(x)\) is in meters per second. Then:
In this way, integration undoes differentiation. If the derivative of position is velocity, then the integral of velocity is position.
| Quantity | Symbol | Interpretation | Units (if \(x\) is time) |
|---|---|---|---|
| Velocity | \(f(x)\) | Rate of change of position | Meters per second (m/s) |
| Position | \(\int f(x)\, dx\) | Total distance traveled (accumulated) | Meters (m) |
The key idea is this: integration accumulates change. It’s the natural inverse of differentiation.
Many real-world questions ask about totals or areas:
All of these questions require integration. Let’s build some fluency with it.
Theorem D.1 (Constant Rule) If \(f(x) = a\), then:
\[ \int a\, dx = ax + C \]
Example D.1 Compute \(\int 5\, dx\).
Solution. Use the constant rule: \(\int 5\, dx = 5x + C\).
Theorem D.2 (Power Rule) If \(f(x) = x^n\), then:
\[ \int x^n\, dx = \frac{x^{n + 1}}{n + 1} + C,\quad \text{for } n \ne -1 \]
Example D.2 Compute \(\int x^3\, dx\).
Solution. Apply the power rule:
\[ \int x^3\, dx = \frac{x^4}{4} + C \]
Example D.3 Compute \(\int (x^5 - 2x^2 + 7)\, dx\).
Solution. Integrate each term using the power rule:
\[ \int x^5\, dx = \frac{x^6}{6},\quad \int -2x^2\, dx = -\frac{2x^3}{3},\quad \int 7\, dx = 7x \]
So the full result is:
\[ \frac{x^6}{6} - \frac{2x^3}{3} + 7x + C \]
Theorem D.3 (Exponential Rule) If \(f(x) = e^x\), then:
\[ \int e^x\, dx = e^x + C \]
Theorem D.4 (Logarithm Rule) If \(f(x) = \frac{1}{x}\), then:
\[ \int \frac{1}{x}\, dx = \log|x| + C,\quad x \ne 0 \]
Theorem D.5 (Sum Rule) If \(f(x) = g(x) + h(x)\), then:
\[ \int f(x)\, dx = \int g(x)\, dx + \int h(x)\, dx \]
Example D.4 Compute \(\int (x^2 + \frac{1}{x})\, dx\).
Solution. Apply the sum and power rules:
\[ \int x^2\, dx = \frac{x^3}{3},\quad \int \frac{1}{x}\, dx = \log|x| \]
So:
\[ \int (x^2 + \frac{1}{x})\, dx = \frac{x^3}{3} + \log|x| + C \]
Substitution allows us to integrate composite functions, reversing the chain rule.
Theorem D.6 (Substitution Rule) Let \(u = g(x)\). Then:
\[ \int f(g(x)) g'(x)\, dx = \int f(u)\, du \]
Example D.5 Compute \(\int 2x \cdot \exp(x^2)\, dx\).
Solution. Let \(u = x^2\), so \(du = 2x\, dx\). Then:
\[ \int 2x \cdot \exp(x^2)\, dx = \int \exp(u)\, du = \exp(u) + C = \exp(x^2) + C \]
Sometimes, it helps to reverse the product rule.
Theorem D.7 (Integration by Parts) If \(u = u(x)\) and \(v = v(x)\), then:
\[ \int u\, dv = uv - \int v\, du \]
Example D.6 Compute \(\int x \cdot \log(x)\, dx\).
Solution. Use integration by parts:
Let \(u = \log(x)\), so \(du = \frac{1}{x} dx\)
Let \(dv = x\, dx\), so \(v = \frac{x^2}{2}\)
Then:
\[ \int x \log(x)\, dx = \frac{x^2}{2} \log(x) - \int \frac{x^2}{2} \cdot \frac{1}{x}\, dx = \frac{x^2}{2} \log(x) - \int \frac{x}{2}\, dx = \frac{x^2}{2} \log(x) - \frac{x^2}{4} + C \]
If we want to compute the total accumulated value over a specific interval \([a, b]\), we use definite integrals.
Definition D.3 The definite integral from \(a\) to \(b\) is:
\[ \int_a^b f(x)\, dx = F(b) - F(a) \]
where \(F(x)\) is any antiderivative of \(f(x)\).
Example D.7 Compute \(\int_1^2 x^2\, dx\).
Solution. Find the antiderivative: \(F(x) = \frac{x^3}{3}\)
Evaluate:
\[ \int_1^2 x^2\, dx = \frac{2^3}{3} - \frac{1^3}{3} = \frac{8 - 1}{3} = \frac{7}{3} \]
Sometimes the interval has no upper bound. We handle an unbounded interval by integrating to a finite endpoint \(b\) and then letting \(b\) grow without bound.
Definition D.4 The improper integral of \(f(x)\) from \(a\) to \(\infty\) is
\[ \int_a^\infty f(x)\, dx = \lim_{b \to \infty} \int_a^b f(x)\, dx \]
If this limit exists and is finite, the integral converges. Otherwise, the integral diverges.
Example D.8 Compute \(\int_0^\infty e^{-x}\, dx\).
Solution. Find the antiderivative \(F(x) = -e^{-x}\) and evaluate it from \(0\) to a finite endpoint \(b\), so that
\[ \int_0^b e^{-x}\, dx = -e^{-b} - \left( -e^{0} \right) = 1 - e^{-b} \]
Now let \(b\) grow without bound. Since \(e^{-b} \to 0\) as \(b \to \infty\), we obtain
\[ \int_0^\infty e^{-x}\, dx = \lim_{b \to \infty} \left( 1 - e^{-b} \right) = 1 \]
Improper integrals come up whenever we work with a continuous random variable defined on \([0, \infty)\), because its probability density function accumulates to one over that whole range. The exponential distribution is the case we use most.
When you integrate by parts on an unbounded interval, the boundary term \(\left[ u v \right]_0^\infty\) is also a limit. Terms like \(b e^{-\lambda b}\) and \(b^2 e^{-\lambda b}\) go to zero as \(b \to \infty\), because \(e^{-\lambda b}\) shrinks faster than any power of \(b\) grows.
R does not compute symbolic integrals with base functions, but numerical integration is straightforward using integrate().
Example D.9 Compute \(\int_1^2 x^2\, dx\) numerically.
f <- function(x) x^2
integrate(f, lower = 1, upper = 2)2.333333 with absolute error < 2.6e-14
This matches the exact value \(\frac{7}{3} \approx 2.3333\).
Example D.10 Compute \(\int_0^1 x \log(x)\, dx\) numerically.
f <- function(x) ifelse(x == 0, 0, x * log(x))
integrate(f, 0, 1)-0.25 with absolute error < 3e-05
This matches the exact value \(-\frac{1}{4}\).
Numerical integration is useful for functions that have no closed-form antiderivative or are only defined computationally.
| Operation | Symbol | Meaning |
|---|---|---|
| Derivative | \(f'(x)\) or \(\frac{df}{dx}\) | Instantaneous rate of change |
| Integral | \(\int f(x)\, dx\) | Accumulated change (area under curve) |
| Definite Int. | \(\int_a^b f(x)\, dx\) | Total change from \(x = a\) to \(x = b\) |
Together, derivatives and integrals are the fundamental tools of calculus. They describe change and accumulation—central ideas in modeling, statistics, economics, physics, and beyond.