극좌표에서의 넓이

425 days ago by namy0727

t = var('t') @interact def polar_area(f=input_box(1+sin(t), label='r =', type=SR), Start = input_box(default = pi/6), End = input_box(default = 5*pi/6), n = slider(1,100,1,4)): pretty_print(html('$$r= %s$$'%latex(f))) a = RDF(Start) b = RDF(End) func(t) = f dt = (b-a)/n lts = [q*dt + a for q in range(n)] rts = [(q+1)*dt + a for q in range(n)] midts = [q*dt+dt/2 + a for q in range(n)] midrs = [func(t=midts[q]) for q in range(n)] mxs = [func(t=midts[q])*cos(midts[q]) for q in range(n)] mys = [func(t=midts[q])*sin(midts[q]) for q in range(n)] lxs = [func(t=midts[q])*cos(q*dt + a) for q in range(n)] lys = [func(t=midts[q])*sin(q*dt + a) for q in range(n)] rxs = [func(t=midts[q])*cos((q+1)*dt + a) for q in range(n)] rys = [func(t=midts[q])*sin((q+1)*dt + a) for q in range(n)] area = [] sects = Graphics() for q in range(n): tm = midts[q] rm = midrs[q] area.append(0.5*dt*rm*rm) sects+= line([[0,0],[lxs[q],lys[q]]], rgbcolor = (0,1.5,0))+line([[0,0],[rxs[q],rys[q]]], rgbcolor = (0,1.5,0)) sects+= arc([0,0], rm, sector=(tm-dt/2,tm+dt/2) , rgbcolor = (0,1.5,0)) min_x = min(0, find_local_minimum(func*cos(t),a,b)[0]) max_x = max(0, find_local_maximum(func*cos(t),a,b)[0]) min_y = min(0, find_local_minimum(func*sin(t),a,b)[0]) max_y = max(0, find_local_maximum(func*sin(t),a,b)[0]) An = sum(area); An=RDF(An) A = integral(0.5*func*func,t,a,b); A=RDF(A) err = abs(A - An) p = polar_plot(func,(t,a,b),fill=True, fillcolor='lightblue') + sects p.show(xmin = 1.5*min_x, xmax = 1.5*max_x, ymin = 1.5*min_y, ymax = 1.5*max_y, aspect_ratio=1) print "A =", A print "An = %s" %(An) print "Error =", err 
       
r = 
Start 
End 

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