Tutorial 13
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:
- Surface integrals of a vector field:
- Flux across a graph
- Orientation: upward versus downward normals
- Surface integrals of a scalar function:
- Area of a surface and the surface element
Introduction
For a surface given as the graph over a region :
For a parametrised surface :
import sympy as sy
from sympy.abc import x, y, z, u, v, theta, phi, rho, a, H
from sympy import (sqrt, sin, cos, tan, pi, ln, exp, atan, integrate, diff, simplify,
Rational, N, Matrix, Symbol, asinh)
sy.init_printing(use_latex=True)
def gradient(f, vars=(x, y, z)):
return Matrix([diff(f, q) for q in vars])
Question 1
Evaluate the surface integral of over the surface that is the graph of over the rectangle .
Here , so the upward normal is .
g = 2*x - y
n = Matrix([-diff(g, x), -diff(g, y), 1])
display(n) # <-2, 1, 1>
F = Matrix([3*x**2, -2*y*x, 8])
integrand = simplify((F.subs({z: g})).dot(n))
display(integrand) # -6*x**2 - 2*x*y + 8
display(integrate(integrand, (x, 0, 2), (y, 0, 2))) # -8
Question 2
is the triangle with vertices , and , and . The triangle is oriented by the downward normal.
The plane through the three vertices is , so with , we get and — which points upward.
r = Matrix([u, v, -2*u - v + 2])
cross = r.diff(u).cross(r.diff(v))
display(cross) # <2, 1, 1>
F = Matrix([u*v*(-2*u - v + 2), u*v*(-2*u - v + 2), 0]) # xyz (i + j) with z = -2u-v+2
integrand = simplify(F.dot(cross))
display(integrand) # 3*u*v*(-2*u - v + 2)
# the domain D is the triangle with vertices (1,0), (0,2), (0,1): 0<=u<=1, 1-u<=v<=2-2u
upward = integrate(integrand, (v, 1 - u, 2 - 2*u), (u, 0, 1))
display(upward) # 1/10
display(-upward) # -1/10 (downward orientation)
The sign flip is the whole point of the question: the parametrisation naturally gives the upward orientation, so the answer must be negated to get the downward flux.
Question 3
The disk , , with .
F = Matrix([x, y, z])
g = 12
n = Matrix([-diff(g, x), -diff(g, y), 1])
display(n) # <0, 0, 1>
integrand = simplify((F.subs({z: g})).dot(n))
display(integrand) # 12
display(integrate(integrand, (y, 0, 5), (x, 0, 5))) # 300 (over the square, for illustration)
display(12 * (pi*5**2)) # 300*pi (area of the disk)
Question 4
is the closed surface made of the upper hemisphere , and its base , . Find the flux of .
Split . On the hemisphere the outward unit normal is , and on the base it is .
# hemisphere: E . n = 2(x^2 + y^2 + z^2) = 2 -> flux = 2 * area(hemisphere)
flux_H = 2 * (2*pi*1**2) # area of a hemisphere of radius 1 is 2*pi
display(flux_H) # 4*pi
# base: E . n = (2x, 2y, 0) . (0, 0, -1) = 0
flux_D = 0
display(flux_H + flux_D) # 4*pi
Question 5
Area of the ellipse cut on the plane by the cylinder .
zplane = (60 - 2*x - 3*y)/6
dS = sqrt(1 + diff(zplane, x)**2 + diff(zplane, y)**2)
display(simplify(dS)) # 7/6
display(simplify(sy.factor(x**2 + y**2 - 2*x))) # x**2 - 2*x + y**2 = (x-1)**2 + y**2 - 1 -> unit circle
display(Rational(7, 6) * pi) # 7*pi/6
The projection is the unit circle with area , so
Question 6
where is the part of in the first octant.
In spherical coordinates and , so the integral becomes over , .
I = integrate(a**3 * cos(phi)*sin(theta)**2, (phi, 0, pi/2), (theta, 0, pi/2))
display(simplify(I)) # pi*a**3/4
Question 7
over the cylinder , , .
# radius and height are positive, so sqrt(a^2) simplifies to a
a = Symbol('a', positive=True)
H = Symbol('H', positive=True)
rv = Matrix([a*cos(u), a*sin(u), v])
ru, rv_ = rv.diff(u), rv.diff(v)
display(ru, rv_)
cross = ru.cross(rv_)
display(cross) # <a*cos(u), a*sin(u), 0>
dS = sqrt(cross.dot(cross))
display(simplify(dS)) # a
integrand = dS / sqrt(a**2 + v**2) # x^2+y^2+z^2 = a^2 + v^2
I = integrate(integrand, (v, 0, H), (u, 0, 2*pi))
display(simplify(I)) # 2*pi*a*asinh(H/a)
# asinh(H/a) is the same as ln((H + sqrt(a^2 + H^2))/a)
display(simplify(I.rewrite(ln) - 2*pi*a*ln((H + sqrt(a**2 + H**2))/a))) # 0
Extra Learning Resources
Key Concepts to Master
- Flux across a graph: use the normal for the upward orientation
- Orientation matters: a downward normal flips the sign of the flux
- Surface element from a parametrisation:
- Scalar surface integral: — substitute the surface into and multiply by
- Closed surfaces: split into the parts (hemisphere plus base) and add the fluxes
SymPy Resources
- SymPy
cross— - SymPy
integrate— the resulting double integral - SymPy
asinh—
Common Pitfalls
- Always check the direction of before deciding on the sign
sqrt(cross.dot(cross))— the magnitude of a vector is the square root of its dot product with itself- When the surface lies in a plane , substitute into before taking the dot product
- For a closed surface, the outward normal points away from the enclosed volume on every face