Untitled


SUBMITTED BY: Guest

DATE: Nov. 11, 2013, 12:06 p.m.

FORMAT: Text only

SIZE: 686 Bytes

HITS: 3314

  1. # -*- coding: utf-8 -*-
  2. # Write your program under these comment lines
  3. # Γράψτε το πρόγραμμά σας κάτω από αυτές τις γραμμές των σχολίων
  4. def f(x):
  5. return (-1)*(1/6.)*(x-1)*(x-2)*(x+2)*(x-4)
  6. x1,x2,n = input()
  7. while n!=0:
  8. u = abs((x2 - x1))/ float(n)
  9. S = 0
  10. for i in range(0,n):
  11. m1 = x1 + u*i
  12. b = f(m1)
  13. m2 = x1 + u*(i+1)
  14. B = f(m2)
  15. E = float((b+B))*u / 2.
  16. S = S + E
  17. print format(S, '.3f')
  18. x1,x2,n = input()

comments powered by Disqus