
// Make newform 6480.2.a.ba in Magma, downloaded from the LMFDB on 13 March 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_ba();".
// 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_ba();".
// 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, 0, 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], [-2, 1], [-2, 2], [-2, -2], [4, -2], [2, 0], [-2, -1], [5, -2], [2, 0], [0, 6], [3, 4], [8, -2], [-2, 1], [6, 0], [-4, -6], [-5, -2], [-8, 1], [-6, -2], [0, 4], [-12, -2], [8, 3], [-3, -4], [-2, -4], [-6, 4], [-4, -6], [0, -3], [-7, -6], [0, 8], [-18, 1], [0, 2], [8, 8], [0, 0], [1, -2], [-2, -2], [-2, 4], [-4, 10], [6, 9], [16, -4], [-10, -2], [-13, 2], [-10, -4], [-14, -2], [8, 4], [-14, 4], [10, -6], [-14, -5], [0, -14], [1, 14], [0, -6], [0, -12], [-13, 4], [-6, 8], [6, -4], [-12, -6], [1, 6], [6, 8], [-4, -6], [-1, -8], [-20, -1], [-4, -2], [8, -7], [-10, 4], [2, 6], [6, -2], [0, 2], [16, -4], [8, 6], [-3, 2], [-8, -8], [6, 4], [4, 6], [-2, -4], [-4, -18], [0, -2], [-27, 2], [10, 0], [-6, 12], [-2, 4], [-6, -14], [-30, -4], [8, -2], [-16, 2], [-28, 4], [-12, -13], [18, -8], [16, -6], [15, -6], [0, 2], [20, 6], [4, 6], [-16, -14], [12, 8], [4, 8], [6, 7], [-31, 6], [-13, 0], [-16, 3], [-29, 6], [-20, -15], [-2, 20], [28, -9], [10, 0], [20, 12], [26, 4], [-24, 9], [-36, -2], [-12, 6], [10, 12], [-42, 1], [12, 6], [24, 4], [10, 16], [-4, -16], [-21, -8], [36, -1], [-6, 13], [28, 2], [0, 12], [-6, 16], [-30, 10], [14, -18], [-12, -6], [40, 6], [7, -18], [5, 6], [16, 10], [10, -15], [30, -8], [-24, 14], [-6, 23], [-6, -6], [-10, -6], [-21, 0], [13, 12], [12, -12], [16, -10], [-18, 6], [-42, -4], [40, 6], [-1, 14], [-22, -1], [36, -11], [1, 6], [-22, -8], [-46, -2], [-6, 14], [10, 6], [-18, -5], [22, -6], [3, 20], [4, 3], [-8, 10], [12, 1], [16, -2], [28, -6], [-10, 20], [16, -16], [-13, -6], [-8, 13], [30, 6], [-30, 5], [2, -16], [-14, 18], [-18, -13], [-8, 26], [6, 24], [5, 8], [-32, -2], [-28, -16], [-29, 10], [38, -2], [8, 0], [-8, -28], [-42, -8], [32, -12], [10, -16], [-22, -5], [25, -2], [-44, -2], [-18, 16], [-16, 6], [-10, -2], [-34, 3], [1, 22], [44, -8], [40, 7], [5, 28], [4, 22], [-22, 14], [12, 11], [22, 4], [-5, 22], [-8, -7], [-26, -6], [3, -24], [12, 4], [16, 10], [2, -5], [-30, -16], [-10, -18], [8, -24], [-3, -16], [-24, -4], [34, -2], [-10, -14], [-32, -13], [-15, -4], [16, -12], [-14, -8], [46, -8], [22, 3], [12, -2], [-14, 18], [3, 8], [2, 13], [22, -16], [-6, 9], [20, 16], [47, 2], [14, 10], [53, 8], [-18, 7], [-12, -15], [-2, 0], [-8, 30], [14, -10], [-14, 9], [-58, 4], [34, -8], [6, 10], [-14, 30], [47, 4], [12, 7], [18, -3], [-3, 8], [30, -10], [-50, 4], [-6, 2], [-8, 15], [-34, -10], [2, 3], [25, 22], [16, -14], [-10, -20], [2, 5], [-10, -16], [14, -16], [-10, -25], [-24, -30], [59, 4], [24, -22], [-7, -20], [28, 0], [-60, -4], [-70, 0], [-12, 5], [12, 10], [24, -6], [14, -25], [8, 17], [-42, -4], [-10, 4], [-26, -6], [32, -18], [-10, -12], [-21, -20], [36, 11], [-34, -16], [14, 32], [-16, -15], [12, -22], [52, -2], [20, 24], [10, -37], [28, 9], [-10, 4], [-25, 0], [-6, 6], [-60, -6], [-18, 18], [-64, -6], [7, -10], [-28, -3], [4, 8], [2, -30], [24, 20], [48, 12], [21, 36], [-10, 32], [48, 22], [-12, -10], [6, -16], [16, 30], [33, 30], [-26, -14], [12, 20], [28, 6], [24, -18], [0, 2], [24, 4], [10, 24], [8, -10], [0, -26], [-26, 2], [60, -11], [-11, 14], [-6, 44], [-4, -12], [-32, -6], [33, 10], [-6, -20], [-28, 7], [44, -18], [-35, 12], [-44, -14], [6, 14], [10, -4], [26, -16], [-8, -12], [-10, 42], [18, 28], [-16, 30], [-22, -28], [27, -8], [14, 32], [40, 7], [2, -23], [-30, 8], [-25, 26], [-40, -26], [8, -12], [28, 10], [20, -2], [-48, 17], [29, -10], [-36, -8], [79, 4], [48, -10], [-28, 16], [24, 28], [5, 42], [-8, -6], [-16, 10], [52, -20], [-2, -32], [8, 37], [36, 30], [12, 0], [20, -6], [-42, 10], [-13, 18], [46, -1], [29, -22], [80, 2], [-12, -8], [4, -28], [20, -36], [26, 11], [44, -16], [-13, 4], [8, 2], [-30, -14], [12, -10], [-8, -2], [-54, 2], [-38, -9], [50, 12], [-54, 20], [4, 20], [62, 7], [9, -34], [-60, 20], [20, -16], [30, 26], [-64, 0], [-40, -16], [-87, -8], [-4, -34], [-29, 30], [-10, 6], [30, -27], [18, 14], [42, 32], [-44, -6], [26, -20], [-12, -4], [-72, -17], [22, -15], [1, 16], [-66, 18], [0, 26], [44, 22], [8, -2], [-46, 28], [4, -10], [6, -12], [4, -6], [6, -40], [-39, 2], [-78, -12], [8, -2], [24, 10], [-75, 6], [-54, 18], [-32, -12], [-21, -8], [20, 3], [48, 10], [-32, 4], [60, -8], [20, -45], [-64, 12], [-2, -26], [51, 2], [-14, -18], [-16, 14], [-36, 20], [6, -45], [-15, -30], [-56, 8], [4, -2], [52, -14], [-24, 2], [-48, -4], [0, -9], [30, -20], [-2, -30], [32, -2]];
    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_ba();".
// 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_ba(: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_ba();".
// 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_ba( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_6480_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<7,R![1, 4, 1]>,<11,R![-8, 4, 1]>,<13,R![-8, 4, 1]>,<17,R![4, -8, 1]>,<19,R![-2, 1]>,<23,R![1, 4, 1]>],Snew);
    return Vf;
end function;