
// Make newform 6480.2.a.bm in Magma, downloaded from the LMFDB on 23 February 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_6480_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_6480_2_a_bm();".
// 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_6480_2_a_bm();".
// 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 := [-14, -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_6480_a();"
function MakeCharacter_6480_a()
    N := 6480;
    order := 1;
    char_gens := [2431, 1621, 6401, 1297];
    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_6480_a_Hecke( : Kf := Kf)
    return MakeCharacter_6480_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, -1], [-3, 1], [2, 1], [2, 0], [-1, 0], [4, -1], [3, -1], [-3, 1], [-4, 2], [1, -2], [-4, 0], [-2, -1], [4, 1], [13, 0], [2, -2], [6, 2], [5, -1], [2, -4], [-4, 2], [-4, -2], [3, -3], [16, 0], [13, 1], [-4, -3], [-2, 4], [-3, 1], [-6, 0], [-8, 1], [5, 2], [8, -2], [9, 0], [2, 0], [9, -1], [14, 1], [-14, 2], [14, 2], [12, 1], [5, -2], [13, -1], [-3, 5], [4, 0], [-6, 5], [-8, 0], [3, -4], [-8, 0], [14, 2], [2, -2], [4, 4], [20, 2], [-21, 1], [-22, -1], [-10, -4], [4, 1], [-3, 7], [-20, -2], [22, -1], [16, 3], [18, 2], [14, 1], [12, 4], [3, -7], [8, 0], [2, -1], [9, -3], [12, 2], [-14, 0], [3, -3], [0, -2], [9, 3], [-6, 2], [18, -4], [-6, 1], [14, 5], [-10, 2], [-6, -4], [20, -1], [-20, 3], [-4, -4], [-29, 1], [3, -1], [6, -2], [9, -5], [-4, 2], [-5, -2], [16, 0], [-7, 5], [-12, 9], [14, -8], [1, -1], [34, -1], [-15, 0], [23, -2], [0, 0], [2, -8], [-4, 7], [20, -6], [21, -7], [-20, 0], [10, -7], [-24, 4], [-33, -2], [11, 3], [-18, -2], [28, -2], [-22, 8], [19, 1], [-15, -4], [24, 0], [-10, 11], [-24, 6], [2, -5], [5, 9], [11, -7], [20, -4], [22, -2], [16, 2], [14, -1], [-17, 7], [-22, -4], [-4, 7], [8, 2], [-2, -3], [-17, 5], [-14, -4], [35, -3], [14, -5], [-6, 0], [7, 7], [22, -2], [-28, 2], [18, -5], [43, -2], [-13, 1], [12, -6], [34, 0], [-32, -2], [-3, -6], [-23, -3], [-5, -3], [-30, -2], [-8, 4], [-23, -3], [-23, 9], [-10, 12], [-20, 10], [-23, 9], [-20, 1], [-10, 1], [35, 5], [-6, 8], [-10, -3], [-38, 4], [-9, -11], [11, 7], [-11, 15], [6, 2], [-6, -4], [34, 2], [-20, 4], [-30, -6], [-17, 6], [-16, -6], [14, -10], [5, 1], [-8, -5], [1, 2], [4, 5], [-33, 2], [9, -7], [17, -5], [-2, -10], [-20, 6], [-31, 8], [-6, 7], [5, 3], [16, 8], [33, -1], [20, 4], [-6, -3], [-20, 5], [-14, -6], [-18, -7], [23, -3], [-28, 3], [-38, 0], [11, 6], [20, 6], [22, -4], [-24, -6], [-8, -12], [7, -7], [8, 0], [-18, -2], [-39, 0], [18, -3], [26, 0], [-10, -5], [15, 9], [11, -9], [32, 3], [-31, 8], [0, -12], [-26, 5], [45, -5], [28, -10], [-46, -4], [-12, 8], [46, 0], [7, -1], [-54, -1], [20, 8], [29, 9], [-23, -2], [-14, 2], [25, -1], [44, -7], [-26, 0], [-1, 9], [-37, 9], [41, -2], [-58, 5], [-42, -6], [-47, -3], [-6, -8], [0, 2], [26, -5], [-6, 5], [-20, 3], [-3, 0], [8, -8], [-28, -5], [4, -8], [-24, 9], [-9, -6], [18, 0], [2, 3], [-5, -5], [-18, -14], [2, 15], [-2, -7], [6, 8], [12, -14], [-17, -3], [-6, 7], [18, -1], [-17, -4], [-36, 8], [-32, -2], [-17, 0], [4, 4], [31, -4], [-26, 11], [-38, -5], [-3, 7], [-38, -2], [32, 5], [10, -2], [-2, 11], [-36, 2], [7, 7], [2, 3], [-40, 12], [-19, 18], [-2, 0], [-37, 8], [-44, 4], [8, 7], [1, -13], [8, 0], [-4, 2], [-65, 3], [14, 0], [12, -16], [-6, 10], [23, 9], [16, -13], [26, -7], [58, 1], [-32, -8], [0, -13], [-2, -18], [18, -14], [25, -7], [32, 6], [14, 5], [-15, 9], [22, -8], [7, 9], [-28, 8], [-14, -8], [-27, -3], [32, 1], [9, 3], [9, -13], [-62, 4], [-19, 0], [34, 4], [-14, -14], [48, 3], [-25, 7], [26, 4], [-25, 2], [22, 0], [-10, -16], [51, -7], [-9, 9], [56, 6], [-18, 10], [35, -7], [-9, 6], [48, 4], [22, 6], [-71, 0], [-29, 8], [45, 9], [0, 8], [-31, 7], [-26, -9], [10, 14], [-33, -9], [2, -6], [28, 6], [21, -18], [-47, -7], [6, 14], [46, 9], [-36, 9], [67, -7], [-26, -3], [-5, -7], [-18, 16], [25, 14], [-40, -4], [-31, 3], [26, 14], [-3, 8], [14, 17], [-26, -7], [14, -22], [17, 13], [-12, 14], [-32, -3], [12, 16], [7, -3], [-20, 2], [15, -15], [2, -7], [41, -12], [24, -6], [38, -14], [28, -21], [-9, -5], [14, -8], [-21, -9], [17, -18], [-26, 12], [42, -1], [-56, 2], [-21, 8], [52, 3], [17, -22], [8, -10], [32, -8], [2, -13], [-68, 0], [-51, 10], [59, 8], [-38, 15], [0, -7], [-27, 9], [49, 7], [4, -7], [-61, -4], [33, -1], [-40, 12], [-31, 11], [-38, -10], [-10, 12], [-6, 14], [2, -13], [70, 4], [7, 19], [-32, 11], [-52, 0], [36, -3], [-46, 8], [-12, -17], [-50, 0], [38, 5], [4, -8], [40, 14], [11, 1], [-20, 2], [9, 11], [-20, 13], [-6, 11], [-5, -17], [-23, 13], [40, -14], [32, -9], [34, -14], [-23, -5], [20, 14], [-40, 1], [-52, 11], [88, 2], [51, 3], [-18, -4], [-34, -4], [10, -18], [-15, -8], [32, 4], [-22, -10], [37, -7], [46, 14], [54, -12], [-14, -14], [-50, -2], [-18, -7], [-26, -1], [15, 4], [-68, 4], [38, -19], [-52, -4], [44, 5], [-17, -9], [-80, 0]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_6480_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_6480_2_a_bm();".
// 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_6480_2_a_bm(:prec:=2)
    chi := MakeCharacter_6480_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_6480_2_a_bm();".
// 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_6480_2_a_bm( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_6480_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<7,R![-14, 1, 1]>,<11,R![-8, 5, 1]>,<13,R![-8, -5, 1]>,<17,R![-2, 1]>,<19,R![1, 1]>,<23,R![-2, -7, 1]>],Snew);
    return Vf;
end function;