πŸŽ‰ 75% of content is free forever β€” Unlock Premium from $10/mo β†’
CW
Search courses…
πŸ’Ό Servicesℹ️ Aboutβœ‰οΈ ContactView Pricing Plansfrom $10

Integration Fundamentals

CalculusIntegration🟒 Free Lesson

Advertisement

Integration Fundamentals

Why It Matters

Integration is the reverse operation of differentiation and one of the two pillars of calculus. While derivatives measure rates of change, integrals accumulate quantities: areas under curves, volumes of solids, total probability, and expected values. In machine learning, integration is indispensable β€” probability density functions are normalized by integrating to 1, expected values are computed as integrals, Bayesian inference requires marginalizing over posterior distributions, and variational inference approximates intractable integrals. Every time you compute the probability that a continuous random variable falls in a range, you are performing integration. Every time you sample from a distribution or estimate an expectation, integration is happening underneath. Mastering integration means understanding the mathematical foundation behind probability, statistics, and the training of probabilistic models.


What is an Integral

DfIndefinite Integral (Antiderivative)

The indefinite integral of a function f(x)f(x) is a family of functions F(x)F(x) whose derivative is f(x)f(x). It is written ∫f(x) dx=F(x)+C\int f(x)\,dx = F(x) + C, where CC is an arbitrary constant of integration representing the fact that infinitely many antiderivatives differ only by a constant.

DfDefinite Integral

The definite integral of f(x)f(x) from aa to bb is the signed area between the curve y=f(x)y = f(x) and the xx-axis over the interval [a,b][a, b]. It is defined as the limit of Riemann sums:

Riemann Sum Definition

∫abf(x) dx=lim⁑nβ†’βˆžβˆ‘i=1nf(xiβˆ—)Ξ”x\int_a^b f(x)\,dx = \lim_{n \to \infty} \sum_{i=1}^{n} f(x_i^*) \Delta x

Here,

  • Ξ”x\Delta x=Width of each subinterval: (b - a) / n
  • xiβˆ—x_i^*=A sample point in the i-th subinterval
  • f(xiβˆ—)f(x_i^*)=Function value at the sample point
  • a,ba, b=The lower and upper limits of integration

Definite vs Indefinite

An indefinite integral produces a family of functions (F(x)+CF(x) + C), while a definite integral produces a number (the signed area). The Fundamental Theorem of Calculus connects them: the definite integral equals the antiderivative evaluated at the bounds.

Not All Functions Have Elementary Antiderivatives

Many common functions β€” such as eβˆ’x2e^{-x^2}, sin⁑xx\frac{\sin x}{x}, and sin⁑x\sqrt{\sin x} β€” do not have closed-form antiderivatives in terms of elementary functions. For these, we rely on numerical integration or special functions (e.g., the error function erf(x)\text{erf}(x)).


Fundamental Theorem of Calculus

ThFundamental Theorem of Calculus (Part 1)

If ff is continuous on [a,b][a, b] and F(x)=∫axf(t) dtF(x) = \int_a^x f(t)\,dt, then FF is differentiable on (a,b)(a, b) and Fβ€²(x)=f(x)F'(x) = f(x). In other words, differentiation undoes integration.

ThFundamental Theorem of Calculus (Part 2)

