
// Make newform 6000.2.a.bb in Magma, downloaded from the LMFDB on 29 September 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_6000_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_6000_2_a_bb();".
// 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_6000_2_a_bb();".
// 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, -1, 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_6000_a();"
function MakeCharacter_6000_a()
    N := 6000;
    order := 1;
    char_gens := [751, 4501, 4001, 5377];
    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_6000_a_Hecke( : Kf := Kf)
    return MakeCharacter_6000_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], [1, 0], [0, 0], [4, -1], [1, 3], [-5, 1], [2, -6], [4, -5], [5, -5], [-4, 6], [0, 4], [0, 1], [2, -1], [-2, 6], [7, 1], [-2, 1], [6, 3], [2, 6], [0, 2], [-2, 4], [8, 0], [-6, -4], [2, 0], [1, 9], [-2, 10], [-4, -6], [11, -5], [-2, 0], [8, -6], [6, -6], [-12, 4], [9, 7], [8, -8], [1, 1], [10, -12], [10, -6], [-6, 8], [-24, 0], [-10, 5], [-6, 1], [14, -11], [-14, -4], [4, 0], [0, -6], [2, 8], [8, -2], [8, 9], [-16, -8], [14, -2], [-26, 2], [-4, 4], [20, -8], [7, 5], [24, 0], [-24, 4], [14, 7], [10, -12], [-10, 12], [13, -25], [-3, 17], [-8, 10], [3, 11], [10, -10], [4, -8], [-10, 6], [-19, -3], [0, -4], [-18, 24], [2, -10], [-20, 0], [-20, 18], [-2, 12], [-4, 12], [8, 7], [11, -29], [6, 13], [14, -30], [-12, -7], [10, -7], [0, -3], [8, -16], [4, -18], [-14, -2], [-6, -20], [10, 14], [16, -18], [2, 9], [-8, -16], [-16, 22], [-28, 8], [18, 2], [-20, 18], [5, -11], [10, -13], [7, -1], [-35, 3], [22, -6], [-7, 5], [0, 20], [6, -12], [-4, 2], [27, -25], [-6, 8], [-19, 29], [20, -15], [-6, -2], [22, 2], [14, -28], [10, -2], [25, -9], [24, -21], [1, 19], [-12, 4], [7, 3], [-24, -6], [-34, 3], [-28, 8], [10, 3], [-17, 3], [13, -17], [-30, 18], [16, -4], [-6, 19], [-4, -16], [8, 16], [-8, -6], [-4, 14], [-38, 16], [-24, 7], [29, -29], [-12, -7], [-43, 3], [-38, 26], [-23, 7], [34, 13], [23, -7], [14, 8], [-30, 12], [-26, 37], [35, 7], [-21, 15], [-4, -16], [12, -29], [22, -10], [38, -20], [-46, 14], [-24, -15], [6, -6], [-20, 13], [-10, 13], [-25, 21], [34, -31], [12, -12], [-6, -13], [6, -14], [42, -8], [-40, 2], [-31, 45], [16, -14], [-2, -10], [-12, 16], [-26, 30], [15, 27], [31, -15], [36, -28], [15, -23], [-42, 16], [4, -5], [2, 20], [-42, -3], [-23, -5], [-44, 16], [-26, 24], [-2, 24], [20, 8], [-26, 8], [-40, 19], [-46, 16], [25, -11], [-4, -4], [-21, 43], [-8, 0], [-34, 8], [36, 16], [6, 3], [-32, 12], [-24, -1], [-22, 10], [5, -13], [32, -26], [-38, 10], [-8, 0], [-27, -15], [4, -28], [-16, 20], [-10, 18], [-35, -5], [12, 23], [-36, 42], [4, 24], [-18, 22], [-22, -2], [-9, -23], [36, 21], [30, 5], [14, -8], [-22, -16], [2, 42], [2, -4], [-15, -19], [-4, 32], [-6, 6], [-20, 23], [24, -48], [18, 0], [-29, -15], [24, 27], [2, 24], [-44, 16], [-33, 19], [-2, 34], [-8, 36], [63, -1], [32, -23], [-12, -12], [-26, -14], [-24, 26], [32, 6], [45, -15], [30, -31], [-48, 7], [-31, 17], [-34, 10], [-14, -11], [-40, 14], [14, -41], [25, -25], [62, 9], [-34, 47], [-6, -32], [-26, 54], [5, 5], [16, -1], [26, -46], [-52, 22], [-6, 38], [17, -3], [1, -5], [-5, -29], [48, -24], [1, 7], [54, -21], [15, -51], [-29, 25], [-26, 45], [20, -24], [34, -6], [-30, -26], [-58, 12], [-66, 18], [9, -3], [-36, -12], [16, 12], [46, -44], [56, -26], [67, -17], [-18, -24], [6, 7], [-14, 26], [22, 23], [16, -40], [-40, 0], [34, 14], [12, 26], [-36, 30], [32, -33], [-16, -20], [0, -4], [-4, -11], [-6, 27], [-1, 1], [38, 24], [0, -4], [14, -48], [10, -38], [-46, 24], [12, 18], [-38, -13], [-40, 34], [59, -21], [8, -56], [20, 20], [8, -14], [-52, 4], [-43, -21], [42, -38], [2, -6], [-17, -25], [-31, -13], [-26, 16], [30, -40], [-49, -1], [32, -34], [2, -30], [-48, -5], [10, -58], [34, 8], [62, 4], [-4, -18], [15, 37], [7, 45], [-40, -8], [-35, 17], [46, -28], [-38, 27], [22, 28], [-52, -12], [-14, 30], [36, 8], [-22, 19], [-28, 13], [16, -66], [-10, -18], [33, -39], [-58, 28], [16, -33], [48, -31], [2, 44], [10, -19], [-31, 9], [0, 24], [26, -29], [32, -8], [-66, 2], [8, 8], [12, -22], [46, 20], [-28, 60], [24, -35], [56, -7], [-44, 55], [34, -34], [-38, 10], [-2, -26], [25, -31], [7, -27], [52, 22], [38, 16], [48, -62], [51, -21], [64, -48], [10, -20], [-32, 38], [19, -49], [-2, -48], [-10, -18], [42, -18], [11, -11], [52, -62], [-38, 45], [-10, -20], [14, -29], [-26, 7], [-36, -8], [14, -14], [-58, 40], [-42, 44], [-20, 41], [-26, 4], [26, 31], [-20, 32], [-51, 11], [-42, 38], [2, -14], [89, -9], [-22, 61], [-6, -4], [64, -36], [-6, 41], [36, 16], [36, 24], [38, -78], [21, -3], [34, 36], [4, -19], [38, -27], [78, 8], [-35, 3], [-6, 36], [10, -43], [-20, 19], [26, -60], [31, -11], [28, -50], [14, 44], [0, -36], [58, -40], [50, -1], [-65, 35], [-98, -2], [72, 4], [-2, 14], [-21, 11], [-34, -20], [64, -38], [16, -60], [33, -49], [-67, 57], [-52, 66], [6, 29], [-62, 50], [-83, 29], [52, 6], [-28, 48], [-10, 56], [-14, 16], [16, -10], [-29, 67], [12, -30], [-10, 27], [68, -22], [-12, 27], [-30, -11], [69, 11], [-56, 18], [2, -33], [48, 6], [-58, -21], [-64, 23], [-70, 8]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_6000_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_6000_2_a_bb();".
// 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_6000_2_a_bb(:prec:=2)
    chi := MakeCharacter_6000_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_6000_2_a_bb();".
// 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_6000_2_a_bb( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_6000_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<7,R![11, -7, 1]>,<11,R![-5, -5, 1]>,<13,R![19, 9, 1]>],Snew);
    return Vf;
end function;