Consider that the Equation of line \(x = \frac{{\Delta x}}{{\Delta y}}y + (x\)-intercept) ….(1)
Substitute \(\frac{a}{2} - \frac{b}{2}\) for \(\Delta x,h - 0\) for \(\Delta y\), and \(\frac{b}{2}\) for \(x\)-intercept in Equation (1).
\(\begin{aligned}x = &\frac{{\frac{a}{2} - \frac{b}{2}}}{{h - 0}}y + \frac{b}{2}\\ &= \frac{{a - b}}{{2h}}y + \frac{b}{2}\end{aligned}\)
The dimensions of the frustum of a pyramid as shown in Figure 1 .

Refer to Figure 1 .
Consider that the frustum of a pyramid is obtained by the line \(x = \frac{{a - b}}{{2h}}y + \frac{b}{2}\).
The region lies between \(a = 0\) and \(b = h\).
The expression to find the volume of the cap of a sphere as shown below.
\(V = \int_a^b A (y)dy\) ……(2)
Find the area of the cap of a sphere as shown below.
\(\begin{aligned}A(y) &= {(2x)^2}\\ &= {\left( {2\left( {\frac{{a - b}}{{2h}}y + \frac{b}{2}} \right)} \right)^2}\\ &= {\left( {\frac{{a - b}}{h}y + b} \right)^2}\\ &= \frac{{{{(a - b)}^2}}}{{{h^2}}}{y^2} + {b^2} + \frac{{2(a - b)}}{h}yb\end{aligned}\)
Which means, \(A(y) = \frac{{{{(a - b)}^2}}}{{{h^2}}}{y^2} + \frac{{2b(a - b)}}{h}y + {b^2}\)
Substitute 0 for a, h for \(b\), and \(\frac{{{{(a - b)}^2}}}{{{h^2}}}{y^2} + \frac{{2b(a - b)}}{h}y + {b^2}\) for \(A(y)\) in Equation (2).
\(\begin{aligned}V &= \int_0^h {\left( {\frac{{{{(a - b)}^2}}}{{{h^2}}}{y^2} + \frac{{2b(a - b)}}{h}y + {b^2}} \right)} dy\\ &= \left( {\frac{{{{(a - b)}^2}}}{{{h^2}}}\frac{{{y^3}}}{3} + \frac{{2b(a - b)}}{h}\frac{{{y^2}}}{2} + {b^2}y} \right)_0^h\\ &= \left( {\frac{{{{(a - b)}^2}}}{{{h^2}}}\frac{{{h^3}}}{3} + \frac{{2b(a - b)}}{h}\frac{{{h^2}}}{2} + {b^2}h - 0} \right)\\ &= \left( {\left( {{a^2} + {b^2} - 2ab} \right)\frac{h}{3} + bh(a - b) + {b^2}h} \right)\end{aligned}\)
On simplify further,
\(\begin{aligned}V &= \frac{1}{3}\left( {{a^2}h + {b^2}h - 2abh + 3abh - 3{b^2}h + 3{b^2}h} \right)\\ &= \frac{1}{3}\left( {{a^2}h + {b^2}h - 2abh} \right)\\ &= \frac{1}{3}\left( {{a^2} + {b^2} - 2ab} \right)\end{aligned}\) …..(3)
Therefore, the volume of the frustum of a pyramid is \(\frac{1}{3}\left( {{a^2} + {b^2} - 2ab} \right)\).