
// Make newform 3645.2.a.a in Magma, downloaded from the LMFDB on 03 January 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_3645_a();"
// To make the coeffs of the qexp of the newform in the Hecke field type "qexpCoeffs();"
// To make the newform (type ModFrm), type "MakeNewformModFrm_3645_2_a_a();".
// This may take a long time!  To see verbose output, uncomment the SetVerbose lines below.
// The precision argument determines an initial guess on how many Fourier coefficients to use.
// This guess is increased enough to uniquely determine the newform.
// To make the Hecke irreducible modular symbols subspace (type ModSym)
// containing the newform, type "MakeNewformModSym_3645_2_a_a();".
// This may take a long time!  To see verbose output, uncomment the SetVerbose line below.
// The default sign is -1.  You can change this with the optional parameter "sign".
function ConvertToHeckeField(input: pass_field := false, Kf := [])
    if not pass_field then
        poly := [-1, -3, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0], [0, 1, 0], [-2, 0, 1]];
    Rf_basisdens := [1, 1, 1];
    Rf_basisnums := ChangeUniverse([[z : z in elt] : elt in Rf_num], Kf);
    Rfbasis := [Rf_basisnums[i]/Rf_basisdens[i] : i in [1..Degree(Kf)]];
    inp_vec := Vector(Rfbasis)*ChangeRing(Transpose(Matrix([[elt : elt in row] : row in input])),Kf);
    return Eltseq(inp_vec);
end function;


// To make the character of type GrpDrchElt, type "MakeCharacter_3645_a();"
function MakeCharacter_3645_a()
    N := 3645;
    order := 1;
    char_gens := [731, 2917];
    v := [1, 1];
    // chi(gens[i]) = zeta^v[i]
    assert UnitGenerators(DirichletGroup(N)) eq char_gens;
    F := CyclotomicField(order);
    chi := DirichletCharacterFromValuesOnUnitGenerators(DirichletGroup(N,F),[F|F.1^e:e in v]);
    return MinimalBaseRingCharacter(chi);
end function;

function MakeCharacter_3645_a_Hecke( : Kf := Kf)
    return MakeCharacter_3645_a();
end function;


