For your function f(x)
, you want to calculate the volume of revolution about the x
-axis.
This is given by integrating f(x)*f(x)
, i.e. the function f(x)
-squared, using np.trapz
or any other integration method, and then multiplying by the constant pi (which is built in to NumPy as np.pi
).
The intuition for this lies in the formula for calculating the area of a circle from its radius: pi * r**2
.
The solid formed by rotating the curve 360 degrees about the x
-axis is composed of infinitesimally thin disks at each point along the x
-axis. Each disk has radius f(x)
. The area of the face of each disk is therefore pi * f(x)**2
.
Integrating along the x
-axis sums the volumes of the infinitesimally thin disks and calculates the volume of the solid.