
// Make newform 6080.2.a.bp in Magma, downloaded from the LMFDB on 24 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_6080_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_6080_2_a_bp();".
// 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_6080_2_a_bp();".
// 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, -5, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0], [0, 1, 0], [-4, 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_6080_a();"
function MakeCharacter_6080_a()
    N := 6080;
    order := 1;
    char_gens := [191, 5701, 1217, 1921];
    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_6080_a_Hecke(Kf)
    return MakeCharacter_6080_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, 1, 0], [1, 0, 0], [-1, 0, 1], [-1, 0, -1], [-2, 1, -1], [2, 0, 0], [1, 0, 0], [-3, 0, -1], [0, -2, 0], [0, -2, 0], [0, -1, 1], [6, -2, 0], [-3, 2, 1], [-1, 0, 1], [-4, 1, -1], [-2, 4, 0], [-1, -2, -3], [1, -5, 2], [-8, -2, 0], [0, 2, 0], [2, 0, 0], [-5, 2, -1], [8, 2, 0], [6, -1, -1], [1, 0, 1], [-1, 1, -2], [3, -3, -2], [-2, -4, 2], [12, -3, 1], [-1, -1, 2], [4, -6, 2], [8, 0, 6], [1, -4, 1], [-9, -2, -3], [4, -6, 6], [0, -8, 2], [-5, -2, -1], [-15, 5, 2], [-12, 3, 3], [-6, 0, 0], [2, 8, -4], [-2, 0, 6], [2, 3, -5], [-12, 2, 4], [0, -4, 4], [0, 2, -2], [-9, 5, -4], [1, -11, 4], [-9, 8, -1], [-4, 6, 4], [-14, 2, -8], [-4, 2, -2], [-2, 0, -6], [4, 5, 3], [-1, 4, 5], [0, 0, 8], [1, 8, -3], [-16, 4, -2], [-6, 10, 0], [17, -2, 1], [-10, 5, 5], [-5, -7, 2], [-3, 4, -3], [-8, 10, 4], [8, -11, 9], [-6, -10, 4], [6, -7, 7], [-17, 4, -3], [16, -10, -4], [6, 12, 0], [-1, 0, -9], [-11, 10, -7], [10, 5, 5], [-12, 0, 4], [1, -1, -2], [-8, 6, -8], [-10, 10, -10], [0, -12, -2], [0, 4, -4], [6, 6, 0], [8, 6, 6], [2, -6, -4], [-8, 5, -7], [-24, 8, -2], [-9, 0, -3], [10, 0, 6], [-10, 8, -12], [6, 0, 0], [5, -12, 3], [-5, -8, 1], [19, 4, -1], [-19, 1, -4], [14, -8, 14], [-1, 0, 3], [13, -4, 7], [-14, -2, -2], [-12, 0, 2], [9, -1, 0], [3, 8, -9], [-9, 5, 8], [-28, 4, -6], [-23, 7, -8], [20, -4, -4], [19, 0, 7], [8, 10, 0], [1, -6, 1], [-14, 4, 4], [0, 0, -2], [-8, -6, 2], [-5, 5, -2], [4, -6, 8], [8, 2, -8], [13, -4, -7], [-15, 0, -7], [-12, 6, 6], [-7, 8, 3], [-31, 2, 1], [12, -6, -4], [-14, -4, 4], [12, 10, 2], [2, -17, 5], [-14, 9, 1], [21, -5, 12], [11, -16, -1], [9, 18, -1], [12, 2, 8], [-7, 16, -3], [-19, -6, 5], [-10, 2, -10], [-8, 0, -12], [3, -9, -6], [-18, 10, -8], [12, -14, 4], [-25, 4, 7], [-9, 0, 11], [-32, 5, 1], [-33, 5, 0], [16, -11, 3], [-12, 6, -12], [-16, -2, -12], [-12, -2, 0], [31, 10, -1], [-23, 11, -12], [22, 0, -2], [40, 4, -2], [-16, 12, 6], [24, -15, -9], [10, 2, -4], [5, 7, -8], [-26, 5, -11], [-9, -2, 1], [-9, -16, 9], [-13, 15, -12], [-1, -3, -2], [10, 6, 8], [-14, -6, 4], [30, 0, 0], [4, -18, 4], [4, 12, 2], [-15, 20, -1], [10, -15, 9], [19, -10, -5], [30, 6, -6], [6, -9, 1], [3, -13, -8], [-16, 18, -10], [-14, 4, 12], [-12, -14, 4], [-2, 6, 6], [44, -4, 12], [-20, 8, -6], [15, 12, -1], [4, 8, 6], [6, 24, -10], [23, -16, -5], [-36, 10, -10], [1, -16, 5], [9, 7, -4], [5, -6, 11], [-3, -6, 13], [30, -14, 6], [-8, -7, -7], [12, -9, 19], [-5, -8, -3], [10, -16, -4], [14, -1, -11], [27, 3, -2], [-10, 4, -6], [38, -4, 2], [0, -7, 3], [19, 14, -1], [20, -6, -8], [-26, 10, -4], [5, -16, 11], [6, 17, -5], [-26, 8, -12], [12, -2, 12], [36, 0, 6], [23, 12, -7], [-26, 10, -22], [-14, 2, 12], [-8, 17, 5], [-12, 10, -8], [-41, 8, 3], [-42, -2, 6], [15, 16, -1], [5, 13, -4], [12, -2, -4], [-20, 22, 0], [-22, 8, 4], [-21, -2, 9], [37, -12, 15], [27, 11, -2], [8, -12, 8], [36, 14, -6], [-3, -16, -1], [28, 0, -2], [-9, -9, -2], [-6, -18, -6], [12, -26, -2], [6, -4, 6], [12, -2, 4], [31, -14, -1], [-1, 5, 2], [-14, 4, 8], [4, -5, -17], [-2, -4, 6], [7, -17, 4], [18, -24, -2], [10, -16, 12], [-12, 24, 4], [36, -2, 2], [16, 18, 2], [9, 2, -11], [55, -2, -1], [1, -6, 19], [8, -10, 0], [27, 0, 3], [16, -14, 14], [-39, -1, 2], [-20, 2, 10], [-1, 16, -7], [-12, 18, 4], [18, -13, -1], [8, 0, -4], [-31, 10, -15], [-6, -6, -8], [-6, 8, 18], [21, -6, -15], [-10, 2, 10], [-14, 16, 0], [-9, -28, 5], [-14, 16, 14], [-6, 0, 16], [-4, 4, 8], [4, 2, 0], [5, 11, 18], [10, 13, 1], [-28, 2, -12], [-27, -23, 8], [13, 3, -8], [-39, 16, -3], [0, -19, -13], [-6, 14, -2], [16, 4, -6], [40, -2, 16], [13, -12, 21], [-1, 21, 6], [-20, -20, 14], [-10, 0, 12], [-9, -25, -2], [22, -6, -6], [1, -8, -23], [30, -17, 11], [-11, 6, 5], [23, -16, 1], [-4, 18, -8], [2, -2, -20], [-15, 8, 13], [-1, -1, -4], [-33, 0, -21], [-33, 8, -15], [16, 4, -18], [-55, -4, -1], [35, 0, 11], [12, -6, 16], [-4, 17, -19], [2, -2, -8], [2, 24, -6], [28, -14, -4], [-23, -2, -19], [-48, 3, -7], [0, 18, 6], [-20, 15, -1], [-15, 6, 3], [6, -2, 2], [-10, 24, 0], [-10, -16, -10], [-17, -6, -13], [34, -16, -4], [-6, -9, 13], [-15, -4, 17], [-51, -3, -6], [16, -18, -2], [-58, 1, -1], [-5, -17, -2], [38, -14, 26], [-28, 28, -4], [-8, 14, -12], [-13, 8, 13], [25, -12, 17], [18, -20, -20], [-3, 23, -8], [-29, 22, 15], [-42, 22, -2], [3, -16, -9], [-4, -6, 2], [-30, -10, 6], [-46, 4, 4], [-30, -2, 14], [36, -18, -8], [6, 2, 0], [-17, 11, 16], [24, -24, 14], [-30, 14, -24], [8, -12, 10], [9, 7, -20], [25, -5, 4], [26, -18, -10], [-37, -6, -3], [32, 3, -13], [19, -20, -5], [13, 16, 7], [-45, -16, 11], [-1, -22, 19], [58, -16, 6], [32, 9, 11], [2, 24, -12], [-55, 2, 1], [0, 23, 7], [-16, 8, 6], [8, 20, 12], [-6, -26, 14], [18, -35, 1], [32, 12, 2], [-34, -8, -8], [13, -21, 8], [-14, 10, -6], [-24, -26, 0], [24, -22, 8], [-16, -17, 11], [15, 18, -19], [15, -17, -20], [10, -2, 10], [-28, 23, -29], [78, -2, 4], [4, 6, -2], [-6, -16, -8], [-13, -13, 10], [-10, 24, -12], [-13, 4, -17], [-21, 21, -6], [-2, 16, 2], [-11, 30, -15], [42, -23, 7], [14, 14, 2], [25, -25, -14], [2, 14, 4], [-5, 28, -5], [-60, 8, -10], [-11, -32, 11], [10, -8, -2], [-14, 12, 2], [14, -8, -8], [10, -20, 18], [38, -28, -6], [-12, 18, -8], [32, 14, -8], [-2, -37, 3], [10, -20, 12], [-12, -24, -6], [15, 2, 7], [0, -6, 8], [-18, -4, 20], [-1, -7, -18], [-9, 4, 19], [28, -16, 2], [-9, 20, 5], [3, 1, 2], [-40, 16, -16], [10, 19, -3], [-14, 6, -20], [-53, 10, -21], [32, -10, -14], [24, 11, 11], [-66, -12, 8], [2, -2, -2], [-68, 2, -4], [-10, 20, -4], [76, -8, 12], [8, -40, 14], [-37, 25, 12], [-14, -21, -15], [-26, 24, 2], [-4, 2, -2], [2, 6, -2], [-14, 8, -8], [-11, 19, 20], [-8, 28, -4], [-26, 21, 13], [60, -18, 8], [9, 9, 20], [23, 32, -17], [12, -8, -22], [-16, -6, 8], [32, 8, -14], [-39, 7, -20], [-32, -18, 12], [27, 3, -16], [-40, 4, -12], [96, 5, -1], [33, -12, -21], [-38, 24, -10], [-44, -11, -7], [60, -21, -1], [-11, -1, -20], [-33, 10, 1], [-44, 2, -26], [43, 4, 7]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_6080_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_6080_2_a_bp();".
// 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_6080_2_a_bp(:prec:=3)
    chi := MakeCharacter_6080_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_6080_2_a_bp();".
// 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_6080_2_a_bp( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_6080_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<3,R![-2, -4, 2, 1]>,<7,R![-4, -4, 4, 1]>,<11,R![-12, -8, 2, 1]>],Snew);
    return Vf;
end function;