Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

All published worksheets from http://sagenb.org

Views: 168742
Image: ubuntu2004
# 8.6 Number. 17 def f1(input): return sin (pi * (input))
# Trapezoid Rule Approximation # TR = Trapazoid Rule # Define Variables n = 6 a = 0 b = 1 answer = 0 TR = 0 tx = (b - a)/n for ix in range(n - 1): lowt = a + ix*tx hight = a + (ix + 1)*tx tp = hight TR = 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