Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from math import sqrt, cos, sin
- a, b = map(float, input().split())
- f = 'abs(' + input().replace('^', '**') + ')'
- N = 2000
- coef = (b - a) / (2 * N)
- def func_i(i):
- x = a + i * coef
- return eval(f)
- ans = func_i(0)
- for i in range(1, 2 * N + 1, 2):
- ans += 4 * func_i(i)
- for i in range(2, 2 * N + 1, 2):
- ans += 2 * func_i(i)
- print(ans * coef / 3)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement