
// Make newform 5610.2.a.bn in Magma, downloaded from the LMFDB on 30 December 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_5610_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_5610_2_a_bn();".
// 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_5610_2_a_bn();".
// 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, -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_5610_a();"
function MakeCharacter_5610_a()
    N := 5610;
    order := 1;
    char_gens := [1871, 3367, 1531, 3301];
    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_5610_a_Hecke( : Kf := Kf)
    return MakeCharacter_5610_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 := [[-1, 0], [-1, 0], [-1, 0], [0, -1], [1, 0], [-2, 2], [-1, 0], [-4, 0], [4, 1], [-2, -1], [-4, 3], [6, 0], [-2, -2], [0, -5], [-4, 4], [6, 2], [0, -2], [-6, 0], [12, 0], [8, 2], [-2, -4], [-12, 0], [4, -4], [-6, -2], [6, -3], [2, -4], [4, -3], [0, 5], [-6, 6], [6, -8], [0, 6], [12, 0], [-2, 5], [-4, 3], [2, -2], [-8, -4], [-18, 0], [0, 5], [0, 6], [18, 0], [8, -10], [2, 1], [8, 5], [-2, 0], [2, 2], [0, 0], [-12, 5], [-4, -3], [0, -3], [-2, 6], [10, 1], [16, -2], [18, -5], [8, -4], [14, -1], [12, 3], [-6, 8], [-4, 9], [2, 0], [2, 5], [-8, 6], [6, -9], [20, 0], [8, -4], [6, -9], [22, -7], [8, -11], [6, 0], [12, 8], [-2, 0], [-10, 5], [0, 6], [-16, -6], [6, -12], [12, -8], [4, -8], [14, 4], [6, -4], [-6, -9], [10, -10], [16, 7], [30, -2], [12, 11], [-6, 18], [28, -6], [4, -1], [2, 1], [18, -12], [18, 0], [0, 8], [24, 4], [-4, -11], [24, -6], [-4, 4], [4, 0], [0, 4], [-34, 4], [6, 12], [-8, 3], [18, -2], [0, 6], [6, -3], [4, -8], [-26, 4], [24, -4], [-14, 8], [-4, 17], [6, 0], [24, 3], [-26, 0], [-12, 12], [14, 0], [-10, -4], [4, 14], [32, -6], [10, 5], [24, -5], [12, -18], [22, 1], [0, -15], [-18, 6], [6, -2], [10, 8], [28, 4], [28, -12], [2, 16], [-34, 12], [24, 6], [-4, -3], [14, 10], [20, -18], [8, -4], [12, -3], [2, -17], [18, -1], [-6, 16], [-34, -2], [32, -8], [22, -14], [-26, 16], [16, 0], [-2, 1], [0, -6], [16, -5], [14, 4], [-24, 6], [-18, 13], [18, 11], [0, -13], [-4, -8], [-2, -19], [-38, 7], [20, -12], [-16, 8], [0, 3], [-8, -16], [-12, 23], [-22, 1], [-14, 12], [18, 4], [-20, -2], [-26, -8], [-24, -6], [-8, -20], [-14, 28], [20, -7], [12, -15], [-10, -5], [-14, -7], [6, 9], [-40, -1], [6, -6], [0, -20], [6, -13], [8, 0], [46, -8], [0, 12], [-14, 28], [-8, 12], [-14, 3], [-4, -3], [36, -12], [54, 0], [-26, 16], [-44, -4], [-18, -8], [-10, 13], [36, 4], [-46, 7], [24, 0], [-42, -7], [4, -16], [8, 15], [2, -13], [0, 9], [30, -14], [14, 0], [-26, 12], [18, 9], [-12, 21], [-30, -12], [4, 18], [50, 3], [2, 6], [0, -18], [-18, -10], [-48, -6], [-12, -8], [30, 14], [0, -7], [-42, -6], [-6, -23], [-24, 0], [20, -13], [-40, 8], [-30, -10], [16, -6], [-46, 7], [-40, 16], [-10, 28], [-30, 11], [52, -12], [10, -14], [56, -6], [-20, 8], [10, -7], [-18, -20], [32, -10], [-8, -10], [-4, 26], [-38, -9], [-12, 13], [12, 13], [10, 13], [36, 8], [28, 17], [26, 6], [-14, -14], [-32, 17], [-44, 4], [36, -4], [-4, 10], [12, 9], [-34, 0], [42, -5], [12, -19], [24, -6], [32, -19], [-28, 22], [-12, 11], [-10, 6], [-26, 2], [-44, -8], [34, -16], [-42, 9], [-8, -17], [6, -12], [-40, -2], [30, -19], [-22, 28], [-20, 24], [52, 10], [-30, 16], [6, -9], [-10, -2], [-24, 5], [-46, -5], [-6, -6], [-8, 2], [-10, 1], [-14, -1], [-20, 6], [42, 4], [-36, 9], [30, 3], [-72, -4], [-8, 20], [18, 9], [18, 0], [20, 16], [4, 19], [0, -8], [24, 0], [42, -23], [56, -2], [12, -20], [-14, -12], [-6, -24], [16, 6], [-6, 1], [18, 12], [28, -28], [6, 6], [44, 2], [-26, 17], [50, -4], [0, -18], [-26, 22], [-36, -18], [-48, -3], [30, -33], [-18, -9], [-36, 18], [60, 0], [12, -16], [42, 12], [-36, 7], [30, 0], [8, 1], [30, 0], [-48, 14], [-14, 4], [-10, -10], [52, 12], [28, 11], [18, -30], [-24, -20], [48, 16], [66, 4], [-22, -1], [-60, 15], [14, -17], [42, 6], [60, -9], [-26, 16], [-26, 21], [20, 12], [48, -3], [56, -8], [-30, 6], [42, -8], [30, 9], [36, -6], [60, 12], [24, 12], [4, 4], [54, -10], [-6, 39], [90, -2], [-80, -6], [-10, 0], [50, -20], [14, 1], [8, 30], [-66, 18], [-4, 14], [14, 0], [36, 12], [60, -3], [-34, 29], [4, -28], [-14, -24], [26, -37], [-12, 0], [78, 0], [-10, -8], [-8, 17], [44, -4], [-46, 13], [36, 6], [6, -15], [-26, -28], [20, -20], [-12, -6], [-12, 20], [66, -2], [34, 4], [16, 18], [30, -8], [-8, 22], [-68, 0], [40, -14], [-30, -12], [-12, -5], [-42, -18], [20, -8], [4, -19], [14, -9], [-18, 28], [-78, 4], [42, -30], [-50, -1], [-28, 12], [-78, 13], [76, -3], [84, -3], [-16, 18], [18, -21], [16, 30], [-28, -20], [-54, -6], [-18, 27], [16, -14], [-52, 30], [-28, -4], [-10, -18], [56, 4], [-78, 12], [-36, 6], [26, -2], [-46, 18], [2, 20], [-16, 28], [54, -18], [-22, 44], [-36, -10], [30, 20], [-42, 24], [4, -6], [-48, -13], [-34, -24], [26, 16], [-24, -12], [28, 3], [-18, -9], [2, -4], [0, 24], [24, 4], [-34, 2], [48, -24], [-10, -20], [-86, 12], [8, -32], [-20, 8], [26, -8], [-18, 4], [-84, -8], [38, 4], [16, -27], [-12, -13]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_5610_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_5610_2_a_bn();".
// 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_5610_2_a_bn(:prec:=2)
    chi := MakeCharacter_5610_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_5610_2_a_bn();".
// 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_5610_2_a_bn( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_5610_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<7,R![-4, 1, 1]>,<13,R![-16, 2, 1]>,<19,R![4, 1]>,<23,R![16, -9, 1]>],Snew);
    return Vf;
end function;