
// Make newform 4680.2.a.be 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_be();".
// 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_be();".
// 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, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rfbasis := [Kf.1^i : i in [0..Degree(Kf)-1]];
    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], [1, 0], [0, 2], [3, 1], [1, 0], [0, -2], [-5, 1], [3, 3], [2, 2], [-3, -1], [4, -4], [8, 2], [-1, -1], [8, 2], [-8, -2], [7, -3], [-2, -2], [2, 8], [-3, -5], [0, 0], [6, -2], [-8, -2], [-2, 4], [2, -8], [10, -4], [-5, -1], [9, -3], [-6, 0], [-4, 6], [5, -7], [-4, 4], [6, -4], [-2, -6], [10, -8], [-7, -1], [14, 0], [-2, -8], [-4, -6], [12, 6], [0, -8], [-6, 10], [-12, 4], [14, 0], [6, -4], [8, 4], [4, 12], [8, -6], [22, 4], [-4, 2], [6, -8], [-3, -13], [-8, 6], [10, 2], [2, 8], [-9, -9], [-2, -8], [13, 3], [16, 6], [20, 6], [-21, 3], [12, 8], [-12, 2], [10, 2], [-4, 14], [8, -12], [3, -15], [16, 6], [-21, -5], [12, -10], [12, -8], [-31, 3], [11, 11], [-18, 0], [-19, -5], [20, -6], [2, 16], [16, 0], [-18, 12], [-20, 10], [6, -10], [-2, -12], [3, 17], [6, -12], [8, 0], [-7, -7], [-8, -10], [-2, -12], [-8, -2], [-10, 12], [-11, -7], [17, 3], [30, -4], [-10, -2], [-25, 5], [17, 5], [4, -6], [-6, 14], [19, -5], [8, -2], [15, -5], [-28, -4], [17, 1], [6, 6], [-2, -14], [16, 0], [10, 16], [2, -4], [-10, 6], [26, -8], [5, 1], [-30, -8], [18, 0], [-31, 3], [19, -7], [18, 4], [-20, -2], [3, -9], [-18, -8], [-38, 2], [-10, -12], [-12, -2], [32, 6], [6, 16], [-25, 5], [-18, 0], [-36, -6], [-32, 4], [-5, 19], [14, 8], [-9, 9], [0, -2], [-14, -2], [16, -2], [-18, -16], [6, -12], [-24, 8], [-16, -2], [-2, 4], [6, -26], [23, -3], [6, -4], [-33, -5], [-40, 6], [-22, -6], [-21, 5], [-16, 20], [26, 0], [-10, -10], [12, 18], [-14, 16], [-10, -6], [-17, -9], [-3, -11], [-5, 7], [8, -12], [-2, -18], [24, 14], [-2, 12], [0, 10], [12, 10], [-10, -20], [14, -20], [-40, 0], [0, 32], [-22, 20], [-16, -16], [-20, 6], [6, -4], [-20, 2], [-21, 13], [40, -10], [18, -2], [52, 0], [-4, -12], [-2, 16], [-33, 1], [-24, 6], [17, -15], [-26, 16], [0, -18], [-18, 10], [0, 22], [22, 12], [14, 12], [14, -22], [2, -4], [56, -6], [-40, 6], [19, -19], [-36, -14], [-28, -6], [-24, 0], [-34, 4], [-5, -21], [2, 12], [-20, -6], [10, 20], [-40, -12], [49, -3], [12, -14], [-28, 16], [2, 8], [18, -6], [25, 7], [-48, 10], [7, 9], [1, -15], [38, -8], [-42, -10], [-26, 20], [10, -22], [31, 3], [4, -10], [3, 1], [4, -26], [3, 3], [42, 0], [26, -24], [-6, -8], [-18, 14], [45, -13], [-18, -12], [32, -18], [53, -7], [-22, -14], [-54, 0], [6, -30], [11, 19], [41, -17], [-2, -20], [-70, 2], [7, 25], [-42, 4], [-41, -9], [14, -24], [-20, -30], [0, 12], [-12, -4], [44, 12], [-8, -22], [18, -10], [-17, 27], [4, 26], [-30, 8], [-12, 28], [12, -22], [23, -3], [-43, 3], [41, -3], [-16, -16], [6, -32], [20, 2], [-14, 16], [30, 0], [15, 5], [14, -14], [-30, -24], [-2, 16], [12, 20], [-31, -23], [-53, -5], [-12, 6], [24, 18], [0, -4], [-14, 30], [48, 2], [-54, -4], [-30, -4], [48, -2], [-18, 36], [54, 0], [-66, 8], [0, 20], [-36, -2], [40, -14], [6, 20], [20, -14], [8, -22], [18, -10], [-39, 13], [39, 13], [3, -25], [16, -34], [-48, -2], [-34, 2], [2, 8], [-22, 28], [27, -15], [-2, 22], [-14, -14], [-7, 5], [42, 12], [47, -3], [-6, 16], [2, -8], [-4, 0], [-6, -16], [2, -2], [-24, 10], [-34, -4], [26, -20], [44, 8], [25, 33], [4, -32], [52, 4], [-43, 17], [-26, -12], [15, 17], [62, 4], [-9, -33], [-12, 22], [2, -26], [17, -3], [-16, 14], [50, 18], [33, 3], [9, 7], [20, 20], [58, -8], [26, 18], [-8, -40], [-22, 34], [58, 0], [24, -8], [6, 22], [-47, -21], [20, -2], [-37, 7], [58, 4], [-6, 0], [10, -28], [26, -6], [54, -20], [-23, 23], [-6, -4], [22, 16], [54, 16], [-64, 14], [17, -3], [-22, 20], [-52, 22], [-30, -8], [62, -2], [6, 36], [-40, 8], [26, 8], [-44, 14], [35, -19], [-18, -40], [23, -19], [46, 16], [-38, 8], [-21, -41], [-18, -16], [-12, -10], [27, 5], [13, -1], [34, 24], [-16, 2], [28, -24], [18, -14], [81, -7], [3, 5], [-3, -27], [-60, -10], [34, 4], [54, 12], [6, -20], [-24, -24], [-8, -12], [-18, 12], [30, 18], [8, -28], [-20, -30], [89, -5], [18, -14], [-26, 4], [-38, -34], [-20, -6], [0, -10], [-12, -12], [-8, 10], [20, -4], [-25, 17], [10, -20], [37, -9], [4, 18], [-8, 18], [-25, 3], [-8, 10], [12, -12], [19, -23], [3, -1], [-1, 25], [62, 8], [15, -7], [70, -6], [-16, -20], [50, 0], [14, 16], [-4, 10], [64, -2], [-24, 20], [6, -8], [-20, -12], [12, 24], [18, -16], [-70, 12], [-69, 9], [-26, -28], [-32, 6], [-1, -45], [66, -6], [14, 32], [-38, -32], [21, -21], [33, -35], [-28, 32], [1, -35], [6, 38], [-34, 8], [30, 0], [-38, 10], [38, -4], [48, -12], [-3, 21], [12, -2], [3, -35], [10, 10]];
    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_be();".
// 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_be(:prec:=2)
    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_be();".
// 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_be( : 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, 0, 1]>,<11,R![6, -6, 1]>,<17,R![-12, 0, 1]>,<19,R![22, 10, 1]>],Snew);
    return Vf;
end function;