function ExtendMultiplicatively(weight, aps, character)
    prec := NextPrime(NthPrime(#aps)) - 1; // we will able to figure out a_0 ... a_prec
    primes := PrimesUpTo(prec);
    prime_powers := primes;
    assert #primes eq #aps;
    log_prec := Floor(Log(prec)/Log(2)); // prec < 2^(log_prec+1)
    F := Universe(aps);
    FXY<X, Y> := PolynomialRing(F, 2);
    // 1/(1 - a_p T + p^(weight - 1) * char(p) T^2) = 1 + a_p T + a_{p^2} T^2 + ...
    R<T> := PowerSeriesRing(FXY : Precision := log_prec + 1);
    recursion := Coefficients(1/(1 - X*T + Y*T^2));
    coeffs := [F!0: i in [1..prec]];
    coeffs[1] := 1; //a_1
    for i := 1 to #primes do
        p := primes[i];
        coeffs[p] := aps[i];
        b := p^(weight - 1) * F!character(p);
        r := 2;
        p_power := p * p;
        //deals with powers of p
        while p_power le prec do
            Append(~prime_powers, p_power);
            coeffs[p_power] := Evaluate(recursion[r + 1], [aps[i], b]);
            p_power *:= p;
            r +:= 1;
        end while;    
    end for;
    Sort(~prime_powers);
    for pp in prime_powers do
        for k := 1 to Floor(prec/pp) do
            if GCD(k, pp) eq 1 then
                coeffs[pp*k] := coeffs[pp]*coeffs[k];
            end if;
        end for;
    end for;
    return coeffs;
end function;


function qexpCoeffs()
    // To make the coeffs of the qexp of the newform in the Hecke field type "qexpCoeffs();"
    weight := 2;
    raw_aps := [[0, 1, 0], [0, 0, 0], [-1, 0, 0], [-2, 0, -2], [0, 1, -3], [0, -1, 1], [4, 2, -1], [5, 3, -2], [0, -4, 5], [1, 3, -1], [6, 4, -2], [-9, 0, 1], [1, 4, -3], [-9, 2, 1], [1, -4, 2], [-4, 0, -5], [6, -2, 3], [1, -2, 1], [0, 5, -4], [1, 4, 0], [3, 0, 2], [-3, 5, -1], [10, 1, -4], [8, -6, -1], [0, 3, -2], [4, 2, -3], [-3, 5, -3], [-2, 7, 2], [3, -9, 7], [-3, -1, 1], [2, -2, -7], [9, -1, 8], [4, -1, -3], [7, -9, 5], [6, 0, -5], [-9, 2, 4], [-2, 8, 1], [0, 0, 10], [5, -3, -4], [11, -7, 7], [6, 1, 0], [11, -5, -2], [-4, -8, 4], [-1, -3, 0], [-3, 0, -9], [2, -9, 1], [1, -9, -1], [-1, -1, 14], [11, 10, -5], [-12, 7, -5], [-16, 8, 4], [0, 7, -6], [16, -7, 2], [13, 7, 2], [7, -6, 13], [4, 6, -1], [21, 2, -2], [13, 0, 6], [17, -1, -2], [-9, 4, -17], [7, -6, 1], [-1, 4, -12], [8, -7, 9], [-3, 2, 5], [-10, 7, -17], [-4, 9, 6], [1, -18, 13], [-8, -4, -10], [11, -9, 4], [-5, -4, -1], [31, -1, 3], [7, -16, 3], [1, -20, 5], [-15, -9, 5], [5, 2, 3], [6, 20, -7], [-4, -4, 4], [10, -13, -1], [-13, 15, 8], [-4, 1, -14], [15, 0, -2], [9, -11, 12], [18, -3, 15], [25, -1, 2], [-15, -8, -3], [5, -1, 13], [-2, -19, 14], [-8, 2, 5], [8, -9, 20], [4, 0, -2], [6, -3, 1], [-4, -4, 19], [7, 14, -11], [5, 2, 14], [-22, 6, -11], [2, 20, -10], [-11, -13, 17], [1, 16, -12], [7, 3, 12], [26, 16, -12], [8, -4, -3], [15, -9, 0], [13, -2, -1], [-3, -11, -8], [5, 3, -6], [-6, 17, -15], [14, 4, -9], [0, -9, -11], [2, -3, -6], [-14, 5, 4], [5, -1, 18], [2, -20, 29], [-19, 0, -4], [-15, 15, -17], [-7, 16, 8], [-3, -13, 23], [-13, 13, -27], [-11, 15, -6], [-9, 15, -20], [-14, -12, 9], [20, 6, -8], [6, 24, -18], [-9, 10, -2], [7, -5, -16], [25, -9, -12], [-6, 23, -24], [22, -6, 15], [16, -14, -13], [-12, -9, -5], [-23, -14, 6], [-1, -26, 14], [-21, -12, 11], [5, -4, 9], [13, 12, 0], [16, 6, -11], [8, -16, 17], [-25, -7, 7], [-4, -16, 15], [-14, 8, -11], [18, 8, 6], [19, 15, -11], [-9, 8, -4], [-7, 15, -9], [-11, 15, 18], [-11, -26, 26], [14, 12, 6], [-18, 21, 3], [-16, -17, -1], [3, -4, -11], [17, -5, -11], [7, -18, 19], [3, 9, -28], [-20, -14, 15], [-11, -10, 6], [8, -7, -8], [1, -29, 19], [-3, -7, -14], [33, -1, -9], [-19, 8, -17], [-5, -6, -10], [-1, -12, -1], [-9, 14, 13], [5, 13, -5], [-36, -1, 11], [26, 0, 4], [13, -11, 23], [5, 1, -17], [-32, -1, 6], [-4, 26, 8], [-18, 17, 3], [-13, -18, 26], [1, 2, 20], [-22, -6, 2], [-17, -14, -4], [-18, 0, 2], [2, 18, 8], [9, -4, 14], [21, 0, 21], [-15, 21, -11], [20, 17, 3], [24, 21, 1], [3, 22, -28], [-8, -12, -6], [-11, -8, 0], [20, 7, -18], [-47, 3, 0], [-19, 0, -1], [13, -15, 0], [-13, 22, 13], [11, -19, 24], [19, 4, 4], [-13, 10, -31], [7, -7, -24], [-16, 3, -26], [2, -9, -19], [13, -10, 10], [-20, -12, -3], [15, 25, -20], [8, -19, 34], [-10, -25, 11], [-5, -31, 12], [-8, -6, 19], [-10, 16, 21], [9, -17, 6], [-31, -28, 13], [8, 13, -6], [-1, -2, -11], [13, -6, 21], [26, -2, 21], [42, -5, -10], [-29, 13, -15], [-37, -7, -10], [11, -7, -20], [7, -23, 19], [-36, 10, 7], [8, -15, 33], [-3, 2, 13], [3, -19, 8], [21, -26, 5], [-5, -9, 13], [-24, -2, -15], [-8, 1, -21], [2, 2, 22], [0, 33, -28], [1, -1, -17], [39, -10, 18], [10, -9, -17], [8, 40, -23], [-17, 6, -3], [16, -9, 10], [-5, -19, 33], [10, -6, 0], [-37, 9, -21], [-29, -22, 17], [6, 25, 8], [-7, -7, -14], [7, 16, 5], [7, 20, -5], [12, -35, 19], [14, -24, 41], [38, 4, 12], [-9, 17, -34], [-1, -1, -3], [-1, 19, -15], [35, -21, -4], [13, -3, -18], [-21, -7, 30], [31, -13, 38], [14, -29, -23], [33, 0, -4], [-5, -12, -21], [-20, 33, -18], [-23, 19, -1], [11, 9, -1], [-15, 7, -4], [29, -23, 3], [-17, 16, 1], [7, 8, 10], [19, 13, 2], [31, -18, -10], [-8, -37, 11], [-6, 44, -21], [-38, 3, 5], [-1, 25, 0], [1, -22, -21], [-45, -22, 16], [-51, -19, 4], [18, 13, 26], [31, -17, 18], [-4, -5, 2], [20, 43, -26], [-12, 12, -22], [22, -9, 17], [5, 1, 6], [-49, -9, 2], [-1, -45, 9], [-9, 36, -27], [13, -13, 39], [11, 3, -7], [32, -12, -1], [19, -8, -24], [29, -23, -16], [12, 41, -24], [-38, 2, -24], [56, 1, 3], [-33, -40, 20], [16, -14, 7], [-12, -38, 31], [-38, -10, 19], [-41, 7, -7], [-19, -7, -7], [-10, -30, 36], [17, 1, 9], [50, 1, 3], [-19, -26, 31], [54, -2, 13], [23, 25, -11], [36, -11, -20], [-50, 18, 10], [-10, 10, 22], [-26, -26, 14], [20, 23, 0], [-13, -20, 26], [-1, -13, -2], [-10, 30, -32], [-46, 9, 6], [21, -5, -20], [43, -20, 12], [20, -12, -7], [-21, 33, 3], [14, -8, -24], [22, 32, -15], [-12, 1, -20], [-11, -12, 38], [27, -1, 33], [-18, -14, 18], [31, 21, -5], [17, 33, -22], [5, 20, -11], [-14, -18, 22], [24, 9, 1], [-36, 2, 24], [55, -3, -6], [10, -27, 12], [-18, -48, 15], [-3, -49, 40], [-1, 15, -3], [12, -16, 37], [-1, 15, 20], [9, 0, 35], [-33, -22, 11], [11, -5, -16], [26, -26, 34], [-27, 30, 19], [-5, -43, 13], [-21, -38, 38], [1, -7, -29], [5, -36, 51], [-16, -10, -1], [21, 49, -35], [27, 40, -27], [-50, -21, 17], [28, -4, -18], [18, -1, -4], [-23, 32, -64], [31, 1, -4], [-24, -2, -34], [-53, 6, 12], [-53, 17, -33], [16, 25, -15], [-19, -29, 21], [-28, -20, -6], [11, 23, -4], [-3, 31, -6], [32, -6, -4], [-22, -38, 21], [-27, 23, 0], [5, 24, -1], [31, 15, 10], [38, -17, 26], [13, 13, 4], [18, -6, 2], [4, -12, -41], [29, 33, -2], [8, -23, 49], [7, 45, -24], [5, 29, -2], [-9, 20, -16], [-33, -39, 19], [6, -4, -1], [31, 26, -27], [-50, -26, 4], [-33, -8, 13], [-46, -5, 18], [33, 7, 3], [-11, 12, -18], [-21, -10, 2], [65, -22, 5], [-33, 27, -12], [12, -4, -8], [43, 24, -10], [-21, -10, -34], [-62, 11, -22], [-29, 6, -7], [4, 5, 39], [-7, -15, 1], [-29, 17, 13], [-13, 3, 15], [-16, -26, -6], [-15, 2, 2], [-53, 6, 7], [47, -7, -9], [-17, 26, 11], [13, -28, -17], [-60, 23, 13], [36, 4, 29], [30, -27, 25], [-6, 18, -45], [-2, 9, 9], [13, -30, 64], [41, 14, -24], [-19, -35, 15], [-8, -48, 48], [54, -11, 38], [6, 19, -10], [34, -26, 37], [-17, 35, -59], [-40, 21, 18], [3, 23, -10], [5, -3, -37], [1, -13, 36], [6, -3, 18], [-4, -57, 46], [34, 38, -15], [-19, 22, 28], [-10, -1, -9], [-19, 9, 36], [-53, 6, 0], [-43, -31, 28], [-38, 4, -9], [-21, -54, 43], [-25, 1, 35], [-64, -22, 10], [-19, -5, -25], [35, 26, -34], [-48, 13, 18], [29, 22, 7], [12, -16, 35], [10, -31, 31], [16, -1, 32]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_3645_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_3645_2_a_a();".
// This may take a long time!  To see verbose output, uncomment the SetVerbose lines below.
// The precision argument determines an initial guess on how many Fourier coefficients to use.
// This guess is increased enough to uniquely determine the newform.
function MakeNewformModFrm_3645_2_a_a(:prec:=3)
    chi := MakeCharacter_3645_a();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 2));
    S := BaseChange(S, Kf);
    maxprec := NextPrime(2999) - 1;
    while true do
        trunc_vec := Vector(Kf, [0] cat [f_vec[i]: i in [1..prec]]);
        B := Basis(S, prec + 1);
        S_basismat := Matrix([AbsEltseq(g): g in B]);
        if Rank(S_basismat) eq Min(NumberOfRows(S_basismat), NumberOfColumns(S_basismat)) then
            S_basismat := ChangeRing(S_basismat,Kf);
            f_lincom := Solution(S_basismat,trunc_vec);
            f := &+[f_lincom[i]*Basis(S)[i] : i in [1..#Basis(S)]];
            return f;
        end if;
        error if prec eq maxprec, "Unable to distinguish newform within newspace";
        prec := Min(Ceiling(1.25 * prec), maxprec);
    end while;
end function;


// To make the Hecke irreducible modular symbols subspace (type ModSym)
// containing the newform, type "MakeNewformModSym_3645_2_a_a();".
// This may take a long time!  To see verbose output, uncomment the SetVerbose line below.
// The default sign is -1.  You can change this with the optional parameter "sign".
function MakeNewformModSym_3645_2_a_a( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_3645_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<2,R![-1, -3, 0, 1]>],Snew);
    return Vf;
end function;