
// Make newform 4680.2.a.bk in Magma, downloaded from the LMFDB on 19 December 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_4680_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_4680_2_a_bk();".
// 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_4680_2_a_bk();".
// 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 := [-3, -6, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0], [0, 2, 0], [-4, -1, 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_4680_a();"
function MakeCharacter_4680_a()
    N := 4680;
    order := 1;
    char_gens := [3511, 2341, 2081, 937, 1081];
    v := [1, 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_4680_a_Hecke( : Kf := Kf)
    return MakeCharacter_4680_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, 0], [1, 0, 1], [1, -1, -1], [1, 0, 0], [1, 0, -1], [2, 1, 0], [1, 0, -1], [0, -1, 0], [2, 0, 0], [1, -1, 1], [-1, 1, 3], [2, 0, 2], [2, 0, -2], [-1, 1, 1], [0, 2, 0], [3, 1, -1], [4, 0, -2], [1, -1, 3], [0, -1, 2], [5, 1, 3], [0, 0, 0], [-3, -1, -3], [5, -2, -3], [-2, -1, 2], [6, 2, -2], [7, 1, -3], [0, 3, -2], [-4, 3, 0], [4, -2, -4], [6, 1, -2], [-4, 0, -2], [3, 1, 1], [-3, 1, -3], [4, -2, 2], [8, 0, 2], [3, -1, -1], [2, -2, -2], [-6, -2, 2], [0, -3, 4], [-1, 1, 7], [2, 2, 2], [11, 2, -5], [0, 2, 2], [12, -2, 0], [0, -2, -8], [6, 1, 4], [12, 0, 0], [-2, 1, 0], [-13, -2, -7], [-7, 3, -1], [10, -4, -4], [14, -1, 2], [4, -1, -8], [-2, -3, -2], [-12, 1, 4], [0, 2, 2], [10, 2, 8], [-10, 2, 0], [-4, -2, 4], [-14, 0, 4], [-5, 1, 3], [-2, -2, 6], [12, 0, 6], [6, 4, 0], [2, 5, 4], [6, 0, 0], [15, 3, 9], [6, -3, -4], [-6, 2, 0], [4, 4, 0], [-8, 6, 0], [2, -6, -4], [8, 1, 2], [0, 0, 0], [-16, 1, -4], [5, 3, 5], [-6, 2, 4], [4, -4, -6], [0, -1, -4], [-2, -1, 0], [0, 4, 0], [12, 2, 2], [11, -3, -7], [15, 3, 5], [-17, -3, 3], [9, 2, 1], [-5, -3, -5], [-11, 2, 5], [27, -3, -3], [-25, -3, 1], [-1, -2, -5], [20, -1, -4], [4, -3, -6], [6, 1, -2], [-7, -1, 5], [-22, 0, -6], [-24, 0, -4], [-10, -1, -8], [-2, -2, 6], [14, 4, 4], [7, 3, -11], [-18, 0, -2], [-7, 7, 3], [-19, 4, 1], [20, 0, 0], [-10, -6, 8], [-6, -2, 6], [-7, -5, -11], [-24, -2, 0], [-1, -3, -5], [18, -4, 0], [-2, 3, 4], [6, 2, -8], [4, 4, 4], [3, 1, -1], [7, 0, 13], [2, 0, 2], [-4, -5, -12], [8, -7, -6], [-2, 6, 8], [7, 3, 9], [4, 0, 4], [2, -7, -12], [-14, -5, -6], [-6, 1, -4], [4, -6, -8], [-10, -8, 2], [1, -1, -3], [0, 1, -6], [-20, -2, -12], [-5, 9, 1], [-34, 4, 4], [-2, -2, -4], [-6, 8, 8], [-12, 2, -6], [24, 2, -2], [9, -5, -1], [-8, 8, 12], [-20, -5, -2], [-5, -5, 7], [12, -4, -8], [34, -2, -2], [-22, -4, 4], [-35, -1, 3], [-25, 1, 3], [3, 8, 9], [3, -5, 5], [-18, 2, 10], [10, -8, 0], [-10, 4, -2], [-26, -6, 6], [-5, 6, 5], [6, -4, -6], [-32, 2, 4], [-27, 3, -1], [9, 3, -3], [-8, 0, -10], [9, 3, -15], [10, 2, -2], [-11, 0, -9], [2, -5, 8], [22, -1, 2], [42, -2, 4], [-8, 2, 8], [-21, -5, 1], [-18, -6, -8], [-52, 2, 2], [-33, -3, -11], [-16, -2, 0], [30, 5, 4], [10, -4, 2], [21, 0, 5], [11, 3, -3], [-30, -4, 6], [0, -1, 2], [-27, -5, -3], [-24, 0, 4], [-38, 6, 4], [-35, 4, -3], [14, 5, 14], [12, 6, -10], [12, -8, 2], [-30, 10, 6], [-24, 7, 4], [-20, -6, -10], [-7, 7, -3], [-8, 8, 14], [-9, 1, 1], [-28, -6, 6], [-6, -10, 10], [-47, 3, 3], [15, -3, 3], [20, 6, 8], [-15, -6, 3], [6, 10, 4], [22, 2, -4], [16, 2, -2], [13, -2, 3], [6, 2, -16], [-27, -1, -5], [23, 7, -9], [-1, -7, -17], [-9, 3, 9], [25, 5, 7], [-4, 6, 6], [-8, -6, 4], [13, 3, -15], [11, 1, 9], [-18, -8, -8], [-16, 3, -12], [-36, 0, 0], [16, -8, -8], [-32, -4, 8], [-22, -4, -16], [6, 6, -10], [26, -4, -10], [12, -6, -4], [-8, 6, -14], [-7, -3, 17], [-14, -6, -16], [18, -2, -4], [-14, -1, 0], [15, 7, 1], [-33, 5, 7], [27, 2, -11], [-14, -8, 6], [-6, 4, -10], [-3, 9, 3], [20, -8, -14], [3, 9, -7], [16, -14, -10], [12, 6, 20], [-8, 2, 0], [-30, -4, -18], [38, -2, -8], [12, 10, 14], [-14, -5, 10], [-32, -2, 12], [0, 4, -16], [-41, 1, -3], [-34, -2, 6], [-24, -7, -14], [10, 2, 12], [-28, 12, 8], [14, -7, 4], [13, 3, 11], [48, -5, -6], [-18, 1, -6], [10, 2, 20], [-6, -2, 20], [4, 4, 4], [3, 7, -13], [21, 3, 23], [-5, 7, -3], [-10, 14, 4], [11, 3, 27], [-14, 6, -10], [5, -2, -7], [-8, -6, -24], [-31, -9, -1], [14, -7, 0], [10, 8, 16], [4, 2, 10], [5, -11, -5], [5, 3, 1], [17, -9, 5], [41, 3, -3], [-46, 4, 2], [2, 0, 8], [9, 9, 17], [41, 4, 17], [40, 0, -4], [8, 8, -2], [3, 6, -5], [-8, 8, 12], [-36, -7, 14], [20, 0, 14], [2, -1, 14], [-59, -2, -5], [34, -2, -8], [14, 5, -6], [60, -5, -2], [-20, 0, -6], [2, 0, 6], [14, -10, -12], [22, 12, -16], [10, -6, -12], [-12, -4, 8], [54, -7, -2], [-28, 4, -12], [-14, 8, 4], [28, -4, 4], [-16, 10, -2], [16, -11, -12], [4, 6, 0], [9, -3, 7], [-30, 5, 6], [31, -1, -1], [48, -8, 2], [0, -6, -6], [17, -3, 15], [17, 5, 23], [-20, -4, -16], [-1, 6, 3], [29, -13, -1], [17, 5, 9], [-32, 12, 0], [-8, 10, -14], [-15, -4, 3], [-10, -6, 0], [-44, 2, -8], [-4, -12, 12], [-34, -8, -22], [-37, -5, -5], [-21, -7, -27], [-31, 3, -5], [48, -5, -6], [4, 4, 4], [-12, -2, 4], [12, 3, 2], [22, 7, 22], [-23, -6, -3], [12, 4, 18], [5, -13, 1], [-30, 7, -4], [31, -11, 3], [-43, -6, -1], [-14, 6, 10], [18, -1, -4], [29, -7, -17], [12, -4, 8], [16, 4, 12], [-14, 9, -8], [-14, 10, 2], [2, 3, 16], [2, -10, -24], [38, -2, 0], [-34, -2, -2], [43, -5, -1], [-45, -4, 9], [-39, 1, -7], [20, 6, -20], [58, 0, 0], [28, -1, 16], [11, 5, -25], [35, -3, -9], [-40, -8, -4], [-19, -11, 3], [-22, 11, 4], [11, 6, 23], [-1, 13, 11], [12, 6, 4], [1, -11, -15], [-32, -11, 4], [-19, 3, 19], [-60, 4, 4], [12, 9, 24], [-22, 0, 14], [22, 4, 20], [26, 6, -18], [-22, 13, 10], [-4, 2, 20], [28, 10, 8], [-14, -8, -20], [-8, 14, 18], [29, -2, -15], [-17, 3, -1], [-4, 7, 8], [32, -6, 0], [6, -2, 18], [6, 9, 22], [35, 7, -19], [-32, -2, 6], [-5, -3, 13], [48, 8, 0], [9, 4, -3], [-14, 16, -2], [72, 4, -6], [-6, 12, -16], [-26, 0, 4], [-30, 1, -16], [50, 4, -4], [72, 1, -10], [-14, -14, 6], [32, 0, 22], [12, -14, -2], [-24, -4, -2], [-31, 10, 11], [-8, -2, 14], [8, 10, -22], [41, 3, -1], [-22, 6, 22], [-31, 7, -5], [4, 4, -10], [54, -12, -8], [0, -12, -8], [-5, -5, -19], [18, -8, 4], [12, 1, -26], [19, -8, -11], [-17, 0, -29], [-24, 2, 6], [-5, -15, 3], [-37, 1, 9], [54, -2, 0], [6, -6, -4], [-39, 5, 5], [23, 3, -7], [-4, -8, 14], [9, -17, -9], [3, 3, -3], [-17, -5, 17], [-24, -8, -2], [-82, 1, -2], [35, -7, -11], [18, -6, 18], [4, 8, -14], [-9, -8, 17], [28, -5, 4], [-23, -15, 1], [8, 0, 24], [80, 1, -4], [12, 15, 2], [52, -6, -10], [51, 9, -11], [-1, 9, 3], [0, -7, -2], [-8, 12, 4]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_4680_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_4680_2_a_bk();".
// 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_4680_2_a_bk(:prec:=3)
    chi := MakeCharacter_4680_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_4680_2_a_bk();".
// 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_4680_2_a_bk( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_4680_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<7,R![12, -6, -3, 1]>,<11,R![64, -24, -3, 1]>,<17,R![4, -6, -3, 1]>,<19,R![16, -12, -6, 1]>],Snew);
    return Vf;
end function;