
// Make newform 9300.2.a.s in Magma, downloaded from the LMFDB on 18 March 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_9300_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_9300_2_a_s();".
// 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_9300_2_a_s();".
// 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, -5, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0], [0, 1, 0], [-3, -1, 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_9300_a();"
function MakeCharacter_9300_a()
    N := 9300;
    order := 1;
    char_gens := [4651, 3101, 2977, 1801];
    v := [1, 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_9300_a_Hecke( : Kf := Kf)
    return MakeCharacter_9300_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 := [[0, 0, 0], [-1, 0, 0], [0, 0, 0], [0, -1, 1], [-2, 1, 0], [-1, 2, -1], [2, -2, 1], [-1, -2, 0], [0, 3, -2], [0, 0, 3], [1, 0, 0], [1, -2, -1], [-5, 1, -4], [6, -2, 0], [0, 2, 0], [-2, 2, 1], [9, -1, -2], [-4, -2, 2], [11, -3, -1], [-2, -2, 2], [2, 0, 2], [-5, 6, 1], [-6, 1, -2], [-6, 3, -2], [-5, 3, -5], [-4, -6, 2], [3, 0, -6], [-1, 1, 4], [-6, 1, -1], [8, 2, -4], [-6, 6, 2], [7, -3, 2], [-2, -4, 7], [-3, 6, -3], [-1, 5, -6], [-4, 2, -2], [5, -2, 6], [19, 2, -2], [-2, 0, -6], [-9, 5, 2], [4, -3, -7], [-11, 0, 3], [-13, -5, 4], [1, -9, 3], [-6, 0, 0], [9, -4, 3], [1, 4, -8], [4, 0, 6], [-2, -8, 0], [-9, 10, 1], [-8, 0, -4], [-14, 12, 3], [-13, 0, -3], [-10, 0, 1], [1, -13, 4], [0, 8, 0], [4, 2, -4], [15, 0, -1], [8, -6, 4], [-14, 8, 0], [5, 2, 8], [-7, 3, -6], [-20, 3, 5], [-13, -5, 4], [7, -8, -1], [5, 1, 2], [-11, -10, 7], [-3, 2, -7], [-16, -11, 5], [-5, 0, -10], [-2, -4, 7], [-4, 4, 2], [4, 6, -6], [9, 3, 5], [-4, -3, -9], [-8, -4, -3], [10, 4, 0], [-5, -1, 9], [-6, 3, 2], [-12, 0, -2], [-6, -6, 0], [4, -7, 1], [-10, 8, -4], [-8, 10, -8], [-6, -9, -1], [-5, -7, -4], [2, 7, 2], [3, -2, 5], [-18, -3, -6], [16, -4, 8], [-16, 6, -4], [-14, 0, -4], [-1, 6, -13], [-6, -3, 6], [-7, 2, 1], [2, 0, 0], [-2, 4, -9], [-11, -1, -6], [18, -4, -4], [5, 1, -1], [5, -11, 1], [-4, -5, -2], [5, -11, 4], [-22, -11, 8], [-20, 12, 8], [-14, -13, 5], [-10, -17, 8], [-21, 13, 4], [9, -9, 0], [-5, -8, -5], [-35, -3, 3], [-12, 12, -12], [-11, 11, -4], [12, 4, 10], [9, -10, 15], [6, 10, -5], [-11, 12, -9], [-18, 15, 2], [-17, 5, -8], [0, 8, 8], [-13, 9, -9], [-3, 4, -7], [8, 19, -11], [-12, -4, 10], [19, 4, -6], [-29, 9, 2], [-1, 2, -7], [12, -6, 6], [-10, -5, 3], [-1, 18, -4], [-5, -2, 7], [0, 7, 2], [3, 7, -3], [11, -14, -5], [-32, 9, 3], [-17, -17, 7], [-22, 3, -8], [2, -16, 16], [0, 19, -7], [-20, -4, 11], [12, -19, -1], [-10, -17, 12], [2, 10, -4], [-18, 2, -7], [-5, 12, -5], [4, -12, 4], [6, -3, 19], [-17, 9, -6], [18, -2, -12], [28, -10, -2], [32, -2, 0], [2, -10, -6], [35, -8, -3], [-23, -3, 12], [5, 6, -4], [-10, -12, 15], [-19, -7, 13], [22, -16, 1], [-1, 16, -12], [-30, 1, -4], [-40, 7, -4], [-6, 0, -4], [-21, -8, 9], [9, 21, -6], [1, -13, -4], [-6, -4, 9], [7, 0, -11], [11, 1, 17], [-8, 6, -20], [-20, -14, 8], [-4, 8, -4], [22, 10, 0], [-22, 2, -2], [-3, 8, -20], [-4, 16, -16], [0, 0, -2], [22, -11, 13], [7, -21, -2], [7, -2, 16], [-4, 8, 14], [21, 19, -7], [10, 16, -7], [-1, 3, 1], [14, 6, -5], [-35, 3, 4], [6, -12, 17], [19, -19, 1], [-14, -17, 19], [-15, 6, 1], [-3, -13, 18], [29, -10, 3], [-13, 19, -14], [35, 10, -3], [-18, 12, 12], [12, -12, 4], [-16, 5, -10], [21, 2, -13], [-4, -2, -4], [36, -12, 0], [21, -3, 0], [-6, -4, 4], [-5, 0, 3], [10, -9, 13], [5, 14, -4], [10, 4, -8], [-16, -4, 6], [29, -12, 4], [6, -12, 21], [22, 8, -16], [3, 11, -13], [-19, 6, -3], [-12, -2, 12], [25, -22, -2], [3, -11, 0], [8, 10, -3], [13, -2, 20], [15, -5, -1], [-19, -23, 14], [0, -17, 0], [-38, 16, 6], [14, 4, -2], [29, -1, -15], [28, 8, 6], [1, 29, -15], [4, 16, 0], [10, -6, -2], [-19, 13, 2], [-12, 15, 8], [14, -4, 4], [41, -3, 10], [13, -20, -1], [16, 11, 9], [9, -11, -9], [12, -11, 27], [-17, 26, -1], [-40, -11, 12], [15, 15, -7], [-35, -3, 2], [20, -5, -12], [48, -2, -1], [11, -13, -16], [-3, -16, -3], [-21, 8, -15], [-34, 0, -4], [34, -7, 14], [33, -13, -6], [45, -4, 9], [12, 4, -3], [11, -4, 5], [24, -18, -6], [23, 12, -8], [-9, 9, -28], [-10, 12, 15], [-18, -5, 21], [4, -26, 2], [8, 22, -24], [13, 11, 9], [25, 8, -5], [42, -2, -6], [6, -7, -9], [20, -23, 3], [24, -4, 5], [14, 2, -22], [-15, -28, 22], [22, -19, -2], [22, -3, 17], [19, -7, -18], [-7, -7, -12], [-3, -25, 9], [-23, -27, 16], [17, -11, 11], [-14, 20, 2], [33, 8, 1], [2, -10, 16], [30, -4, -12], [7, 18, -20], [-17, 9, 0], [-12, -12, 8], [8, 18, -18], [-38, 21, 12], [-2, 2, 6], [23, -13, -7], [-23, -21, 12], [-22, 25, -9], [-1, 17, -27], [8, 27, -21], [-2, -8, 10], [20, 12, -7], [19, -8, 4], [-8, 26, -11], [-4, 24, 0], [-28, 0, -8], [-2, -17, -6], [46, -12, -2], [12, 34, -24], [22, -18, 17], [-27, 20, -9], [6, 12, -26], [20, -15, 22], [-15, 12, 13], [-57, 17, 5], [-2, -9, -10], [17, -14, -1], [19, -15, 4], [18, -4, 6], [12, 7, 7], [-10, 7, 8], [-19, -7, 7], [-6, 3, 16], [23, -5, 5], [-4, -8, 13], [-30, 2, 18], [9, 31, -28], [-15, 14, -11], [-4, 22, 4], [-49, -6, -1], [56, -2, -5], [16, -28, 12], [-17, -11, 13], [-42, -10, 2], [28, 14, -14], [-4, 10, 4], [33, 5, 16], [-47, -11, 7], [-24, 8, 18], [30, 6, 2], [16, 3, 5], [-11, 37, -1], [-16, -11, -15], [24, 6, -21], [51, -29, -9], [34, -12, -4], [47, -6, 8], [-42, -4, -3], [29, -18, 4], [36, -2, 14], [-26, 14, 12], [-18, 12, -12], [59, 1, -5], [-48, 2, 6], [8, 6, -16], [-60, -12, 10], [8, -20, 14], [-43, 2, 11], [58, 8, -2], [30, 30, -24], [-9, 12, 2], [0, 2, -18], [-28, -1, -4], [-33, 13, 14], [-13, 18, -25], [-11, -26, 21], [12, -6, -10], [13, 22, 1], [7, -5, 29], [14, 22, -14], [-20, 20, -27], [12, -2, -14], [18, 26, -1], [-9, -9, 18], [37, 0, -2], [32, 7, 6], [8, -2, 6], [32, 28, -24], [24, -11, 11], [2, 8, 12], [6, 14, 12], [11, 8, -21], [30, -17, 9], [3, 3, 16], [34, 7, -21], [-16, 14, 18], [-6, 34, -16], [-2, 35, -9], [8, 24, -2], [-30, -21, 10], [58, -2, 4], [-2, 15, -11], [-2, -18, 12], [-3, 22, 1], [14, 2, -29], [-16, 1, 7], [-31, -18, 9], [24, -12, 21], [-30, -6, 10], [-41, 1, 12], [1, 14, -10], [3, -10, -23], [1, -18, -15], [10, -36, 6], [-8, -4, 4], [20, 3, 21], [20, 26, -10], [63, -7, 1], [-24, -14, 10], [2, -13, 17], [-66, -2, -6], [-12, -34, 30], [19, 26, -23], [-38, -21, 12], [-3, 0, 15], [56, 6, -6], [-13, -6, 0], [-21, -9, -16], [-22, 2, -1], [54, -21, -5], [48, -14, -4], [34, 14, -6], [-27, 14, -1], [-8, -6, 9], [-4, 4, 10], [-16, -6, 14], [-34, -8, -2], [-58, 4, 12], [-16, 33, -11], [8, -20, 4], [-20, 6, 3], [17, 21, -21], [-13, -3, 22], [12, -32, 4], [-4, 6, 23], [-31, -18, -5], [-8, -5, 15], [-54, 0, 10], [-6, -15, 19], [16, 14, 12], [-51, 1, 20], [-22, -8, -4], [-10, 22, 16], [4, -25, 19], [-31, -9, -15], [31, -1, -10], [-5, 14, -11], [8, -6, 8], [-38, 30, -12], [4, -40, 19], [4, -10, 0], [66, 8, 2], [7, 30, -5], [-39, 13, 15], [31, 3, -26], [-53, -7, -2], [-5, -25, -9], [-23, 13, -6], [16, -20, 22], [-64, 18, 5], [3, -29, 3], [-3, -5, -2], [57, -16, -4], [-33, 5, 19], [13, -4, -8], [-14, -16, 15], [62, -12, 4], [-4, -8, -18], [-20, -34, 22], [5, -5, 10], [15, -19, 11], [22, -8, -9], [-4, -4, -22], [45, -25, -4], [5, 22, -16], [-73, -8, 6], [-20, 0, 1], [6, -24, 16], [4, -6, 34], [0, -40, 6], [49, -21, 1], [72, -8, -4], [36, -18, 19], [-21, 1, 17], [61, 4, 1], [6, -39, 2], [-24, 3, 14], [4, -18, 22], [72, 8, 0], [23, 12, -4], [5, 5, 10], [-11, -8, -3], [-32, 10, -14], [-22, 3, -18], [-32, -14, 24], [-45, -1, 4], [-23, -15, 23], [-63, 15, 4], [-50, 26, 8], [34, -40, -2], [-58, -1, 1], [71, -17, -12], [-32, 2, 12], [-15, 2, -44], [7, 12, 8], [-20, -11, -23], [1, 30, -1], [20, 18, -3], [15, -11, -6], [-17, 27, -19], [0, 8, 2], [18, 32, -20], [-5, 25, -23], [-38, 0, -14], [-53, 27, 14], [27, 18, 6], [46, -18, 2], [-26, 6, -6], [15, -10, 35], [42, 0, 4], [20, 21, -28], [-29, -21, 29], [-21, -8, -10], [-41, 14, -4], [14, 4, 4], [-26, 7, -8], [11, -18, -25], [-1, -29, -2], [2, 4, 18], [-65, -18, 10], [-80, 10, -12], [-37, -35, 19], [0, -30, 23], [-1, -17, 19], [73, 4, 7], [43, -48, -6], [-23, 5, -40], [-73, -1, 8], [-3, 35, -25], [-43, -17, -6], [8, -28, -20], [-20, 2, -24], [18, -35, -2], [-50, -12, 16], [16, 15, 17], [7, 5, 34]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_9300_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_9300_2_a_s();".
// 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_9300_2_a_s(:prec:=3)
    chi := MakeCharacter_9300_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(3833) - 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_9300_2_a_s();".
// 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_9300_2_a_s( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_9300_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<7,R![-4, -8, 0, 1]>,<11,R![-7, 3, 5, 1]>,<13,R![18, -18, 2, 1]>,<17,R![-3, -11, -5, 1]>],Snew);
    return Vf;
end function;