
// Make newform 9072.2.a.ce in Magma, downloaded from the LMFDB on 18 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_9072_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_9072_2_a_ce();".
// 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_9072_2_a_ce();".
// 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 := [4, 5, -6, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0], [0, 1, 0, 0], [-3, 0, 1, 0], [0, -5, 0, 1]];
    Rf_basisdens := [1, 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_9072_a();"
function MakeCharacter_9072_a()
    N := 9072;
    order := 1;
    char_gens := [1135, 6805, 3809, 2593];
    v := [1, 1, 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_9072_a_Hecke(Kf)
    return MakeCharacter_9072_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+1)]];
    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, 0, 0, 0], [0, 0, 0, 0], [-1, 1, 0, 1], [-1, 0, 0, 0], [-2, 1, 0, -1], [1, -1, 1, 1], [-1, -2, -1, 1], [0, 0, 1, -1], [-1, 0, -2, -1], [0, 2, -2, 1], [3, 0, -1, 0], [7, 0, -1, 0], [-2, 3, 2, -1], [-3, -2, 1, -2], [2, -1, 2, 2], [-1, -3, 3, 0], [2, -2, 2, -1], [1, 2, 2, 1], [-3, 2, -1, 1], [4, -3, -3, -2], [4, -3, -2, -2], [-4, 0, -5, 1], [-1, -2, -3, -3], [-4, -1, 0, -3], [2, -6, 0, 1], [-4, 2, -1, 3], [-3, 1, -3, -2], [-3, 1, 3, 1], [-2, 7, 0, -2], [0, -1, 3, -1], [-2, -6, 1, -2], [-2, 3, 1, 4], [3, -8, -1, -2], [-2, 6, -1, -3], [-2, -5, 4, -1], [0, -1, 5, -4], [8, 2, 1, 5], [-11, 2, 1, -1], [-3, -1, 3, -1], [-9, -6, 3, -2], [-6, 1, 4, 4], [-7, 7, 4, 5], [-17, 1, -2, 1], [4, 1, 5, -2], [-12, 4, -2, -1], [-7, 5, 5, 2], [-5, -3, -3, -3], [3, -1, -7, 1], [8, 3, -7, 0], [7, 4, -2, -2], [3, -9, -2, -1], [-5, 0, 0, 0], [9, -5, -5, -2], [-11, -3, 2, -2], [-2, 2, -4, -4], [-4, 6, -3, 5], [2, -1, 3, 4], [-4, 5, -4, 5], [1, 0, -5, 1], [-9, 1, 2, 0], [1, -7, -4, 1], [-20, -1, 3, 0], [-5, 7, 0, 6], [-12, -7, 4, -3], [10, 8, -4, 3], [-12, 5, 2, 1], [-3, 10, 5, -1], [20, -2, 2, 3], [6, 7, -2, 2], [-14, 0, -4, -2], [1, -1, 5, -4], [-1, 7, 4, -2], [13, -8, -1, 0], [7, 0, -1, 10], [-4, -6, 2, -5], [-13, -8, 7, -2], [-10, -7, 2, -4], [-9, 6, -5, 6], [-8, -2, -1, -2], [-2, 0, 2, -6], [-11, 10, -2, -7], [6, 3, 0, 8], [4, 2, -4, 5], [-11, -7, 5, 1], [0, 8, 4, 3], [-4, -4, 6, -6], [-5, -7, -6, 2], [-4, -4, 9, -3], [-7, 5, 0, -2], [-13, 8, 2, -1], [-13, 0, -3, 2], [10, 1, 0, -6], [10, -1, -11, -4], [-5, -4, -1, 2], [-14, 8, 6, 4], [6, 1, -6, -1], [-11, 3, -3, 4], [3, 13, 5, -3], [8, 7, -5, 6], [9, 7, -11, 1], [1, -5, -1, -4], [0, 0, 8, -5], [0, 0, 11, 6], [25, 3, 1, 5], [-8, -12, -4, 5], [-23, -5, 3, -4], [-12, -2, -3, 8], [18, -1, 6, 8], [0, 0, -8, 2], [-14, 3, 8, 5], [1, -3, 5, 1], [7, -15, -7, 5], [-8, 1, 2, 1], [-7, 8, 4, -7], [-8, -4, -1, -8], [-5, -10, 4, -3], [38, 0, 2, -1], [-4, 7, -12, 0], [-5, -2, 1, 7], [-8, -11, -2, 2], [2, 1, 5, -6], [6, -8, 1, -8], [-6, -6, -8, -5], [-2, 10, 8, 4], [0, 0, 3, 8], [4, -4, 2, -2], [20, 0, 8, 6], [16, 4, 8, 1], [23, 4, -7, 4], [-25, 6, 8, 6], [2, 6, 0, 15], [-17, -6, -3, -3], [-4, -2, -1, 1], [-9, -4, -5, -1], [8, -6, -18, -4], [-17, 7, -5, 2], [-31, -4, -2, -2], [1, 10, -1, 2], [-15, 7, -4, -6], [19, 2, -1, -1], [23, 1, 9, -6], [-2, -11, 6, -10], [8, -4, -8, -8], [6, 6, 6, 9], [-2, 11, 8, -6], [-27, 9, 3, -3], [-20, 4, -11, -13], [9, -13, 1, 0], [-5, -3, 5, 7], [-1, 5, 0, 12], [-9, -12, 7, -13], [-5, -8, 1, -16], [-17, 16, 7, 4], [-9, -1, -7, 4], [17, -5, 7, 3], [2, 11, 3, 8], [-34, -4, -1, 4], [-4, 6, -4, -3], [-15, 6, 5, -1], [-13, 5, -4, -3], [-1, -11, -3, 4], [14, 0, 4, -4], [5, -3, 2, 10], [-29, 3, 2, -2], [19, 3, -9, 1], [13, 9, -7, 12], [40, -7, -4, -4], [-12, -17, 3, -3], [1, 6, 1, 11], [-10, -2, -1, 1], [-4, -10, -6, -7], [-10, -14, 11, 2], [-11, 8, -6, -6], [-7, 0, 4, 8], [19, 3, 1, -7], [-6, -7, 2, -1], [7, -18, 3, 6], [-5, 2, 1, 4], [27, -1, 3, 12], [5, -15, 10, -7], [23, -12, -2, -11], [8, 3, -4, -6], [18, 20, -8, 2], [-24, 9, 14, 4], [29, 6, 4, -3], [30, 11, -4, -2], [-7, 8, -3, 8], [19, -7, 12, -4], [12, 6, -13, 2], [4, 11, 0, -6], [-6, -4, -2, 7], [11, 4, -5, 4], [4, 14, -8, -3], [-52, 6, 1, 0], [1, -6, 9, -16], [15, -3, -7, -4], [-14, 6, -9, 3], [22, 13, -10, 8], [29, 4, 5, -5], [-27, -5, -5, 3], [31, 9, -5, 9], [-7, 21, 9, 5], [12, 5, -5, -8], [-6, 1, 6, -3], [-2, 2, 5, -10], [6, -14, -3, -2], [-8, 6, -2, -8], [-3, -5, 23, 0], [-2, 8, -8, -10], [6, 2, -9, -6], [-16, 2, 15, 4], [0, -13, -10, -2], [0, -6, 12, 10], [-20, -2, -1, -8], [35, 16, -11, 3], [-12, 10, 10, 5], [11, -16, 8, 3], [3, 6, 5, 12], [-3, -2, 3, 1], [-24, 0, 4, -3], [-20, 20, 8, -1], [10, 0, -4, 16], [10, 11, 3, 13], [9, 20, 3, -4], [4, -8, 4, -2], [1, -14, -13, -7], [-4, -11, 4, -5], [35, -14, 0, 5], [-4, 11, 4, 9], [1, 16, -13, 4], [21, -6, -5, 0], [-30, -1, 3, -5], [6, -9, -3, 1], [16, 7, -2, 8], [-6, -17, 17, -5], [7, -4, -17, -2], [-10, 12, -2, 16], [29, -3, 1, 6], [5, -18, 3, 12], [2, -15, 4, 0], [44, -3, 0, 13], [4, -2, -4, 9], [4, -3, -12, 9], [12, -10, -14, -1], [27, -3, 11, -10], [9, -16, 3, 9], [26, 6, -4, 5], [8, -10, -5, 16], [0, 9, 16, -2], [15, -26, -10, -4], [-4, -3, 8, -7], [4, 10, -28, -4], [7, 8, -12, 1], [-3, -12, 11, -7], [-4, 15, 2, -12], [17, 12, 7, 3], [-12, 13, 2, -2], [4, 8, -13, -11], [-21, 15, -4, -1], [9, 17, -13, 13], [-11, 5, 3, -16], [35, 2, 5, -3], [42, -5, -8, -1], [-7, -20, 6, 8], [-12, 0, 4, 4], [-12, 14, -8, -4], [-24, 23, 2, -12], [-39, 0, -5, -6], [-16, 13, 4, 7], [3, -5, 1, 2], [-1, 8, -21, -3], [-6, 27, 2, 12], [3, 9, 5, 15], [-31, -6, -9, -7], [2, 10, -16, 5], [-29, -1, 17, 1], [-23, 13, 11, 0], [8, -3, 22, 8], [24, 16, -2, -6], [9, -27, -4, 5], [23, -11, 5, -1], [-4, 7, -4, 19], [13, 9, 5, 12], [-30, 23, 9, 14], [-1, -9, 0, -14], [-8, 0, 7, -13], [-8, 4, 21, 5], [8, -8, -16, 1], [-28, 0, -22, 1], [37, -8, 1, 3], [3, -9, -3, 0], [8, 15, 3, 21], [18, 10, -5, -3], [-24, 19, 0, -10], [5, 11, -7, 16], [25, -13, 8, -17], [26, -22, -4, -9], [-22, 3, -9, 3], [3, 10, 5, -6], [5, 7, -13, 1], [17, -3, 3, -3], [19, 19, 1, -6], [-4, -5, 5, -10], [-12, 15, 0, 0], [-5, -13, -13, 5], [18, -9, 5, 0], [-25, 9, -7, -2], [-32, -7, -9, -16], [5, -13, 3, -7], [-14, -13, 0, -11], [-39, 10, -11, 4], [-25, -2, -9, 7], [29, 0, -11, 8], [-27, 18, 9, 13], [-25, 21, 4, -10], [34, 20, -14, 9], [8, -7, 27, -1], [33, -5, -16, 1], [-3, 11, -23, -13], [-2, 16, 20, 4], [-21, 3, -15, 14], [-14, 16, 17, 17], [-6, 8, 4, -15], [-21, -20, 2, -8], [37, -4, -4, -9], [21, -20, -9, -1], [-19, -17, -1, 0], [-31, 16, -1, 9], [2, 2, -15, -8], [11, 7, -17, -2], [58, 2, -4, -4], [5, -15, -1, 1], [-25, -7, 5, -5], [-16, -4, 9, -13], [-41, 10, 3, 4], [-45, -2, -6, 3], [17, 24, -11, 20], [8, 1, 18, 2], [25, -22, -3, -11], [50, -23, -6, -2], [-3, -13, -7, -11], [9, -19, -2, 9], [-11, -2, 5, 10], [-24, -15, 23, -2], [-39, -18, 15, -8], [49, -2, -7, 1], [20, -12, -15, -8], [16, -16, 0, -2], [-15, -17, -3, 5], [-32, -5, 6, 6], [-4, 14, 19, 1], [-12, 9, -19, 1], [11, 31, -11, 28], [7, 5, 1, 22], [25, -15, 15, 10], [-52, 16, 6, 3], [11, 13, -21, 12], [26, 4, -1, -8], [42, 7, 7, -1], [-28, 9, -16, -2], [34, 4, 6, 0], [-12, 10, 14, 9], [29, 8, 11, 0], [30, -17, 10, 14], [34, -14, -2, -12], [40, -17, 1, -5], [-31, -19, 21, 4], [-27, 1, -5, -4], [3, -8, -22, 11], [-5, 2, 21, 17], [-34, -14, 14, 7], [-12, -3, 7, 16], [-22, 10, 2, -20], [6, -23, -8, -12], [-5, -18, -9, -14], [27, -21, -4, -3], [-16, -6, -1, 4], [-32, 3, 16, 0], [-21, -10, -21, 0], [-24, 4, -12, -18], [0, -9, -7, 4], [3, -27, 6, 1], [1, 34, -8, -5], [-36, 15, 3, 12], [-11, -6, 8, -10], [-12, -16, 4, 0], [-44, 10, -8, -13], [-30, 9, -3, 1], [23, -8, -9, 5], [12, -3, -20, -1], [3, 27, 3, -5], [-34, 3, -15, 4], [1, 22, -3, 17], [12, 21, -5, 10], [-9, -10, 1, -8], [35, -2, 12, 16], [-5, -4, 1, 2], [12, 7, 2, 26], [-38, 14, 0, 19], [-12, 14, 22, 0], [33, 7, -10, -3], [-41, 25, 18, 9], [8, -6, 28, 15], [20, -26, -8, 7], [13, 11, 0, 25], [-28, -14, -2, 9], [-52, 15, 6, 15], [-45, 2, -2, 5], [35, -7, 18, 10], [-32, 24, 16, 11], [10, -6, -14, -10], [-4, 13, 26, 11], [-6, -4, -6, -23], [-18, 19, 8, -2], [-19, -11, -16, -4], [52, -21, -11, -7], [45, -16, -1, 8], [31, 8, 19, -13], [32, -17, -2, 13], [-50, 16, 10, 1], [38, -15, 8, 13], [-36, -5, 19, -6], [-23, 0, 22, 5], [-37, -1, -4, -3], [5, 8, 15, -20], [16, 20, -14, 4], [22, 32, -2, -4], [20, 32, -11, 2], [3, -31, -12, 10], [-6, -18, -4, -6], [7, -19, 1, 14], [-3, 6, -5, -12], [-2, -24, -4, 8], [16, -6, 6, 7], [-13, -18, 20, -9], [-5, 15, 17, 6], [-56, -1, -11, -1], [-13, 6, -3, 12], [36, -17, 14, 8], [-10, -7, 8, 14], [-23, 9, -4, 9], [-17, 22, -14, -14], [-27, -10, 1, 1], [-1, 22, 18, -6], [-3, -8, -13, -20], [-31, 4, -10, 5], [-62, -2, -2, -21], [19, -6, -3, -5], [3, -26, 3, -22], [28, 10, -6, 3], [-30, 2, -2, 4], [9, 18, -7, 11], [-29, -7, -23, 21], [3, 15, -19, 6], [-5, -28, -12, -1], [13, -11, 23, -14], [-15, 20, -19, 0], [-8, 6, -11, 6], [44, -19, -1, -4], [49, -1, -2, 0], [-21, -15, -3, 12], [-54, 5, -5, -25], [48, -5, 2, 20], [18, 8, -20, -10], [-1, 5, 1, 4], [14, 4, 27, 20], [-58, -3, 15, 6], [-52, 26, 0, -2], [58, -19, -19, -7], [-27, -1, -12, 18], [-8, 11, -12, -17], [-19, 2, -3, -21], [40, -4, -14, -4], [-42, 25, 9, 13], [9, -30, 7, 10], [34, -2, 12, -10], [-57, 19, 1, -18], [-28, 5, 12, -4], [-48, -2, -6, 10], [14, 4, -14, -5], [-7, -2, -13, -8], [-65, -7, 9, -3], [-42, 14, 16, 10]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_9072_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_9072_2_a_ce();".
// 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_9072_2_a_ce(:prec:=4)
    chi := MakeCharacter_9072_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(3457) - 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_9072_2_a_ce();".
// 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_9072_2_a_ce( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_9072_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<5,R![31, -29, -9, 4, 1]>,<11,R![-54, -81, -9, 6, 1]>,<13,R![-78, 99, -27, -3, 1]>],Snew);
    return Vf;
end function;