If ff is continuous on [a,b][a, b] and FF is any antiderivative of ff (i.e., Fβ€²(x)=f(x)F'(x) = f(x)), then:

Fundamental Theorem of Calculus

∫abf(x) dx=F(b)βˆ’F(a)\int_a^b f(x)\,dx = F(b) - F(a)

Here,

  • f(x)f(x)=The integrand β€” the function being integrated
  • F(x)F(x)=An antiderivative of f, where F'(x) = f(x)
  • aa=The lower limit of integration
  • bb=The upper limit of integration
  • F(b)βˆ’F(a)F(b) - F(a)=The net change of F over [a, b]

Intuition

Part 1 says that if you build a function by integrating ff from a fixed point aa to a variable point xx, the rate at which this accumulated area grows is exactly f(x)f(x). Part 2 says that to compute the accumulated area, you only need any antiderivative β€” evaluate it at the top bound and subtract its value at the bottom bound. This transforms the hard problem of summing infinitely many infinitesimal contributions into the easy problem of evaluating a function at two points.

Applying the Fundamental Theorem

Problem: Compute ∫02(3x2+2x) dx\int_0^2 (3x^2 + 2x)\,dx.

Solution

Find an antiderivative: F(x)=x3+x2F(x) = x^3 + x^2 (since Fβ€²(x)=3x2+2xF'(x) = 3x^2 + 2x).

Evaluate at the bounds: F(2)βˆ’F(0)=(8+4)βˆ’(0+0)=12F(2) - F(0) = (8 + 4) - (0 + 0) = 12.

The area under 3x2+2x3x^2 + 2x from x=0x = 0 to x=2x = 2 is 1212.


Properties of Definite Integrals

PropertyFormulaDescription
Reversing bounds∫abf(x) dx=βˆ’βˆ«baf(x) dx\int_a^b f(x)\,dx = -\int_b^a f(x)\,dxSwapping limits negates the integral
Additivity∫abf(x) dx=∫acf(x) dx+∫cbf(x) dx\int_a^b f(x)\,dx = \int_a^c f(x)\,dx + \int_c^b f(x)\,dxSplit at any intermediate point cc
Linearity∫ab[Ξ±f(x)+Ξ²g(x)] dx=α∫abf(x) dx+β∫abg(x) dx\int_a^b [\alpha f(x) + \beta g(x)]\,dx = \alpha\int_a^b f(x)\,dx + \beta\int_a^b g(x)\,dxConstants factor out, integrals add
Zero-width∫aaf(x) dx=0\int_a^a f(x)\,dx = 0Integrating over a point gives zero
PositivityIf f(x)β‰₯0f(x) \geq 0 on [a,b][a,b], then ∫abf(x) dxβ‰₯0\int_a^b f(x)\,dx \geq 0Non-negative functions have non-negative integrals
ComparisonIf f(x)≀g(x)f(x) \leq g(x) on [a,b][a,b], then ∫abf(x) dxβ‰€βˆ«abg(x) dx\int_a^b f(x)\,dx \leq \int_a^b g(x)\,dxInequality preserved under integration
Triangle Inequality∣∫abf(x) dxβˆ£β‰€βˆ«ab∣f(x)βˆ£β€‰dx\left|\int_a^b f(x)\,dx\right| \leq \int_a^b |f(x)|\,dxThe integral of the absolute value bounds the absolute value of the integral

Basic Integration Rules

The following rules allow us to integrate complex functions by breaking them into simpler parts.

RuleFormulaExample
Constant∫c dx=cx+C\int c\,dx = cx + C∫5 dx=5x+C\int 5\,dx = 5x + C
Power Rule∫xn dx=xn+1n+1+C\int x^n\,dx = \frac{x^{n+1}}{n+1} + C (nβ‰ βˆ’1n \neq -1)∫x3 dx=x44+C\int x^3\,dx = \frac{x^4}{4} + C
Reciprocal∫1x dx=ln⁑∣x∣+C\int \frac{1}{x}\,dx = \ln|x| + C∫1x dx=ln⁑∣x∣+C\int \frac{1}{x}\,dx = \ln|x| + C
Exponential∫ex dx=ex+C\int e^x\,dx = e^x + C∫ex dx=ex+C\int e^x\,dx = e^x + C
General Exponential∫ax dx=axln⁑a+C\int a^x\,dx = \frac{a^x}{\ln a} + C∫3x dx=3xln⁑3+C\int 3^x\,dx = \frac{3^x}{\ln 3} + C
Sine∫sin⁑x dx=βˆ’cos⁑x+C\int \sin x\,dx = -\cos x + C∫sin⁑x dx=βˆ’cos⁑x+C\int \sin x\,dx = -\cos x + C
Cosine∫cos⁑x dx=sin⁑x+C\int \cos x\,dx = \sin x + C∫cos⁑x dx=sin⁑x+C\int \cos x\,dx = \sin x + C
Secant∫sec⁑2x dx=tan⁑x+C\int \sec^2 x\,dx = \tan x + C∫sec⁑2x dx=tan⁑x+C\int \sec^2 x\,dx = \tan x + C
Cosecant∫csc⁑2x dx=βˆ’cot⁑x+C\int \csc^2 x\,dx = -\cot x + C∫csc⁑2x dx=βˆ’cot⁑x+C\int \csc^2 x\,dx = -\cot x + C
Secant-Tangent∫sec⁑xtan⁑x dx=sec⁑x+C\int \sec x \tan x\,dx = \sec x + C∫sec⁑xtan⁑x dx=sec⁑x+C\int \sec x \tan x\,dx = \sec x + C
Cosecant-Cotangent∫csc⁑xcot⁑x dx=βˆ’csc⁑x+C\int \csc x \cot x\,dx = -\csc x + C∫csc⁑xcot⁑x dx=βˆ’csc⁑x+C\int \csc x \cot x\,dx = -\csc x + C
Inverse Sine∫11βˆ’x2 dx=arcsin⁑x+C\int \frac{1}{\sqrt{1-x^2}}\,dx = \arcsin x + C∫11βˆ’x2 dx=arcsin⁑x+C\int \frac{1}{\sqrt{1-x^2}}\,dx = \arcsin x + C
Inverse Tangent∫11+x2 dx=arctan⁑x+C\int \frac{1}{1+x^2}\,dx = \arctan x + C∫11+x2 dx=arctan⁑x+C\int \frac{1}{1+x^2}\,dx = \arctan x + C
Hyperbolic Sine∫sinh⁑x dx=cosh⁑x+C\int \sinh x\,dx = \cosh x + C∫sinh⁑x dx=cosh⁑x+C\int \sinh x\,dx = \cosh x + C
Hyperbolic Cosine∫cosh⁑x dx=sinh⁑x+C\int \cosh x\,dx = \sinh x + C∫cosh⁑x dx=sinh⁑x+C\int \cosh x\,dx = \sinh x + C

Power Rule Exception

The power rule ∫xn dx=xn+1n+1+C\int x^n\,dx = \frac{x^{n+1}}{n+1} + C fails when n=βˆ’1n = -1. In that case, ∫xβˆ’1 dx=∫1x dx=ln⁑∣x∣+C\int x^{-1}\,dx = \int \frac{1}{x}\,dx = \ln|x| + C. This is because ddxln⁑∣x∣=1x\frac{d}{dx}\ln|x| = \frac{1}{x}.


Integration by Substitution

DfIntegration by Substitution (u-substitution)

The substitution rule is the reverse of the chain rule for differentiation. If u=g(x)u = g(x) is a differentiable function whose range is an interval, and ff is continuous on that interval, then:

Substitution Rule

∫f(g(x))β‹…gβ€²(x) dx=∫f(u) duwhereΒ u=g(x)\int f(g(x)) \cdot g'(x)\,dx = \int f(u)\,du \quad \text{where } u = g(x)

Here,

  • u=g(x)u = g(x)=The substitution β€” the inner function
  • du=gβ€²(x)dxdu = g'(x)dx=The differential of u
  • f(g(x))β‹…gβ€²(x)f(g(x)) \cdot g'(x)=The original integrand with chain rule factor

When to Use Substitution

Use substitution when the integrand contains a function and its derivative (or a constant multiple of it). Look for a "inner function" g(x)g(x) whose derivative gβ€²(x)g'(x) appears as a factor. Common patterns: ∫sin⁑(cos⁑x)cos⁑x dx\int \sin(\cos x) \cos x\,dx, ∫xex2 dx\int xe^{x^2}\,dx, ∫xx2+1 dx\int \frac{x}{x^2+1}\,dx.

Substitution Example 1

Problem: Compute ∫2xcos⁑(x2) dx\int 2x \cos(x^2)\,dx.

Solution

Let u=x2u = x^2, so du=2x dxdu = 2x\,dx.

∫cos⁑(u) du=sin⁑(u)+C=sin⁑(x2)+C\int \cos(u)\,du = \sin(u) + C = \sin(x^2) + C.

Substitution Example 2

Problem: Compute ∫0Ο€/2sin⁑3(x)cos⁑(x) dx\int_0^{\pi/2} \sin^3(x) \cos(x)\,dx.

Solution

Let u=sin⁑(x)u = \sin(x), so du=cos⁑(x) dxdu = \cos(x)\,dx.

When x=0x = 0, u=0u = 0. When x=Ο€/2x = \pi/2, u=1u = 1.

∫01u3 du=[u44]01=14\int_0^1 u^3\,du = \left[\frac{u^4}{4}\right]_0^1 = \frac{1}{4}.

Don't Forget to Change the Bounds

When performing substitution on a definite integral, you must either change the limits of integration to match the new variable or back-substitute before evaluating. Forgetting to update the bounds is one of the most common errors.


Integration by Parts

DfIntegration by Parts

Integration by parts is the reverse of the product rule for differentiation. It is used to integrate products of functions:

Integration by Parts

∫u dv=uvβˆ’βˆ«v du\int u\,dv = uv - \int v\,du

Here,

  • uu=The part you differentiate (choose something that simplifies)
  • dvdv=The part you integrate (choose something easy to integrate)
  • dudu=The derivative of u
  • vv=The antiderivative of dv

Definite Integral Version

∫abu dv=[uv]abβˆ’βˆ«abv du\int_a^b u\,dv = [uv]_a^b - \int_a^b v\,du

Here,

  • [uv]ab[uv]_a^b=The boundary term: u(b)v(b) - u(a)v(a)
  • ∫abv du\int_a^b v\,du=The remaining integral (often simpler)

LIATE Rule for Choosing u

A helpful heuristic for choosing uu: Logarithmic -> Inverse trig -> Algebraic -> Trigonometric -> Exponential. Choose uu as whichever comes first in this list. The remaining factor becomes dvdv.

Integration by Parts Example 1

Problem: Compute ∫xex dx\int x e^x\,dx.

Solution

Let u=xu = x (algebraic), dv=ex dxdv = e^x\,dx (exponential). Then du=dxdu = dx, v=exv = e^x.

∫xex dx=xexβˆ’βˆ«ex dx=xexβˆ’ex+C=ex(xβˆ’1)+C\int x e^x\,dx = xe^x - \int e^x\,dx = xe^x - e^x + C = e^x(x - 1) + C.

Integration by Parts Example 2

Problem: Compute ∫ln⁑x dx\int \ln x\,dx.

Solution

Let u=ln⁑xu = \ln x, dv=dxdv = dx. Then du=1x dxdu = \frac{1}{x}\,dx, v=xv = x.

∫ln⁑x dx=xln⁑xβˆ’βˆ«xβ‹…1x dx=xln⁑xβˆ’βˆ«1 dx=xln⁑xβˆ’x+C\int \ln x\,dx = x\ln x - \int x \cdot \frac{1}{x}\,dx = x\ln x - \int 1\,dx = x\ln x - x + C.

Integration by Parts Example 3

Problem: Compute ∫exsin⁑x dx\int e^x \sin x\,dx.

Solution

Apply integration by parts twice:

Let u=sin⁑xu = \sin x, dv=ex dxdv = e^x\,dx. Then du=cos⁑x dxdu = \cos x\,dx, v=exv = e^x.

I=exsin⁑xβˆ’βˆ«excos⁑x dxI = e^x \sin x - \int e^x \cos x\,dx

Now integrate ∫excos⁑x dx\int e^x \cos x\,dx by parts again:

Let u=cos⁑xu = \cos x, dv=ex dxdv = e^x\,dx. Then du=βˆ’sin⁑x dxdu = -\sin x\,dx, v=exv = e^x.

∫excos⁑x dx=excos⁑x+∫exsin⁑x dx=excos⁑x+I\int e^x \cos x\,dx = e^x \cos x + \int e^x \sin x\,dx = e^x \cos x + I

Substitute back: I=exsin⁑xβˆ’(excos⁑x+I)=ex(sin⁑xβˆ’cos⁑x)βˆ’II = e^x \sin x - (e^x \cos x + I) = e^x(\sin x - \cos x) - I

2I=ex(sin⁑xβˆ’cos⁑x)2I = e^x(\sin x - \cos x)I=ex(sin⁑xβˆ’cos⁑x)2+CI = \frac{e^x(\sin x - \cos x)}{2} + C

Cyclic Integration by Parts

When integration by parts returns you to the original integral (as in the exsin⁑xe^x \sin x example), you can solve for the integral algebraically. This "cyclic" pattern occurs with products of exponentials and trigonometric functions.


Common Integrals

IntegralResultNotes
∫xn dx\int x^n\,dxxn+1n+1+C\frac{x^{n+1}}{n+1} + Cnβ‰ βˆ’1n \neq -1
∫1x dx\int \frac{1}{x}\,dxln⁑∣x∣+C\ln|x| + CThe n=βˆ’1n = -1 case
∫ex dx\int e^x\,dxex+Ce^x + CIts own antiderivative
∫ax dx\int a^x\,dxaxln⁑a+C\frac{a^x}{\ln a} + Ca>0a > 0, aβ‰ 1a \neq 1
∫sin⁑x dx\int \sin x\,dxβˆ’cos⁑x+C-\cos x + C
∫cos⁑x dx\int \cos x\,dxsin⁑x+C\sin x + C
∫sec⁑2x dx\int \sec^2 x\,dxtan⁑x+C\tan x + C
∫csc⁑2x dx\int \csc^2 x\,dxβˆ’cot⁑x+C-\cot x + C
∫sec⁑xtan⁑x dx\int \sec x \tan x\,dxsec⁑x+C\sec x + C
∫csc⁑xcot⁑x dx\int \csc x \cot x\,dxβˆ’csc⁑x+C-\csc x + C
∫11βˆ’x2 dx\int \frac{1}{\sqrt{1-x^2}}\,dxarcsin⁑x+C\arcsin x + C
∫11+x2 dx\int \frac{1}{1+x^2}\,dxarctan⁑x+C\arctan x + C
∫tan⁑x dx\int \tan x\,dxln⁑∣sec⁑x∣+C\ln|\sec x| + CRewrite as ∫sin⁑xcos⁑x dx\int \frac{\sin x}{\cos x}\,dx
∫sec⁑x dx\int \sec x\,dxln⁑∣sec⁑x+tan⁑x∣+C\ln|\sec x + \tan x| + C
∫1x2+a2 dx\int \frac{1}{x^2+a^2}\,dx1aarctan⁑xa+C\frac{1}{a}\arctan\frac{x}{a} + C
∫1a2βˆ’x2 dx\int \frac{1}{\sqrt{a^2-x^2}}\,dxarcsin⁑xa+C\arcsin\frac{x}{a} + C
∫1x2βˆ’a2 dx\int \frac{1}{x^2-a^2}\,dx12aln⁑∣xβˆ’ax+a∣+C\frac{1}{2a}\ln\left|\frac{x-a}{x+a}\right| + CPartial fractions
∫1x2Β±a2 dx\int \frac{1}{\sqrt{x^2 \pm a^2}}\,dxln⁑∣x+x2Β±a2∣+C\ln|x + \sqrt{x^2 \pm a^2}| + C
∫sinh⁑x dx\int \sinh x\,dxcosh⁑x+C\cosh x + C
∫cosh⁑x dx\int \cosh x\,dxsinh⁑x+C\sinh x + C
∫sech2x dx\int \text{sech}^2 x\,dxtanh⁑x+C\tanh x + C
∫csch2x dx\int \text{csch}^2 x\,dxβˆ’cothΒ x+C-\text{coth } x + C

Improper Integrals

DfImproper Integral

An improper integral is an integral where either the interval of integration is infinite or the integrand has an infinite discontinuity (vertical asymptote) within the interval. We evaluate it as a limit.

Infinite Upper Limit

∫a∞f(x) dx=lim⁑bβ†’βˆžβˆ«abf(x) dx\int_a^\infty f(x)\,dx = \lim_{b \to \infty} \int_a^b f(x)\,dx

Here,

  • aa=The finite lower bound
  • bβ†’βˆžb \to \infty=The upper bound approaches infinity

Infinite Lower Limit

βˆ«βˆ’βˆžbf(x) dx=lim⁑aβ†’βˆ’βˆžβˆ«abf(x) dx\int_{-\infty}^b f(x)\,dx = \lim_{a \to -\infty} \int_a^b f(x)\,dx

Here,

  • aβ†’βˆ’βˆža \to -\infty=The lower bound approaches negative infinity
  • bb=The finite upper bound

Double Infinite

βˆ«βˆ’βˆžβˆžf(x) dx=βˆ«βˆ’βˆžcf(x) dx+∫c∞f(x) dx\int_{-\infty}^{\infty} f(x)\,dx = \int_{-\infty}^{c} f(x)\,dx + \int_{c}^{\infty} f(x)\,dx

Here,

  • cc=Any finite point (often 0)

DfConvergence and Divergence

An improper integral converges if the limit exists and is finite. It diverges if the limit does not exist or is infinite. Both parts must converge independently for the full integral to converge.

Improper Integral That Converges

Problem: Evaluate ∫1∞1x2 dx\int_1^\infty \frac{1}{x^2}\,dx.

Solution

∫1∞1x2 dx=lim⁑bβ†’βˆžβˆ«1bxβˆ’2 dx=lim⁑bβ†’βˆž[βˆ’1x]1b=lim⁑bβ†’βˆž(βˆ’1b+1)=1\int_1^\infty \frac{1}{x^2}\,dx = \lim_{b \to \infty} \int_1^b x^{-2}\,dx = \lim_{b \to \infty} \left[-\frac{1}{x}\right]_1^b = \lim_{b \to \infty}\left(-\frac{1}{b} + 1\right) = 1.

The integral converges to 11.

Improper Integral That Diverges

Problem: Evaluate ∫1∞1x dx\int_1^\infty \frac{1}{x}\,dx.

Solution

∫1∞1x dx=lim⁑bβ†’βˆžβˆ«1b1x dx=lim⁑bβ†’βˆž[ln⁑x]1b=lim⁑bβ†’βˆžln⁑b=∞\int_1^\infty \frac{1}{x}\,dx = \lim_{b \to \infty} \int_1^b \frac{1}{x}\,dx = \lim_{b \to \infty} [\ln x]_1^b = \lim_{b \to \infty} \ln b = \infty.

The integral diverges (grows without bound).

p-Integral Test

∫1∞1xp dx\int_1^\infty \frac{1}{x^p}\,dx converges if and only if p>1p > 1. This is a quick way to determine convergence for power-type integrands. For example, ∫1∞1x1.01 dx\int_1^\infty \frac{1}{x^{1.01}}\,dx converges (just barely), while ∫1∞1x0.99 dx\int_1^\infty \frac{1}{x^{0.99}}\,dx diverges.

Improper Integral with Discontinuity

Problem: Evaluate ∫011x dx\int_0^1 \frac{1}{\sqrt{x}}\,dx.

Solution

The integrand has a vertical asymptote at x=0x = 0.

∫01xβˆ’1/2 dx=lim⁑aβ†’0+∫a1xβˆ’1/2 dx=lim⁑aβ†’0+[2x]a1=lim⁑aβ†’0+(2βˆ’2a)=2\int_0^1 x^{-1/2}\,dx = \lim_{a \to 0^+} \int_a^1 x^{-1/2}\,dx = \lim_{a \to 0^+} [2\sqrt{x}]_a^1 = \lim_{a \to 0^+}(2 - 2\sqrt{a}) = 2.

The integral converges to 22.


Numerical Integration

When an antiderivative cannot be found in closed form, or when the integrand is defined only by data points, we approximate the integral numerically.

Trapezoidal Rule

DfTrapezoidal Rule

Approximates the area under the curve by dividing the interval into nn subintervals and approximating each strip as a trapezoid. The error is proportional to h2h^2 (second-order method).

Trapezoidal Rule

∫abf(x) dxβ‰ˆh2[f(x0)+2βˆ‘i=1nβˆ’1f(xi)+f(xn)]\int_a^b f(x)\,dx \approx \frac{h}{2}\left[f(x_0) + 2\sum_{i=1}^{n-1}f(x_i) + f(x_n)\right]

Here,

  • h=bβˆ’anh = \frac{b-a}{n}=Width of each subinterval
  • xi=a+ihx_i = a + ih=The i-th grid point
  • nn=Number of subintervals

Simpson's Rule

DfSimpson's Rule

Approximates the area using parabolic arcs instead of straight lines. Requires an even number of subintervals. The error is proportional to h4h^4 (fourth-order method), making it significantly more accurate than the trapezoidal rule for smooth functions.

Simpson's Rule

∫abf(x) dxβ‰ˆh3[f(x0)+4βˆ‘iΒ oddf(xi)+2βˆ‘iΒ evenf(xi)+f(xn)]\int_a^b f(x)\,dx \approx \frac{h}{3}\left[f(x_0) + 4\sum_{i \text{ odd}} f(x_i) + 2\sum_{i \text{ even}} f(x_i) + f(x_n)\right]

Here,

  • h=bβˆ’anh = \frac{b-a}{n}=Width of each subinterval (n must be even)
  • xi=a+ihx_i = a + ih=The i-th grid point
  • 4βˆ‘iΒ odd4 \sum_{i \text{ odd}}=Weight 4 for odd-indexed points
  • 2βˆ‘iΒ even2 \sum_{i \text{ even}}=Weight 2 for even-indexed points (except endpoints)

Gaussian Quadrature

DfGaussian Quadrature

A higher-order numerical integration method that chooses both the nodes and weights optimally. An nn-point Gaussian quadrature rule integrates polynomials of degree 2nβˆ’12n - 1 exactly. It is particularly efficient for smooth functions.

MethodOrder of AccuracyBest ForNodes Required
TrapezoidalO(h2)O(h^2)Rough data, quick estimatesUniform grid
Simpson'sO(h4)O(h^4)Smooth functions, moderate precisionUniform grid (even nn)
GaussianO(h2n)O(h^{2n})High-precision integration of smooth functionsOptimally placed nodes
Monte CarloO(1/n)O(1/\sqrt{n})High-dimensional integralsRandom samples

Monte Carlo Integration in High Dimensions

For integrals over high-dimensional spaces (common in Bayesian inference and physics simulations), grid-based methods suffer from the curse of dimensionality β€” the number of grid points grows exponentially with dimension. Monte Carlo integration converges at rate O(1/n)O(1/\sqrt{n}) regardless of dimension, making it the only practical choice for high-dimensional integrals.


Python Implementation

Basic Integration with scipy.integrate

import numpy as np
from scipy import integrate

# Define the function to integrate
def f(x):
    return x**2 * np.exp(-x)

# Compute the integral from 0 to infinity (improper integral)
result, error = integrate.quad(f, 0, np.inf)
print(f"Integral of x^2 * exp(-x) from 0 to inf:")
print(f"  Result: {result:.6f}")
print(f"  Error estimate: {error:.2e}")
print(f"  Exact (2! = 2): 2.000000")

# Definite integral from 0 to 1
result, error = integrate.quad(lambda x: np.sin(x), 0, np.pi)
print(f"\nIntegral of sin(x) from 0 to pi: {result:.6f} (exact: 2)")

Numerical Methods Comparison

import numpy as np
from scipy import integrate

# Define test function: f(x) = x^2
f = lambda x: x**2
a, b = 0, 1
exact = 1/3

# Trapezoidal rule
for n in [10, 100, 1000]:
    x = np.linspace(a, b, n + 1)
    trap_result = np.trapz(f(x), x)
    print(f"Trapezoidal (n={n:4d}): {trap_result:.8f}  error: {abs(trap_result - exact):.2e}")

print()

# Simpson's rule
for n in [10, 100, 1000]:
    x = np.linspace(a, b, n + 1)
    simp_result = integrate.simpson(f(x), x=x)
    print(f"Simpson's   (n={n:4d}): {simp_result:.8f}  error: {abs(simp_result - exact):.2e}")

print()

# Gaussian quadrature (scipy)
for n in [5, 10, 20]:
    result, error = integrate.fixed_quad(lambda x: x**2, a, b, n=n)
    print(f"Gauss quad  (n={n:4d}): {result:.8f}  error: {abs(result - exact):.2e}")

# scipy.integrate.quad (adaptive)
result, error = integrate.quad(f, a, b)
print(f"\nAdaptive quad:      {result:.8f}  error: {error:.2e}")

Symbolic Integration with SymPy

import sympy as sp

x = sp.Symbol('x')

# Symbolic indefinite integral
f = x**2 * sp.exp(x)
F = sp.integrate(f, x)
print(f"Indefinite integral of x^2 * e^x: {F}")

# Definite integral
result = sp.integrate(x**2, (x, 0, 1))
print(f"Definite integral of x^2 from 0 to 1: {result}")

# Improper integral
result = sp.integrate(sp.exp(-x**2), (x, -sp.oo, sp.oo))
print(f"Integral of e^(-x^2) from -inf to inf: {result}")
print(f"  = sqrt(pi) = {sp.sqrt(sp.pi)}")

# Verify Fundamental Theorem
F = sp.integrate(sp.sin(x), x)
print(f"\nAntiderivative of sin(x): {F}")
print(f"FTC: F(pi) - F(0) = {F.subs(x, sp.pi) - F.subs(x, 0)}")

High-Dimensional Integration (Monte Carlo)

import numpy as np

def monte_carlo_integrate(f, bounds, n_samples=100000):
    """Monte Carlo integration for arbitrary dimensions."""
    dim = len(bounds)
    samples = np.random.uniform(
        low=[b[0] for b in bounds],
        high=[b[1] for b in bounds],
        size=(n_samples, dim)
    )
    values = np.array([f(s) for s in samples])
    volume = np.prod([b[1] - b[0] for b in bounds])
    mean_val = np.mean(values)
    std_err = np.std(values) / np.sqrt(n_samples)
    return mean_val * volume, std_err

# Example: integral of x^2 + y^2 over [0,1] x [0,1]
f = lambda p: p[0]**2 + p[1]**2
result, error = monte_carlo_integrate(f, [(0, 1), (0, 1)])
exact = 2/3  # integral of x^2 + y^2 over [0,1]^2
print(f"Monte Carlo estimate: {result:.6f} +/- {error:.6f}")
print(f"Exact value:          {exact:.6f}")

Applications in AI/ML

Probability Density Functions

Integration and Probability

The entire foundation of continuous probability rests on integration. A probability density function fX(x)f_X(x) must satisfy βˆ«βˆ’βˆžβˆžfX(x) dx=1\int_{-\infty}^{\infty} f_X(x)\,dx = 1 (normalization), and the probability of any event is computed as an integral of the density.

Probability from PDF

P(a≀X≀b)=∫abfX(x) dxP(a \leq X \leq b) = \int_a^b f_X(x)\,dx

Here,

  • fX(x)f_X(x)=The probability density function of the random variable X
  • a,ba, b=The interval bounds
  • P(a≀X≀b)P(a \leq X \leq b)=The probability that X falls in [a, b]

Normalization Condition

βˆ«βˆ’βˆžβˆžfX(x) dx=1\int_{-\infty}^{\infty} f_X(x)\,dx = 1

Here,

  • fX(x)f_X(x)=A valid PDF must integrate to 1 over its support

Expected Values and Moments

Expected Value

E[X]=βˆ«βˆ’βˆžβˆžxβ‹…fX(x) dxE[X] = \int_{-\infty}^{\infty} x \cdot f_X(x)\,dx

Here,

  • E[X]E[X]=The expected value (mean) of X
  • xβ‹…fX(x)x \cdot f_X(x)=Each value weighted by its probability density

Variance

Var(X)=E[(Xβˆ’ΞΌ)2]=βˆ«βˆ’βˆžβˆž(xβˆ’ΞΌ)2fX(x) dx\text{Var}(X) = E[(X - \mu)^2] = \int_{-\infty}^{\infty} (x - \mu)^2 f_X(x)\,dx

Here,

  • ΞΌ=E[X]\mu = E[X]=The mean of X
  • (xβˆ’ΞΌ)2(x - \mu)^2=Squared deviation from the mean

General Moment

E[g(X)]=βˆ«βˆ’βˆžβˆžg(x)β‹…fX(x) dxE[g(X)] = \int_{-\infty}^{\infty} g(x) \cdot f_X(x)\,dx

Here,

  • g(X)g(X)=Any function of the random variable
  • E[g(X)]E[g(X)]=The expected value of g(X) β€” a weighted average

Bayesian Inference

Integrals in Bayesian Methods

Bayesian inference is built on integration. The posterior distribution requires the evidence (marginal likelihood), which is an integral: p(θ∣data)=p(data∣θ)p(ΞΈ)∫p(data∣θ)p(ΞΈ) dΞΈp(\theta | \text{data}) = \frac{p(\text{data} | \theta) p(\theta)}{\int p(\text{data} | \theta) p(\theta)\,d\theta}. This integral is often intractable, which is why methods like MCMC, variational inference, and Laplace approximation exist β€” they all approximate this integral.

Evidence (Marginal Likelihood)

p(data)=∫p(data∣θ)β‹…p(ΞΈ) dΞΈp(\text{data}) = \int p(\text{data} | \theta) \cdot p(\theta)\,d\theta

Here,

  • p(data∣θ)p(\text{data} | \theta)=The likelihood of the data given parameters
  • p(ΞΈ)p(\theta)=The prior distribution over parameters
  • p(data)p(\text{data})=The evidence β€” obtained by integrating over all parameter values

Common Probability Integrals

DistributionPDFKey Integral
Normal N(ΞΌ,Οƒ2)\mathcal{N}(\mu, \sigma^2)1Οƒ2Ο€eβˆ’(xβˆ’ΞΌ)22Οƒ2\frac{1}{\sigma\sqrt{2\pi}}e^{-\frac{(x-\mu)^2}{2\sigma^2}}βˆ«βˆ’βˆžβˆžf(x) dx=1\int_{-\infty}^{\infty} f(x)\,dx = 1
Standard Normal12Ο€eβˆ’x2/2\frac{1}{\sqrt{2\pi}}e^{-x^2/2}βˆ«βˆ’βˆžβˆžeβˆ’x2/22π dx=1\int_{-\infty}^{\infty} \frac{e^{-x^2/2}}{\sqrt{2\pi}}\,dx = 1
Exponential Exp(Ξ»)\text{Exp}(\lambda)Ξ»eβˆ’Ξ»x\lambda e^{-\lambda x}, xβ‰₯0x \geq 0∫0∞λeβˆ’Ξ»x dx=1\int_0^\infty \lambda e^{-\lambda x}\,dx = 1
Beta Beta(Ξ±,Ξ²)\text{Beta}(\alpha, \beta)xΞ±βˆ’1(1βˆ’x)Ξ²βˆ’1B(Ξ±,Ξ²)\frac{x^{\alpha-1}(1-x)^{\beta-1}}{B(\alpha,\beta)}∫01f(x) dx=1\int_0^1 f(x)\,dx = 1
Gamma Gamma(Ξ±,Ξ²)\text{Gamma}(\alpha, \beta)Ξ²Ξ±xΞ±βˆ’1eβˆ’Ξ²xΞ“(Ξ±)\frac{\beta^\alpha x^{\alpha-1}e^{-\beta x}}{\Gamma(\alpha)}∫0∞f(x) dx=1\int_0^\infty f(x)\,dx = 1

Common Mistakes

MistakeIncorrectCorrectExplanation
Forgetting the constant of integration∫x2 dx=x33\int x^2\,dx = \frac{x^3}{3}∫x2 dx=x33+C\int x^2\,dx = \frac{x^3}{3} + CAlways include +C+ C for indefinite integrals
Wrong sign on trig integral∫sin⁑x dx=cos⁑x+C\int \sin x\,dx = \cos x + C∫sin⁑x dx=βˆ’cos⁑x+C\int \sin x\,dx = -\cos x + CThe integral of sine is negative cosine
Power rule on 1/x1/x∫1x dx=x00+C\int \frac{1}{x}\,dx = \frac{x^0}{0} + C∫1x dx=ln⁑∣x∣+C\int \frac{1}{x}\,dx = \ln|x| + CPower rule fails at n=βˆ’1n = -1; use ln⁑∣x∣\ln|x|
Not changing bounds on substitutionEvaluate with old bounds after uu-subUpdate bounds when substitutingIf u=g(x)u = g(x), new bounds are g(a)g(a) and g(b)g(b)
Dropping absolute value in ln⁑\ln∫1x dx=ln⁑(x)+C\int \frac{1}{x}\,dx = \ln(x) + C∫1x dx=ln⁑∣x∣+C\int \frac{1}{x}\,dx = \ln|x| + C1x\frac{1}{x} is defined for x<0x < 0 too
Confusing integration with differentiation rulesTreating integrals like derivativesIntegration follows different rulesE.g., ∫sin⁑xcos⁑x dxβ‰ sin⁑xβ‹…sin⁑x\int \sin x \cos x\,dx \neq \sin x \cdot \sin x
Forgetting boundary term in integration by parts∫u dv=βˆ’βˆ«v du\int u\,dv = -\int v\,du∫u dv=uvβˆ’βˆ«v du\int u\,dv = uv - \int v\,duThe uvuv term is essential
Divergent improper integralsAssuming ∫1∞1xp dx\int_1^\infty \frac{1}{x^p}\,dx always convergesConverges only for p>1p > 1Check convergence before evaluating
Wrong dudu in substitutionForgetting to include the derivativedu=gβ€²(x) dxdu = g'(x)\,dx not just du=g(x)du = g(x)The differential dudu must include the derivative
Splitting integrals incorrectlyβˆ«βˆ’111x dx=0\int_{-1}^{1} \frac{1}{x}\,dx = 0 (by symmetry)βˆ«βˆ’111x dx\int_{-1}^{1} \frac{1}{x}\,dx divergesThe integrand has a singularity at x=0x = 0

Double-Check Your Work

After computing an integral, verify by differentiating your answer. If ∫f(x) dx=F(x)+C\int f(x)\,dx = F(x) + C, then Fβ€²(x)F'(x) should equal f(x)f(x). For definite integrals, check boundary values and sign consistency.


Interview Questions

Q1: State the Fundamental Theorem of Calculus and explain its significance.

Answer

The Fundamental Theorem of Calculus has two parts:

Part 1: If F(x)=∫axf(t) dtF(x) = \int_a^x f(t)\,dt and ff is continuous, then Fβ€²(x)=f(x)F'(x) = f(x). This shows differentiation undoes integration.

Part 2: If FF is any antiderivative of ff, then ∫abf(x) dx=F(b)βˆ’F(a)\int_a^b f(x)\,dx = F(b) - F(a). This allows us to compute definite integrals using antiderivatives.

Significance: It connects the two branches of calculus (differential and integral), transforms the problem of computing areas into evaluating antiderivatives, and provides the theoretical foundation for the entire field.

Q2: When would you use integration by parts vs. substitution?

Answer

  • Substitution is used when the integrand contains a composition of functions where the inner function's derivative appears as a factor (reverse of the chain rule). Example: ∫2xcos⁑(x2) dx\int 2x\cos(x^2)\,dx.
  • Integration by parts is used for products of different types of functions (reverse of the product rule). Example: ∫xex dx\int x e^x\,dx.
  • A good heuristic: if you see a "inner-derivative" pattern, use substitution. If you see a product of different function types (algebraic Γ— exponential, algebraic Γ— trig, etc.), use by parts. The LIATE rule helps choose uu.

Q3: Why does βˆ«βˆ’βˆžβˆžeβˆ’x2 dx=Ο€\int_{-\infty}^{\infty} e^{-x^2}\,dx = \sqrt{\pi}? Why is this important in ML?

Answer

This is the Gaussian integral. It cannot be computed by finding an antiderivative (since eβˆ’x2e^{-x^2} has no elementary antiderivative). The classic proof squares the integral and converts to polar coordinates:

(βˆ«βˆ’βˆžβˆžeβˆ’x2 dx)2=βˆ«βˆ’βˆžβˆžβˆ«βˆ’βˆžβˆžeβˆ’(x2+y2) dx dy=∫02Ο€βˆ«0∞eβˆ’r2r dr dΞΈ=Ο€\left(\int_{-\infty}^{\infty} e^{-x^2}\,dx\right)^2 = \int_{-\infty}^{\infty}\int_{-\infty}^{\infty} e^{-(x^2+y^2)}\,dx\,dy = \int_0^{2\pi}\int_0^{\infty} e^{-r^2} r\,dr\,d\theta = \pi.

Taking the square root gives Ο€\sqrt{\pi}.

Importance in ML: This integral is the normalization constant for the Gaussian distribution, the most important distribution in statistics and ML. It ensures βˆ«βˆ’βˆžβˆž1Οƒ2Ο€eβˆ’(xβˆ’ΞΌ)2/(2Οƒ2) dx=1\int_{-\infty}^{\infty} \frac{1}{\sigma\sqrt{2\pi}}e^{-(x-\mu)^2/(2\sigma^2)}\,dx = 1, which is required for any valid probability distribution.

Q4: Explain the difference between convergence and divergence for improper integrals. Give an example of each.

Answer

An improper integral converges if the limit exists and is finite; it diverges if the limit does not exist or is infinite.

Convergent example: ∫1∞1x2 dx=lim⁑bβ†’βˆž[βˆ’1x]1b=1\int_1^\infty \frac{1}{x^2}\,dx = \lim_{b\to\infty}\left[-\frac{1}{x}\right]_1^b = 1. The area is finite despite the infinite interval.

Divergent example: ∫1∞1x dx=lim⁑bβ†’βˆžln⁑b=∞\int_1^\infty \frac{1}{x}\,dx = \lim_{b\to\infty}\ln b = \infty. The area grows without bound.

Key insight: The p-test says ∫1∞1xp dx\int_1^\infty \frac{1}{x^p}\,dx converges iff p>1p > 1. For integrals near a singularity like ∫011xp dx\int_0^1 \frac{1}{x^p}\,dx, it converges iff p<1p < 1.

Q5: How is numerical integration used when analytical solutions are unavailable?

Answer

When the antiderivative cannot be expressed in closed form (e.g., eβˆ’x2e^{-x^2}, sin⁑xx\frac{\sin x}{x}, or integrands defined only by data), we use numerical methods:

  1. Trapezoidal rule: Approximate area with trapezoids. Simple, O(h2)O(h^2) convergence. Good for rough data.
  2. Simpson's rule: Use parabolic arcs. O(h4)O(h^4) convergence. Better for smooth functions.
  3. Gaussian quadrature: Optimally placed nodes. Integrates degree 2nβˆ’12n-1 polynomials exactly with nn points.
  4. Monte Carlo integration: Random sampling. Converges at O(1/n)O(1/\sqrt{n}) but is the only practical method for high-dimensional integrals (critical in Bayesian inference).
  5. Adaptive quadrature: Automatically refines the grid where the integrand is difficult. scipy.integrate.quad uses this.

Q6: What role does integration play in training probabilistic models?

Answer

Integration is essential in several aspects of probabilistic model training:

  1. Normalization: Every PDF must integrate to 1. For complex models, this constant is often intractable.
  2. Marginalization: To compute p(x)=∫p(x,ΞΈ) dΞΈp(x) = \int p(x, \theta)\,d\theta, we integrate out latent variables.
  3. Evidence computation: p(data)=∫p(data∣θ)p(ΞΈ) dΞΈp(\text{data}) = \int p(\text{data}|\theta)p(\theta)\,d\theta is needed for model comparison and Bayesian model selection.
  4. Expected loss: E[L]=∫L(ΞΈ)p(θ∣data) dΞΈ\mathbb{E}[\mathcal{L}] = \int \mathcal{L}(\theta) p(\theta|\text{data})\,d\theta β€” computing the expected loss over the posterior.
  5. Variational inference: Approximates intractable integrals with tractable ones by minimizing KL divergence.
  6. MCMC: Draws samples from posteriors by constructing Markov chains whose stationary distribution is the target β€” a way to estimate integrals via sampling.

Q7: Prove that ∫01xn dx=1n+1\int_0^1 x^n\,dx = \frac{1}{n+1} using the definition of the integral.

Answer

Using the Riemann sum with a uniform partition into nn subintervals of width Ξ”x=1/n\Delta x = 1/n:

∫01xn dx=lim⁑nβ†’βˆžβˆ‘i=1n(in)nβ‹…1n=lim⁑nβ†’βˆž1nn+1βˆ‘i=1nin\int_0^1 x^n\,dx = \lim_{n\to\infty} \sum_{i=1}^{n} \left(\frac{i}{n}\right)^n \cdot \frac{1}{n} = \lim_{n\to\infty} \frac{1}{n^{n+1}} \sum_{i=1}^{n} i^n

Using Faulhaber's formula βˆ‘i=1ninβ‰ˆnn+1n+1\sum_{i=1}^{n} i^n \approx \frac{n^{n+1}}{n+1} for large nn:

∫01xn dx=lim⁑nβ†’βˆž1nn+1β‹…nn+1n+1=1n+1\int_0^1 x^n\,dx = \lim_{n\to\infty} \frac{1}{n^{n+1}} \cdot \frac{n^{n+1}}{n+1} = \frac{1}{n+1}

Alternatively, by the Fundamental Theorem: ∫01xn dx=[xn+1n+1]01=1n+1\int_0^1 x^n\,dx = \left[\frac{x^{n+1}}{n+1}\right]_0^1 = \frac{1}{n+1}.


Practice Problems

Problem 1: Substitution

Compute ∫x1+x2 dx\int x\sqrt{1 + x^2}\,dx.

Solution

Let u=1+x2u = 1 + x^2, so du=2x dxdu = 2x\,dx and x dx=du2x\,dx = \frac{du}{2}.

∫uβ‹…du2=12∫u1/2 du=12β‹…u3/23/2+C=(1+x2)3/23+C\int \sqrt{u} \cdot \frac{du}{2} = \frac{1}{2} \int u^{1/2}\,du = \frac{1}{2} \cdot \frac{u^{3/2}}{3/2} + C = \frac{(1+x^2)^{3/2}}{3} + C.

Problem 2: Integration by Parts

Compute ∫x2ex dx\int x^2 e^x\,dx.

Solution

First application: u=x2u = x^2, dv=ex dxdv = e^x\,dx. Then du=2x dxdu = 2x\,dx, v=exv = e^x.

∫x2ex dx=x2exβˆ’2∫xex dx\int x^2 e^x\,dx = x^2 e^x - 2\int xe^x\,dx

Second application: u=xu = x, dv=ex dxdv = e^x\,dx. Then du=dxdu = dx, v=exv = e^x.

∫xex dx=xexβˆ’βˆ«ex dx=xexβˆ’ex\int xe^x\,dx = xe^x - \int e^x\,dx = xe^x - e^x

Combine: x2exβˆ’2(xexβˆ’ex)+C=ex(x2βˆ’2x+2)+Cx^2 e^x - 2(xe^x - e^x) + C = e^x(x^2 - 2x + 2) + C.

Problem 3: Definite Integral with Substitution

Compute ∫01ex1+ex dx\int_0^1 \frac{e^x}{1 + e^x}\,dx.

Solution

Let u=1+exu = 1 + e^x, so du=ex dxdu = e^x\,dx.

When x=0x = 0: u=2u = 2. When x=1x = 1: u=1+eu = 1 + e.

∫21+e1u du=[ln⁑∣u∣]21+e=ln⁑(1+e)βˆ’ln⁑2=ln⁑1+e2\int_2^{1+e} \frac{1}{u}\,du = [\ln|u|]_2^{1+e} = \ln(1+e) - \ln 2 = \ln\frac{1+e}{2}.

Problem 4: Improper Integral

Determine whether ∫1∞ln⁑xx2 dx\int_1^\infty \frac{\ln x}{x^2}\,dx converges, and if so, evaluate it.

Solution

Use integration by parts: u=ln⁑xu = \ln x, dv=xβˆ’2 dxdv = x^{-2}\,dx. Then du=1x dxdu = \frac{1}{x}\,dx, v=βˆ’1xv = -\frac{1}{x}.

∫ln⁑xx2 dx=βˆ’ln⁑xx+∫1x2 dx=βˆ’ln⁑xxβˆ’1x\int \frac{\ln x}{x^2}\,dx = -\frac{\ln x}{x} + \int \frac{1}{x^2}\,dx = -\frac{\ln x}{x} - \frac{1}{x}

Evaluate the improper integral:

∫1∞ln⁑xx2 dx=lim⁑bβ†’βˆž[βˆ’ln⁑xxβˆ’1x]1b=lim⁑bβ†’βˆž(βˆ’ln⁑bbβˆ’1b+0+1)=0βˆ’0+1=1\int_1^\infty \frac{\ln x}{x^2}\,dx = \lim_{b\to\infty}\left[-\frac{\ln x}{x} - \frac{1}{x}\right]_1^b = \lim_{b\to\infty}\left(-\frac{\ln b}{b} - \frac{1}{b} + 0 + 1\right) = 0 - 0 + 1 = 1

The integral converges to 11.

Problem 5: Probability Application

Let XX have PDF fX(x)=12eβˆ’βˆ£x∣f_X(x) = \frac{1}{2}e^{-|x|} for x∈Rx \in \mathbb{R} (Laplace distribution). Find E[X]E[X] and Var(X)\text{Var}(X).

Solution

Expected value: By symmetry of fX(x)f_X(x) (even function) and xβ‹…fX(x)x \cdot f_X(x) (odd function):

E[X]=βˆ«βˆ’βˆžβˆžxβ‹…12eβˆ’βˆ£xβˆ£β€‰dx=0E[X] = \int_{-\infty}^{\infty} x \cdot \frac{1}{2}e^{-|x|}\,dx = 0 (odd integrand over symmetric interval).

Variance: Var(X)=E[X2]βˆ’(E[X])2=E[X2]\text{Var}(X) = E[X^2] - (E[X])^2 = E[X^2]

E[X2]=βˆ«βˆ’βˆžβˆžx2β‹…12eβˆ’βˆ£xβˆ£β€‰dx=2∫0∞x2β‹…12eβˆ’x dx=∫0∞x2eβˆ’x dxE[X^2] = \int_{-\infty}^{\infty} x^2 \cdot \frac{1}{2}e^{-|x|}\,dx = 2\int_0^{\infty} x^2 \cdot \frac{1}{2}e^{-x}\,dx = \int_0^{\infty} x^2 e^{-x}\,dx

Using integration by parts twice (or the gamma function Ξ“(3)=2!=2\Gamma(3) = 2! = 2):

Var(X)=2\text{Var}(X) = 2.


Quick Reference

Key Takeaways

  • Indefinite Integral: ∫f(x) dx=F(x)+C\int f(x)\,dx = F(x) + C where Fβ€²(x)=f(x)F'(x) = f(x) β€” a family of antiderivatives.
  • Definite Integral: ∫abf(x) dx=F(b)βˆ’F(a)\int_a^b f(x)\,dx = F(b) - F(a) β€” the signed area under the curve, computed via the Fundamental Theorem.
  • Fundamental Theorem: Connects differentiation and integration: ddx∫axf(t) dt=f(x)\frac{d}{dx}\int_a^x f(t)\,dt = f(x) and ∫abf(x) dx=F(b)βˆ’F(a)\int_a^b f(x)\,dx = F(b) - F(a).
  • Power Rule: ∫xn dx=xn+1n+1+C\int x^n\,dx = \frac{x^{n+1}}{n+1} + C for nβ‰ βˆ’1n \neq -1; for n=βˆ’1n = -1: ∫1x dx=ln⁑∣x∣+C\int \frac{1}{x}\,dx = \ln|x| + C.
  • Substitution: ∫f(g(x))gβ€²(x) dx=∫f(u) du\int f(g(x))g'(x)\,dx = \int f(u)\,du β€” reverse of the chain rule.
  • Integration by Parts: ∫u dv=uvβˆ’βˆ«v du\int u\,dv = uv - \int v\,du β€” reverse of the product rule; use LIATE to choose uu.
  • Improper Integrals: Evaluate as limits; converges if the limit is finite, diverges otherwise.
  • Numerical Methods: Trapezoidal (O(h2)O(h^2)), Simpson's (O(h4)O(h^4)), Gaussian quadrature (O(h2n)O(h^{2n})), Monte Carlo (O(1/n)O(1/\sqrt{n})).
  • Probability: P(a≀X≀b)=∫abfX(x) dxP(a \leq X \leq b) = \int_a^b f_X(x)\,dx, E[X]=∫xfX(x) dxE[X] = \int x f_X(x)\,dx, normalization requires ∫fX(x) dx=1\int f_X(x)\,dx = 1.
  • Bayesian Integration: Evidence p(data)=∫p(data∣θ)p(ΞΈ) dΞΈp(\text{data}) = \int p(\text{data}|\theta)p(\theta)\,d\theta is often intractable, motivating MCMC and variational methods.

Cross-References

⭐

Premium Content

Integration Fundamentals

Unlock this lesson and 900+ advanced tutorials with a Premium plan.

🎯End-to-end Projects
πŸ’ΌInterview Prep
πŸ“œCertificates
🀝Community Access

Already a member? Log in

Need Expert Mathematics Help?

Get personalized tutoring, project support, or professional consulting.

Advertisement