A small kernel of code for playing with Galois fields of arbitrary characteristic
Revision | 0b77fa2db6fa3a13e8db4381e43d20e076ae3cfd (tree) |
---|---|
Time | 2020-01-13 07:45:56 |
Author | Eric Hopper <hopper@omni...> |
Commiter | Eric Hopper |
Turning this into a grab-bag of math stuff.
@@ -0,0 +1,8 @@ | ||
1 | +from fractions import Fraction as F | |
2 | + | |
3 | +"""I have no better place to put this. This is a quickly converging series for | |
4 | +computing a rational approximation of pi. For when you want more precision | |
5 | +than math.pi will give you.""" | |
6 | + | |
7 | +def ratpi(n): | |
8 | + return sum(F(1/16**k)*(F(4,8*k+1) - F(2,8*k + 4) - F(1,8*k+5) - F(1, 8*k+6)) for k in range(0, n)) |