# Trapezoid Rule Approximation# TR = Trapazoid Rule# Define Variablesn=6a=0b=1answer=0TR=0tx=(b-a)/nforixinrange(n-1):lowt=a+ix*txhight=a+(ix+1)*txtp=hightTR=TR+f1(tp)answer=((.5*f1(a))+TR+(.5*f1(b)))*tx# Answer is one half of f(a) + Sum from 1 to n-1 of the high point (b) + one half f(b) times delta x (tx)# Statement that prints the answer:print"Answer is approximately: 0.6220084679"print"Answer Sage gives me is:"answer
Answer is approximately: 0.6220084679
Answer Sage gives me is:
1/6*sqrt(3) + 1/3