
// Make newform 9075.2.a.cl in Magma, downloaded from the LMFDB on 17 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_9075_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_9075_2_a_cl();".
// 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_9075_2_a_cl();".
// 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, 1, -3, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0], [0, 1, 0, 0], [-1, -1, 1, 0], [1, -2, -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_9075_a();"
function MakeCharacter_9075_a()
    N := 9075;
    order := 1;
    char_gens := [3026, 727, 5326];
    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_9075_a_Hecke(Kf)
    return MakeCharacter_9075_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 := [[-2, 1, 1, 0], [-1, 0, 0, 0], [0, 0, 0, 0], [0, -2, 1, 1], [0, 0, 0, 0], [-1, 1, -1, 1], [-5, 0, 0, 0], [-1, -3, 2, 3], [0, 1, 1, 1], [-1, 1, 4, 0], [0, 3, 0, -2], [0, -1, -1, 5], [6, 4, 1, -5], [3, 0, 1, -6], [6, 4, -1, -3], [-1, -6, -3, 5], [-5, 1, 1, 6], [3, -3, -6, -2], [5, 5, -5, -1], [-4, 3, -2, -4], [-2, 3, -5, -4], [2, 2, 2, -7], [-10, -5, -2, 8], [2, 2, 0, 3], [1, -4, -3, 3], [-3, 5, 1, 0], [7, -5, 0, -5], [-1, -7, -6, 5], [-4, 6, 7, -2], [6, -5, -4, -6], [8, 4, -3, -4], [4, -11, -6, 5], [-9, 3, 1, -1], [3, 4, -3, -6], [0, -3, 1, 4], [1, 0, -4, -3], [3, 11, 6, -10], [2, -8, -8, 1], [-8, 6, 6, -8], [-6, -7, 1, 6], [-3, -3, 0, 5], [6, -3, 6, 5], [7, 11, 6, -12], [-9, 2, 10, -6], [-17, 4, 3, -2], [-4, 9, 0, -7], [-14, 6, 3, 11], [13, -6, -4, -11], [-7, -1, -5, -2], [-10, -10, 3, 2], [-2, 5, -5, 5], [4, -6, 3, 3], [1, 4, -4, -2], [-9, -6, 6, -6], [-11, 7, 6, -3], [7, 4, -9, -10], [2, 0, 7, 6], [11, 1, 1, 0], [8, 7, -4, 0], [5, -8, -8, 2], [-5, 3, -3, 10], [8, -11, 0, -3], [-9, 2, 9, 5], [17, -2, -15, 1], [8, -10, -6, 7], [-6, 4, -6, 2], [-6, -10, -3, 7], [-5, -11, 6, -7], [-18, -5, 1, 11], [18, -9, -16, -2], [12, -4, 6, 5], [-8, 12, 11, -1], [-2, -2, 11, -1], [2, 5, 4, 2], [1, -2, -11, 2], [-21, 12, 11, 5], [1, -6, -13, -5], [-5, 9, 13, -14], [5, -11, -19, 9], [18, 4, 0, -20], [-8, 4, 9, -17], [-11, 8, 21, 1], [4, -2, -16, 15], [10, -9, 4, 0], [-13, 5, -3, 3], [-8, -8, -6, 7], [4, 7, 6, -7], [4, -21, -16, 12], [-9, -16, -6, 21], [-6, -14, -8, 23], [-12, 17, 5, 4], [13, 1, -8, -27], [-4, 8, 0, -13], [5, -2, 5, -12], [29, -11, -14, -10], [-7, 6, 0, 6], [5, 3, -7, -15], [-8, -11, -17, 18], [21, 3, -4, 2], [0, -7, -17, 1], [15, -4, -18, 11], [-4, -4, 5, 7], [-13, 0, -9, -5], [-3, 3, -14, 7], [-7, 7, -10, -19], [-7, -3, 2, -3], [-10, 6, 13, 3], [-11, -12, 8, -1], [-3, -10, 8, 15], [-4, -3, -11, 22], [33, -5, -7, -8], [4, -5, -1, -7], [-4, 23, -8, -18], [13, 28, 6, -26], [-13, 17, 5, 4], [-2, 4, 7, -2], [-1, 6, 6, 1], [-16, 1, -2, 1], [-7, -4, 10, 9], [-19, 4, -6, 16], [-13, 0, 0, 14], [4, -23, 4, 9], [-11, -22, 3, 4], [-17, 14, 6, 5], [-28, 7, 23, -3], [-25, -13, 7, 4], [8, -2, -6, 25], [18, -22, -3, 14], [10, -10, 10, 4], [-23, 7, -6, -8], [-7, -4, 15, -11], [-4, 11, 16, -3], [3, 19, -1, -12], [-16, 18, 28, -8], [16, 5, 8, -2], [21, -6, 0, 10], [6, -5, 8, 11], [16, 1, 4, -3], [6, -3, -6, 9], [5, 13, -2, -11], [-2, 3, -15, 14], [-13, -13, -19, 17], [-12, 17, 25, -8], [8, 13, 2, -11], [2, -9, 6, -24], [-25, -4, 10, 14], [4, 7, 3, -10], [-12, -6, -15, 5], [28, 21, 3, -12], [-2, 11, -11, 15], [-9, -13, 0, 12], [0, 17, 8, -12], [10, 34, -12, -7], [7, 29, -3, -14], [9, -6, 0, -24], [-7, 4, -16, 7], [-19, 15, 6, 13], [8, 7, 2, -25], [-25, 5, 9, -14], [-17, 18, 4, 4], [15, 12, 15, -12], [11, -15, -23, 9], [3, -9, -1, 23], [20, -22, -2, -8], [-20, 6, 11, -16], [-20, 10, -5, -13], [-30, -11, -4, 21], [-18, 0, -6, 6], [-12, 3, 26, -23], [-42, 12, 7, 5], [-12, 1, -5, -25], [-7, -8, 9, 17], [-20, 1, -4, 11], [-13, 16, 2, -1], [2, -2, 3, -15], [-16, -4, 30, 13], [13, 14, 14, -12], [33, -8, -20, -15], [1, -21, 3, 19], [-4, 4, 19, -21], [-20, -4, 7, 1], [-15, 8, -10, -13], [5, 17, -3, -23], [-21, -6, 2, -8], [-2, -11, 9, -20], [-22, 24, -1, 13], [-25, 16, 3, -12], [-9, -9, -13, 15], [4, 16, -2, -6], [21, 7, -11, -13], [-22, -13, 2, 34], [-31, -3, -8, -2], [-51, 19, 23, 1], [-12, 5, 10, 20], [-2, 6, 1, 8], [4, -2, 19, 6], [25, -12, -11, -11], [-37, -5, 8, 11], [-3, 30, -7, -27], [1, -5, -27, -1], [-18, -9, -15, 42], [-12, -12, 7, 21], [-40, 11, 18, 12], [16, -15, 4, 29], [-17, -16, -7, 46], [27, 1, -5, -49], [27, -24, -11, 0], [-30, 0, 8, -5], [-21, -8, 1, 23], [1, -18, -27, 19], [-36, 11, 6, 7], [-10, -6, 25, -18], [36, 9, -2, -14], [-5, -25, 11, 25], [-16, -17, -21, 34], [-44, -3, 9, 11], [34, 7, -7, -19], [35, 4, -2, -44], [8, -11, -8, -7], [8, 21, -18, -8], [10, 21, -5, -21], [-13, 36, -8, -24], [1, 26, -5, -24], [20, -9, 1, 10], [10, 2, 6, 9], [-9, 1, -24, -15], [-11, -1, 5, 6], [-22, -1, 17, 33], [12, 24, 5, -11], [31, -4, -6, -47], [7, 15, -6, -16], [-10, 27, -1, -26], [-28, 3, 33, -8], [38, 0, -16, -2], [-8, -19, 14, 15], [22, 8, -8, -1], [-4, 14, -20, -34], [12, 4, -25, -4], [-16, 20, 1, -7], [20, -3, -12, -16], [27, -31, -2, 8], [-28, -12, -5, 60], [-11, 13, -9, 29], [19, -8, -6, -7], [11, 14, 4, -45], [-30, -13, 21, 8], [2, -20, 11, 40], [17, 18, -1, -18], [-28, -22, 21, -17], [13, 5, -16, 13], [18, -6, -8, -11], [-27, -2, -5, 56], [-4, 13, 0, -19], [-48, 6, 3, 21], [7, -21, -9, 20], [38, -43, -16, 6], [-27, -15, -10, 31], [45, 17, 2, -28], [35, -10, -1, -4], [-33, -12, 5, 17], [0, -2, 5, 26], [43, 20, 12, -30], [11, -8, 6, 13], [8, 11, 15, -21], [15, -13, -36, 8], [35, 1, 2, -9], [-6, 44, -4, -14], [-26, -7, 11, -28], [-9, -16, 4, 30], [4, 22, -12, -6], [-18, -15, -28, 11], [7, 33, -6, -13], [37, 12, -1, -36], [-9, -37, -9, 19], [-8, 32, 25, -14], [8, 24, -7, -43], [11, -34, 1, 32], [-29, 21, 25, 19], [-15, -6, 20, -23], [-19, 1, -4, -12], [11, -18, 4, 13], [18, 8, -14, 32], [25, -12, 4, -19], [47, -6, -5, -45], [23, 2, -26, 16], [-53, 30, 32, -3], [-20, -31, -2, 7], [-38, 14, 12, 23], [-29, 16, 35, 22], [29, -1, -14, -14], [-32, -6, 13, 33], [31, -17, -12, -6], [-23, -25, -1, 15], [6, -33, -12, -3], [-16, -5, 42, 7], [-13, 6, -3, -15], [-10, -34, 15, 30], [15, 7, -32, -1], [-31, 10, 16, 19], [-6, -5, -7, 47], [-8, 1, -13, -27], [-20, 8, -30, -17], [-36, 0, 12, -8], [30, 1, 17, 12], [-61, 6, 0, 1], [-32, -4, 15, -6], [-10, -15, 23, 16], [5, 27, 20, -4], [12, -11, 15, 3], [31, 37, 10, -29], [5, 9, 23, -1], [-5, 23, -6, -2], [-33, 8, 2, 5], [34, -5, -24, 6], [-19, -17, 16, 30], [55, -5, -21, 2], [-21, -22, -24, 11], [-8, -10, -3, 22], [-8, -2, 21, -5], [-14, -11, -13, 11], [-15, -22, 22, 1], [-25, 32, 24, -14], [20, 27, 28, -45], [19, 39, -8, -45], [49, 3, 2, -28], [11, -5, -17, -31], [3, -33, -2, 16], [-9, 2, -11, -9], [-16, -6, 23, 5], [13, 1, 25, -23], [-47, 11, 25, 30], [-4, -24, 7, 1], [-7, -10, -32, 14], [-1, -10, -33, 19], [9, -27, -6, 19], [37, -13, -50, 14], [2, -10, -36, 15], [-19, -16, -2, 18], [-11, 31, 16, -6], [35, 13, 5, 0], [48, 11, -5, -10], [-37, 21, -13, -19], [6, 15, 7, -44], [62, 1, 11, -7], [-20, 40, -5, -35], [-2, 12, -17, 12], [24, 25, 0, -19], [12, -8, -21, -30], [9, 5, 9, 35], [14, 4, 14, 22], [-6, 10, 6, 20], [-28, -4, -8, 47], [14, 42, -5, -55], [45, -12, 9, 8], [-27, -15, 25, -13], [-29, -8, 9, -19], [32, -19, -6, -38], [12, 14, 37, -10], [-18, -24, -26, 48], [-4, -29, 0, 34], [-22, 48, 21, -9], [-27, -31, 11, 20], [23, -19, 1, -9], [54, -5, -16, -33], [-35, 18, 48, -16], [-23, -46, 4, 59], [-33, -34, 6, 22], [12, -10, -45, 3], [15, -29, 4, 21], [29, 33, -2, -13], [43, 5, -12, 9], [-14, 28, 6, -32], [-82, 10, 10, 8], [5, 33, 14, -24], [5, 56, -16, -47], [-14, 15, 2, -27], [-19, -22, 11, -23], [9, -25, -26, 17], [4, 6, 2, 19], [18, 14, 13, -36], [-16, -29, -7, 34], [13, -13, -18, -19], [-16, -29, 1, 23], [-12, 26, -20, -9], [-11, 37, -5, 7], [49, -8, 5, -9], [-6, 17, 31, -13], [5, 15, 11, 19], [-51, 3, 5, -5], [41, -7, -16, 10], [15, -31, 0, 1], [13, 34, 9, -58], [55, -27, -12, -33], [-26, -12, -29, 44], [21, -14, -17, 12], [-39, -6, 30, -10], [-10, -9, 21, -28], [0, -27, 0, 11], [-42, -1, 32, -12], [-53, 25, 42, 6], [17, -36, -6, 26], [2, 20, -19, -32], [49, 2, 6, -30], [12, 19, 3, -7], [-1, 24, 7, -34], [44, 41, -2, -30], [48, -41, -29, 3], [-35, -2, 34, 16], [9, -4, 6, 15], [34, -3, 2, -32], [42, -19, -7, -21], [-41, -20, 13, -11], [-15, -36, 2, 20], [44, -7, -18, -19], [-77, 45, 43, 10], [12, -4, 20, -41], [-30, 4, 28, 1], [-32, 3, 54, 18], [5, 15, 25, -29], [-3, -7, -4, 12], [37, 12, 11, 9], [-18, -7, -12, 15], [39, 1, 0, -9], [-24, 4, 17, 14], [-12, -6, 42, 1], [42, -41, -18, 10], [-31, -17, -7, 41], [-14, 7, 21, -31], [28, -17, -49, 22], [-29, -7, 5, -6]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_9075_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_9075_2_a_cl();".
// 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_9075_2_a_cl(:prec:=4)
    chi := MakeCharacter_9075_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_9075_2_a_cl();".
// 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_9075_2_a_cl( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_9075_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<2,R![-11, -10, 4, 5, 1]>,<7,R![41, 17, -16, -2, 1]>,<13,R![-1, 6, -10, 3, 1]>,<17,R![5, 1]>,<19,R![-31, 204, -50, -3, 1]>,<23,R![-1, 5, -1, -5, 1]>,<37,R![431, 133, -37, -7, 1]>],Snew);
    return Vf;
end function;