
// Make newform 9075.2.a.bu 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_bu();".
// 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_bu();".
// 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], [3, 0], [0, 0], [3, -3], [1, 4], [6, -2], [-6, -1], [-2, -1], [-4, -3], [-4, -3], [-3, 2], [5, -2], [-11, 1], [-6, 4], [-9, 3], [9, -2], [-1, 6], [-5, 4], [-2, -3], [-7, 9], [12, -1], [-12, 9], [-9, 12], [-7, 5], [1, -10], [-3, 12], [-15, 0], [-2, -4], [5, 1], [4, -7], [5, -11], [-1, -3], [0, -10], [-7, 10], [0, -11], [-9, -5], [-8, -8], [1, -4], [9, -18], [5, -11], [-15, 19], [12, 4], [0, 6], [-18, 6], [3, -10], [3, 6], [0, -9], [-10, 0], [5, -7], [-2, 14], [-3, -3], [-6, -9], [11, -13], [18, -18], [-7, 4], [-2, 15], [-10, 21], [-8, 7], [19, 5], [0, -12], [-10, 16], [-25, 4], [-21, -6], [7, -10], [3, -12], [-14, -6], [-1, -7], [-16, -8], [-17, 16], [19, -23], [-20, 24], [-2, 12], [14, -23], [28, -4], [-10, -5], [5, 9], [17, -10], [-19, 18], [6, 8], [17, -15], [-21, 3], [11, 10], [-22, 9], [0, 17], [8, 4], [30, -4], [-7, 10], [19, -6], [26, -13], [25, -20], [-23, 15], [9, 3], [-27, 24], [-18, 9], [3, -11], [15, -36], [21, 11], [-14, 24], [31, -6], [18, -30], [21, -24], [-22, 4], [-33, 12], [-17, 23], [11, -28], [-2, 17], [28, 4], [31, -1], [24, 3], [-9, 21], [-22, 8], [35, -20], [-33, -10], [-11, 31], [-22, 1], [-31, 11], [-8, 8], [2, 26], [-3, 0], [5, -17], [-14, 4], [3, 6], [-15, -6], [-11, -2], [-3, -4], [-39, 8], [3, -2], [21, -9], [-20, -15], [-21, -10], [-11, -4], [18, 13], [26, -16], [29, -3], [-1, 14], [-24, -1], [-12, 33], [1, -2], [10, 6], [-3, -33], [3, -4], [-13, 37], [-14, -7], [7, 11], [-10, -27], [-2, -5], [12, -9], [33, 1], [49, -12], [-18, -10], [27, -27], [-2, -10], [15, 24], [33, 13], [-11, -3], [-48, -4], [17, 12], [3, 0], [-49, 17], [9, -40], [32, -23], [-2, 38], [12, 15], [30, -18], [-8, -25], [5, 6], [18, -6], [6, -15], [15, -10], [-12, 3], [16, -11], [3, -28], [-27, 24], [-31, 17], [19, -22], [-17, -2], [14, 15], [-31, 12], [-9, 27], [26, -11], [-1, 24], [24, -12], [48, 6], [-11, -23], [-4, 19], [-4, 30], [32, -9], [-32, 5], [18, 26], [-18, 24], [38, -47], [-1, 26], [27, -28], [31, 10], [-5, -4], [35, -18], [38, 5], [-27, 17], [23, -16], [-17, 0], [11, -18], [3, 14], [23, -31], [34, -14], [-24, 33], [-11, -25], [49, -28], [-42, 18], [12, -18], [-23, -5], [-4, 15], [33, -32], [17, -14], [-16, 36], [44, 3], [-39, -6], [-14, 17], [-20, 2], [-57, -10], [39, 17], [39, -33], [-17, -4], [-5, 1], [-17, 9], [-20, 2], [4, 2], [1, -6], [43, -20], [-21, 4], [-16, 27], [33, 0], [-12, 30], [-11, -36], [-4, 29], [5, 0], [-18, 24], [-3, -19], [19, 16], [-2, 1], [55, -4], [-13, 18], [-58, 31], [-34, 41], [-19, 23], [-37, -2], [14, -49], [36, 18], [-30, 33], [17, -18], [48, -15], [13, -32], [42, 1], [-49, 26], [25, 10], [7, 30], [22, 27], [-18, -20], [-40, 36], [22, -36], [34, -2], [6, -12], [1, -9], [-32, -7], [-1, 42], [33, -36], [-19, 32], [33, -68], [26, -19], [5, -11], [-21, 11], [39, 24], [56, -12], [48, -30], [-23, -7], [-18, 0], [-29, 38], [-8, 47], [-7, -10], [-30, -2], [-51, -14], [17, 32], [12, -33], [24, -27], [12, -30], [5, -38], [29, -22], [-5, 30], [60, 0], [-60, 24], [-1, -29], [-31, 20], [-21, -2], [-23, -1], [-18, 36], [24, -14], [-63, -12], [51, -47], [38, -15], [-49, 31], [-39, 69], [-9, 33], [-44, 40], [37, 15], [-15, 19], [-20, 34], [-7, 24], [13, 4], [-3, 14], [10, -47], [-10, -35], [-5, -19], [10, 2], [-24, 24], [21, -12], [12, 36], [45, -24], [-24, 35], [-45, -25], [21, 4], [-24, 17], [42, 2], [21, 15], [-15, 18], [2, 30], [-53, 21], [9, -36], [-6, -22], [-15, 58], [-24, 9], [23, -47], [51, -2], [-73, 29], [-64, 39], [-35, 14], [-39, 23], [4, 10], [1, 42], [-36, 28], [33, -24], [-31, 11], [-50, 10], [0, -6], [-69, -15], [27, -4], [26, -38], [62, -30], [0, 16], [31, -68], [-22, 60], [23, -12], [-17, 8], [-54, 36], [-6, -43], [-8, -26], [16, -2], [32, 2], [45, -54], [37, -62], [-16, -27], [0, 36], [9, -44], [38, -61], [-50, -16], [39, -26], [49, -17], [41, -54], [43, -15], [82, 10], [-3, 6], [-6, 15], [-39, -37], [34, 38], [13, 18], [-32, -26], [-37, 5], [-47, -13], [-53, -14], [-49, 54], [-35, 4], [25, -28], [-3, 42], [-85, 11], [13, 29], [60, -43], [46, 12], [1, -13], [-33, 54], [-24, 17], [-45, 75], [20, 2], [-73, -4], [-15, -1], [17, 10], [-61, 30], [67, 6], [29, -8], [57, -45], [-8, 2], [-27, -6], [30, -48], [3, -15], [62, -10], [19, -8], [-17, -45], [67, -30], [-36, -22], [-29, 50], [-58, 26], [26, 36], [24, 3], [-52, -4], [8, 0], [-40, 16], [21, -18], [41, 38], [26, -38], [-36, 31], [-63, 9], [36, 18], [65, -14], [3, 58], [18, -6], [-31, 39], [51, -13], [-73, 28], [0, 45], [-7, -2], [24, 12]];
    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_bu();".
// 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_bu(: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_bu();".
// 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_bu( : 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![-3, 1]>,<13,R![-9, -3, 1]>,<17,R![-11, -6, 1]>,<19,R![20, -10, 1]>,<23,R![41, 13, 1]>,<37,R![19, 11, 1]>],Snew);
    return Vf;
end function;