222 - Topic 15 - Volumes

2476 days ago by Professor222

Double integrals and volumes for multivariate Calculus

John Travis

Mississippi College.

# This cell illustrates one rectangular prism in the desired volume. # By adjusting x0 and y0 the user can determine which prism to view. # # For this cell, the first constraint must not involve the top or bottom of the solid # The second (functional) constraint involves the top of the solid. # Here, the bottom is presumed to be z = 0. var('x,y,z,t') # constraint1(x,y,z) = y == 4-x^2 # constraint2(x,y) = z == 4-x^2 # Larson #27 constraint1(x,y,z) = z == x*y constraint2(x,y,z) = y == x # Larson #29 constraint1(x,y,z) = 1 == x^2 + z^2 constraint2(x,y,z) = 1 == y^2 + z^2 # Larson #30 # constraint1(x,y,z) = z == 4 - x^2 # constraint2(x,y,z) = y == 4 - x^2 n=10 @interact def _(x0 = slider(0,2),y0 = slider(0,4), xmin = input_box(-4,label='Min x',width=5), xmax = input_box(4,label='Max x',width=5), ymin = input_box(-4,label='Min y',width=5), ymax = input_box(4,label='Max y',width=5)): delx = (xmax-xmin)/n dely = (ymax-ymin)/n # Larson, #29 G = implicit_plot3d(constraint1, (x, 0, 2), (y,0,2), (z,0,2),opacity=0.6) G += implicit_plot3d(constraint2, (x, 0, 2), (y,0,2), (z,0,2),color='green',opacity=0.6) # Larson, #27 # G = implicit_plot3d(constraint1, (x, 0, 1), (y,0,2), (z,0,4),opacity=0.6) # G += implicit_plot3d(constraint2, (x, 0, 1), (y,0,2), (z,0,4),color='green',opacity=0.6) # for k in range(40): # m = k/20 # G += parametric_plot3d([t,m,m*t], (t, 0, 1), color='red', opacity = 0.7) # G += parametric_plot3d([t,m,0], (t, 0, 2), color='red', opacity = 0.7) # G += parametric_plot3d([1,m,m*t], (t, 0, 2), color='red', opacity = 0.7) # Larson, #30 # G = implicit_plot3d(constraint1, (x, 0, 2), (y,0,4), (z,0,4),opacity=0.6) # G += implicit_plot3d(constraint2, (x, 0, 2), (y,0,4), (z,0,4),color='green',opacity=0.6) # G = implicit_plot3d(constraint1, (x, 0, 2), (y,0,4), (z,0,4),opacity=0.6) # G += implicit_plot3d(constraint2, (x, 0, 2), (y,0,4), (z,0,4),color='green',opacity=0.6) # G += line3d([(x0,y0,0),(x0,y0,constraint2(x0,y0))],thickness=10,color='red') G.show() # I1 = integrate(constraint2,y,0,4-x^2) # I1.show() # I = integrate(I1,x,0,2) # print "The desired volume of the region is",I 
       
x0 
y0 
Min x 
Max x 
Min y 
Max y 

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

# This cell illustrates all rectangular prisms in the desired volume. # By adjusting x0 and y0 the user can prune off some of the beginning prisms and see what's left. var('x,y,z') xmin=0 xmax=2 ymin=0 ymax=4 n = 20 @interact def _(x0 = slider(0,2),y0 = slider(0,4)): delx = (xmax-xmin)/n dely = (ymax-ymin)/n G = implicit_plot3d(y==4-x^2, (x, 0, 2), (y,0,4), (z,0,4),opacity=0.6) G += implicit_plot3d(z==4-x^2, (x, 0, 2), (y,0,4), (z,0,4),color='green',opacity=0.6) for j in range(n+1): x1 = x0 + j*delx for k in range(n+1): y1 = y0 + k*dely if y1 <= 4-x1^2: G += line3d([(x1,y1,0),(x1,y1,4-x1^2)],thickness=10,color='red') G.show() 
       

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

# From the Sage interact wiki from sage.plot.plot3d.platonic import index_face_set def cuboid(v1,v2,**kwds): """ Cuboid defined by corner points v1 and v2. """ ptlist = [] for vi in (v1,v2): for vj in (v1,v2): for vk in (v1,v2): ptlist.append([vi[0],vj[1],vk[2]]) f_incs = [[0, 2, 6, 4], [0, 1, 3, 2], [0, 1, 5, 4], [1, 3, 7, 5], [2, 3, 7, 6], [4, 5, 7, 6]] if 'aspect_ratio' not in kwds: kwds['aspect_ratio'] = [1,1,1] return index_face_set(f_incs,ptlist,enclosed = True, **kwds) var('x,y') R16 = RealField(16) npi = RDF(pi) sin,cos = math.sin,math.cos html("<h1>The midpoint rule for a function of two variables</h1>") @interact def midpoint2d(func = input_box('y*sin(x)/x+sin(y)',type=str,label='function of x and y'), nx = slider(2,20,1,3,label='x subdivisions'), ny = slider(2,20,1,3,label='y subdivisions'), x_start = slider(-10,10,.1,0), x_end = slider(-10,10,.1,3*npi), y_start= slider(-10,10,.1,0), y_end= slider(-10,10,.1,3*npi),spinning=checkbox(default='false')): f = sage_eval('lambda x,y: ' + func) delx = (x_end - x_start)/nx dely = (y_end - y_start)/ny xvals = [RDF(x_start + (i+1.0/2)*delx) for i in range(nx)] yvals = [RDF(y_start + (i+1.0/2)*dely) for i in range(ny)] num_approx = 0 cubs = [] darea = delx*dely for xv in xvals: for yv in yvals: num_approx += f(xv,yv)*darea cubs.append(cuboid([xv-delx/2,yv-dely/2,0],[xv+delx/2,yv+dely/2,f(xv,yv)], opacity = .5, rgbcolor = (1,0,0))) html("$$\int_{"+str(R16(y_start))+"}^{"+str(R16(y_end))+"} "+ "\int_{"+str(R16(x_start))+"}^{"+str(R16(x_end))+"} "+func+"\ dx \ dy$$") html('<p style="text-align: center;">Numerical approximation: ' + str(num_approx)+'</p>') p1 = plot3d(f,(x,x_start,x_end),(y,y_start,y_end)) show(p1+sum(cubs),spin=spinning) 
       

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

# This cell is experimental... var('x,y,z') print solve(z+y==2,z)[0] g(y) = solve(z+y==2,z)[0] print g(3) implicit_plot(g,(x,-1,1),(y,-1,2))