
// Make newform 9075.2.a.ci in Magma, downloaded from the LMFDB on 24 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_ci();".
// 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_ci();".
// 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 := [4, -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_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 := [[0, 1, 0], [-1, 0, 0], [0, 0, 0], [1, 1, 1], [0, 0, 0], [-2, 0, -2], [-2, 1, -1], [1, 1, -1], [-2, 1, 1], [-4, 2, 0], [-1, 0, -2], [-1, 3, 3], [2, 4, 0], [0, 2, 0], [-4, -3, 1], [-2, 5, -1], [8, -2, 4], [-9, 2, 2], [-1, 3, -1], [2, 6, -2], [-3, 1, -1], [-5, 4, -2], [4, 0, 0], [10, 2, 0], [1, -3, 1], [0, 0, -4], [1, -7, 3], [0, -3, 5], [9, -1, 5], [0, -3, 3], [-1, 1, 5], [2, 0, -4], [-4, -3, -5], [-4, 1, -3], [-6, 4, -2], [0, 3, -1], [-1, -1, -5], [1, -1, -5], [6, -5, -1], [2, 4, -4], [8, 0, 2], [9, -5, -3], [12, -4, -2], [-5, -1, -5], [-8, -2, -2], [-13, 2, 4], [-9, 6, 4], [-5, 1, -5], [20, -3, 1], [-2, -9, 5], [-20, -1, -3], [8, -2, 0], [10, 7, -3], [-2, 0, -2], [6, -1, 5], [-10, 7, -5], [4, 0, -8], [4, -3, -7], [13, -7, -5], [-10, -2, 0], [1, 11, 1], [10, -1, 1], [-3, -5, 1], [-2, 2, 0], [-10, 4, -2], [18, -3, -1], [-11, 2, 0], [-3, -5, -7], [-18, 9, 5], [3, 10, -2], [-14, 5, -9], [10, -6, 10], [-4, 8, -6], [-25, 3, 1], [-8, 9, -3], [10, 2, -2], [14, -8, 6], [15, -3, -5], [14, 6, -6], [-19, 4, 4], [-4, 2, 6], [-10, 7, 5], [-14, 0, 6], [-21, 5, -11], [-11, -4, -2], [-2, 2, 2], [22, 0, 0], [10, 0, 4], [30, -4, 2], [8, -10, -6], [14, 5, 5], [12, -14, -8], [8, 2, 4], [-6, -2, 6], [-25, 3, -7], [-8, -1, -9], [4, -8, -6], [4, -10, -12], [-23, -3, -3], [6, -12, 0], [0, -6, 4], [6, 9, -1], [-4, 0, 8], [0, -6, -4], [7, -8, 6], [-5, 15, 5], [-20, 1, -7], [10, 8, 0], [-10, 14, 12], [-5, -3, -13], [-16, 4, 2], [11, -5, 1], [2, 12, -4], [12, -12, -8], [-16, 3, -1], [18, -6, 8], [3, 13, -1], [0, -11, -7], [10, 0, -8], [-18, -2, 4], [7, 5, -1], [-13, 3, -9], [8, 14, -2], [-18, -2, -6], [-13, -4, -6], [-14, -6, -4], [6, 3, -7], [4, 6, -10], [-8, 2, -2], [22, 0, 0], [-3, 6, -4], [-12, -3, -3], [-5, 10, 8], [25, -9, 5], [6, 0, 6], [-1, -10, 6], [12, 11, -7], [-12, -8, -8], [14, 16, -8], [-6, 2, 6], [3, -14, 8], [-2, -8, 8], [29, -7, 15], [-16, -4, -12], [25, -4, -4], [16, 8, 12], [27, -11, 7], [-2, -7, 3], [-17, 11, 1], [16, 4, 12], [19, 5, -5], [12, 16, -8], [-15, 19, 7], [14, -6, -10], [13, 7, -3], [-20, -8, -2], [11, 11, -3], [30, -12, 4], [19, -5, 7], [-18, -4, -2], [-24, -1, 7], [-50, 0, 0], [33, -7, 3], [-22, 12, -6], [-14, 1, -5], [14, 13, 1], [-24, 1, -15], [-25, -3, 1], [6, -13, 1], [8, 5, 15], [-2, 2, -8], [15, -16, 16], [36, 2, -6], [-14, -14, 4], [8, 1, 1], [28, 0, 8], [19, -14, -4], [10, 2, -14], [4, 2, -16], [-17, 5, -17], [-3, -15, 7], [-18, -6, -2], [14, 2, 16], [20, 18, -6], [16, -3, -7], [16, 6, -2], [-3, -7, -9], [-1, -11, -5], [26, -15, -13], [18, 20, -6], [-27, 7, -17], [24, 1, 21], [-33, 8, 10], [-24, -2, -12], [10, -5, 3], [-10, -12, -4], [-2, -11, -13], [21, 3, -1], [-8, -19, 11], [-34, 10, 6], [-12, 0, -10], [-31, 1, -5], [-43, 1, 3], [21, -9, -3], [24, -6, -2], [-18, 3, -11], [9, -4, 6], [-2, -17, -9], [4, -2, 6], [-21, 16, 14], [-29, 1, -13], [-8, 8, -8], [29, -9, 5], [-4, 25, 1], [10, -26, 6], [-10, -11, 3], [-9, 13, 3], [-18, 20, 0], [-26, 7, -13], [4, 10, 2], [29, -6, 26], [8, 8, 4], [-24, 22, 4], [35, 9, -3], [-34, 18, 2], [2, 0, -8], [8, -11, -13], [12, -8, 2], [-32, 6, -22], [-10, -6, -24], [-10, 0, -10], [-19, -16, -2], [13, -20, 2], [-12, 8, 12], [25, -17, -5], [-8, 0, -12], [9, -4, -8], [46, -8, -4], [26, -8, -12], [-2, -8, 6], [40, -9, -1], [20, 0, 16], [25, -7, 1], [3, -2, -10], [-2, -3, -1], [-26, -6, 6], [-12, -20, -2], [-46, 4, -4], [40, 4, 4], [-26, 14, 10], [17, 11, 19], [-8, 10, -14], [-8, -1, -17], [21, 4, 8], [-38, 4, 12], [-8, 32, 4], [-10, 12, 8], [12, -14, 10], [30, -3, 7], [-29, 15, 9], [-8, -24, 2], [-6, -18, 18], [13, 7, 17], [-45, 1, 1], [20, 2, -2], [-23, 13, 3], [-6, 32, 0], [-20, 4, 14], [15, 11, 21], [12, -17, 17], [10, 3, -15], [7, -19, 13], [-35, -13, -9], [-28, 9, -7], [1, 1, 23], [-7, 21, 3], [20, 7, 23], [2, -3, 15], [-9, 10, -2], [-36, -10, 8], [12, 5, 1], [-25, -13, 1], [-2, -25, -13], [10, 27, -11], [29, -3, -15], [-24, 16, -10], [5, 17, 5], [4, -17, -3], [9, 21, -13], [-34, -6, -4], [-28, 16, -6], [-28, -13, -5], [14, -7, -17], [18, 22, 0], [-30, 0, -6], [-14, 30, -12], [-39, 17, -1], [36, -11, 7], [16, 0, -6], [-1, -31, 1], [15, -7, -15], [24, -9, -15], [-25, 6, -28], [-18, -3, -19], [20, -24, 20], [-39, 23, 7], [-58, -1, -13], [-35, -6, -2], [-10, 10, -16], [7, -3, 9], [20, -5, -5], [40, -12, 16], [40, 2, -2], [40, 2, 6], [-20, -17, -13], [-31, 6, -18], [10, 4, 24], [-12, 22, 10], [-15, 19, -9], [48, 4, 6], [11, 3, 1], [11, 7, -1], [-34, -12, -6], [-11, 19, -19], [-18, 16, -8], [9, 22, -2], [-20, 27, -5], [5, -35, 3], [62, -2, 2], [10, 11, 25], [13, -2, 10], [28, -13, 1], [11, -26, -8], [-38, 15, 7], [-52, 1, -15], [-54, 9, -7], [31, 4, 4], [-38, 5, -1], [29, -1, 13], [-15, 19, -5], [-22, 14, -16], [12, 26, 6], [-14, 16, 16], [-37, -9, -3], [-18, -8, -4], [-18, -8, -24], [-31, -6, -22], [47, 11, -7], [2, -8, -24], [28, 17, 7], [12, -17, 7], [9, 15, 13], [-6, -12, -6], [-16, 2, 10], [-21, -11, 7], [-16, 23, -23], [-4, -10, 16], [4, 28, 4], [-10, 8, 4], [30, 10, 18], [19, -11, -13], [-4, -20, 4], [-4, -12, -20], [-34, 4, -18], [-29, 13, -21], [-2, 10, 8], [-10, 21, 3], [-24, 2, -22], [7, -14, 10], [22, -16, 4], [7, 16, 14], [36, 1, -7], [28, 12, 8], [-32, -8, -8], [1, -37, 11], [64, -2, 0], [12, 6, 4], [-37, 21, 13], [-26, -6, -8], [25, 5, 19], [-2, -24, -8], [-56, -14, 6], [-17, 21, 3], [22, -3, 11], [37, -2, -8], [6, 18, 10], [-24, 0, 12], [-34, 12, -16], [60, 4, 14], [-22, 3, 11], [21, -28, 4], [6, -3, 3], [48, 0, 4], [-7, 17, 11], [-2, 18, -16], [2, -24, 8], [-19, -16, -2], [16, -4, 10], [-31, 32, 14], [74, 2, 10], [-22, 7, 5], [-4, 1, 19], [56, -12, 0], [38, 7, -11], [-54, 14, 18], [20, -23, -7], [49, -1, -7], [4, -28, 24], [0, 12, 2], [10, 22, -8], [14, 26, -10], [-64, 2, -2], [-22, -15, -11], [-31, -2, -20], [-54, -6, -4], [44, 12, 18], [-44, -16, 2], [-7, 9, 25], [26, -8, 20], [8, -21, 3], [-44, -22, -6], [7, 29, -9], [-6, -30, 14], [-16, -22, 2], [-21, -3, 1], [40, 6, -6], [60, -5, 7], [4, -4, 12], [45, -15, -5], [-14, 16, 8]];
    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_ci();".
// 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_ci(:prec:=3)
    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_ci();".
// 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_ci( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_9075_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<2,R![4, -5, -1, 1]>,<7,R![-4, -10, -3, 1]>,<13,R![-88, -24, 4, 1]>,<17,R![-14, -7, 4, 1]>,<19,R![16, -4, -5, 1]>,<23,R![-34, -1, 6, 1]>,<37,R![-548, -114, 3, 1]>],Snew);
    return Vf;
end function;