Last active
August 29, 2015 14:17
-
-
Save mango314/0fd296f89532b227f0d5 to your computer and use it in GitHub Desktop.
gauss reduction algorithm and cycles
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def S((a,b,c), k=1): | |
return (a, -2*a*k+b, a*k**2-b*k+c) | |
def T((a,b,c)): | |
return (c,b,a) | |
x = (1,33,-21) | |
x = (7, 33, -8) | |
x = (13,13,-22) | |
# never changes in this process. eveluate it once | |
D = x[1]**2 - 4*x[0]*x[2] | |
O = [x] | |
x = (x[2], -1*x[1], x[0]) | |
c = 0 | |
while True: | |
while x[1] < 0 or 2*abs(x[2]) < np.sqrt(D) - x[1] or 2*abs(x[2]) > np.sqrt(D) + x[1]: | |
x = S(x, -1*x[0]/abs(x[0])) | |
if x == O[0]: | |
break | |
else: | |
O += [x] | |
x = (x[2], -1*x[1], x[0]) | |
O |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[(13, 13, -22), | |
(-22, 31, 4), | |
(4, 33, -14), | |
(-14, 23, 14), | |
(14, 33, -4), | |
(-4, 31, 22), | |
(22, 13, -13), | |
(-13, 13, 22), | |
(22, 31, -4), | |
(-4, 33, 14), | |
(14, 23, -14), | |
(-14, 33, 4), | |
(4, 31, -22), | |
(-22, 13, 13)] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment