
// Make newform 8464.2.a.bd in Magma, downloaded from the LMFDB on 31 December 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_8464_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_8464_2_a_bd();".
// 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_8464_2_a_bd();".
// 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_8464_a();"
function MakeCharacter_8464_a()
    N := 8464;
    order := 1;
    char_gens := [7407, 2117, 6353];
    v := [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_8464_a_Hecke( : Kf := Kf)
    return MakeCharacter_8464_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, 1], [-2, 0], [0, 0], [0, 2], [2, 1], [-2, 2], [0, 2], [0, 0], [2, -1], [4, 1], [-2, 4], [-2, 5], [-8, 0], [-4, -3], [-2, 0], [-4, 4], [-2, -4], [0, -2], [-12, 1], [-10, 3], [0, -2], [8, -4], [-2, 6], [-2, 6], [6, -4], [-8, 4], [8, -2], [-10, 2], [6, 2], [4, 3], [-8, -3], [-10, -2], [8, 3], [14, -4], [12, 1], [-18, 2], [-8, 7], [16, 0], [-10, 0], [8, 3], [-10, -4], [16, -6], [-2, -1], [-6, 7], [8, -2], [4, 0], [16, -8], [0, 4], [-18, -2], [-2, 9], [-12, 9], [6, 8], [0, 4], [-10, -3], [-16, 2], [18, 3], [-24, 0], [10, -5], [-2, 2], [0, -2], [6, -6], [12, -4], [-4, 1], [6, -6], [-10, -4], [-8, 15], [6, -10], [4, -8], [-30, 3], [14, -1], [-8, 10], [-8, 4], [-2, -8], [0, 8], [16, 4], [14, -6], [18, 1], [22, -4], [6, -13], [8, -8], [22, 2], [-8, -8], [6, -12], [12, -9], [24, -7], [2, -4], [-10, 6], [2, -5], [8, -8], [0, -6], [0, 4], [-20, 3], [0, -5], [0, 9], [-8, 6], [18, -13], [6, -10], [16, -4], [18, 7], [0, -17], [6, -2], [16, -4], [-2, 4], [-32, 8], [-2, 7], [0, 9], [-14, -12], [-8, 0], [-26, -5], [-16, 12], [-18, 18], [6, -16], [8, 8], [24, -12], [-2, 6], [-8, -6], [-4, 13], [2, 9], [-8, 4], [-10, 4], [-26, 9], [-2, 16], [-24, 3], [20, -16], [6, -14], [22, 6], [16, -8], [-24, -6], [-34, -6], [-8, 3], [24, 4], [0, 16], [22, -8], [-26, 3], [6, 0], [-18, 6], [-16, -4], [-2, -4], [26, 0], [-16, -7], [6, -12], [-52, 1], [-16, 8], [-10, -4], [40, 4], [6, -16], [14, 1], [-40, 9], [-20, 11], [-10, 16], [-10, 2], [4, -16], [-12, -3], [48, -2], [-32, -2], [48, -4], [22, 5], [-26, 4], [-34, -2], [0, 1], [-34, -4], [-12, -9], [16, 6], [6, 20], [-24, 18], [32, -16], [14, 0], [-26, 16], [-6, 1], [-24, -6], [2, -13], [8, -12], [14, 2], [20, 15], [-18, -2], [16, -5], [26, -7], [-16, 6], [-2, 14], [-4, -13], [-24, -4], [26, 11], [-22, 16], [0, -18], [14, 2], [14, 16], [-56, -2], [-26, -5], [-8, 24], [6, -15], [-36, 16], [-24, 14], [-18, 20], [-32, 22], [30, -2], [-18, 12], [-2, -6], [-26, -14], [-28, 19], [22, -2], [40, 8], [26, -9], [14, -12], [56, 4], [-14, -1], [-16, 6], [8, 13], [30, -3], [16, -9], [22, -23], [-22, 13], [24, -24], [-16, -2], [0, 16], [-58, 2], [4, 9], [30, -21], [-16, 30], [-46, 5], [-6, -19], [32, -10], [14, -5], [-16, 32], [16, -19], [-54, 5], [6, -16], [-60, 3], [-32, -10], [20, 8], [22, -20], [-32, 16], [40, 2], [-6, -16], [8, 20], [-40, 4], [-2, -22], [38, 0], [32, -3], [28, -17], [16, 24], [40, -11], [-4, 17], [-30, 29], [-30, 20], [-4, -7], [28, -3], [32, 14], [0, 30], [8, 2], [-26, 2], [-18, 0], [32, -6], [-50, -2], [14, 4], [56, -5], [-26, 20], [40, 10], [-6, 11], [-10, -1], [-64, -4], [-40, -4], [-50, -4], [-26, -6], [-46, 4], [24, -14], [-18, 4], [-66, 6], [-16, -14], [-22, 15], [18, -21], [8, 2], [-34, -14], [-32, 16], [-2, -17], [4, -11], [-52, 16], [-2, 12], [6, 4], [32, -24], [28, -25], [-16, 18], [40, -10], [-26, -12], [36, 4], [32, -24], [-10, 16], [-58, -4], [-32, -8], [34, 12], [-58, 16], [24, -8], [-22, 8], [16, 10], [18, -1], [6, 24], [40, 8], [26, -15], [0, 7], [32, -21], [-42, 22], [-50, 8], [-72, 8], [-16, -1], [32, -20], [6, 5], [4, 16], [6, 6], [-64, -6], [-42, -4], [4, 17], [-34, -12], [46, -26], [32, -1], [8, -30], [30, -14], [-56, 3], [-52, -7], [6, -6], [6, 29], [0, -24], [6, 6], [50, -7], [48, -8], [-34, 24], [14, -14], [40, -14], [40, -1], [-8, 6], [-50, 14], [34, -29], [2, 21], [-44, -1], [16, -25], [0, -14], [-32, 7], [70, 4], [-10, -6], [-18, -11], [-16, -12], [-54, -3], [22, -22], [22, 16], [-8, -14], [-18, -24], [-52, 16], [26, 9], [-44, 8], [64, -14], [30, 20], [0, -27], [-58, -5], [38, 8], [-32, 30], [-18, -18], [-70, 16], [64, 0], [-8, 22], [-34, -13], [48, -4], [-58, 24], [22, -37], [-12, 3], [16, 14], [-32, 7], [-26, 15], [18, -3], [24, -14], [-82, 8], [-8, -17], [4, 8], [-4, 25], [-18, 2], [-40, 8], [18, 25], [-16, 15], [-48, 2], [46, -4], [46, 6], [62, -3], [14, 4], [14, -4], [0, -20], [22, -3], [40, 8], [4, 15], [-60, -1], [-2, 8], [-8, 2], [24, -28], [-42, -22], [14, -8], [0, -19], [36, -8], [-16, -20], [-18, 24], [-16, 12], [-42, 10], [-8, -8], [-10, -32], [-62, 17], [-34, 3], [-24, -28], [22, 2], [74, 5], [12, 5], [46, -20], [-50, 3], [-48, -16], [-20, -8], [38, -27], [10, 25], [-40, 22], [-16, -14], [6, -24], [50, -1], [-8, -32], [8, -4], [30, 18], [-48, 4], [38, 6], [54, 2], [32, 0], [12, 0], [-42, 3], [-14, 21], [-56, -18], [74, -4], [32, 17], [4, -3]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_8464_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_8464_2_a_bd();".
// 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_8464_2_a_bd(:prec:=2)
    chi := MakeCharacter_8464_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_8464_2_a_bd();".
// 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_8464_2_a_bd( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_8464_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<3,R![-4, -1, 1]>,<5,R![2, 1]>,<7,R![0, 1]>,<13,R![2, -5, 1]>],Snew);
    return Vf;
end function;