Advertisement
iskhakovt

Untitled

May 18th, 2015
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.36 KB | None | 0 0
  1. from math import sqrt, cos, sin
  2.  
  3. a, b = map(float, input().split())
  4. f = 'abs(' + input().replace('^', '**') + ')'
  5.  
  6. N = 2000
  7. coef = (b - a) / (2 * N)
  8.  
  9. def func_i(i):
  10.     x = a + i * coef
  11.     return eval(f)
  12.  
  13. ans = func_i(0)
  14.  
  15. for i in range(1, 2 * N + 1, 2):
  16.     ans += 4 * func_i(i)
  17. for i in range(2, 2 * N + 1, 2):
  18.     ans += 2 * func_i(i)
  19.    
  20. print(ans * coef / 3)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement