Advertisement
jukaukor

Basel_Problem_Euler.py

Jun 23rd, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. # https://en.wikipedia.org/wiki/Basel_problem
  2. # Leonhard Euler solved it in 1734
  3. # and published it in 1735 St Peterburg's Adacemy of Sciences
  4. # Basel problem is Riemann's zeta-function at value s = 2
  5. # https://en.wikipedia.org/wiki/Riemann_zeta_function
  6.  
  7. # Juhani Kaukoranta 23.6.2018
  8.  
  9. import math
  10. import numpy as np
  11.  
  12.  
  13. def Basel():
  14. '''reciprocals, 1/n'''
  15. a = np.reciprocal(np.arange(1,500000000,1.0))
  16. '''sum of 1/(n*n)'''
  17. summa = np.sum(np.multiply(a,a))
  18. return(summa)
  19.  
  20. print(" Basel problem sum = ",Basel())
  21. print("Pii^2 / 6 = ",math.pi*math.pi/6)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement