<jupyter_start><jupyter_text>Fractional Linear TransformationsThis notebook will be used to generated figures to understand the effect of fractional linear transformations on the Farey diagram.<jupyter_code>import numpy as np
import matplotlib.patches as mpatches
import matplotlib.pyplot as plt<jupyter_output><empty_output><jupyter_text>Infinite strip<jupyter_code>x_low = np.arange(-5,3)
fig = plt.figure()
ax = plt.gca()
# to remove frame box and axes
ax.axis("off")
ax.set_aspect(4)

num1,den1 = -8,13
num2,den2 = -5,8
for x in x_low:
    plt.scatter(x,0,color='b',alpha=0.7)
    plt.scatter(x+0.5,0.5,color='b',alpha=0.7)
    plt.plot([x,x+0.5],[0,0.5],color='b')
    plt.plot([x+0.5,x+1],[0.5,0],color='b')
   
    label = r"$\frac{" + str(num1) + "}{" + str(den1) + "}$"
    ax.text(x,-0.15,label,\
                    horizontalalignment='center',\
                    verticalalignment='center',fontsize=20)
    label2 = r"$\frac{" + str(num2) + "}{" + str(den2) + "}$"
    ax.text(x+0.5,0.5+0.15,label2,\
                    horizontalalignment='center',\
                    verticalalignment='center',fontsize=20)
    
    num1,den1 = (2*num1 + den1),(num1 + den1)
    if num1 < 0 and den1 < 0:
        num1,den1 = -num1,-den1
    num2,den2 = (2*num2 + den2),(num2 + den2)
    if num2 < 0 and den2 < 0:
        num2,den2 = -num2,-den2

plt.plot([x_low.min(),x_low.max()],[0,0],color='r',zorder=-1)
plt.plot([x_low.min()+0.5,x_low.max()+0.5],[0.5,0.5],color='r',zorder=-1)

plt.tight_layout()
#plt.ylim([-0.5,1.0])
plt.savefig("./saved_figs/farey_translation_strip.svg")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.19106699751861042, 'fraction_numerical': 0.060794044665012405, 'mean_word_length': 3.5823863636363638, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '186520', 'license': 'MIT', 'n_tokens_mistral': 697, 'n_tokens_neox': 663, 'n_words': 102, 'path': 'Fractional Linear Transformations.ipynb', 'repo_name': 'sandeshkalantre/top-num', 'size': '1612'}