Volumes of Revolution
In this example, we use Python to find volumes of solids formed by rotating regions about an axis. Suppose we have a general ellipse, y=b/a*sqrt(a^2-x^2), and we wish to find the volume of the ellipsoid formed by rotating this ellipse about the x-axis. Our strategy by hand is very similar to our strategy for finding area:
1) Graph the curves to identify the region (plot)
2) Find the point(s) of intersection (solve)
3) After determining a method (slices or shells), compute an appropriate integral to find either the volume in question. (integrate)
As always, we first import commands from the sympy package, define our symbolic variable x, and create an expression f for the ellipse. Step 1, we cannot plot as is since we are using parameters a and b, so we will substitute values for them such as a=3 and b=4 (remember to use type dictionary for multiple substitutions at once) and then use the plot command to visualize the region after running our command matplotlib notebook. Step 2, we find the intersections, which we’ll call c, of f with the x-axis (y=0) using the solve command. Note that we print the result in case there are several solutions to identify which ones are appropriate. We see that the 0th solution (remember Python counts a list starting at 0) is our left endpoint, and our 1st solution is our right endpoint (you may have been able to tell without solving, but we demonstrate the process here in case it isn’t so obvious). Step 3, we use our brains to decide on slices, so we integrate pi*f^2 from c[0] to c[1].