
// Make newform 2601.2.a.bf in Magma, downloaded from the LMFDB on 07 September 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_2601_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_2601_2_a_bf();".
// 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_2601_2_a_bf();".
// 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, 4, -5, -2, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0], [0, 1, 0, 0], [-3, -1, 1, 0], [2, -3, -2, 1]];
    Rf_basisdens := [1, 1, 1, 2];
    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_2601_a();"
function MakeCharacter_2601_a()
    N := 2601;
    order := 1;
    char_gens := [290, 2026];
    v := [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_2601_a_Hecke( : Kf := Kf)
    return MakeCharacter_2601_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, 1, 0, -1], [0, 0, 0, 0], [1, 1, 0, 0], [-1, 0, 1, -1], [2, -1, 1, 0], [0, 1, 1, -2], [0, 0, 0, 0], [2, 1, -1, 0], [-2, 1, -1, -2], [5, -2, 1, 0], [-2, 2, 0, 0], [-4, 2, -2, -1], [-3, -1, 2, -4], [4, -1, -1, -2], [-2, 2, 0, 2], [6, -2, 0, 2], [5, 2, 1, -5], [-2, -2, 0, 3], [2, -2, 4, 2], [2, -2, 0, 4], [-5, 0, 1, 2], [-1, -2, -1, -1], [2, -2, 4, -2], [1, -4, -1, 3], [-5, -2, -1, 0], [12, -4, 0, 0], [0, -3, 1, 2], [2, 5, -1, 4], [1, -6, 5, 0], [-3, 3, -2, -8], [2, -3, 3, 0], [-2, 1, -1, -4], [-7, -2, 1, 7], [13, -2, 1, 3], [5, 0, -3, 1], [8, -6, 2, 8], [2, -7, 1, -2], [-10, 6, -4, -6], [-8, 3, -1, 0], [5, 1, -4, 0], [10, -6, 4, 2], [10, 0, -2, -3], [-5, 6, 3, -3], [-9, 4, 1, -8], [9, 1, 0, 2], [-4, 4, 4, -2], [-2, 6, -4, 2], [6, 1, -1, -8], [-4, -5, -5, 6], [12, -6, 0, 2], [5, -3, 0, 2], [4, -4, -4, 0], [-2, -2, 0, 5], [13, -4, -1, 7], [5, 2, 3, 1], [9, 0, -1, -1], [13, -5, -2, -2], [0, 1, -7, 6], [-11, -4, 3, 2], [-3, 8, -1, -9], [1, 2, -7, -1], [5, -2, -1, 9], [2, -6, -4, 14], [0, -6, -2, 6], [3, -2, -1, -10], [7, -6, 3, 4], [-4, -1, -9, 6], [-12, -4, 0, -5], [8, 6, -6, 4], [0, 3, 3, 10], [13, -8, 5, 1], [7, -4, -7, 5], [7, -12, -3, 3], [0, -8, 0, -8], [3, 12, 1, -15], [10, 8, -6, 14], [-5, 14, 1, -5], [-7, -6, 5, 6], [-3, -1, 2, 0], [-2, -1, 7, -14], [12, -2, -2, -8], [0, -5, -5, 10], [-14, 2, 4, 4], [-6, 1, -7, -2], [2, -4, -2, -4], [6, -6, 0, -14], [-25, 4, 5, -2], [8, 1, 7, 4], [5, 6, -3, -13], [10, -2, 8, 6], [5, -2, 1, -9], [-12, -9, -1, 12], [-9, -2, -1, -5], [4, -2, -2, 8], [6, -6, 0, -2], [-4, -7, 1, -12], [-10, 14, -2, 4], [1, -5, 2, 2], [2, 6, 4, 2], [-14, -2, 4, -3], [9, 0, -1, 15], [5, 14, 5, -21], [-2, 6, 0, -6], [-10, 12, -2, -2], [4, 0, 8, -8], [-12, 9, -3, -6], [-14, 8, -6, -2], [-8, -18, 6, 0], [1, -10, 9, -5], [-15, -4, -9, 18], [17, -10, -3, -3], [-20, -3, 7, 0], [-15, 6, 5, 12], [5, -2, 9, -9], [4, -17, -1, 14], [-25, 11, -4, -8], [28, 0, 0, -8], [5, 6, 1, -13], [29, 3, -2, -2], [21, 2, 1, 7], [-14, 3, -7, -8], [-13, 4, 5, 4], [-3, 7, 2, -16], [-8, -1, 3, 14], [6, 0, 14, -10], [10, 0, -2, 18], [-13, 8, -7, 12], [-8, 7, -5, -20], [-12, 24, -4, -12], [-2, 0, 2, 10], [-6, 9, -1, -8], [-10, -8, -10, 24], [14, -6, 0, 8], [0, -1, -7, 20], [10, -6, -8, -10], [26, -1, 5, 8], [-6, 2, -6, 12], [16, 4, 0, 16], [-6, 12, -6, 2], [-11, 9, -4, 10], [26, 2, -4, 10], [21, 9, -4, 6], [-7, 0, -9, 25], [-2, 1, -1, 0], [-4, 6, 4, -6], [-16, 17, -3, -8], [-16, 16, -8, -9], [-21, 2, -1, -16], [2, 10, -4, 2], [-11, 0, 7, -21], [-4, -4, -8, 9], [-1, 16, -7, -10], [-14, 3, 9, -8], [-10, 17, -1, -2], [-1, 2, 3, 17], [0, 3, 7, -16], [4, 11, -1, 6], [-17, 7, 0, -16], [16, -2, 6, -20], [9, 18, -7, -6], [16, 2, 6, -12], [-18, -8, -6, 6], [-4, 15, -9, -10], [6, -14, -4, 2], [-9, 6, 3, 1], [4, -13, 3, 20], [4, -16, 0, 6], [12, -16, -4, 21], [-27, 18, 1, -8], [-5, 6, 3, 28], [27, -6, 11, 1], [14, 11, -11, 4], [24, -15, 13, 8], [-10, 3, -11, 4], [14, 17, -5, 4], [19, -11, 2, 2], [2, 8, 2, -10], [11, 5, -6, -18], [24, -9, -5, -6], [14, 9, 5, -22], [-20, 1, 1, -18], [14, -2, 4, 6], [-15, 16, -5, 0], [-7, 0, -13, 11], [15, 2, 11, -19], [22, -10, 8, 10], [-18, -4, 6, -17], [4, 3, 11, -6], [32, 4, -4, 11], [-34, 2, 8, 0], [-5, 20, -11, 4], [26, -14, 4, 6], [-20, 15, 3, -6], [-13, -14, 5, -13], [16, 9, -19, 14], [3, -2, 19, -14], [-17, 8, 13, 2], [7, 18, -1, -6], [11, -18, 3, 12], [6, -22, 4, 22], [37, 1, 4, 0], [-2, 0, -2, -24], [4, 5, 7, -8], [-26, 25, -7, -10], [31, 4, 9, -7], [2, -12, 12, -8], [6, -6, -8, 10], [37, -4, -9, -5], [13, -5, -10, 14], [26, -14, 4, 30], [28, 8, -4, 19], [16, -4, 2, -2], [-41, -10, -1, 11], [-10, 4, 2, -14], [4, 7, -17, 4], [21, 6, -3, -4], [16, -13, 7, 6], [-10, 6, 2, 32], [-4, -17, 15, 4], [-32, 4, 4, -4], [42, -7, -3, -6], [-27, 16, -5, -15], [-7, 4, -1, -13], [-31, 2, 1, 17], [21, 10, 5, 3], [0, 8, 0, 8], [-27, 7, -6, 4], [-22, -19, 7, 2], [-8, 7, 15, -10], [4, -6, 2, 0], [10, -11, 3, 20], [-27, 2, -11, 15], [4, -18, -2, 8], [14, 4, -8, -4], [-12, 8, -4, -20], [16, -10, 22, 8], [8, -6, -6, 29], [7, 5, -10, 4], [-4, -7, -7, 30], [21, -4, -5, -9], [-10, 11, 9, -8], [-8, 0, 4, -28], [18, 1, -9, -4], [-22, 3, 3, -22], [5, -15, 4, 28], [28, 17, -15, 12], [12, -30, 10, 6], [-8, -11, -7, 34], [-18, 9, -1, -16], [-23, 12, -1, 3], [2, 19, -9, -10], [-17, 14, -1, -32], [-8, 12, -8, -32], [6, -10, 0, 9], [-13, -16, -1, 19], [-11, 4, 7, -17], [0, 2, -14, -3], [-3, 8, 11, -5], [21, 3, -10, 26], [-8, 18, -8, -6], [-11, -2, 1, -11], [31, -4, -15, 9], [1, -6, 21, -12], [-11, -22, 9, 10], [-17, -1, 8, 14], [18, 17, -9, -4], [7, -18, -5, 9], [28, -6, -8, 2], [-19, 8, 3, -13], [8, -4, 14, -14], [-7, 10, 5, 6], [-22, 17, 11, -16], [-18, 7, -7, -20], [20, 12, 12, -44], [-22, 16, -10, 6], [2, -7, 3, 28], [-1, 12, -15, 29], [40, 1, 9, -18], [-20, 1, 5, 26], [7, 0, -19, 21], [28, 12, -4, 16], [19, -38, -1, 23], [12, 18, -14, 26], [-26, 4, -18, 2], [-3, -6, -11, 19], [24, -8, 16, 16], [24, -4, -20, 1], [53, 2, -3, -6], [0, 21, 5, -14], [-2, -2, 6, 44], [27, -9, 4, 22], [12, -1, -17, 22], [-25, 0, 15, -5], [2, -15, 11, -12], [-19, 10, -15, -12], [-9, -7, -14, 16], [-16, 4, 8, 4], [0, -12, 4, -12], [-28, 9, 9, 10], [6, -18, -4, 6], [6, -15, 3, 32], [-20, 22, -4, -6], [-33, 12, -11, -21], [8, -23, 5, -10], [0, -20, 0, 4], [-27, -4, -5, 12], [-59, 2, 1, 15], [18, 6, -4, -3], [-29, 8, -7, -11], [-30, 16, -12, -12], [10, -6, 4, -24], [9, 26, 1, -10], [-27, 13, 8, -2], [0, -27, 5, 26], [-37, 16, -23, -11], [-48, 11, 11, 10], [-25, 18, -13, -11], [4, 7, 7, -28], [34, 10, 8, -23], [21, -2, 7, -15], [-27, 2, -11, 15], [-46, 8, -2, -5], [14, -36, 4, 32], [2, -15, -5, 16], [29, -26, 1, 24], [10, 1, -9, -4], [-36, 22, -2, -24], [28, -18, 6, 28], [-10, -16, -2, 16], [21, -17, -14, 16], [13, 10, -7, 36], [-3, -23, 4, -16], [-24, 10, -10, -2], [1, 14, -7, 11], [17, -8, -1, 47], [24, 11, -9, 22], [-14, 7, -3, 0], [-23, 27, -14, -2], [30, -8, -6, -25], [10, 7, -7, 16], [10, 5, -13, -20], [-10, 12, -2, 6], [-19, -5, 22, -6], [-6, 21, -1, -32], [23, -40, 5, 21], [32, 3, -17, 22], [1, 24, 3, -10], [34, 9, -1, 12], [22, -9, -3, -38], [-5, 24, -11, 18], [-10, 15, -11, 20], [25, -14, 13, 40], [-26, -26, 10, -8], [26, 2, 12, -8], [8, 13, -1, -16], [11, 20, -3, -7], [-35, 16, -1, -25], [30, 2, 8, -22], [7, -5, -4, -16], [-2, -6, 8, -18], [2, -34, 12, 1], [-21, 5, 10, 4], [-45, 12, -7, -7], [54, -2, -4, -6], [-8, 37, -11, -6], [-12, -11, 1, -6], [21, -33, -6, 14], [40, 2, 2, 12], [25, 2, -11, 22], [-25, -28, 9, 5], [14, -24, 14, 22], [-24, 13, 17, 4], [11, 8, -31, 17], [14, -6, 4, -34], [-39, -6, -19, 22], [-4, 25, 9, -22], [10, -22, 4, 24], [-14, 3, -5, -38], [-34, -14, 4, -22], [30, -49, 3, 14], [13, -9, 2, -34], [-6, 12, 2, 18], [-24, 8, -4, 22], [-23, 13, 4, -6], [-24, -2, 2, 20], [16, -15, 5, 32], [6, 7, 9, 24], [-4, 2, -12, 14], [17, -4, -5, -13], [41, -28, 7, 31], [-1, 12, -7, 18], [9, 27, 2, -18], [-1, -20, 25, -23], [16, -33, 3, 22], [26, -10, 0, -14], [15, -18, 11, 26], [-16, -8, 8, 24], [10, -2, 4, 14], [50, 8, -14, 10], [17, 2, 13, -9], [10, -14, 24, 15], [-19, -8, -25, 39], [-36, -7, 1, 30], [1, -6, 17, -20], [1, 4, 9, -47], [-55, 18, -7, -15], [-54, -2, 2, -16], [10, 8, -10, 18], [-26, 13, -21, 8], [34, -5, -11, -12], [10, -2, -20, 25], [5, -24, 9, 13], [-42, 0, -6, 10], [4, -4, 12, -44], [-24, -23, -13, 40], [5, 16, 3, -22], [36, 9, 1, -36], [-26, 2, 8, -12], [-13, -9, -4, 36], [-29, 2, 15, -3], [10, 14, -20, -18], [-13, 20, -3, -36], [-42, 15, 5, -2], [-8, -14, -10, 36], [32, -14, 2, -15], [0, 2, 0, 18], [28, -14, -6, 12], [27, 3, 8, 0], [32, -7, 1, 14], [30, -11, 3, 38]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_2601_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_2601_2_a_bf();".
// 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_2601_2_a_bf(:prec:=4)
    chi := MakeCharacter_2601_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_2601_2_a_bf();".
// 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_2601_2_a_bf( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_2601_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<2,R![2, 8, -5, -2, 1]>,<5,R![-2, 4, 7, -6, 1]>,<7,R![16, -16, -6, 4, 1]>],Snew);
    return Vf;
end function;