Guest User

Untitled

a guest
Dec 8th, 2014
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.28 KB | None | 0 0
  1. from multiprocessing.dummy import Pool
  2. import numpy as np
  3.  
  4. SAMPLES = 10**6
  5. RANGE = 200
  6.  
  7. points = np.linspace(-RANGE, RANGE, RANGE + 1) * 2 * np.pi
  8.  
  9. print( sum( Pool().imap_unordered(
  10.     lambda r: (np.sin(np.linspace(r[0], r[1], SAMPLES))/SAMPLES).sum(),
  11.     zip(points, points[1:])
  12. )))
Advertisement
Add Comment
Please, Sign In to add comment