
// Make newform 9675.2.a.e in Magma, downloaded from the LMFDB on 06 June 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_9675_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_9675_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_9675_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
        Kf := Rationals();
    end if;
    return [Kf!elt[1] : elt in input];
end function;


// To make the character of type GrpDrchElt, type "MakeCharacter_9675_a();"
function MakeCharacter_9675_a()
    N := 9675;
    order := 1;
    char_gens := [7526, 8902, 5851];
    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_9675_a_Hecke( : Kf := Kf)
    return MakeCharacter_9675_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]];
    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 := [[-1], [0], [0], [-4], [-3], [-1], [-2], [0], [3], [0], [1], [10], [-9], [-1], [5], [1], [-1], [0], [-12], [-6], [14], [13], [9], [8], [-9], [13], [16], [9], [-1], [-12], [13], [-20], [-12], [5], [-24], [2], [20], [-14], [24], [-17], [16], [5], [12], [7], [6], [4], [-26], [14], [12], [-11], [4], [5], [-12], [-11], [-20], [-18], [-18], [16], [30], [6], [11], [-31], [9], [-16], [28], [-2], [8], [-27], [-32], [26], [3], [0], [-11], [16], [-20], [16], [-36], [34], [2], [30], [26], [-20], [-15], [-26], [-11], [0], [-12], [6], [-25], [30], [6], [0], [-12], [-26], [24], [4], [-14], [30], [16], [-18], [-31], [-1], [-39], [-3], [-4], [4], [8], [8], [-29], [-20], [-46], [-31], [-19], [-7], [0], [-6], [-23], [-24], [12], [45], [-5], [-30], [12], [36], [-4], [-11], [27], [-27], [-16], [10], [-14], [40], [-38], [-18], [36], [-21], [-24], [44], [10], [55], [32], [2], [23], [21], [-36], [-24], [2], [-15], [6], [-14], [-2], [-25], [35], [-30], [3], [-34], [16], [-10], [-24], [-21], [-51], [22], [-41], [-52], [13], [-4], [46], [-56], [-26], [29], [32], [42], [46], [42], [4], [5], [-14], [-10], [9], [-34], [-20], [-28], [-32], [-46], [12], [-34], [2], [6], [35], [62], [-62], [6], [-13], [0], [42], [-34], [57], [-51], [-61], [2], [33], [-18], [-62], [-24], [-66], [-58], [-32], [-44], [66], [49], [56], [57], [-39], [-48], [64], [35], [52], [-24], [-68], [-7], [-50], [36], [-6], [-31], [-32], [13], [11], [-12], [22], [36], [-20], [56], [51], [-66], [51], [17], [18], [43], [24], [7], [22], [-6], [19], [17], [36], [24], [2], [-21], [-19], [48], [-47], [54], [-72], [20], [24], [-70], [16], [28], [-44], [37], [-30], [4], [75], [-19], [0], [-14], [44], [-23], [8], [59], [49], [-44], [-32], [50], [-55], [-74], [-65], [-32], [-75], [26], [-20], [55], [77], [-4], [-22], [-68], [34], [0], [-20], [37], [-31], [-59], [-10], [-40], [26], [-49], [-69], [30], [-69], [12], [65], [28], [59], [33], [74], [-66], [69], [14], [-4], [80], [-6], [-86], [25], [22], [55], [-3], [0], [3], [-13], [-36], [67], [50], [-60], [-47], [-10], [-38], [74], [57], [-88], [26], [-34], [17], [-54], [24], [-49], [28], [44], [-18], [20], [-38], [11], [38], [-30], [80], [30], [-60], [52], [-17], [-46], [54], [60], [14], [33], [86], [-13], [30], [24], [-26], [1], [87], [28], [0], [30], [94], [13], [50], [58], [-19], [28], [38], [-14], [-44], [-18], [-40], [2], [-28], [55], [-31], [-50], [44], [-46], [-21], [-43], [-2], [12], [7], [26], [-26], [-39], [63], [-43], [-78], [-80], [-28], [-38], [42], [44], [-68], [8], [-2], [1], [45], [56], [-54], [-36], [8], [-4], [93], [-14], [-76], [-97], [-48], [18], [77], [-4], [75], [51], [-64], [71], [-48], [42], [-21], [-90], [-17], [-20], [32], [106], [44], [-92], [54]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_9675_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_9675_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_9675_2_a_e(:prec:=1)
    chi := MakeCharacter_9675_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_9675_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_9675_2_a_e( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_9675_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<2,R![1, 1]>,<7,R![4, 1]>,<11,R![3, 1]>,<13,R![1, 1]>],Snew);
    return Vf;
end function;