import math
SIMPSON_ESP = 10 ** (-8)
# 被积函数(根据实际问题进行修改)
def f(x):
return math.sin(x) / x
# 普通simpson积分估值函数, func是被积函数,a, b是积分区间
def __simpson(func, a, b):
return (func(a) + 4*func((a+b)/2) + func(b)) * (b-a) / 6
# 自适应simpson积分
def adaptive_simpson(func, a, b):
mid = (a + b) / 2
val, val1, val2 = __simpson(func, a, b), __simpson(func, a, mid), __simpson(func, mid, b)
if abs(val - val1 - val2) < SIMPSON_ESP:
return val1 + val2
return adaptive_simpson(func, a, mid) + adaptive_simpson(func, mid, b)
a, b = map(float, input().split())
print("%0.6f" % adaptive_simpson(f, a, b))