
// Make newform 9072.2.a.bs in Magma, downloaded from the LMFDB on 02 September 2025.
// 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_bs();".
// 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_bs();".
// 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_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 := 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]];
    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], [-1, 1, 0], [-1, 0, 0], [2, 1, 0], [-1, -4, 2], [-2, 1, -1], [1, -1, -1], [4, 2, -3], [-3, 4, 1], [1, -3, 6], [-1, 3, -6], [0, -1, 2], [1, 1, -2], [1, 3, -5], [-2, -2, -1], [-1, 0, 5], [2, 0, -3], [4, -3, 3], [3, -6, 3], [-7, 1, -5], [7, -3, 3], [-6, -1, 5], [-4, -7, 4], [-1, 8, -1], [7, -1, 3], [-2, 0, -3], [1, 4, -4], [5, -3, 3], [-12, -4, 2], [4, -5, -8], [-5, -10, 3], [-5, -7, 0], [-5, -5, -5], [2, 7, 0], [1, 12, -3], [-1, -5, -5], [-2, 3, -3], [-3, 4, 10], [-13, 3, -10], [-7, -1, 1], [-7, -3, 6], [1, 9, -8], [5, 0, 3], [-15, 6, -3], [-2, 0, -3], [1, -2, 4], [-5, 6, 0], [-7, -2, 3], [5, 0, 12], [-7, 5, 4], [3, -2, 10], [-10, 0, 3], [-6, 9, -15], [-16, -2, 6], [-1, -17, 3], [7, -2, -7], [-8, -3, 0], [2, 3, -9], [-18, 7, 1], [-5, -3, -12], [-3, 2, 5], [-2, 7, 1], [-16, 3, -4], [-1, 10, 7], [8, 3, 8], [-14, -1, 5], [5, 12, -15], [5, 15, -7], [8, 8, 2], [-8, 2, 3], [-2, -5, 11], [-5, 5, -10], [5, -5, 4], [1, 10, -5], [-11, 11, -12], [7, -13, 9], [-19, -3, 6], [-4, 7, -18], [-4, -18, 6], [-12, -8, -5], [-13, -15, 9], [5, -4, 19], [17, 14, -4], [-11, 8, -19], [-2, -6, 10], [0, 3, 3], [-19, -15, 3], [-6, 7, -5], [4, -6, 3], [-23, -11, 8], [-25, 7, -3], [7, -16, 17], [-9, 7, -20], [-2, 18, -12], [-12, 9, -18], [8, -2, -9], [13, -2, -4], [-11, 12, 3], [11, -2, -8], [-8, -20, 19], [1, 4, 17], [-10, -21, 8], [17, -6, -4], [13, 14, -1], [-16, 0, 9], [18, -13, 20], [-19, -7, 13], [14, 12, 2], [-22, -1, -4], [-17, 8, 14], [-1, -24, 18], [-24, 11, -16], [22, 0, 15], [-2, -17, 16], [-14, -10, -3], [19, -2, -11], [-7, -19, 1], [8, -23, 21], [-3, 5, 23], [5, 22, -17], [14, -3, -6], [-1, -24, 23], [32, 2, -2], [4, -15, 6], [-6, -6, -6], [2, 12, -6], [-11, 16, 5], [13, 19, -2], [11, 12, -18], [31, 0, 3], [-6, -23, 13], [-11, 11, 5], [14, -13, 5], [-10, 16, -18], [20, -12, 3], [1, 16, -4], [19, -9, -6], [-24, -19, 17], [-8, 7, 5], [4, 24, -15], [5, 3, -25], [-32, 12, -12], [3, 18, -21], [5, 1, -11], [9, -10, 2], [11, -15, 15], [4, 14, 3], [31, 0, -12], [-2, -11, -1], [2, -9, 9], [-33, 15, 6], [-5, 21, -18], [4, 26, -9], [-17, 6, -24], [9, -22, 11], [-8, -9, 12], [-25, -12, -7], [2, 17, -1], [31, -15, 16], [-8, -12, -5], [-18, -12, -12], [22, -11, -17], [-26, 19, -1], [-17, 24, -8], [32, 4, 9], [-35, -15, 15], [2, 24, -12], [14, -25, 11], [-13, 19, -15], [41, -2, 3], [-28, 3, -12], [7, 8, 0], [-19, 4, 4], [-5, -6, 12], [-18, -31, 20], [7, 7, -14], [19, 1, 20], [16, -20, -11], [-37, -15, 12], [-2, 26, -19], [-9, 29, -25], [8, -16, 2], [-19, 11, -29], [-10, 6, -7], [19, 23, -21], [-7, 9, 18], [-14, 5, 17], [-16, 21, -42], [-1, -19, 31], [-25, 16, -17], [-15, 23, 2], [19, -12, -15], [20, 3, 2], [17, -1, 28], [-32, -12, 13], [-13, -11, 31], [5, 21, 15], [-36, 1, 7], [-11, -20, 14], [25, 30, -14], [-5, -32, 22], [-43, 0, -3], [-16, 15, 6], [6, -33, 6], [40, -5, 8], [-26, 24, 6], [16, -4, 21], [-12, -8, -2], [-14, 27, -18], [14, -15, 36], [21, 5, -13], [-20, -2, 16], [10, -27, 16], [2, -3, -31], [17, -6, -21], [28, 32, -13], [25, 17, -24], [40, -5, 17], [-21, -4, 11], [11, 0, 27], [22, -8, 4], [-16, 4, -24], [1, 17, -10], [6, -8, -2], [20, 29, -31], [-28, 27, -16], [20, 2, 1], [34, 23, -22], [-5, -9, -14], [11, -11, 28], [22, 8, 2], [-20, 10, -8], [7, -3, 7], [-2, -2, 22], [-19, 31, 12], [50, 10, -8], [2, -4, -11], [33, 13, 4], [-3, -9, 3], [14, 13, -6], [25, -10, 5], [16, -19, -4], [-7, 36, -27], [6, -22, -13], [10, 15, -17], [7, 10, -11], [2, -3, 32], [-17, -43, 29], [-3, -6, -12], [-16, -1, -16], [-10, -22, 34], [38, -12, 11], [2, -7, 11], [19, 5, 33], [4, -11, -19], [5, -15, -3], [-41, 21, -3], [3, -9, -12], [17, 4, -32], [-26, 14, 5], [18, 5, 5], [-16, 15, 6], [-7, 20, -34], [16, 24, -8], [-2, 30, -6], [3, -3, -9], [15, 1, -32], [16, -21, 36], [46, -6, 7], [-28, 13, -29], [-11, 9, -15], [5, 6, 30], [28, 33, -21], [-25, 24, 3], [31, 6, 12], [10, -10, -9], [-1, -3, -21], [2, -6, 18], [-35, 15, -8], [17, -24, 20], [-26, 9, 18], [-12, 20, -7], [-1, 32, -43], [10, 15, -3], [7, 19, -25], [-7, 21, -9], [3, 32, -1], [7, -18, 27], [48, 21, -9], [52, -10, 33], [26, -4, 16], [-13, -5, 39], [3, 13, -5], [-22, 26, 11], [37, 3, -20], [-23, -6, 15], [30, 16, -26], [31, -17, 26], [1, 28, -20], [-43, -12, 12], [26, -34, -17], [-5, -4, -1], [-63, 13, -5], [43, 6, -18], [-13, -10, 11], [-10, 4, -15], [17, -36, 21], [55, 26, -18], [32, -11, -14], [-41, -9, 16], [28, -5, 29], [47, -21, 14], [28, 15, -21], [24, 45, -27], [5, -24, -15], [18, 14, 8], [-31, 9, -10], [-31, -16, -16], [-6, 20, -28], [10, 50, -49], [47, 25, -5], [27, 6, -21], [-23, -8, 22], [28, 44, -15], [-16, -39, 9], [-8, -36, 3], [46, -15, 9], [46, -27, 10], [54, 12, -21], [8, 30, 6], [43, -18, -14], [-5, 0, -24], [11, -23, -15], [49, 3, 0], [12, 24, -3], [-7, 41, 2], [-25, -29, 33], [8, 41, -43], [1, -21, 27], [23, -18, 36], [15, 7, 16], [9, 29, 2], [-23, 0, -15], [17, 39, -16], [-12, -15, 9], [-46, -9, 24], [22, -40, 2], [-57, -10, 8], [-31, -43, 31], [-35, -9, 3], [-4, -24, 18], [-24, -22, 5], [16, -4, -7], [-34, 6, -9], [15, -36, 21], [-26, -34, 9], [-34, -37, 34], [14, 16, -42], [-3, 35, 11], [14, -22, -16], [-25, 18, 5], [11, -25, -2], [61, -9, 1], [-32, -36, 18], [8, -42, 30], [-18, -20, 13], [-2, 18, 21], [38, 14, 23], [-10, -35, 45], [13, 12, -21], [49, -28, -3], [24, 4, 34], [43, 29, -19], [-37, -3, -18], [41, -27, 14], [-12, -33, 42], [17, 21, -33], [5, -13, 16], [50, 0, 6], [-11, -52, 33], [-3, -13, -28], [4, 10, -23], [19, -4, -15], [7, 22, -20], [56, 8, -8], [13, -24, -9], [-22, 24, 6], [4, 23, -19], [-42, -29, -2], [-13, -16, 2], [-37, -12, 17], [44, -19, -11], [-17, -30, 9], [-5, 39, -20], [-7, -54, 54], [-17, -57, 48], [-27, -59, 43], [7, 4, 43], [-14, -36, -2], [29, 7, 22], [-31, 35, 16], [1, -40, 11], [-55, 16, 15], [-17, 7, 14], [-23, 0, 9], [8, 39, -24], [-18, -32, 13], [-32, -9, 15], [-41, 0, -41], [2, 4, 4], [2, 15, -22], [-27, -24, 9], [7, 39, -21], [-4, 23, -13], [-10, 38, 4], [55, 7, -10], [-14, -31, -1], [-24, 27, 12], [7, -34, -27], [-14, 5, 36], [-7, 18, -3], [12, 14, -37], [57, 1, 10], [11, -9, 54], [-44, 6, -20], [-26, 30, -8], [-18, -9, -12], [40, -7, 23], [74, -2, 0], [14, -56, 25], [-75, 1, -8], [-14, 8, 44], [-39, 0, -27], [38, 18, 15], [4, -38, -7], [32, -14, 10], [17, -45, 12], [43, 33, -15], [37, 1, 7], [41, 15, 8], [-43, -48, 44], [20, -9, 33], [-25, 18, 14], [47, -25, -22], [-6, 14, -25], [-11, -36, 3], [8, -1, -17], [41, -15, -6], [-13, 18, -51], [52, -4, 38], [18, 19, -29], [-37, 26, -44], [-8, -30, 37], [26, 16, 7], [-18, -30, 45], [5, 9, 6], [-4, -5, 42], [5, 12, -27], [2, 5, -29], [-56, 8, -31], [-8, 54, -24], [25, -25, 39], [-76, 16, -14], [-2, 0, 51], [-34, 27, -6], [43, -36, -3], [4, 54, 4], [-38, -32, 2], [52, -29, 49], [-2, -3, -30], [-30, 9, 15], [-24, -70, 56], [-46, 20, 14], [-1, -27, 14], [74, 30, -12], [54, -22, 23], [-23, 45, -27], [-32, -4, 0], [19, -22, -3], [53, -11, -20], [-7, 18, 44], [-34, -46, 44]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_9072_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_9072_2_a_bs();".
// 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_bs(:prec:=3)
    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_bs();".
// 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_bs( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_9072_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<5,R![-3, 0, 3, 1]>,<11,R![-3, 9, -6, 1]>,<13,R![-107, -33, 3, 1]>],Snew);
    return Vf;
end function;