
// Make newform 6480.2.a.bx in Magma, downloaded from the LMFDB on 20 January 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_bx();".
// 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_bx();".
// 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 := [3, -5, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0], [0, 1, 0], [-4, 0, 1]];
    Rf_basisdens := [1, 1, 1];
    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_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, 0, 0], [1, 0, 0], [1, 1, -1], [1, 0, 1], [-1, 2, -1], [1, -2, -1], [1, 0, -1], [3, -3, -1], [-3, 2, 0], [5, 0, -1], [1, 0, 1], [0, 0, 1], [-1, 2, 1], [6, -1, 4], [-4, 2, 0], [2, 2, 2], [-2, -4, 1], [-2, 5, 0], [3, 2, -3], [4, 4, 0], [4, -4, 2], [7, 1, 1], [-11, 0, 0], [12, -2, 4], [-2, -2, 2], [3, -6, 1], [7, 3, -3], [10, -2, 5], [-6, -6, 0], [4, -1, 6], [8, 0, -2], [-8, 2, -2], [-4, 0, -4], [-6, -2, -3], [11, 0, -1], [10, -2, 6], [-11, 2, 3], [4, -7, 0], [6, -8, 6], [3, -6, 1], [-1, -6, 0], [5, 2, -3], [13, -6, 1], [-6, -2, 4], [5, 8, -1], [1, 4, 1], [12, -1, 0], [5, -8, 5], [-1, 6, 2], [-11, 8, -3], [2, 2, 8], [-8, 6, -1], [5, -6, 1], [10, 0, 4], [-5, -2, 1], [6, 6, -3], [11, -4, 1], [-1, 10, 1], [2, 6, 1], [11, -5, 3], [-7, -2, -9], [9, -7, 1], [-7, 10, 1], [11, 4, 1], [1, -4, 3], [12, 2, 4], [16, -10, -6], [1, 10, -5], [1, -4, -6], [-8, 8, 4], [1, -14, 5], [-11, 2, -1], [16, -6, 8], [-22, 0, 0], [-15, 6, -5], [-10, -4, -1], [10, -4, -4], [10, -6, -2], [4, 8, -6], [5, -4, -3], [4, 8, -2], [6, 8, -4], [9, -6, -1], [14, 6, 0], [-2, -3, -2], [0, -18, 8], [19, -4, 3], [1, -10, -6], [5, 4, 9], [-1, 10, 1], [-18, -8, 0], [-17, -4, -5], [-12, -6, -2], [6, -14, -4], [-14, 3, -2], [1, 12, -2], [-1, 2, -6], [-12, -1, -6], [-7, 8, 0], [-11, 1, -7], [22, 4, -4], [-18, 1, -6], [-18, 0, -8], [8, -16, 12], [4, 2, 0], [17, 1, -7], [15, 0, -5], [-30, 8, 4], [-28, 0, -6], [18, -5, 0], [9, 2, -5], [14, 6, 0], [-9, -4, 5], [22, 6, -4], [12, 6, 3], [-8, 5, 4], [32, -7, -4], [-19, 0, 5], [2, 6, 0], [-10, -4, -8], [1, 0, 11], [21, 4, 3], [-19, 6, -1], [-14, 8, -4], [16, 4, 11], [-3, 10, -4], [-6, 6, -6], [8, 15, -2], [6, 8, 4], [16, -6, 8], [-13, 7, 5], [-7, -2, -1], [21, -10, 9], [-3, -14, 8], [-17, -14, 4], [-8, 4, -4], [-43, 6, -1], [19, -12, -7], [10, -2, 10], [-24, -4, 6], [-4, 0, 7], [20, 5, -2], [4, -5, 0], [-12, -4, 1], [-15, -8, -5], [17, 0, -5], [19, -10, 15], [-27, 10, -9], [12, -1, -4], [-23, 6, 9], [-16, 12, 1], [2, -3, 6], [31, 10, 1], [-22, -9, 6], [20, 2, 4], [-2, 12, -4], [-36, 12, 6], [-14, 10, 8], [7, -6, 8], [-18, 9, -4], [9, -4, -9], [-11, -17, -3], [-1, -16, 1], [-9, 8, -11], [-23, 9, -11], [32, -6, 4], [-12, 6, -12], [-11, 6, -10], [-1, -4, 11], [-12, -2, 2], [-41, 0, 2], [15, -12, 7], [-12, -14, 2], [-4, 20, -8], [-28, 6, -4], [16, 2, -2], [-4, -14, 8], [5, -11, 17], [6, -4, 7], [5, -2, 15], [-7, -2, 9], [-23, -6, -9], [17, 14, -7], [-28, -15, 2], [-21, 12, 8], [4, -12, 8], [-25, -11, 1], [6, -8, -7], [12, 2, 0], [23, -8, -11], [-10, -1, 8], [5, 2, 9], [10, -6, -5], [14, -1, -6], [-31, -14, 1], [-22, 6, 13], [-24, 10, 2], [-1, -12, -1], [-39, -3, -7], [2, 4, 4], [-21, 14, -7], [32, 4, -8], [-3, 18, -14], [-14, 4, -22], [-11, 14, -11], [21, -8, 5], [39, -9, -1], [-5, 4, -14], [-20, 2, -10], [22, 12, 8], [-34, 8, -8], [28, -9, -4], [11, -6, -15], [1, 4, -7], [-4, 2, -17], [9, -1, 1], [22, -4, -4], [22, -5, 12], [18, -18, 12], [6, -8, -11], [7, -16, 3], [-27, 8, 0], [-9, 19, 5], [4, -3, -6], [32, -10, 4], [-29, 4, -5], [-13, 14, -7], [-10, -3, 6], [19, 4, 1], [-4, -6, -12], [-47, 0, -3], [7, 6, 9], [12, 2, -5], [-16, -11, -4], [9, -15, 3], [-4, 0, 7], [-27, 10, 9], [15, -4, 5], [41, 0, 13], [7, -15, 1], [-9, -2, -19], [-10, -5, 2], [-27, 10, -8], [1, 14, -1], [-15, 6, 9], [-15, 7, 1], [-11, 16, -5], [11, -6, 23], [-27, 23, -5], [-9, -12, -1], [9, 18, -12], [39, 0, -1], [-18, 8, -11], [-10, 24, -6], [-6, 12, 6], [28, 14, -12], [12, 17, 10], [-25, 4, -1], [3, -22, 1], [-4, 15, -12], [56, -7, 6], [-14, 6, 18], [-36, 6, 4], [-3, 6, 5], [2, 0, 12], [-34, 2, -2], [-21, 6, 10], [-2, -27, 14], [-38, 10, 6], [-36, 6, -20], [11, -27, -1], [-41, 6, -15], [22, -22, -10], [-20, -12, 4], [-26, 15, 10], [6, 21, 0], [-26, 2, -2], [16, -24, 1], [-21, -6, -15], [-25, 14, -7], [-17, 6, 5], [27, 12, -1], [29, -12, 16], [3, -5, 1], [16, 8, -8], [-33, -12, 9], [26, 8, 10], [-12, 12, 16], [42, -2, 15], [0, -14, -8], [-3, -26, 15], [-11, -8, 1], [21, 6, -7], [7, -4, 15], [-2, -14, -3], [13, -10, 23], [-16, -10, -10], [38, -16, 8], [-39, -2, -13], [9, -28, 5], [-4, 2, -14], [15, -30, 7], [51, -12, 15], [-2, -10, 10], [-15, 2, -11], [-31, 1, 9], [7, -10, -2], [25, 4, -9], [20, 0, 12], [-63, 6, -5], [-29, 12, 4], [-22, 10, 10], [-33, 13, -11], [5, -2, -9], [-25, -10, 4], [26, -28, -8], [-15, 20, -15], [-38, 18, 10], [-16, -2, -16], [-8, -2, 6], [11, -16, 5], [-20, 0, 10], [5, -8, -7], [-12, -18, -8], [30, 20, 3], [5, -14, -3], [57, 1, -1], [8, -11, 8], [-14, 22, -6], [34, 2, 3], [3, -18, 5], [-24, 2, -14], [-11, 10, -13], [6, 22, -2], [12, 9, 22], [4, -10, -5], [-22, 14, -16], [18, 6, 17], [19, -2, 1], [16, -16, 0], [-32, 12, -8], [-22, -10, -15], [-70, 2, -2], [15, 30, -11], [-18, 2, 20], [10, -16, -16], [41, -7, 9], [6, 12, -4], [16, -24, -20], [-42, -6, 2], [-37, 24, -23], [-24, 26, -3], [-1, -5, 13], [5, -32, 6], [-3, 10, 19], [30, -18, 24], [-50, 16, 14], [-14, 20, 2], [-38, 17, -24], [4, 6, 2], [55, 4, 4], [7, 16, -17], [-65, 8, -13], [11, 10, 21], [41, -10, -9], [-9, 2, 3], [58, -1, 6], [20, -4, -6], [25, 38, -11], [28, 30, -6], [-7, 1, -11], [-20, -34, 11], [-18, -8, -22], [-38, 26, -12], [-25, 32, -13], [46, 10, -8], [64, -10, -2], [16, 4, 7], [-21, 4, 19], [-11, 0, -8], [19, -6, 23], [44, 1, 8], [1, -12, -5], [5, -14, 25], [-49, -18, -3], [49, -18, -3], [-30, 16, 18], [-39, 23, 1], [-27, 13, -5], [40, -16, 19], [39, -10, -17], [-56, 6, -24], [19, -10, -19], [32, -8, -14], [-42, 14, -6], [-12, 22, 4], [-2, 10, 6], [-20, 4, -30], [36, 6, -8], [12, 14, -1], [-8, -16, -2], [19, 14, -11], [57, 6, -1], [-60, -12, -3], [7, -36, -1], [-20, 12, -12], [33, -18, -12], [57, -13, 1], [14, -38, 14], [-6, -22, -12], [-20, 6, -14], [50, -17, 4], [30, -26, 4], [-27, -18, -11], [1, 14, 2], [-13, 2, 5], [-1, -30, 1], [-16, 4, 8], [-24, -29, 12], [36, -16, 29], [22, -2, 0], [33, -14, 15], [-2, -2, 2], [-17, -6, -3], [36, -12, 36], [66, 1, -10], [48, -4, -6], [-1, 4, -21], [-36, -4, -6]];
    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_bx();".
// 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_bx(:prec:=3)
    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_bx();".
// 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_bx( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_6480_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<7,R![9, -3, -5, 1]>,<11,R![12, -8, -2, 1]>,<13,R![36, -24, 0, 1]>,<17,R![108, -36, -2, 1]>,<19,R![4, -4, -4, 1]>,<23,R![303, -51, -7, 1]>],Snew);
    return Vf;
end function;