Lesson 14 of 18

Triple Integral

Triple Integrals

A triple integral integrates over a 3D box [xa,xb]×[ya,yb]×[za,zb][x_a, x_b] \times [y_a, y_b] \times [z_a, z_b]:

Vf(x,y,z)dV\iiint_V f(x,y,z)\, dV

The 3D Midpoint Rule

Divide each axis into nn equal intervals. Evaluate ff at each cell center:

fdVijkf(xi,yj,zk)ΔxΔyΔz\iiint f\, dV \approx \sum_i \sum_j \sum_k f(x_i, y_j, z_k) \cdot \Delta x \cdot \Delta y \cdot \Delta z

Geometric Meaning

  • 1dV\iiint 1\, dV = volume of the region
  • ρ(x,y,z)dV\iiint \rho(x,y,z)\, dV = total mass, if ρ\rho is density
  • fdV  /  Volume\iiint f\, dV \;/\; \text{Volume} = average value of ff over the region

Examples

1dV\iiint 1\, dV over [0,2]×[0,3]×[0,4][0,2] \times [0,3] \times [0,4] =24= 24 (volume of the box)

xdV\iiint x\, dV over [0,1]3[0,1]^3 =1211=12= \frac{1}{2} \cdot 1 \cdot 1 = \frac{1}{2}

(x+y+z)dV\iiint (x+y+z)\, dV over [0,1]3[0,1]^3 =32= \frac{3}{2} (by symmetry and linearity)

Applications

  • Volume calculations of 3D regions
  • Mass of non-uniform solid objects
  • Center of mass calculations
  • Moment of inertia

Your Task

Implement double triple_integral(double (*f)(double, double, double), double xa, double xb, double ya, double yb, double za, double zb, int n) using the 3D midpoint rule with nn divisions per axis.

TCC compiler loading...
Loading...
Click "Run" to execute your code.