This sheet will draw the surface that lies below $f(x,y)$ and above the curve $f(t)$ in the $xy$-plane. The first block of code will draw the surface. The second block of code will compute a line integral.
<sagecell>
- The code below will draw a surface that lies below f(x,y) and above the curve r(t) in the xy plane.
- Start by defining f(x,y), r(t), and the bounds.
f(x,y)=9-x^2-y^2 r(t)=(2*cos(t), 3*sin(t)) trange=(t,0,2*pi)
- This section makes the plot of the surface.
r1(t,u)=(r(t)[0], r(t)[1],u*f(x=r(t)[0],y=r(t)[1])) curve_options=dict(color='red',thickness=3) curves=parametric_plot(r1(t,0), trange,**curve_options)+parametric_plot(r1(t,1),trange,**curve_options) sheet=parametric_plot(r1,trange,(u,0,1)) show(curves+sheet) </sagecell>
<sagecell>
- The code below will find the surface area of a surface that lies below f(x,y) and above the curve r(t) in the xy plane.
f(x,y)=9-x^2-y^2 r(t)=(2*cos(t), 3*sin(t)) trange=(t,0,2*pi)
ds=r.diff(t).norm() dA=f(x=r(t)[0],y=r(t)[1])*ds(t)
- Let's make a function right off to evaluate an integral over this curve.
- We'll use a numerical integral, because sometimes we might not be able to get an exact integral.
def line_integral(integrand):
return RR(numerical_integral(integrand, trange[1], trange[2])[0])
A = line_integral(dA(t))
table([ [r"$f(x,y)$",f(x,y)], [r"$\vec r(t)$",r(t)], [r"$d\vec r(t)/dt$",r.diff(t)(t)], [r"$ds$",ds(t)], [r"$d\sigma=f ds$",dA(t)], [r"$Surface Area = \sigma =\int_C f ds$",A], ]) </sagecell>