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