
// Make newform 4560.2.a.bs in Magma, downloaded from the LMFDB on 25 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_4560_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_4560_2_a_bs();".
// 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_4560_2_a_bs();".
// 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 := [8, -12, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0], [-10, 3, 1], [-8, -1, 1]];
    Rf_basisdens := [1, 2, 2];
    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_4560_a();"
function MakeCharacter_4560_a()
    N := 4560;
    order := 1;
    char_gens := [1711, 1141, 3041, 2737, 1921];
    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_4560_a_Hecke(Kf)
    return MakeCharacter_4560_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], [-1, 0, 0], [1, 0, 0], [0, 0, -1], [-2, 0, -1], [1, -1, 0], [4, 0, 0], [-1, 0, 0], [1, -1, 1], [0, 0, -1], [2, 0, 0], [-1, 1, -2], [1, 1, -2], [-1, -1, 0], [-1, 1, -1], [-3, 1, -1], [-1, -1, 3], [5, 1, 1], [-4, 0, 0], [2, 2, 0], [6, 0, 0], [1, 1, 3], [2, 0, 2], [3, -1, 2], [11, 1, -2], [-2, 0, 2], [0, 0, 4], [0, 0, 4], [1, -1, 3], [-9, -1, 3], [-6, -2, -2], [6, 0, 3], [7, 1, -1], [0, 0, -2], [-8, 2, -2], [8, -2, 2], [5, -1, -1], [1, 1, -2], [5, -1, -1], [-5, -1, 3], [3, -1, -1], [7, 1, 5], [4, -2, 3], [-3, -1, -6], [-5, -1, 5], [6, 2, 0], [6, 2, 2], [2, 2, 2], [-3, 3, -1], [17, 1, 1], [-7, 3, 1], [12, -2, -1], [6, -4, 0], [0, -2, -5], [5, -3, 1], [-5, 1, 1], [-2, -2, 3], [16, 0, 2], [15, 1, -1], [9, 1, -2], [-3, 1, 2], [-17, -1, -1], [-24, 0, 2], [12, 2, -3], [10, 0, 6], [-3, 5, -1], [1, 3, -3], [3, 1, 4], [-2, 0, -6], [4, 2, -2], [-7, -1, 5], [16, 2, -1], [2, 2, -3], [5, -1, 0], [15, 1, -5], [-6, -2, 6], [-14, 0, 0], [23, -3, -1], [-7, 1, -8], [22, 0, -2], [0, 2, 1], [1, 3, 5], [-6, 2, -8], [-19, -1, 2], [25, 1, 3], [6, 4, -4], [-5, -1, 0], [10, -4, 2], [-16, -2, 2], [8, 0, -1], [-6, 4, 4], [30, 0, -1], [-2, -2, -8], [0, 2, -1], [8, 0, -2], [9, -1, -5], [-8, -4, -3], [-15, -3, -2], [-4, -4, -6], [-10, 0, 0], [-16, 0, 2], [6, 0, 0], [-37, 1, 1], [-21, -1, 0], [10, -2, 4], [4, 2, 8], [-4, -2, 2], [-7, -1, -7], [4, 0, 12], [8, -2, 0], [0, 4, 6], [5, -5, 3], [6, 2, 6], [2, -2, 8], [20, 4, -4], [-3, 1, 8], [-23, 1, 0], [-3, 3, -1], [-33, -1, -3], [-13, -5, 1], [-5, -3, 1], [3, 5, 4], [-9, 3, -3], [-18, -2, 2], [18, -2, 0], [2, -4, 4], [-5, -1, -9], [-6, 0, -7], [2, -2, 11], [21, -1, 1], [8, -4, 0], [10, -2, 6], [8, 2, -2], [23, 1, -7], [8, 6, 2], [20, 2, -6], [-25, -1, 1], [4, -4, 2], [-15, -3, 1], [6, 0, -4], [-6, 6, 6], [8, 6, -4], [26, -2, 1], [-3, -1, -1], [-9, 1, 1], [2, 2, -4], [21, -1, -1], [13, -7, 3], [10, 2, -2], [6, 2, -2], [11, -3, 0], [-22, 4, -6], [-13, 3, -4], [-12, 4, -8], [-10, 2, 0], [8, -4, 0], [10, -2, 6], [4, 2, 12], [-2, -8, 6], [24, 0, 9], [-28, -2, 0], [9, 1, 13], [2, -6, -1], [3, 3, -3], [-9, -1, 1], [23, -3, 5], [-29, -5, 5], [17, 3, 3], [-16, 2, -10], [-6, -4, 8], [-25, 3, -1], [-11, 7, 1], [-38, 0, -7], [8, 6, -10], [27, -5, -3], [14, -4, 2], [-10, 2, 0], [30, -4, -2], [14, 2, -12], [8, -2, -6], [-10, 6, -1], [-3, -3, -1], [7, 5, 4], [7, -5, -9], [-37, -3, 3], [-2, -4, 8], [-1, 5, -2], [-16, 0, -6], [28, 2, 12], [-32, -2, 1], [-13, 1, 6], [-6, 4, -4], [14, -6, 2], [-6, -2, 11], [-26, 0, 4], [27, 3, -5], [-1, 3, 7], [-3, 3, -7], [-12, -4, -8], [9, -1, 13], [18, 6, -9], [-29, -5, -3], [-17, 5, 0], [8, -2, -6], [-6, 4, 11], [39, 3, -7], [14, -2, 10], [9, 3, -9], [12, 2, -8], [46, 2, 10], [-8, 2, -4], [18, -8, 2], [-18, 6, 1], [-23, -1, 3], [10, 6, 0], [26, 0, -6], [-8, -8, 3], [17, 5, -6], [13, -1, -13], [11, 3, 9], [9, 7, 1], [-8, 2, -10], [1, 5, -4], [16, -4, 5], [1, -9, -5], [12, 2, 6], [19, -1, 3], [46, -2, -4], [-44, -4, 0], [26, -4, -5], [27, 1, 5], [-1, 5, -1], [-3, 5, 3], [-25, 3, 6], [-41, -1, -10], [27, 5, -5], [-7, -7, -11], [0, -2, -2], [12, 6, 1], [-12, -8, 10], [-10, 6, -6], [-4, 0, -8], [52, 0, 7], [33, 3, -13], [-45, -1, 1], [-30, -4, -13], [22, -6, 3], [3, -5, 5], [1, -1, 13], [-9, -3, -11], [7, -7, 5], [-42, -4, 0], [19, 5, 9], [-2, -4, -2], [25, 1, -1], [-30, -4, -3], [-21, -5, 11], [22, -2, 6], [-51, -3, -1], [-40, 6, 2], [26, 2, -10], [54, 2, -6], [6, 4, 4], [-33, 9, 0], [-6, 10, 2], [-13, 1, -1], [-6, -2, 7], [-4, -6, 0], [20, 0, 12], [3, -5, -11], [5, 7, -11], [-16, -4, 4], [-12, 6, 8], [-34, 2, 4], [-17, -3, -12], [12, 4, 17], [4, -6, -8], [19, 1, 5], [-14, -4, -14], [-18, -4, 5], [-42, 2, 2], [6, 2, -6], [35, 1, -5], [-59, -1, -3], [17, 5, -4], [32, 6, -11], [-6, 0, -16], [-11, 1, -5], [20, 4, -12], [-3, 1, 6], [50, 0, 2], [58, 0, -6], [-15, 1, -5], [15, 3, -5], [-31, -5, -16], [18, 0, -6], [-19, -3, -9], [3, 7, 13], [-51, 1, 7], [-39, -7, 8], [46, 0, 0], [9, -3, -13], [26, -2, 6], [21, 7, -13], [12, -4, -10], [-55, -1, -2], [-6, 6, -10], [37, 3, -3], [4, 2, 13], [-9, 9, 1], [-5, 1, -17], [14, 8, -20], [5, 5, 16], [-12, 12, 2], [27, 1, 1], [0, 6, 10], [-4, -2, -7], [-18, 6, -2], [-28, 6, -8], [-12, -6, 10], [41, -1, -7], [-26, -4, -2], [-8, 4, -7], [-40, -4, 10], [52, 0, -8], [-18, -4, 4], [10, 6, -10], [-40, 0, -6], [39, 5, 5], [1, 5, 11], [14, 4, -12], [-11, 1, -1], [-46, -6, 8], [36, 6, -12], [24, -8, 2], [26, 0, 14], [21, 3, -15], [-9, 7, 1], [1, -3, 21], [-22, 6, 5], [43, -3, 8], [35, 9, -17], [-26, -2, -9], [8, -2, -18], [11, -1, 17], [3, -1, 9], [-39, -3, 9], [-18, 6, -6], [34, 6, -10], [-18, 4, 4], [-19, -1, -3], [-45, -7, 4], [32, -2, 0], [-12, -8, 14], [11, 5, 1], [23, -1, 5], [18, 4, 11], [48, -10, 1], [-12, -4, 20], [30, -6, -2], [-19, 3, -3], [58, 4, -4], [18, -2, 6], [-3, 5, -3], [-25, 7, 8], [17, -5, 8], [-32, 2, -14], [34, 2, -16], [10, 0, 10], [24, 6, 1], [16, 4, 4], [13, 3, 19], [-30, 2, -17], [44, 0, 12], [31, 5, 21], [47, 3, -11], [24, 6, 1], [34, 0, -12], [28, -6, 8], [13, 11, 6], [-36, -4, 9], [-2, 6, -2], [10, -2, -13], [57, 3, -7], [-3, -5, 1], [5, -1, -9], [-26, -6, 0], [-13, -3, -21], [29, 1, -16], [65, 3, 15], [22, -4, 6], [-37, 7, 5], [-24, 2, 9], [-43, 9, -4], [-12, -12, 10], [37, -5, -4], [-32, 6, 6], [27, 3, -16], [7, 1, -1], [26, 0, 0], [35, -7, 3], [6, -10, 14], [8, 0, -2], [-79, 1, 1], [14, -6, -3], [20, -8, 8], [-11, 7, -1], [7, -5, -8], [64, -8, -2], [18, -12, -1], [-7, -5, 4], [45, -7, 7], [12, 0, 12], [-22, -2, 12], [-26, 0, 4], [12, -2, 22], [6, -2, -6], [-2, -2, -10], [5, 11, -3], [-58, 2, 2], [32, -4, -9], [11, 5, -20], [29, -5, 5], [-47, 5, -1], [59, 5, -12], [-3, 1, 1], [32, 0, -12], [-30, 0, -16], [50, 6, -16], [-20, 10, -3]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_4560_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_4560_2_a_bs();".
// 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_4560_2_a_bs(:prec:=3)
    chi := MakeCharacter_4560_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_4560_2_a_bs();".
// 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_4560_2_a_bs( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_4560_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<7,R![-12, -14, 0, 1]>,<11,R![-32, -2, 6, 1]>,<13,R![164, -38, -4, 1]>,<17,R![-4, 1]>],Snew);
    return Vf;
end function;