
// Make newform 9675.2.a.d 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_d();".
// 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_d();".
// 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 := [[-2], [0], [0], [4], [3], [-5], [-7], [0], [-9], [0], [7], [8], [-3], [1], [-8], [-1], [8], [0], [9], [12], [4], [-8], [3], [8], [-9], [-17], [5], [12], [11], [-18], [5], [-20], [-18], [-1], [12], [-10], [-8], [-4], [15], [14], [-20], [14], [-6], [-25], [18], [-8], [10], [-14], [0], [1], [-16], [8], [-18], [1], [8], [-24], [-9], [-29], [-6], [27], [-11], [10], [9], [-25], [-16], [-7], [-4], [21], [-10], [-10], [-15], [-33], [-16], [-4], [-29], [20], [0], [-22], [17], [-24], [8], [-8], [3], [-34], [-35], [-12], [30], [30], [-10], [-6], [0], [-15], [24], [-20], [-30], [14], [-11], [-6], [44], [-39], [-41], [37], [-39], [-21], [8], [26], [-32], [34], [-29], [22], [34], [10], [-29], [-4], [-30], [18], [-4], [-6], [-6], [9], [-41], [30], [6], [15], [-28], [-2], [51], [12], [-2], [-34], [-8], [-34], [10], [6], [42], [30], [12], [-32], [14], [34], [-10], [17], [7], [12], [-30], [-18], [-29], [-18], [0], [-22], [-19], [-7], [19], [30], [15], [-40], [-29], [-34], [12], [-3], [-9], [8], [17], [11], [-58], [34], [34], [20], [-50], [10], [44], [36], [-20], [21], [-26], [-10], [40], [32], [-12], [44], [44], [-4], [32], [40], [-6], [-34], [-8], [-24], [38], [50], [-67], [-6], [20], [-6], [12], [-20], [21], [21], [10], [46], [-9], [-30], [8], [-54], [6], [-32], [4], [-49], [42], [67], [22], [27], [3], [-27], [-26], [-1], [-46], [6], [-40], [55], [-32], [0], [24], [25], [38], [-71], [61], [54], [-34], [18], [26], [17], [51], [-12], [51], [-8], [6], [-31], [-24], [-35], [-70], [-48], [56], [-46], [-24], [24], [16], [-15], [77], [-27], [-58], [57], [-51], [-40], [-12], [-46], [-20], [-13], [-22], [-43], [6], [-40], [-42], [-26], [24], [-50], [44], [-29], [-32], [13], [-59], [62], [14], [2], [34], [20], [59], [-20], [-3], [-34], [17], [40], [49], [-28], [-44], [-38], [-31], [72], [4], [43], [35], [47], [-62], [-76], [55], [-19], [75], [63], [84], [72], [-11], [-16], [35], [15], [2], [6], [33], [-34], [20], [4], [-36], [-80], [-41], [2], [65], [-51], [36], [0], [79], [12], [-5], [-38], [-12], [-16], [46], [-35], [32], [-27], [-32], [46], [50], [-65], [36], [-72], [68], [-7], [-4], [-42], [14], [50], [-5], [58], [0], [44], [-27], [15], [22], [92], [68], [45], [-48], [-38], [-30], [-74], [50], [30], [30], [-38], [-13], [21], [-46], [30], [-78], [-86], [-37], [-62], [-52], [-56], [52], [-70], [70], [80], [-12], [41], [-2], [-88], [16], [-59], [-68], [100], [71], [-51], [-65], [68], [-27], [89], [-88], [5], [96], [-3], [5], [-66], [100], [-29], [58], [102], [-19], [16], [14], [-2], [25], [-66], [1], [-78], [60], [62], [-92], [78], [50], [59], [-50], [24], [84], [29], [-80], [-15], [-21], [-80], [-50], [-66], [-72], [-42], [36], [61], [38], [70], [-46], [20], [-95], [-24]];
    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_d();".
// 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_d(: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_d();".
// 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_d( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_9675_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<2,R![2, 1]>,<7,R![-4, 1]>,<11,R![-3, 1]>,<13,R![5, 1]>],Snew);
    return Vf;
end function;