
// Make newform 9075.2.a.bx 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_bx();".
// 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_bx();".
// 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, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rfbasis := [Kf.1^i : i in [0..Degree(Kf)-1]];
    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], [1, 0], [0, 0], [2, -2], [0, 0], [4, -2], [-3, 4], [-4, 4], [1, -6], [0, -2], [-3, 6], [-2, -2], [-6, -4], [-4, 2], [-5, 6], [-5, 8], [8, -6], [-1, -4], [-10, 2], [-12, 4], [-8, 4], [-9, 6], [-4, 0], [6, 2], [-14, -2], [8, 4], [-4, -8], [13, -2], [-10, 8], [5, -12], [0, -6], [-2, -4], [-15, 4], [11, 6], [8, 6], [-11, -6], [-6, -6], [0, 10], [-3, -10], [-2, -8], [-14, 10], [-14, 12], [14, -22], [10, -10], [6, 12], [15, -2], [-3, -2], [-14, -8], [13, -6], [7, 0], [1, -16], [16, -14], [13, -8], [-20, 6], [-19, 16], [9, -18], [12, 8], [23, -2], [0, 8], [-14, 2], [2, -16], [19, -4], [-2, 16], [-2, 2], [-24, -2], [-1, -8], [-11, 10], [2, 16], [-13, 2], [15, 0], [7, 0], [0, 12], [-6, -2], [20, -16], [17, -22], [-16, 0], [-8, 22], [10, -12], [16, -8], [-17, 32], [-14, 0], [15, -24], [12, 10], [-24, 2], [-3, -18], [0, 12], [-10, 0], [-22, 20], [-24, 10], [-6, 0], [5, 2], [4, 6], [8, -6], [36, -4], [4, 8], [-17, 10], [2, -22], [24, 10], [-6, 30], [26, -28], [4, 22], [-11, -4], [4, 8], [16, -6], [11, 18], [-20, 0], [3, -14], [-30, 8], [-10, 34], [-26, 4], [10, 6], [0, 24], [-22, 32], [-12, -4], [3, -10], [2, 18], [14, -24], [15, -2], [-2, 24], [-22, 22], [26, -32], [-14, 22], [-2, -12], [24, 0], [-19, 30], [-30, 10], [-13, 8], [14, -20], [-30, 24], [38, -16], [7, 14], [1, -2], [-13, 34], [-14, 8], [36, -14], [27, 4], [3, -8], [-32, -8], [-30, 0], [8, 0], [-19, -18], [14, -32], [-16, 36], [4, -8], [-11, 0], [16, -20], [-22, 16], [1, 0], [-12, 24], [28, -16], [-6, -28], [24, -24], [-4, 10], [12, -8], [42, 0], [22, -42], [4, 12], [46, -8], [22, -18], [44, -2], [17, -2], [22, -16], [-32, 0], [28, -2], [11, -8], [49, -10], [5, -2], [40, 2], [-43, 24], [-39, 8], [18, -26], [7, -16], [34, 12], [-34, 14], [-27, -18], [-12, 8], [9, -14], [-28, 28], [-32, 2], [-26, -24], [-4, 12], [24, 8], [14, -26], [-10, 44], [7, 6], [10, -20], [-12, -12], [-14, 28], [-1, -32], [40, -14], [-8, -34], [-19, 10], [-7, 2], [40, -30], [-35, -6], [-42, 8], [-5, -4], [0, 18], [-29, 4], [4, 8], [10, 34], [16, -24], [0, 24], [26, 0], [-46, -8], [13, -28], [7, -30], [53, 2], [-2, -28], [-15, 30], [-2, -8], [-8, 0], [14, 0], [3, -30], [-40, 12], [-43, 28], [-18, -12], [38, -4], [-17, -22], [2, -20], [49, 4], [36, -28], [28, 26], [-28, -10], [32, 12], [-2, -8], [-27, 36], [-58, 2], [34, -24], [-2, -10], [4, -6], [-19, 42], [9, 10], [-56, 12], [-28, 2], [-12, 28], [9, -20], [-38, 4], [-42, -4], [-12, 6], [25, 6], [20, -16], [18, -30], [-47, 4], [29, -40], [24, 0], [38, -10], [-2, 16], [20, 0], [-48, 8], [52, -38], [-18, 12], [33, -2], [13, -4], [30, 0], [-24, 36], [-50, 4], [-18, 20], [43, 0], [28, -12], [-46, -6], [28, 8], [46, -20], [0, -42], [-42, 24], [-24, 28], [-46, -16], [18, 26], [-28, 20], [-35, 4], [-65, 0], [28, -6], [16, 10], [-33, 34], [40, -4], [0, 4], [45, 6], [35, -16], [51, -32], [-48, 10], [-59, 10], [20, -16], [-23, -18], [-11, -12], [-2, 10], [-30, -10], [10, -42], [-55, 16], [-16, 4], [-42, 26], [-6, -30], [9, 30], [45, -36], [-22, 50], [0, -38], [-18, -18], [-28, -36], [-59, 16], [10, -42], [16, -2], [-32, 14], [9, 28], [-43, -2], [-19, 50], [24, 12], [-8, 54], [-25, 58], [-29, 16], [-34, -6], [-8, 26], [-9, -6], [32, -12], [6, 40], [-26, 24], [55, 6], [9, 20], [10, 28], [-10, 16], [32, -38], [62, -18], [48, 0], [-58, -18], [-24, 58], [26, -60], [6, -24], [31, 36], [35, -14], [-20, -4], [16, -32], [-29, 64], [41, -72], [27, -24], [-27, -30], [-15, -22], [31, 2], [37, -46], [-5, 32], [57, 0], [22, -56], [-48, -6], [30, 26], [46, -56], [-50, -16], [28, 0], [-2, 4], [-6, 0], [35, 20], [-80, -8], [26, -24], [-11, 20], [9, -50], [-10, -8], [36, -26], [6, -4], [-22, -16], [17, 4], [32, -18], [16, -64], [42, -68], [-40, 20], [-2, -20], [4, -48], [80, 0], [-12, 54], [2, 12], [-38, 38], [41, -28], [46, 12], [15, -20], [62, 12], [13, -58], [-3, 38], [4, -36], [-24, 8], [-68, 46], [28, -10], [-36, -18], [-68, -10], [-26, 62], [4, 12], [-10, -16], [18, -48], [-74, 28], [49, -28], [-61, 26], [-48, 28], [-12, 4], [74, 4], [30, -22], [59, 14], [-31, -16], [-65, 12], [32, -4], [-20, 40], [58, -6], [-22, 32], [29, -70], [-6, 30], [71, -26], [-28, 12], [37, -32], [-23, 0], [-60, 60], [-59, 24], [52, 8], [47, -38], [18, 12], [-8, -60], [-62, 26], [-34, 22], [0, 24], [-10, -24], [57, 14], [-5, -18], [-86, -2], [-26, -42], [18, 6], [-26, 18], [-46, 68], [19, 26], [30, -52], [10, 56], [16, 24], [-42, -4], [24, -18], [54, 24], [13, -70], [16, 40], [44, 32], [-82, 24]];
    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_bx();".
// 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_bx(:prec:=2)
    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_bx();".
// 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_bx( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_9075_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<2,R![-1, -1, 1]>,<7,R![-4, -2, 1]>,<13,R![4, -6, 1]>,<17,R![-19, 2, 1]>,<19,R![-16, 4, 1]>,<23,R![-41, 4, 1]>,<37,R![4, 6, 1]>],Snew);
    return Vf;
end function;