formula.sf 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #!/usr/bin/ruby
  2. # a(n) = 2^A101925(n).
  3. # https://oeis.org/A101926
  4. # Formula (Daniel Suteu, Feb 03 2017):
  5. # a(n) is the reduced numerator of 2^(2*n+1)*(n!)^2/(2*n+1)/(2*n)!.
  6. # Alternate form:
  7. # a(n) is the reduced numerator of (sqrt(π) Γ(n + 1))/Γ(n + 3/2).
  8. # I came across that formula while studying some limits for Pi, related to Wallis product (Product_{k=1..n} (4*k^2)/(4*k^2-1) = Pi/2). (see: A002454)
  9. # In particular:
  10. # A002454(n) / (2*n+1)! = A046161(n) / A001803(n)
  11. # 2*A002454(n) / (2*n+1)! = A101926(n) / A001803(n)
  12. # Lim_{n->oo} n*A002454(n) / ((2n+1)!!)^2 = Pi/4
  13. # Lim_{n->oo} A002454(n) / A079484(n) = Pi/2
  14. # Since A101926(n) is even and A001803(n) is odd, we get:
  15. # A101926(n) = numerator(2*A002454(n) / (2*n+1)!)
  16. # A101926(n) = 2 * A046161(n)
  17. # Where:
  18. # A046161(n) = 2^A005187(n) -- see "formula" section
  19. # A101926(n) = 2^(1 + A005187(n)) -- by definition
  20. # which proves the identity:
  21. # A101926(n) = 2 * A046161(n)
  22. # This program checks the formula against the definition for the first 10^3 terms.
  23. func A005187(n) {
  24. 2*n - popcount(2*n)
  25. }
  26. func A101925(n) {
  27. A005187(n) + 1
  28. }
  29. func A101926(n) {
  30. 2**A101925(n)
  31. }
  32. for n in (1..1e3) {
  33. var t = (2**(2*n + 1) * (n!)**2 / (2*n + 1) / (2*n)!)
  34. var num = t.nu
  35. say [n, num]
  36. assert_eq(num, A101926(n))
  37. }