(1) Integral formula:
(2) Integrand components:
Option 1: Set at the base, going up.
Take a cross-sectional slice with a vertical plane. This intersects the surface of the pyramid in a triangle whose width is the side length of the square (the horizontal cross section) at height .
Note that . So we have:
Option 2:
Set at the vertex, going down.
And: