# MAT 223 New Coordinate Systems and Triple Integrals

## 2668 days ago by kcrisman

This is based on an example due to Robert Marik.

x,y=var('x y') html('<h2>Showing the difference between surface area and area</h2>') html('We look at the tangent plane only in the rectangle determined by the partial derivatives at a point, and compare that to the rectangle it lies over') @interact def _(func=input_box('sqrt(x^3+y^3)',label="f(x,y)=",type=str), x0=1, y0=2, \ xmin=0, xmax=2, ymin=0, ymax=3,show_plane=False): f=sage_eval('lambda x,y: ' + func) derx(x,y)=diff(f(x,y),x) dery(x,y)=diff(f(x,y),y) arrow1 = arrow((x0,y0,f(x0,y0)),(x0+1,y0,f(x0,y0)+derx(x0,y0)),color='green') arrow2 = arrow((x0,y0,f(x0,y0)),(x0,y0+1,f(x0,y0)+dery(x0,y0)),color='green') rectangle1 = polygon3d([(x0,y0,f(x0,y0)),(x0+1,y0,f(x0,y0)+derx(x0,y0)),(x0+1,y0+1,f(x0,y0)+dery(x0,y0)+derx(x0,y0)),(x0,y0+1,f(x0,y0)+dery(x0,y0))],color='green') rectangle2 = polygon3d([(x0,y0,0),(x0+1,y0,0),(x0+1,y0+1,0),(x0,y0+1,0)],color='green') tangent(x,y)=f(x0,y0)+derx(x0,y0)*(x-x0)+dery(x0,y0)*(y-y0) A=plot3d(f(x,y),(x,xmin,xmax),(y,ymin,ymax),opacity=0.5) B=plot3d(tangent(x,y),(x,xmin,xmax),(y,ymin,ymax),color='red',opacity=0.5) C=point3d((x0,y0,f(x0,y0)),rgbcolor='blue',size=9) exact_value_ori=f(x0,y0).n(digits=10) html(r'Function $f(x,y)=%s \approx %s$ '%(latex(f(x,y)),latex(tangent(x,y)))) html(r' $f %s = %s$'%(latex((x0,y0)),latex(exact_value_ori))) if show_plane: show(A+B+C+arrow1+arrow2+rectangle1+rectangle2) else: show(A+C+arrow1+arrow2+rectangle1+rectangle2) html("The tangent plane rectangle area is %s"%vector((x0,y0,f(x0,y0))).cross_product(vector((x0+1,y0,f(x0,y0)+derx(x0,y0)))).norm().n()) html("The area of the rectangle below is %s"%vector((x0,y0,0)).cross_product(vector((x0+1,y0,0))).norm().n())

## Click to the left again to hide and once more to show the dynamic interactive window

This example is due to Jason Grout.

var('u v') # polar coordinates #(x,y)=(u*cos(v),u*sin(v)); (u_range,v_range)=([0..6],[0..2*pi,step=pi/12]) # okay example #(x,y)=(1/3*(v-u),1/3*(2*v+u)); (u_range,v_range)=([-5..5],[-5..5]) # weird example (x,y)=(u^2-v^2,u*v+cos(u*v)); (u_range,v_range)=([-5..5],[-5..5]) thickness=4 square_length=.05 from sage.ext.fast_eval import fast_float from functools import partial @interact def trans(x=input_box(x, label="x",type=SR), y=input_box(y, label="y",type=SR), u_percent=slider(0,1,0.05,label="<font color='red'>u</font>", default=.7), v_percent=slider(0,1,0.05,label="<font color='blue'>v</font>", default=.7), t_val=slider(0,10,0.2,6, label="Length"), u_range=input_box(u_range, label="u lines"), v_range=input_box(v_range, label="v lines")): x(u,v)=x y(u,v)=y u_val = min(u_range)+(max(u_range)-min(u_range))*u_percent v_val = min(v_range)+(max(v_range)-min(v_range))*v_percent t_min = -t_val t_max = t_val uvplot=sum([parametric_plot((i,v), (v,t_min,t_max), color='red',axes_labels=['u','v'],figsize=[5,5]) for i in u_range]) uvplot+=sum([parametric_plot((u,i), (u,t_min,t_max), color='blue',axes_labels=['u','v']) for i in v_range]) uvplot+=parametric_plot((u,v_val), (u,t_min,t_max), rgbcolor=(0,0,1), linestyle='-',thickness=thickness) uvplot+=parametric_plot((u_val, v), (v,t_min,t_max),rgbcolor=(1,0,0), linestyle='-',thickness=thickness) pt=vector([u_val,v_val]) du=vector([(t_max-t_min)*square_length,0]) dv=vector([0,(t_max-t_min)*square_length]) uvplot+=polygon([pt,pt+dv,pt+du+dv,pt+du],color='purple',alpha=0.7) uvplot+=line([pt,pt+dv,pt+du+dv,pt+du],color='green') T(u,v)=(x,y) xuv = fast_float(x,'u','v') yuv = fast_float(y,'u','v') xvu = fast_float(x,'v','u') yvu = fast_float(y,'v','u') xyplot=sum([parametric_plot((partial(xuv,i),partial(yuv,i)), (v,t_min,t_max), color='red', axes_labels=['x','y'],figsize=[5,5]) for i in u_range]) xyplot+=sum([parametric_plot((partial(xvu,i),partial(yvu,i)), (u,t_min,t_max), color='blue') for i in v_range]) xyplot+=parametric_plot((partial(xuv,u_val),partial(yuv,u_val)),(v,t_min,t_max),color='red', linestyle='-',thickness=thickness) xyplot+=parametric_plot((partial(xvu,v_val),partial(yvu,v_val)), (u,t_min,t_max), color='blue', linestyle='-',thickness=thickness) jacobian=abs(T.diff().det()).simplify_full() t_vals=[0..1,step=t_val*.01] vertices=[(x(*c),y(*c)) for c in [pt+t*dv for t in t_vals]] vertices+=[(x(*c),y(*c)) for c in [pt+dv+t*du for t in t_vals]] vertices+=[(x(*c),y(*c)) for c in [pt+(1-t)*dv+du for t in t_vals]] vertices+=[(x(*c),y(*c)) for c in [pt+(1-t)*du for t in t_vals]] xyplot+=polygon(vertices,color='purple',alpha=0.7) xyplot+=line(vertices,color='green') html("$T(u,v)=%s$"%(latex(T(u,v)))) html("Jacobian: $%s$"%latex(jacobian(u,v))) html("A very small region in $xy$ plane is approximately %0.4g times the size of the corresponding region in the $uv$ plane"%jacobian(u_val,v_val).n()) html.table([[uvplot,xyplot]])

## Click to the left again to hide and once more to show the dynamic interactive window

var('x,y,z') L = [-30,-60,40,80,100,150,200] R = rainbow(len(L)) P = implicit_plot3d(x^2 + y^2 + 10*z, (x,-10,10), (y,-10,10), (z,-10,10),opacity=.6,color='blue') for c in range(len(L)): P += implicit_plot3d(x^2 + y^2 + 10*z==L[c], (x,-10,10), (y,-10,10), (z,-10,10),opacity=.6,color=Color(R[c])) P += implicit_plot3d(x^2 + y^2 + 10*z==-20, (x,-10,10), (y,-10,10), (z,-10,10),opacity=.6,color='orange') show(P)
var('x y z') P = plot3d(2-2*x-2*y,(x,0,1),(y,0,1)) P += plot3d(0,(x,0,1),(y,0,1),opacity=.5,color='red') P += implicit_plot3d(x==1,(x,0,1),(y,0,1),(z,-2,0),color='green') P += implicit_plot3d(y==1,(x,0,1),(y,0,1),(z,-2,0),color='green') show(P)
var('x y z') P = plot3d(2+x,(x,0,4),(y,-2,2)) P += plot3d(0,(x,0,4),(y,-2,2),opacity=.5,color='red') P += implicit_plot3d(x==4,(x,0,4),(y,-2,2),(z,0,6),color='green') P += implicit_plot3d(x==y^2,(x,0,4),(y,-2,2),(z,0,6),color='green') show(P)
T = Cylindrical('height', ['radius', 'azimuth']) r, theta, z = var('r theta z') plot3d(2-r^2, (r, 0, 1), (theta, 0, 2*pi), transformation=T)+plot3d(r^2, (r, 1,sqrt(2)), (theta, 0, 2*pi), transformation=T,opacity=.5)+plot3d(r^2, (r, 0, 1), (theta, 0, 2*pi), transformation=T)+plot3d(2-r^2, (r, 1,sqrt(2)), (theta, 0, 2*pi), transformation=T,opacity=.5)
x,y=var('x,y') spherical_plot3d(2,(x,0,2*pi),(y,0,pi))