Skip to content

Instantly share code, notes, and snippets.

@3-24
Last active October 9, 2018 02:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 3-24/eddec8721a6e3fa3736dff215829fd16 to your computer and use it in GitHub Desktop.
Save 3-24/eddec8721a6e3fa3736dff215829fd16 to your computer and use it in GitHub Desktop.
code for plotting Rogers-Ramanujan continued fraction on real plane
# Copyright (c) by Youngseok Choe in 2018.
# Fundamental Recurrence Formulas
import matplotlib.pyplot as plt
class Graph:
def __init__(self, point):
self.point = point
self.x = [point[p][0] for p in range(len(point))]
self.y = [point[p][1] for p in range(len(point))]
self.name = None
def plot(self):
plt.plot(self.x,self.y,'tab:green')
plt.show()
def add(self,p):
self.point.append(p)
self.x.append(p[0])
self.y.append(p[1])
def name(self,name):
self.name = name
G = Graph([])
def add_point(start,end,nbr,accuracy):
def eval(x):
A = [1,0]
B = [0,1]
for i in xrange(1,accuracy):
if i == 1:
a = x**0.2
else:
a = float(x)**(i-1)
A.append(A[1] + a*A[0])
B.append(B[1] + a*B[0])
A.pop(0)
B.pop(0)
return A[1]/B[1]
for i in xrange(1,nbr):
x = start + (end - start)/float(nbr) * i
G.add([x,eval(x)])
add_point(0,1,10000,999)
G.plot()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment