
// Make newform 5328.2.a.bj in Magma, downloaded from the LMFDB on 01 May 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_5328_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_5328_2_a_bj();".
// 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_5328_2_a_bj();".
// 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, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0], [-2, 0, 1], [2, 2, -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_5328_a();"
function MakeCharacter_5328_a()
    N := 5328;
    order := 1;
    char_gens := [1999, 1333, 2369, 1297];
    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_5328_a_Hecke( : Kf := Kf)
    return MakeCharacter_5328_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, 0, -1], [2, -1, -1], [2, -2, 0], [0, -2, 0], [-1, -2, 1], [2, 1, 1], [-1, 1, 0], [-5, 0, -1], [4, -3, -1], [1, 0, 0], [-6, 0, 0], [4, 1, -1], [0, -2, -2], [4, -4, -2], [3, -3, 0], [-2, 0, 0], [6, -3, 1], [4, 2, -2], [-2, 1, -1], [-2, -3, -3], [-2, 4, 2], [1, -2, 3], [-4, 0, -2], [6, 2, -2], [6, 5, -3], [-4, 0, 4], [12, 4, -2], [5, 2, 3], [-4, 0, 4], [1, -1, 0], [-8, 2, 0], [6, 3, 3], [10, -6, -2], [-8, 0, 0], [2, -1, -7], [0, -1, -3], [5, -1, 0], [0, 6, -4], [3, -3, 4], [2, 3, 5], [-3, -5, -4], [2, -8, 0], [2, 2, 6], [-4, -9, 5], [-12, 0, 0], [-8, 10, 6], [21, -1, 0], [-14, -4, 0], [-6, -2, 2], [19, -7, -4], [0, 10, 0], [3, 1, 0], [5, 2, -5], [-14, 2, 0], [10, -4, 4], [6, -7, 1], [-4, -8, 2], [-3, -6, -5], [6, -3, 1], [8, -4, 2], [0, 2, -6], [-1, 3, 6], [-2, -4, 8], [8, 4, -2], [-18, 3, 3], [10, -4, 4], [15, -1, 2], [-10, -3, -1], [-7, 6, 7], [6, 2, -8], [4, -8, -4], [-6, -3, 3], [-2, 3, -5], [-9, 11, 2], [5, -4, 5], [-18, -5, 1], [-1, 14, 1], [8, -6, 0], [-2, 2, 4], [-8, 8, -2], [-9, -1, 2], [-10, 9, -1], [16, -1, 1], [-4, -2, 2], [-23, 2, -5], [-4, -2, 0], [-11, -4, -3], [-20, 5, -1], [31, 1, 0], [1, -1, -4], [-14, -5, 3], [-6, -4, -2], [8, -15, -5], [7, -1, -2], [4, 0, -10], [6, -6, 2], [0, 1, 11], [-8, 8, -2], [-8, -1, -3], [-11, 0, -11], [23, -13, -6], [-11, -14, 3], [-18, 7, -1], [6, 2, -6], [3, 9, 0], [-2, 0, 0], [0, 0, 12], [-6, -17, 5], [-10, -5, -1], [18, -4, 0], [-4, -8, 10], [4, -4, 4], [22, 9, -7], [-14, 10, 2], [26, -7, 1], [3, -7, 0], [-11, 0, 5], [6, 6, -4], [-10, -4, 12], [-22, 11, 1], [12, 12, 2], [-9, 5, 12], [-14, 9, 1], [-11, -4, -7], [24, -12, -6], [-14, 4, -6], [-4, 1, 3], [2, 4, 8], [16, -8, -4], [-18, 4, 2], [6, 1, 9], [16, 4, 2], [-44, 2, 0], [2, 2, -2], [-6, 2, 6], [0, 0, -12], [-9, -8, 7], [-13, 22, 1], [18, 1, 1], [0, -14, 4], [8, -6, -2], [35, 3, 6], [-12, 8, -6], [-18, -2, 8], [2, 14, 6], [-3, -10, -9], [32, 1, 3], [-22, 0, 6], [2, -9, 1], [20, -6, -8], [-22, -3, 5], [-6, 10, -8], [0, 19, 1], [43, -9, -6], [-10, 15, -5], [6, -4, -16], [10, -16, 0], [-12, -2, 4], [11, -5, -2], [-28, 2, 8], [0, 1, 15], [-14, -8, 2], [15, -14, -11], [2, -16, 2], [36, -17, -3], [30, 0, 0], [30, 0, -4], [-25, 8, 11], [-11, 1, 6], [-18, -10, 2], [-11, 5, -6], [-10, -8, 4], [-22, 1, 5], [11, 6, 13], [6, 1, -3], [-2, 0, 0], [20, 2, 10], [10, -8, 4], [-10, 21, 5], [11, -15, -16], [12, 0, 2], [17, 6, -5], [-26, 14, 8], [8, -2, -12], [-6, 12, 0], [-2, 13, 1], [0, 6, 12], [-4, 14, 6], [12, -2, 8], [28, 4, -8], [16, -7, -5], [-12, 6, 12], [-20, -6, 6], [-20, 2, -4], [30, 10, 2], [12, -6, -16], [26, -6, 2], [-19, -9, -4], [-1, -4, 7], [-4, -2, -2], [-22, 0, -12], [22, -3, 3], [8, -20, 4], [5, 8, -3], [-50, 7, 3], [0, -14, -14], [-7, -6, -5], [-6, -13, -1], [-10, 4, -8], [5, 16, -11], [6, -13, -9], [-6, -4, -10], [5, 7, -12], [26, -17, -11], [-62, -1, -1], [-33, -6, 1], [-11, -7, 10], [20, 16, 6], [-14, 5, -13], [0, -6, 14], [6, 12, 16], [16, 7, -7], [30, 8, -6], [18, -10, -18], [0, -10, 16], [-18, -18, 4], [6, 7, 3], [19, 17, -4], [26, 1, -9], [-4, -10, -14], [-40, -8, 8], [-4, 10, -12], [-40, -10, -2], [38, -12, -2], [-34, 8, 4], [27, -20, -9], [-15, 5, 10], [-29, 3, 2], [-23, 21, 2], [32, -3, -9], [-2, 1, -7], [-6, -12, 16], [4, -2, 12], [-31, 23, 4], [28, -15, -5], [-11, 11, -4], [-22, 29, 13], [-1, 13, -16], [-16, 6, -16], [-12, -8, -10], [2, -2, 0], [-16, 28, 6], [-29, -4, -1], [-50, 16, 2], [38, -13, -7], [18, -7, 17], [20, 4, 6], [-14, -2, 10], [0, -3, 19], [-23, 11, -4], [-14, 28, 8], [-14, 20, 0], [27, -22, -3], [-10, 15, 7], [36, 12, -10], [3, 6, 13], [10, 17, 1], [-69, 0, 3], [-18, 2, -2], [-46, 13, 5], [-32, 16, 10], [-6, 15, 23], [-54, 0, -8], [-8, 4, 4], [-44, -4, 4], [42, 2, 10], [-10, 12, -16], [13, -1, 0], [2, -12, 2], [2, -3, -15], [34, 10, -4], [2, 12, 16], [42, -13, -9], [-6, 20, -10], [12, -18, -16], [-2, 2, 22], [-2, 11, -17], [-39, 34, 11], [-1, -8, -9], [23, -7, 4], [-44, 6, -8], [10, 20, 6], [-10, -7, 3], [6, -14, -10], [46, -15, 1], [36, -2, -12], [3, 27, 2], [10, 21, -3], [-10, 16, 20], [-4, -12, -22], [26, -3, -15], [15, -5, -6], [-16, 9, 19], [16, 0, 10], [-13, -1, -10], [16, -2, 8], [32, 6, 18], [10, 4, 0], [28, 6, -2], [-24, 8, -18], [-32, -2, -12], [-34, 7, -9], [25, -9, -8], [-8, 2, -8], [22, 20, -2], [-33, -15, 4], [10, -24, -8], [-5, -10, -7], [-32, 11, -7], [30, -16, 4], [37, 8, -11], [30, -1, -5], [32, 2, 24], [12, 12, 18], [32, 10, 2], [12, -21, -3], [1, -19, 6], [14, 4, 4], [-30, 11, -11], [1, -4, 17], [46, 1, 17], [-5, -21, 22], [24, -9, 13], [32, 24, -8], [54, -15, -5], [54, -6, -2], [0, -12, 14], [26, 7, -9], [30, -16, 8], [14, 26, -22], [31, -4, -17], [-10, 11, -1], [-55, 0, 1], [13, 11, 4], [-46, -1, 9], [-22, -17, -5], [9, -31, 2], [-46, 14, -6], [8, -36, 0], [22, 12, 16], [-25, -8, 11], [36, -9, 13], [-34, -4, -20], [4, 6, -4], [-27, -7, -10], [17, -23, 6], [10, 22, -18], [19, -3, 4], [-50, 8, 8], [-36, -16, 2], [-5, -19, -8], [-61, 5, 8], [28, -28, -12], [2, -10, 10], [19, 20, 7], [-10, -1, 19], [-34, -6, -6], [-11, 25, 6], [14, 5, 9], [-14, 26, -8], [-2, 18, 10], [18, -19, -7], [-42, 3, 1], [-64, 2, -10], [-20, 4, -4], [-22, -23, -5], [41, 26, -13], [54, -32, -12], [-17, 20, 7], [31, 26, -19], [48, 21, -13], [32, 10, 12], [-8, -15, 3], [2, -24, -6], [44, -14, 2], [24, -24, -10], [18, -15, 17], [69, -7, -6], [-2, 13, -5], [-27, 32, 13], [-55, 15, 4], [22, 17, 5], [-36, 34, 6], [2, 35, 1], [4, 17, 19], [0, -4, 18], [20, 4, -20], [42, 10, -14], [-6, 33, -9], [-33, -2, -7], [44, 1, -13], [-19, -30, 7], [5, 12, 17], [8, 24, -16], [4, 10, 8], [-58, -4, 12], [-6, 1, -31], [-10, 8, -10], [-42, 7, 9], [14, 18, 14], [-47, -7, -22], [-6, -9, 11], [-4, 2, 4], [0, -6, 4], [24, 26, -2], [-10, 3, -17], [20, -6, -16], [9, 3, 16], [11, -24, -5], [46, 24, -8], [68, 2, 2], [-40, -8, 0], [18, 12, -4], [-22, 32, 24], [2, -28, 10], [-8, 0, -22], [8, 2, -6], [17, 23, 8]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_5328_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_5328_2_a_bj();".
// 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_5328_2_a_bj(:prec:=3)
    chi := MakeCharacter_5328_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_5328_2_a_bj();".
// 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_5328_2_a_bj( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_5328_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<5,R![-20, -4, 4, 1]>,<7,R![16, -8, -4, 1]>,<11,R![32, -16, -4, 1]>,<13,R![-8, -20, 2, 1]>],Snew);
    return Vf;
end function;