Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import mpmath as mp
- #print(mpmath.libmp.BACKEND)
- mp.mp.dps = 128
- print(mp.mp)
- q = mp.mpc(mp.cos(1.0), mp.sin(1))
- qr = 1 / (1 - q)
- print(q, qr, sep='\n')
- def f(x):
- return mp.mpc(mp.cos(x), mp.sin(x)) / mp.log(x)
- def sumf(n, m = 0):
- res = mp.mpc(0)
- for i in range(2, n):
- res += f(i)
- tail = [f(i) for i in range(n, n + m + 1)]
- for i in range(m):
- #print(i, tail[0] * qr)
- res += tail[0] * qr
- for j in range(m - i):
- tail[j] = (tail[j + 1] - q * tail[j]) * qr
- tail.pop()
- return res
- print(sumf(100000, 25))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement