<jupyter_start><jupyter_text>This will be programmed for j(Einit) = 1728. The equations would need to be adjusted for other j-invariants.Delta is a negative number, a fundamental discriminant.When $\Delta$ is odd, it is 1 mod 4 and $(-\Delta+1)/4$ is equal to the norm of a generator of the maximal order of the number field. For example, $\mathbb{Q}(\sqrt{-3})$ has $\Delta = -3$, and $\alpha = \frac{1 + \sqrt{-3}}{2}$ is a generator of the maximal order, and $N(\alpha) =1 = (-\Delta+1)/4$.When $\Delta$ is even, $|\Delta|/4$ is equal to the norm of a generator of the maximal order of the number field. For example, $\mathbb{Q}(i)$ has $\Delta = -4$, and $\alpha = i$ is a generator of the maximal order, and $N(\alpha) = 1$.<jupyter_code>def cornacchias_alg(m): #Only works for prime input m
    if m == 1:
        return 1,0
    if not Mod(-1,m).is_square():
        return "Fail"
    r0_values = mod(-1, m).sqrt(extend = False, all = True)
    for r0 in r0_values:
        if QQ(r0) > QQ(m/2):
            r0 = m - r0
        r_list = [m,r0]
        r_now = r0
        while ZZ(r_now)^2 >= ZZ(m):
            r_now = ZZ(mod(r_list[0],r_list[1]))
            r_list[0] = r_list[1]
            r_list[1] = r_now
        if (m - r_now^2).is_square():
            y_now = ZZ(r_now)
            z_now = ZZ(sqrt(m - r_now^2))
            return y_now,z_now
    return "Fail"

def ALGORITHM(Delta, p, ell, RMAX):
    D_count = 0
    AllDs = []
    GoodDs = []
    D_good = 0
    theta_list = [] #Need to keep track of r, D, and theta solution
    r = -1
    while r < RMAX:
        r = r + 1
        NegDeltaEll2r = -Delta*ell^(2*r)
        x = ((NegDeltaEll2r)^((p + 1)/4)) % p #Assumes p \equiv 3 \mod 4
        while x < sqrt(NegDeltaEll2r):
            D = ZZ((NegDeltaEll2r-x^2)/p)
            D_count += 1
            AllDs.append(D)
            if ZZ(D.mod(4)) == ZZ(1):
                if D.is_prime() or ZZ(D) == 1:
                    D_good += 1
                    GoodDs.append(D)
                    Alg_Output = cornacchias_alg(D) #Sol. unique if exists
                    if Alg_Output != "Fail":
                        a,b = Alg_Output
                        if mod(a,2) == ZZ(0):
                            ev = a
                            od = b
                        else:
                            ev = b
                            od = a
                        if ZZ(NegDeltaEll2r.mod(2)) == ZZ(1): #y odd, z even
                            x = QQ(x)
                            y = QQ(od)
                            z = QQ(ev)
                            theta = [1/2,x/2,y/2,z/2]
                        else:
                            x = QQ(x)
                            y = QQ(ev)
                            z = QQ(od)
                            theta = [0,x/2,y/2,z/2]
                        theta_list.append([r,D,theta])
            x = x + p
    return D_count,D_good, theta_list<jupyter_output><empty_output><jupyter_text>For Example 6.6, we run the algorithm on input $p = 179, \Delta = -47, \ell = 2$. We are finding an orientation on $E_{1728}:y^2 = x^3 - x$.As coded above, we don't stop when we find a single orientation: we repeat the loop for $r$ up to a specified bound. For our input, take $r = 8$.<jupyter_code>ALGORITHM(-47, 179, 2, 8)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12890625, 'fraction_numerical': 0.028846153846153848, 'mean_word_length': 1.4787788533134774, 'pattern_counts': {'":': 1, '<': 11, '<?xml version=': 0, '>': 11, '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': '404428', 'license': 'MIT', 'n_tokens_mistral': 1187, 'n_tokens_neox': 1120, 'n_words': 337, 'path': 'Algorithm6-1_ComputingAnOrientationForTheInitialCurve_Ex6-6.ipynb', 'repo_name': 'SarahArpin/WIN5', 'size': '3328'}