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