
// Make newform 8280.2.a.bc in Magma, downloaded from the LMFDB on 24 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_8280_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_8280_2_a_bc();".
// 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_8280_2_a_bc();".
// 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 := [-11, 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_8280_a();"
function MakeCharacter_8280_a()
    N := 8280;
    order := 1;
    char_gens := [2071, 4141, 4601, 1657, 3961];
    v := [1, 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_8280_a_Hecke(Kf)
    return MakeCharacter_8280_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+1)]];
    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], [-3, 0], [1, 1], [1, -1], [0, 1], [-5, 1], [-1, 0], [4, -1], [-3, -2], [5, 2], [0, -1], [-4, 2], [-1, -3], [0, 3], [2, 3], [7, -1], [9, -2], [-2, 3], [5, -1], [0, 0], [-2, -1], [-2, -2], [12, 0], [-2, -1], [18, 0], [4, 3], [-1, -3], [-12, -1], [5, -3], [0, 0], [0, 4], [5, -2], [1, -1], [-8, 2], [13, -2], [-10, 4], [-3, -5], [-4, 0], [16, -2], [14, 2], [-3, -5], [6, 2], [8, 6], [8, -2], [3, 2], [10, -4], [28, 0], [10, 2], [-8, 0], [6, -3], [-3, 7], [-10, 4], [9, 3], [-12, 5], [6, -5], [11, -4], [18, 0], [7, 3], [1, 2], [-2, -3], [-15, 3], [-16, -4], [27, -2], [13, -1], [-5, -8], [18, 4], [18, -2], [-15, -2], [-3, 7], [-1, 9], [9, -8], [10, 6], [20, 0], [-16, -1], [4, 6], [12, 0], [0, 6], [7, -2], [15, -1], [7, 5], [10, 2], [-17, 2], [-22, 0], [25, -1], [4, -1], [19, -2], [4, 2], [15, -7], [20, 3], [-15, -1], [-3, 5], [0, -3], [5, 4], [-8, -9], [-8, 0], [-3, 1], [4, -8], [8, 4], [-12, -4], [16, 3], [-40, 1], [16, -6], [15, 3], [4, -4], [-2, 0], [19, 1], [-22, -2], [3, 2], [-13, -5], [-34, 0], [-22, -3], [4, 12], [7, 3], [-7, 5], [-5, -4], [-1, -5], [27, 7], [21, 5], [-28, -2], [-13, 3], [36, -3], [-17, 1], [4, 2], [7, 1], [-17, -9], [8, 9], [17, -2], [-29, -4], [-37, 0], [-8, -12], [19, 9], [3, 8], [-22, -5], [-5, -5], [12, -10], [27, 8], [12, 9], [28, -7], [-9, -10], [-16, -4], [40, 4], [-2, -5], [19, 0], [6, -4], [20, 2], [2, -8], [27, -2], [8, -2], [-8, -6], [25, -5], [-15, 1], [-40, 2], [1, 2], [-8, -12], [-4, -4], [14, 1], [40, 0], [-21, 5], [6, -2], [26, -8], [9, -3], [-2, -2], [16, -9], [-18, 11], [19, 10], [18, 2], [-20, -8], [-39, -5], [0, 8], [1, 8], [-34, -4], [-39, 0], [0, 0], [-15, 11], [26, 0], [-6, -3], [51, 2], [-31, 7], [17, 11], [-25, 5], [16, -14], [41, -3], [-44, -3], [-29, 7], [-15, 11], [3, 10], [35, -4], [2, 19], [-31, 3], [-10, -16], [17, -5], [30, -11], [32, 6], [24, -11], [-23, 7], [-12, -8], [6, -12], [-34, 8], [21, 7], [0, -2], [19, 9], [-33, 1], [-31, -5], [-36, -6], [9, 5], [11, -1], [-28, 3], [-20, 2], [4, -18], [-36, 2], [-18, 0], [-12, -6], [-32, -7], [55, -5], [0, 18], [-28, 7], [-20, 1], [1, -15], [15, 12], [-8, -18], [10, -15], [-13, 14], [-9, -5], [5, 10], [48, -6], [-54, 1], [20, -8], [-36, 1], [-11, -1], [-19, -5], [4, 6], [12, 7], [27, 0], [-32, -6], [-7, 5], [-18, 4], [-40, -3], [40, -1], [-44, 5], [-47, 6], [20, 6], [0, -4], [-12, 4], [-30, 14], [5, -3], [31, 3], [8, -2], [-4, -11], [-28, 4], [-22, 4], [44, -5], [16, 10], [-39, 1], [-30, -9], [-25, -1], [12, 20], [-55, -3], [-34, 0], [9, -20], [-10, 11], [-3, -8], [39, 12], [30, 6], [-33, -1], [55, -7], [-26, -4], [9, -2], [44, 0], [13, -6], [19, 12], [-43, -6], [-18, -12], [-15, -11], [37, 7], [13, 11], [-31, -6], [25, -7], [-53, -7], [34, -12], [-79, 1], [14, 2], [-16, 4], [15, -19], [-18, -11], [-23, -8], [-50, 0], [-2, 4], [-28, -2], [-32, -6], [54, -7], [-22, -6], [47, -3], [-3, -7], [-4, 12], [-19, 7], [-45, 3], [-56, 7], [-58, 0], [-45, 4], [-24, -7], [-2, -2], [-41, 13], [-12, 8], [-37, -5], [11, 7], [22, -8], [7, -3], [-19, -7], [28, 8], [-21, -5], [-31, 7], [12, -8], [54, 1], [15, 15], [32, -15], [46, 1], [27, -2], [-20, 8], [-11, 9], [-37, -10], [-38, -8], [46, -12], [-32, 3], [1, -3], [17, 13], [-63, -5], [-32, 12], [-62, 1], [-19, 6], [-5, -9], [39, -2], [59, 7], [-8, 16], [-4, -8], [-48, -6], [8, 2], [76, 4], [39, 12], [40, 6], [-34, -4], [48, -2], [-33, 7], [30, 7], [-2, 7], [3, -8], [-27, -13], [-30, -16], [-32, 15], [19, -10], [19, -1], [-8, -7], [35, -14], [31, 11], [-18, 12], [-3, 9], [2, 8], [77, 5], [4, -2], [19, -12], [-20, -13], [60, 6], [-2, 18], [8, 14], [28, 6], [23, 21], [-17, -4], [0, -4], [0, -9], [35, -4], [62, -8], [-30, -14], [-24, 0], [-9, 9], [-32, 9], [20, 6], [-5, 14], [54, -6], [16, 10], [40, -6], [4, 6], [-20, -4], [-47, 5], [-38, -6], [54, 0], [-27, -20], [31, 7], [-1, 6], [8, 9], [-27, -13], [-12, -22], [-34, -1], [61, -3], [61, 1], [3, -10], [72, 6], [26, 2], [28, 4], [-8, 3], [-33, -20], [46, 0], [15, -12], [-32, 15], [-32, 13], [11, -18], [1, -24], [-8, -10], [0, -14], [-4, 16], [51, -5], [-7, 5], [44, 0], [34, 6], [-3, -6], [66, 4], [66, -10], [-33, -5], [-14, 7], [-54, -10], [39, -5], [-36, -20], [5, 17], [8, 0], [-17, 7], [-52, -4], [-58, -2], [14, -9], [74, -8], [10, -7], [-16, -12], [6, 0], [-6, 16], [78, -1], [65, 1], [17, -13], [51, -6], [-78, 8], [42, -4], [32, 2], [-66, 0], [17, 1], [-23, 24], [-32, 0], [31, 12], [35, -7], [14, 12], [11, -15], [53, -10], [-26, 20], [9, -15], [39, -9], [31, 11], [-92, -2], [-56, 4], [68, 11], [-13, 8], [-34, -6], [3, 6], [-24, 25], [41, -2], [69, -5], [36, -4], [71, 4], [-30, -18], [3, 27], [-57, 3], [26, -17], [-13, -1], [46, 4], [34, -2], [-23, -3], [-40, -22], [-18, 2], [38, -7], [-85, -4], [-16, 3], [24, -16], [-19, -17], [-36, 2], [27, 11], [4, 24], [35, 2]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_8280_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_8280_2_a_bc();".
// 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_8280_2_a_bc(:prec:=2)
    chi := MakeCharacter_8280_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(3457) - 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_8280_2_a_bc();".
// 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_8280_2_a_bc( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_8280_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<7,R![3, 1]>,<11,R![-10, -2, 1]>,<13,R![-10, -2, 1]>,<17,R![-11, 0, 1]>],Snew);
    return Vf;
end function;