-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlimits_for_pi.sf
65 lines (53 loc) · 1.29 KB
/
limits_for_pi.sf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/ruby
# Daniel "Trizen" Șuteu
# Date: 09 January 2017
# Edit: 09 April 2022
# https://github.com/trizen
# Two limits for Pi: an upper and a lower limit.
# The following two inequalities hold:
#
# lower(n) < Pi < upper(n)
#
# for n < Infinity.
# See also:
# https://oeis.org/A280100
# https://oeis.org/A280845
# https://oeis.org/A134374
#
## 16^n * n * (n!)^4 / ((2*n + 1)!)^2
## (4^n * n * (n!)^2) / ((2*n + 1)!!)^2
#
func lower(n) {
4 * (16**n * n * n!**4) / (2*n + 1)!**2
#(4**(n+1) * n * (n!)**2) / ((2*n + 1)!!)**2
}
#
## 16^n * (n+1)! * (n!)^3 / ((2*n + 1)!)^2
## (4^n * (n+1) * (n!)^2) / ((2*n + 1)!!)^2
#
func upper(n) {
4 * (16**n * (n+1)! * n!**3) / (2*n + 1)!**2
#(4**n * (n+1) * (n!)**2) / ((2*n + 1)!!)**2
}
#
## 16^n * (n!)^4 / (n * ((2*n)!)^2)
## (2^n * n!)^4 / (n * ((2*n)!)^2)
## 4^n * (n!)^2 / (n * ((2*n - 1)!!)^2)
#
func upper2(n) {
#16**n * n!**4 / (n * (2*n)!**2)
#4**n * (n!)**2 / (n * ((2*n - 1)!!)**2)
(2**n * n!)**4 / (n * (2*n)!**2)
}
define LIMIT = 1e3
say "Lower bounds:"
say lower(LIMIT)
say "\nUpper bounds:"
say upper(LIMIT)
say upper2(LIMIT)
__END__
Lower bounds:
3.13923812696691110493340150080310032881057733291
Upper bounds:
3.14237736509387801603833490230390342913938791024
3.14237814990340975776611113565427862991447011289