from numpy import *
import time
def f(x):
return sin(pi*x)
n = 100000
t0 = time.time()
# range(1, 11)は間違いではない
product = prod( [sum((1/n) * f(k/n)**m for k in range(n)) for m in range(1, 11)] )
result = 1/product
t1 = time.time()
elapsed0 = t1-t0
print(result,elapsed0)
# 36722.3624763
t0 = time.time()
k = arange(n)/n
product = prod( [sum(f(k)**m)/n for m in range(1, 11)] )
t1 = time.time()
elapsed1 = t1-t0
print(result,elapsed1)
t0 = time.time()
k = arange(n)/n
product = exp(sum(log([sum(f(k)**m)/n for m in range(1, 11)]) ))
result = 1/product
t1 = time.time()
elapsed2 = t1-t0
print(result,elapsed2)
ZnJvbSBudW1weSBpbXBvcnQgKgppbXBvcnQgdGltZQoKZGVmIGYoeCk6CiAgICByZXR1cm4gc2luKHBpKngpCiAgICAKbiA9IDEwMDAwMAp0MCA9IHRpbWUudGltZSgpCiMgcmFuZ2UoMSwgMTEp44Gv6ZaT6YGV44GE44Gn44Gv44Gq44GECnByb2R1Y3QgPSBwcm9kKCBbc3VtKCgxL24pICogZihrL24pKiptIGZvciBrIGluIHJhbmdlKG4pKSBmb3IgbSBpbiByYW5nZSgxLCAxMSldICkKcmVzdWx0ID0gMS9wcm9kdWN0IAp0MSA9IHRpbWUudGltZSgpCmVsYXBzZWQwID0gdDEtdDAKcHJpbnQocmVzdWx0LGVsYXBzZWQwKQojIDM2NzIyLjM2MjQ3NjMKCnQwID0gdGltZS50aW1lKCkKayA9IGFyYW5nZShuKS9uCnByb2R1Y3QgPSBwcm9kKCBbc3VtKGYoaykqKm0pL24gZm9yIG0gaW4gcmFuZ2UoMSwgMTEpXSApCnQxID0gdGltZS50aW1lKCkKZWxhcHNlZDEgPSB0MS10MApwcmludChyZXN1bHQsZWxhcHNlZDEpCgp0MCA9IHRpbWUudGltZSgpCmsgPSBhcmFuZ2Uobikvbgpwcm9kdWN0ID0gZXhwKHN1bShsb2coW3N1bShmKGspKiptKS9uIGZvciBtIGluIHJhbmdlKDEsIDExKV0pICkpCnJlc3VsdCA9IDEvcHJvZHVjdAp0MSA9IHRpbWUudGltZSgpCmVsYXBzZWQyID0gdDEtdDAKcHJpbnQocmVzdWx0LGVsYXBzZWQyKQo=