It can be tricky explaining what you mean when you say to take a function and rotate it about the x-axis to create a volume. So, I made an OpenScad program to make 3d prints of functions, including having it subtract one function from another. I also 3d printed a set of axes to mount the volumes on (and a set of cross-sections of the volumes being rotated.
The picture above are the functions Mrs. C. gave her calculus class on a recent worksheet. Specifically:
This VPython program was written by a student, Mr. Alex Shine, to demonstrate how to find the volume of a curve that’s rotated around the x-axis using the disk method in Calculus II.
The program finds volume for the curve:
between x = 0 and x = 3.
To change the curve, change the function R(x), and to set the upper and lower bounds change a and b respectively.
volume_disk_method.py by Alex Shine.
from visual import*
def R(x):
y = -(1.0/4.0)*x**2 + 4
return y
dx = 0.5
a = 0.0
b = 3.0
x_axis = curve(pos=[(-10,0,0),(10,0,0)])
y_axis = curve(pos=[(0,-10,0),(0,10,0)])
z_axis = curve(pos=[(0,0,-10),(0,0,10)])
line = curve(x=arange(0,3,.1))
line.color=color.cyan
line.radius = .1
line.y = -(1.0/4.0) * (line.x**2) + 4
#scene.background = color.white
for i in range(-10, 11):
curve(pos=[(-0.5,i),(0.5,i)])
curve(pos=[(i,-0.5),(i,0.5)])
VT = 0
for x in arange(a + dx,b + dx,dx):
V = pi * R(x)**2 * dx
disk = cylinder(pos=(x,0,0),radius=R(x),axis=(-dx,0,0), color = color.yellow)
VT = V + VT
print V
print "Volume =", VT