
// Make newform 5328.2.a.k in Magma, downloaded from the LMFDB on 03 January 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_k();".
// 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_k();".
// 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
        Kf := Rationals();
    end if;
    return [Kf!elt[1] : elt in input];
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], [1], [3], [-4], [-6], [-2], [6], [6], [4], [1], [9], [-8], [3], [3], [12], [8], [4], [-15], [11], [10], [9], [-6], [8], [-3], [4], [12], [2], [6], [7], [-6], [6], [4], [-15], [-8], [-13], [16], [18], [-9], [18], [-7], [-24], [-4], [-15], [-2], [13], [1], [24], [23], [18], [-6], [-10], [0], [24], [15], [18], [-29], [8], [0], [4], [18], [25], [-6], [-28], [18], [10], [23], [6], [-10], [18], [-27], [-8], [5], [-11], [36], [12], [11], [-24], [-4], [3], [-10], [12], [29], [28], [-15], [6], [-28], [-36], [-14], [18], [18], [-2], [-12], [-32], [42], [-21], [-3], [16], [20], [28], [30], [-12], [-12], [-23], [-34], [6], [-27], [-27], [-10], [-14], [-25], [15], [37], [-38], [9], [-14], [-6], [-36], [-3], [50], [-1], [-21], [24], [28], [48], [26], [15], [10], [-13], [-11], [-27], [-41], [2], [15], [-22], [-3], [-23], [-12], [-30], [-11], [3], [-32], [30], [20], [0], [-46], [6], [-14], [-48], [-22], [6], [52], [-3], [-8], [-24], [-20], [-6], [-7], [-30], [18], [3], [22], [-12], [-12], [-27], [-20], [-10], [29], [30], [0], [-40], [0], [35], [-5], [0], [46], [-42], [-11], [-10], [-8], [42], [-40], [24], [-36], [51], [-7], [-62], [-40], [3], [20], [-36], [-38], [3], [-33], [-57], [-22], [26], [57], [42], [-6], [19], [50], [-37], [-36], [24], [16], [-24], [6], [49], [56], [48], [-26], [36], [-54], [-37], [-68], [24], [-30], [-54], [59], [49], [9], [52], [57], [26], [-66], [-33], [37], [12], [-13], [25], [-59], [3], [-53], [-39], [-22], [6], [0], [0], [12], [70], [-23], [-16], [-42], [6], [-2], [30], [13], [36], [-58], [-18], [48], [-46], [-36], [15], [29], [-8], [-33], [2], [-80], [18], [14], [-34], [36], [-17], [15], [-78], [13], [48], [-22], [70], [-10], [76], [14], [16], [24], [26], [-25], [-54], [51], [-14], [-12], [-55], [-50], [-21], [2], [30], [-8], [48], [-48], [60], [-69], [9], [53], [33], [55], [54], [30], [-35], [32], [-81], [25], [-54], [58], [-34], [-60], [-76], [-9], [-52], [-63], [15], [-9], [49], [60], [74], [-51], [48], [-55], [-48], [-8], [59], [-66], [88], [-33], [38], [-20], [28], [42], [78], [53], [6], [-44], [66], [-2], [-72], [29], [69], [-58], [-56], [-55], [-87], [60], [28], [-36], [36], [-7], [19], [90], [-27], [76], [-25], [18], [10], [-22], [30], [24], [90], [-3], [24], [-82], [15], [-60], [36], [-11], [62], [-18], [34], [20], [-72], [-20], [96], [-6], [-68], [-7], [60], [27], [2], [96], [17], [-84], [12], [-2], [30], [-86], [45], [-71], [-4], [16], [-84], [-1], [-66], [6], [46], [21], [86], [34], [99], [13], [-54], [-31], [30], [-86], [-66], [-18], [97], [26], [42], [-68], [51], [-37], [81], [36], [-80], [-4], [-6], [48], [-17], [54], [-96], [78], [2], [60], [-51], [-34], [-27], [-84], [39], [88], [0]];
    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_k();".
// 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_k(:prec:=1)
    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_k();".
// 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_k( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_5328_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<5,R![0, 1]>,<7,R![-1, 1]>,<11,R![-3, 1]>,<13,R![4, 1]>],Snew);
    return Vf;
end function;