Search code examples
pythonnumpycalculus

Calculating volume of a revolved surface in Python


I have the following curve:

enter image description here

The curve is defined by a set of data points.

How can I calculate the volume that will be enclosed by this curve if it is rotated by 360 degrees about the horizontal axis?

I can calculate the area underneath the curve using numerical integration, with eg np.trapz, but am unsure of what to do next.


Solution

  • 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.