
// Make newform 7500.2.a.e in Magma, downloaded from the LMFDB on 16 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_7500_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_7500_2_a_e();".
// 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_7500_2_a_e();".
// 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, 7, -6, -2, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0], [0, 1, 0, 0], [-4, -1, 1, 0], [0, -4, -1, 1]];
    Rf_basisdens := [1, 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_7500_a();"
function MakeCharacter_7500_a()
    N := 7500;
    order := 1;
    char_gens := [3751, 2501, 6877];
    v := [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_7500_a_Hecke(Kf)
    return MakeCharacter_7500_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, 0, 0], [0, 0, 0, 0], [1, 1, 1, 0], [1, -1, 1, 1], [2, -1, 0, 1], [1, -1, -1, 0], [-1, -1, 0, -1], [3, -2, -1, 1], [2, -1, 0, 0], [2, 1, -2, 3], [2, -3, 0, 0], [-1, 4, 2, 0], [-1, -2, -1, 0], [6, 1, 6, -2], [1, 1, 3, 2], [-4, 1, -7, -1], [-1, -2, 8, -2], [9, -2, -1, -2], [6, 1, 3, 0], [0, 2, -3, -2], [3, -4, 4, -1], [-1, 6, -4, 2], [-8, 1, -6, -3], [-3, 4, 2, 4], [-2, 1, 5, 2], [4, 1, -6, -1], [5, 4, 3, 0], [-9, 2, -2, 5], [11, 1, -2, 3], [6, 1, -2, 6], [-2, -2, -5, -5], [10, 1, 9, -3], [-12, -2, -10, 4], [11, 0, 10, -3], [0, -4, 7, -2], [-3, -4, 6, -5], [3, -3, 1, -6], [-2, 1, -3, -2], [3, 1, -6, 0], [6, 1, -5, 5], [2, 3, -8, 5], [14, -7, 4, 3], [-8, 5, -8, 3], [9, -6, -1, 0], [12, 1, 1, 1], [-8, -3, -3, 3], [-2, 7, 6, -1], [2, 1, 8, -6], [10, 1, 15, -7], [-1, -6, 1, -3], [-13, 3, -10, 2], [-13, 0, -1, -7], [-5, -1, 14, -2], [-1, -7, 1, 3], [2, 4, -5, 2], [6, 6, -8, 8], [5, 0, -4, 7], [13, 5, 14, -9], [16, -7, -3, -3], [18, -7, 4, 3], [2, 2, -16, 2], [13, 0, 6, 3], [3, 6, 5, -2], [-8, 4, -9, -2], [-12, 1, 2, 6], [-4, 2, -10, -5], [14, -2, 2, 1], [23, 1, 12, -2], [10, 1, 12, -6], [-3, -4, 2, -1], [9, -3, -4, -3], [10, 1, 3, -3], [-6, -2, -8, 9], [-1, 8, 14, -3], [9, -2, 3, 4], [0, -11, -10, 4], [1, -1, -6, 7], [5, 7, 13, -1], [0, 5, 8, 0], [-10, -3, -7, 0], [-17, 6, -17, 3], [16, 3, -2, 7], [0, 2, -7, -3], [-1, 4, 3, -4], [16, 0, 1, -4], [10, -1, 15, -4], [18, -3, 18, -5], [20, 2, 7, 6], [9, 0, -2, -2], [-13, 1, -7, 2], [14, -2, 15, -14], [-12, -1, 5, -3], [12, -2, 10, -7], [18, 4, 10, -6], [5, 6, 13, -10], [-8, -3, -7, 3], [15, -8, -7, -5], [4, -2, 0, 5], [0, 2, -5, 2], [16, 0, 5, -4], [-12, 11, -2, 5], [-7, -2, -15, -2], [11, 0, -9, -2], [10, -5, 6, -7], [11, -3, -6, -3], [13, -6, 12, -8], [-3, -1, -23, 3], [-1, -1, -17, 4], [3, 4, -3, 4], [-1, 4, -20, 2], [-10, 3, 3, 3], [-12, -2, -11, -11], [6, 6, 13, 4], [-25, 1, -15, -1], [-12, -7, 6, 0], [5, -7, 18, -6], [18, -3, 22, 5], [-27, 4, 0, 1], [-5, 13, -14, 7], [-16, 0, -4, -8], [15, -9, -11, -6], [-19, 3, -1, -2], [8, -4, 9, -5], [-4, 10, -6, 9], [28, -10, 2, 4], [-14, 10, 3, -8], [1, -4, 12, -10], [5, 9, 12, 6], [13, 12, -10, 7], [4, 5, -7, 0], [17, -2, -7, 2], [-8, 12, -2, 3], [-3, 6, -9, 12], [17, -11, 0, -2], [-14, -8, 15, -5], [-12, 8, -2, 9], [-23, 2, -13, 0], [12, -2, 16, -11], [12, -16, -12, -4], [0, -9, -2, 1], [-25, -5, -5, 6], [23, -2, 7, -8], [-8, 10, -21, 7], [2, -11, -16, -5], [13, -4, -10, 3], [-26, 12, -2, -9], [-6, -7, -1, -19], [23, -10, 5, 7], [21, -6, 16, -3], [-6, -3, 19, 1], [2, 0, 2, 4], [-4, 5, 1, 4], [47, -4, 3, 5], [-5, 13, 0, -1], [-15, -3, -11, 14], [-23, 10, -1, 8], [5, -4, -12, -11], [-17, 2, -4, 7], [4, 5, -16, -2], [-3, 5, -18, 17], [-16, -12, -10, 6], [2, -18, -11, -1], [14, -10, 3, 3], [6, -1, 4, 11], [-8, -2, 9, -1], [9, -2, -1, -8], [-28, -4, -9, -8], [0, -10, -3, -8], [9, -7, 16, -14], [9, -2, -16, 7], [-24, 0, -3, 12], [-13, 2, 16, -3], [-9, 12, -8, 16], [12, -16, 18, -11], [-32, -3, -16, 1], [-24, 4, -19, -1], [26, -4, 16, -6], [24, -2, 12, 13], [5, -1, 2, 13], [-6, 15, 3, -6], [11, -13, 27, -10], [-7, -11, 1, 1], [22, -4, 36, -6], [24, -6, 16, 2], [-22, 16, 13, 8], [-3, 0, 3, 6], [-7, 7, 2, 0], [2, 12, -16, 12], [17, 4, -6, 12], [22, -7, 15, -5], [-3, 20, -12, 6], [-7, -17, 21, -13], [30, 6, 27, -3], [-3, 5, -31, -2], [-41, -1, -38, 1], [1, -4, 0, -2], [-19, -2, 20, -5], [-28, 2, -18, 19], [-22, 12, 7, 12], [-1, 11, -12, -2], [0, -2, 17, -14], [-18, 8, -33, 2], [-40, -4, -17, 2], [-3, -9, -27, -5], [-13, -4, -23, -3], [-58, 5, -10, -3], [1, -11, 31, -14], [22, 4, 29, 2], [13, 0, -14, 13], [2, -1, 3, 8], [-10, -6, -8, -16], [13, -11, 19, -7], [-3, -15, -22, -2], [-4, 12, -28, 20], [-35, -1, -11, 0], [-15, 1, 11, -18], [19, 13, -20, 13], [-39, 15, -22, -5], [-8, 12, 35, 3], [-9, 1, 15, -2], [33, -12, -2, 6], [24, -6, 12, -15], [7, 11, -11, 11], [-20, -11, 13, -8], [-23, 6, -25, -11], [-37, 15, -11, -9], [11, 9, -3, 10], [-15, 11, -15, -1], [-2, -2, 18, -8], [-36, -1, -26, -3], [-7, -4, 12, 0], [19, 14, 2, 0], [22, -13, 6, -7], [20, -4, 21, -2], [9, -1, -34, -4], [25, 7, 28, -12], [-10, 19, -32, 8], [-13, 0, -15, -10], [12, -15, 6, -12], [12, 1, 4, -14], [-27, 5, 10, 5], [-32, 15, -8, 10], [-9, 4, -8, -14], [-17, 12, 7, -4], [-11, -1, 14, -6], [0, -17, 10, 6], [36, -2, 23, 10], [-13, 19, 18, 5], [12, 1, 22, -1], [-13, -15, 8, 5], [20, 5, -15, 17], [-10, 4, -20, 0], [30, -5, 29, 0], [38, -1, 33, 7], [-21, 2, 16, -10], [-25, 12, 20, 11], [-10, -10, -42, -5], [-33, 12, -3, 3], [2, 1, 23, -12], [8, -3, 2, -7], [-18, -5, -26, 17], [-5, -9, -29, -8], [-27, -15, 6, 0], [-13, 3, -22, 9], [-38, 13, -21, -6], [40, -4, 26, -8], [12, 14, 13, 8], [31, -4, 40, 2], [0, 2, 7, 7], [-8, -4, -31, -7], [4, 2, -22, -2], [1, -5, -11, 0], [-14, 27, 1, -8], [-11, 5, 14, -2], [-28, -9, -12, -4], [3, -7, -6, 9], [29, 9, 5, -1], [-28, -1, -23, 5], [-14, 19, -25, 14], [22, 6, -3, 10], [-21, 23, -11, 11], [9, 17, 29, 1], [4, -22, 0, 9], [-18, 15, -43, 8], [5, -17, 0, 4], [-59, 0, -28, -1], [-40, 15, -20, -9], [2, -12, -1, -28], [47, 11, 10, -6], [39, 0, 6, -15], [-28, 4, -18, -5], [-4, 5, 19, 6], [-13, -1, 15, 7], [-2, 4, 20, -7], [27, -2, 2, 16], [-21, -9, -41, -5], [-5, -16, 16, -24], [-24, 1, -24, 18], [13, -7, 5, 19], [12, -14, -4, 1], [-24, -13, 0, -10], [-28, 20, -7, 0], [5, -5, 3, 10], [25, -10, 1, -16], [11, -9, 26, -13], [7, 1, 9, 21], [27, -12, 12, 0], [-6, 0, 14, -8], [10, 12, 40, 1], [-15, -10, -23, 20], [13, 19, 12, -14], [17, -13, -1, -11], [14, 11, 28, 7], [11, -3, 14, -1], [5, -15, -14, 11], [-31, 17, -28, 2], [-7, -6, 22, 9], [6, 1, -16, -2], [1, -7, -16, 23], [-33, -13, -18, 8], [-3, -17, -10, -18], [-6, 13, -5, -14], [38, 4, 47, -5], [-26, -10, 0, -7], [-2, -26, 21, -13], [-10, -15, 2, -10], [-40, 0, -7, -19], [42, -15, -3, 4], [30, 7, 4, 14], [28, -4, 21, -14], [-40, 13, 0, -3], [25, 5, 11, -3], [30, 6, 38, -29], [23, -7, 1, -16], [7, -22, 11, -17], [16, 5, -13, -7], [-11, -7, -36, 5], [4, -4, -19, 23], [5, 0, 55, -2], [2, 2, 27, 2], [28, -4, -17, -2], [-18, -1, -44, 2], [-22, -14, -28, 12], [-3, 19, -18, 1], [-23, 19, -27, -8], [-4, 17, 2, 16], [9, -7, 5, 21], [-31, -2, -43, 3], [-29, 11, -4, -18], [-25, 14, -30, -12], [-11, 15, -43, 8], [-7, 15, -24, 11], [35, -9, 21, -12], [-4, -22, 11, -2], [-42, -3, -33, -6], [27, -3, 40, -1], [19, -21, -2, -14], [7, 7, -6, 34], [29, -22, -20, -6], [-8, -7, -36, -11], [-34, 1, -7, -1], [8, -29, -14, -3], [-20, 7, -12, -5], [-27, 30, 3, -4], [0, 25, -12, 4], [25, 6, 35, 9], [36, -15, 28, -14], [-7, -3, -6, -12], [28, 3, 17, -6], [-24, 16, 9, -1], [35, -21, 14, 14], [-3, 3, 42, -8], [22, -21, 3, 12], [-37, -5, -25, -8], [10, 5, 8, -22], [-49, -2, -16, -10], [6, 28, -13, 4], [14, 23, 29, -1], [19, -14, -3, 9], [5, -10, 23, -22], [27, 4, -3, -2], [16, 14, -14, -4], [28, -31, 0, 17], [23, -15, 7, 7], [-61, -8, 19, -6], [5, 23, -20, 14], [-14, -5, 6, -14], [-33, 4, -28, 19], [-40, 6, -43, -9], [-13, -9, -10, 4], [-66, -9, 5, -8], [9, -19, -8, 14], [-14, -15, 40, -4], [-10, 0, -34, 3], [16, 4, -41, 6], [-19, -20, -28, 10], [26, 4, 37, -13], [44, 5, -21, 5], [-25, -4, -50, 9], [49, 14, 34, -16], [53, -11, -11, -13], [45, 5, 55, -2], [21, -1, 11, -20], [-23, -12, 16, 1], [40, -30, -5, -6], [-25, 12, 8, 1], [19, -9, 19, -2], [-63, 21, -33, -16], [-26, 16, -14, -8], [31, -32, -17, 2], [-10, -19, -14, 9], [10, -11, -18, 3], [-1, 15, -6, -7], [32, -5, -30, 8], [-1, 15, 21, 19], [-15, 9, 32, 13], [26, -21, -6, 21], [24, -8, -3, -2], [9, -4, -17, -21], [-61, 8, -12, -8], [-53, 10, -9, -10], [-21, -23, 20, -21], [-54, -12, -30, 2], [1, 4, -31, 8], [30, -12, 46, -13], [14, -8, -37, -13], [13, 18, -12, 5], [38, -1, 3, 19], [44, -10, 5, -4], [-46, 4, 17, -2]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_7500_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


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