
// Make newform 4928.2.a.cj in Magma, downloaded from the LMFDB on 19 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_4928_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_4928_2_a_cj();".
// 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_4928_2_a_cj();".
// 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, 3, -5, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0], [-3, 0, 1, 0], [0, 5, 0, -1], [2, -3, -1, 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_4928_a();"
function MakeCharacter_4928_a()
    N := 4928;
    order := 1;
    char_gens := [4159, 1541, 2817, 3137];
    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_4928_a_Hecke(Kf)
    return MakeCharacter_4928_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, -1, 0, 0], [1, 0, 0, 1], [-1, 0, 0, 0], [-1, 0, 0, 0], [2, 0, 1, 0], [1, 1, 2, 1], [-1, 1, -1, 1], [2, -1, 1, 2], [2, 2, 0, 0], [-3, -2, -1, -1], [3, -4, 0, -1], [-3, -1, 0, 1], [-1, 1, 3, 1], [1, -3, 0, -1], [5, 3, -1, 1], [4, 1, 2, 0], [6, -2, 1, 0], [0, 1, -1, 0], [0, 3, 1, 0], [1, -1, -2, 1], [-3, -1, 1, 3], [1, -1, 1, -1], [-2, 5, 1, 0], [0, -7, -1, -2], [8, 0, 1, 2], [-5, 3, -2, 1], [-4, 0, 0, 0], [6, 0, -2, 0], [0, -3, 1, -2], [4, 2, 2, -4], [1, 1, 1, 7], [-3, 2, 2, 1], [-3, -3, 3, -5], [6, -6, 2, 0], [7, 1, -1, 1], [11, 6, 2, -1], [0, 4, 2, 0], [-4, 2, -2, -4], [6, 4, 1, 0], [2, -5, 3, 2], [-1, -4, 2, -5], [-6, 5, 1, 6], [8, 0, -4, -2], [4, 2, 2, -2], [-1, 7, 2, 5], [-6, -2, -2, -6], [11, 0, -1, -3], [1, 9, -3, -1], [-1, 0, -2, -5], [0, 0, 2, 2], [10, 0, 4, -2], [5, 5, -2, 1], [0, 1, -4, -4], [0, 2, -6, 2], [6, 6, 6, 2], [1, 11, -3, -3], [2, 8, 2, 6], [-12, -2, -6, -6], [-6, 0, 2, 0], [5, -7, 1, 3], [-2, 4, -1, 8], [-3, 7, -1, 3], [-3, 5, 0, -1], [10, 5, 1, -4], [8, -5, -1, -2], [12, 3, 3, 4], [8, 4, 2, 6], [1, 11, 5, 7], [4, 0, 3, 2], [-6, 1, -3, -4], [1, 3, -3, -1], [-19, -2, 5, -1], [-2, -10, 2, -4], [8, 11, 5, 4], [-5, 8, 5, 5], [6, 5, 9, 8], [1, 3, 7, 5], [-6, 0, -4, 0], [11, 1, 0, -9], [2, -2, -5, -6], [3, 5, 1, 3], [-9, -1, -7, -7], [16, 1, 3, -2], [0, -4, 2, 8], [-12, -3, -7, 0], [5, -12, 0, -7], [-6, 6, -6, -4], [8, 0, 3, 10], [2, -7, -9, -2], [24, -3, 0, 0], [-6, -12, -6, -2], [20, 9, 3, 0], [-29, -9, -3, 5], [0, -4, -2, 4], [10, 8, -6, -2], [11, 12, -2, -1], [-12, 1, 7, 2], [-9, -11, -11, -7], [-8, -14, -2, 2], [-24, 4, 4, 4], [6, 2, -6, -4], [21, 1, 3, -5], [-8, 0, 2, 6], [-22, -2, 2, -6], [10, 11, 1, 4], [8, 8, 3, -4], [21, 5, 8, 9], [12, 4, 6, 8], [-5, 3, -4, -5], [-14, -4, 4, 6], [-18, 2, -4, 4], [-13, -7, -7, -9], [16, 3, 2, -8], [-24, 1, -3, -8], [-5, -2, -2, 3], [28, -3, 4, 0], [-7, 4, 1, 11], [-10, -5, -1, 0], [-19, -9, -3, 3], [-5, -6, -6, -1], [6, -8, -6, -4], [-2, -2, -5, 4], [8, 4, -4, 8], [-2, -13, 4, 10], [-6, -10, -8, -12], [10, -1, 3, 12], [-21, -8, -7, -3], [17, 6, -1, 3], [6, 14, 1, 0], [-2, 8, -4, -10], [10, 6, 2, -2], [-12, 15, 1, 0], [-8, 6, 2, 10], [-29, -3, 0, 7], [-5, 1, -4, -13], [-7, -1, 9, 5], [-7, -7, -13, -1], [7, 14, -2, -5], [-20, 14, -2, 2], [-13, -3, 1, 13], [-6, 8, -4, 12], [0, 9, 5, 8], [-3, 7, -3, 11], [-3, -8, 0, 5], [11, -12, -3, -11], [10, -12, -3, 0], [-17, -13, 2, -5], [16, 1, -8, -4], [-8, -8, 8, 4], [8, -10, 4, 6], [-14, -13, 5, 4], [0, -12, 0, 0], [2, 12, -6, -2], [2, -2, 0, -14], [28, 4, 2, 12], [18, -12, 4, -2], [4, -6, 0, -10], [-3, -17, 6, 1], [-10, -8, -1, -8], [-6, 11, 3, 6], [4, 8, 8, 14], [-11, -3, 3, 3], [-20, -1, 6, -4], [-8, -3, 1, 6], [-13, -8, 3, 1], [18, -22, 0, -6], [20, 12, 1, -6], [-6, 16, -8, -12], [-19, 6, 8, 5], [-14, -8, 0, 2], [3, -7, -3, -5], [1, -5, -3, 7], [-6, -4, -6, 0], [-27, 0, 3, -5], [-12, 1, -1, -6], [-31, -3, -5, -1], [7, -16, -4, -5], [20, -8, 2, -12], [24, 12, -3, -6], [-8, -8, -4, 8], [21, -9, 1, -5], [18, -11, 5, 4], [-37, 1, -2, -5], [20, -1, 3, -8], [17, 7, 5, 5], [14, -12, 0, 4], [20, 4, -1, 12], [-8, 8, -2, 2], [-10, 4, 4, 2], [32, -15, -1, -2], [-44, -8, 0, 0], [16, -15, -1, -16], [3, 5, -3, -13], [7, 13, 3, 9], [-26, 9, 1, 8], [-30, -2, -4, -12], [-17, 8, -4, -5], [-15, -1, -6, -3], [-18, -14, 4, 2], [18, 4, -4, 4], [22, 20, 12, 2], [21, 3, -3, 1], [9, -7, 4, 1], [42, 9, 0, -6], [15, -10, 2, -5], [-9, 10, -11, -3], [-20, 4, -8, -8], [-48, -8, 4, -2], [20, 20, -7, -4], [-8, -4, 2, -2], [-5, -8, -6, -9], [-8, 13, -3, -4], [-10, 6, -5, -14], [2, -10, 4, 6], [18, -3, 5, 12], [3, 17, -5, -3], [-29, 7, -2, -5], [12, 12, -6, -8], [-6, -29, 7, 4], [-8, 6, -8, -6], [16, -10, 12, 16], [-21, 0, -4, 11], [-22, 5, 1, 18], [-9, -11, -7, -23], [-12, 18, -8, -6], [-10, -4, 6, 4], [12, 12, -4, -12], [28, -2, -4, 4], [-17, 5, -5, 1], [33, 0, 8, 1], [13, 7, 19, 11], [2, 0, -4, -10], [-42, -10, -6, 4], [22, 7, -2, 14], [-24, 6, -4, 0], [-16, -11, 3, -2], [4, 6, 14, -6], [-20, 11, -3, 20], [-15, 4, 13, 7], [50, 5, 3, -6], [31, 11, 9, 9], [17, -7, 2, -17], [9, -20, -4, -7], [7, 11, 8, 15], [0, -8, 12, 0], [9, -7, -14, -9], [-4, 4, -11, 8], [-34, -8, 0, -10], [-6, 12, 8, -2], [30, 2, -2, 12], [-39, -23, -8, 9], [2, -19, -1, -18], [0, -6, -6, 10], [-14, -18, -7, -12], [-32, -8, -4, -4], [27, 5, 1, -5], [-25, 3, 5, 9], [-13, -6, -14, -17], [45, 9, 2, -7], [17, -11, 11, 7], [30, 4, 16, 14], [-2, -14, 1, -20], [-32, 24, 1, 14], [6, 8, 4, 4], [12, -12, -9, -8], [31, 12, 4, 11], [-24, 9, -5, -10], [-11, -9, -7, -13], [-36, 2, -12, -18], [43, 6, -2, -1], [-10, -3, -5, 6], [12, 10, 0, -10], [-26, -12, 0, 10], [1, -9, 6, -15], [-1, 12, -5, 17], [-4, 3, -5, -12], [-2, 12, 4, 4], [30, 8, 12, 16], [-19, -5, 5, 11], [-8, -14, -10, 0], [4, -17, -7, -20], [-48, -2, -12, -16], [28, -6, -5, 2], [5, 17, -1, 11], [12, -1, -3, -8], [29, 3, -13, 5], [-34, -2, -14, -24], [-3, -4, -9, -13], [7, 19, 0, 3], [9, -4, 12, 9], [-22, 14, 1, 10], [28, 4, 2, -22], [43, 7, 5, 5], [-2, -2, 2, 8], [24, -10, -7, -14], [-5, -6, -1, 9], [-1, -8, 2, 11], [-17, 3, 17, 1], [23, 17, -13, -7], [-13, -5, -10, 11], [-22, -16, -6, 4], [5, -31, -1, -5], [-16, -4, 6, -8], [-8, -5, 1, -4], [23, -6, -10, -9], [-6, 1, -7, -2], [-9, -14, -6, 3], [-8, -16, -12, -16], [26, 8, 4, 4], [6, -30, -2, -14], [28, 22, -14, -2], [24, -6, -4, 2], [-28, -23, -3, 4], [-17, 19, 5, 25], [25, 9, 16, 13], [14, -3, 8, -14], [-26, 0, 4, -14], [28, 18, 0, -2], [16, 26, 0, 2], [-17, -27, 13, 1], [24, 9, -3, -18], [10, 22, 13, 4], [-20, -17, 7, -4], [-18, -4, 4, -16], [8, 15, -1, -18], [-28, -9, -15, -24], [24, -21, 2, -8], [23, 5, 3, 9], [6, 22, 0, -8], [6, 4, -4, -12], [-5, -19, -23, -13], [50, -6, -2, 6], [5, 13, 3, 19], [-7, -23, 7, -17], [42, -17, 2, -6], [5, -12, -12, -3], [7, -25, -8, -25], [-6, 21, -3, 20], [-24, -4, -10, -8], [4, 3, -13, -6], [15, 2, 2, -25], [-26, -20, -15, -16], [-24, -19, 1, 0], [-6, -9, -9, -20], [20, -10, 2, 8], [41, 6, 12, 1], [6, -3, 3, -10], [0, 10, -2, 0], [15, -12, -6, -13], [17, 27, 21, 7], [13, 16, 12, 9], [-14, -12, -8, -16], [-36, -16, -2, 4], [8, 28, 8, -2], [31, 21, -10, -9], [13, -32, -1, -5], [19, 5, -11, 13], [10, 20, -8, 16], [-10, -19, -3, 6], [36, 18, 2, -6], [11, 3, -4, 3], [-10, -9, -17, 6], [17, -7, -9, 7], [-34, -3, -4, -2], [21, 22, -14, 9], [18, 20, -7, 4], [16, -2, -6, -8], [-18, -4, 0, 8], [36, 17, -13, -4], [36, 16, 9, 4], [-14, -30, 6, -2], [-8, -10, -6, 10], [12, -18, -2, -20], [13, 24, 0, 5], [10, 2, -3, -6], [7, -29, 5, -7], [27, -11, -2, -17], [-19, -17, -8, -3], [53, 1, 10, 13], [-25, 9, -3, 7], [9, -4, 4, -3], [-37, -13, -3, -11], [8, 8, -4, -14], [-7, -3, 3, 7], [55, 12, -9, 1], [4, 16, -4, 8], [9, 12, -4, 1], [-42, -12, -4, -2], [-3, 14, 17, 19], [37, 6, 10, 1], [-27, 2, 0, -3], [4, -23, 7, -12], [22, 5, 12, -6], [58, -1, -1, -6], [22, -16, 2, -20], [48, 8, 6, 0], [-6, 12, -8, 0], [20, -4, -2, 0], [-48, 30, 4, 14], [6, 14, 5, 28], [48, 17, 5, -10], [-8, 8, 0, -8], [42, 4, 4, 0], [-6, 2, 11, 8], [52, 8, 12, 20], [-14, 0, -8, 16], [-24, -26, 10, 6], [-58, -10, -5, 14], [-28, -25, -20, -4], [-23, 19, 6, 29], [10, -6, -12, -8], [2, 14, 14, 18], [5, 5, 7, 11], [20, -16, 10, 6], [-45, 2, -2, -9], [16, 12, 20, -8], [55, 16, 5, -15], [26, 4, -16, 0], [-32, 6, -10, -16], [42, 19, 19, 4], [62, 2, 5, -16], [28, 12, -10, 8], [1, -27, -19, -17], [34, -4, -12, 0], [13, 18, -4, 5], [-40, 3, 1, 12], [14, -6, -8, 4], [18, -27, -10, -22], [80, 0, 6, 0]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_4928_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_4928_2_a_cj();".
// 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_4928_2_a_cj(:prec:=4)
    chi := MakeCharacter_4928_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_4928_2_a_cj();".
// 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_4928_2_a_cj( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_4928_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<3,R![4, 4, -6, -1, 1]>,<5,R![8, 20, -2, -5, 1]>,<13,R![8, 12, -4, -6, 1]>,<17,R![848, -12, -64, 0, 1]>,<19,R![32, 64, -40, 2, 1]>,<23,R![-736, 384, -28, -9, 1]>],Snew);
    return Vf;
end function;