Tutorial 11
Click the badges above to run this tutorial interactively in your browser without installing anything!
- Binder: Free cloud-based Jupyter environment
- Colab: Google's free Jupyter notebook environment
Topics Covered
This tutorial covers the following topics using Python and SymPy:
- Polar coordinates: converting a Cartesian integral and evaluating it
- Volume below a surface and between two cylinders
- Spherical coordinates: volume between a sphere and a cone
- Area of a polar region
- Cylindrical coordinates: curved wedges and setting up triple integrals
- Mass with a variable density
Introduction
The three coordinate systems and their volume elements:
| System | Substitution | |
|---|---|---|
| Polar | ||
| Cylindrical | ||
| Spherical |
The factor (or ) is the Jacobian — forgetting it is the single most common mistake in this chapter.
import sympy as sy
from sympy.abc import x, y, z, t, r, theta, phi, rho, a, H, k
from sympy import (sqrt, sin, cos, tan, sec, pi, ln, exp, log, integrate, simplify,
diff, Rational, N, Matrix, Symbol)
sy.init_printing(use_latex=True)
Question 1
Convert each Cartesian integral to polar coordinates and evaluate.
a.
The region is the upper half of the unit disc: , .
I = integrate(r, (r, 0, 1), (theta, 0, pi))
display(I) # pi/2
b.
The region is the triangle , , i.e. .
display(integrate(y, (y, 0, x), (x, 0, 2))) # 4/3 (direct)
I = integrate(r*sin(theta)*r, (r, 0, 2/cos(theta)), (theta, 0, pi/4))
display(simplify(I)) # 4/3 (polar)
c.
The region is the whole unit disc, and .
I = integrate(2/(1 + r**2)**2 * r, (r, 0, 1), (theta, 0, 2*pi))
display(simplify(I)) # pi
d.
The region is the part of the disc of radius in the first quadrant, so and , and .
I = integrate(exp(r)*r, (r, 0, ln(2)), (theta, 0, pi/2))
display(simplify(I)) # pi*(log(2) - 1/2)
display(simplify(I - pi/2*(ln(4) - 1))) # 0
Question 2
over the unit disc.
I = integrate((1 - r**2)*r, (r, 0, 1), (theta, 0, 2*pi))
display(simplify(I)) # pi/2
Question 3
Volume below , above the -plane, between and .
In polar coordinates , so the volume is .
I = integrate(sin(theta)**2*r, (r, 1, sqrt(2)), (theta, 0, 2*pi))
display(simplify(I)) # pi/2
Question 4
Volume between the sphere and the cone .
In spherical coordinates the cone is , so , , .
V = integrate(rho**2*sin(phi), (rho, 0, 1), (phi, 0, pi/4), (theta, 0, 2*pi))
display(simplify(V)) # pi*(2 - sqrt(2))/3
Question 5
Area of the region bounded by .
The curve is the circle , traced for ; by symmetry we integrate from to and double.
A = 2*integrate(r, (r, 0, 3*cos(theta)), (theta, 0, pi/2))
display(simplify(A)) # 9*pi/4
A naive setup does not describe the region correctly, because for while must be non-negative. It is still worth knowing that this setup does not give : the inner integral is a square, , so a negative upper limit cannot make it vanish. Do not rely on a sign argument here — split the region and double it.
Question 6
over the solid bounded by in the first octant.
# in cylindrical coordinates y = r*sin(theta) and dV = r dz dr dtheta
V = integrate(r*sin(theta)*r, (z, 0, 4 - r**2), (r, 0, 2), (theta, 0, pi/2))
display(simplify(V)) # 64/15
Note the integrand in cylindrical coordinates: .
Question 7
Cylindrical coordinates: volume of the wedge cut from the cylinder by and .
The cylinder becomes and forces , so .
V = integrate(r, (z, 0, -r*sin(theta)), (r, 0, 4*cos(theta)), (theta, 3*pi/2, 2*pi))
display(simplify(V)) # 16/3
Question 8
Set up (do not evaluate) the triple integral for the region inside , above and below the sphere of radius .
The bounds are , and , so
ztop = sqrt(16 - r**2)
display(ztop) # sqrt(16 - r**2) : the upper z-limit
display(sy.Integral(sy.Function('f')(r, theta, z)*r, (z, 0, ztop), (r, 0, 2*sin(theta)), (theta, 0, pi)))
Question 9
Volume of the solid bounded by and .
V = integrate(r, (z, r, 2), (r, 0, 2), (theta, 0, 2*pi))
display(simplify(V)) # 8*pi/3
Question 10
Spherical coordinates: volume outside and inside with .
V = integrate(rho**2*sin(phi), (rho, 2*cos(phi), 2), (phi, 0, pi/2), (theta, 0, 2*pi))
display(simplify(V)) # 4*pi
Question 11
Mass of the solid bounded by and when the density is proportional to the square of the distance from the origin, .
M = integrate(k*rho**2 * rho**2*sin(phi), (rho, 0, 2/cos(phi)), (phi, 0, pi/4), (theta, 0, 2*pi))
display(simplify(M)) # 48*k*pi/5
Question 12
Mass of , bounded by and , with density .
Using cylindrical coordinates with the axis along , we have , and with .
M = integrate(y*r, (y, r**2, 4), (r, 0, 2), (theta, 0, 2*pi))
display(simplify(M)) # 64*pi/3
Extra Learning Resources
Key Concepts to Master
- Always include the Jacobian: for polar/cylindrical, for spherical
- Recognising a disc: becomes ,
- Circles through the origin: (centre on the -axis) and (centre on the -axis)
- Cone spherical: is
- Plane in spherical:
SymPy Resources
- SymPy
integrate— nested integrals with variable limits - SymPy
simplify— clean up trig-heavy results - SymPy
Integral— display an integral without evaluating it (Q8)
Common Pitfalls
- Forgetting the Jacobian or — the most common error in this chapter
- must be non-negative; a region such as only exists where
- In spherical coordinates the polar angle is (from the -axis) and the azimuthal angle is — don't swap them
- When the symmetry axis is not (Q12), relabel the cylindrical coordinates accordingly