적분판정법 설명

21 days ago by namy0727

x, i, n = var('x, i, n') @interact def int_test(fn=input_box(1/n^2, label='$a_n =$'), Start = input_box(default = 1), End = input_box(default = 10), method=selector(['Right', 'Left'], nrows=1, label="Method")): func = fn.subs(n=x) pts = [i for i in range(Start,End+2)] p=Graphics() if method=='Right': pretty_print(html("$$\sum_{n=%s}^{%s} %s \leq %s + \int_{%s}^{%s}%s dx$$"%(Start,End,latex(fn),latex(fn(n=Start)),Start,End,latex(func)))) pts = pts[0:End-Start+1] seqsum=add([func(x=pts[i]) for i in range(End-Start+1)]) h=func(x=pts[0]) p+=polygon([(pts[0]-1,0),(pts[0]-1,h),(pts[0],h),(pts[0],0)], fill=True, color='lightblue') p+=line([[pts[0]-1,0],[pts[0]-1,h],[pts[0],h],[pts[0],0]], rgbcolor = (0,1.5,0)) p+=point((pts[0],h), rgbcolor = (0,1.5,0), size=30) for i in range(End-Start): h=func(x=pts[i+1]) p+=polygon([(pts[i],0),(pts[i],h),(pts[i+1],h),(pts[i+1],0)], fill=True, color='lightblue') p+=line([[pts[i],0],[pts[i],h],[pts[i+1],h],[pts[i+1],0]], rgbcolor = (0,1.5,0)) p+=point((pts[i+1],h), rgbcolor = (0,1.5,0), size=30) p+=plot(func,(x,Start,End),color='red') p.show(xmin=Start-1, xmax=End, aspect_ratio='automatic') elif method=='Left': pretty_print(html("$$\int_{%s}^{%s}%s dx \leq \sum_{n=%s}^{%s}%s$$"%(Start,End+1,latex(func),Start,End,latex(fn)))) pts = pts[0:End+2] for i in range(End-Start+1): h=func(x=pts[i]) p+=polygon([(pts[i],0),(pts[i],h),(pts[i+1],h),(pts[i+1],0)], fill=True, color='lightblue') p+=line([[pts[i],0],[pts[i],h],[pts[i+1],h],[pts[i+1],0]], rgbcolor = (0,1.5,0)) p+=point((pts[i],h), rgbcolor = (0,1.5,0), size=30) p+=plot(func,(x,Start,End+1),color='red') p.show(xmin=Start-1, xmax=End+1, aspect_ratio='automatic') 
       

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