Skip to content

Instantly share code, notes, and snippets.

@pebble8888
Created August 29, 2017 16:13
Show Gist options
  • Select an option

  • Save pebble8888/6b86032229e7ff058339052ed6504082 to your computer and use it in GitHub Desktop.

Select an option

Save pebble8888/6b86032229e7ff058339052ed6504082 to your computer and use it in GitHub Desktop.
from math import *
from fractions import Fraction
from sys import *
def twice(x, y):
x2 = (x*x*x*x-16*x)/(4*x*x*x+8)
y2 = sqrt_frac(x2*x2*x2+2)
return x2, y2
def sqrt_frac(x):
n = x.numerator
d = x.denominator
r_n = 0
r_d = 1
found = False
for i in range(100000000):
if i*i == n:
r_n = i
found = True
break
if i*i > n:
break
if not found:
sys.exit()
found = False
for i in range(100000000):
if i*i == d:
r_d = i
found = True
break
if i*i > d:
break
if not found:
sys.exit()
return Fraction(r_n, r_d)
r1x, r1y = twice(Fraction(-1), Fraction(1))
print(r1x, r1y)
r2x, r2y = twice(r1x, r1y)
print(r2x, r2y)
r3x, r3y = twice(r2x, r2y)
print(r3x, r3y)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment