회전체 겉면적

561 days ago by namy0727

x = var('x') @interact def surfarea(f=exp(x), a=0, b=1, n=slider(2,10,2, default=2)): func(x) = f dx = (b-a)/n xpts = [a+i*dx for i in range(n+1)] ypts = [func(x=xpts[i]) for i in range(n+1)] p=Graphics() ds = []; dS = [] for i in range(n): dx = xpts[i+1] - xpts[i] dy = ypts[i+1] - ypts[i] slope = dy/dx s = ypts[i] + slope*(x- xpts[i]) p+=revolution_plot3d(s,(x,xpts[i],xpts[i+1]), show_curve=True, opacity=0.5, parallel_axis='x') ds.append(sqrt(dx^2 + dy^2)) dS.append(ds[i]*2*pi*func(x=(xpts[i+1] + xpts[i])/2)) Sn = sum(dS); Sn = RDF(Sn) dydx = diff(func,x) dsdx = sqrt(1 + dydx^2) S = integral(2*pi*func*dsdx,x,a,b); S = RDF(S) err = abs(S - Sn) p.show(aspect_ratio=[1,1,1]) print "S =", S print "Sn = %s" %(Sn) print "Error =", err 
       

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