
// Make newform 9300.2.a.u in Magma, downloaded from the LMFDB on 13 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_u();".
// 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_u();".
// 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], [1, 0, -1], [0, 0, 2], [-1, 2, -1], [-4, 1, 1], [0, 2, -2], [0, -3, 1], [3, -3, 0], [1, 0, 0], [-1, -4, 3], [6, 0, -2], [0, -2, 0], [-4, 1, -1], [-2, -1, 1], [5, 1, 0], [6, -4, 0], [-3, 4, -3], [3, -3, 4], [-3, 4, -3], [-6, -1, 3], [-8, -1, -1], [-3, -3, 4], [-2, 0, -2], [-2, 2, 4], [-1, 2, 5], [-10, 1, 1], [-10, 3, 1], [0, -6, 0], [14, -4, -2], [5, 7, -6], [-8, 5, 1], [-2, 4, -2], [-6, 0, -2], [-8, 7, -3], [-2, 6, -4], [9, -2, 3], [2, -2, 4], [8, -2, 4], [8, -2, -6], [6, -4, -4], [-1, -5, 4], [-14, 6, 0], [0, -9, 3], [-12, -1, -3], [-2, -2, 4], [-2, -6, 6], [-6, -3, 5], [-4, 0, -6], [-4, 7, -3], [-10, 10, -2], [-4, 6, 0], [4, 2, -6], [-8, -7, 7], [-10, 4, 2], [7, -7, -4], [-14, -8, 6], [-3, -8, 5], [4, 8, -6], [5, 2, -7], [-20, 5, -1], [7, 0, 5], [17, -11, -2], [-7, -10, 9], [-4, 7, -7], [14, -3, 5], [-5, 0, 3], [-10, 10, -4], [-6, 5, -5], [4, 5, 1], [-13, 1, -10], [16, 0, 0], [-16, -10, 4], [-16, -6, 6], [4, -1, -9], [-27, 3, 2], [-6, 10, 2], [-9, 3, -4], [-14, 4, 8], [-3, -3, -6], [-16, -3, 5], [-3, 9, 6], [-7, 8, -7], [-8, 4, -12], [-2, -1, -13], [-13, -5, 8], [-3, 10, -1], [-3, -9, 0], [12, 4, -2], [4, -1, 1], [-13, 7, -6], [-6, -2, 12], [6, -6, 0], [-8, -8, 12], [4, 5, -1], [-21, 9, 2], [-2, 8, -6], [10, 6, 0], [0, 17, -3], [1, -6, 15], [-4, -17, 7], [2, -5, -5], [-19, 1, 2], [6, 8, -2], [12, -8, 4], [2, 4, 2], [-8, 8, 2], [-3, -9, 12], [4, -8, -2], [31, 6, -3], [-7, 2, -19], [-26, -4, -4], [-10, 15, -9], [-12, 8, -12], [1, 5, -10], [10, -6, 0], [0, -6, 14], [4, 11, 1], [-7, -17, 4], [8, -6, 0], [-9, 16, -7], [-10, 7, -11], [2, -17, 15], [22, -8, 6], [-4, -20, 12], [-14, 4, 4], [-24, 0, 6], [1, 0, -7], [-18, -8, 0], [28, 7, 1], [-2, 8, -18], [-10, 18, -4], [7, 0, -15], [-7, 7, -20], [-14, 7, 13], [4, -7, 21], [14, -4, -8], [-32, 5, -3], [7, -7, 14], [18, -4, 2], [17, 7, -6], [4, 0, -2], [-4, -5, -5], [12, -10, 0], [-25, 13, 2], [20, -10, 6], [8, -2, 4], [8, 0, 20], [16, -16, 4], [-20, 12, 8], [-3, -9, 10], [-14, -12, 8], [-4, -11, -5], [-9, -2, 15], [-20, 8, 2], [16, -8, 0], [-29, -7, 4], [-2, -12, 2], [-23, 5, -12], [20, 1, 5], [24, -9, -1], [-18, 10, 6], [-3, 15, 0], [10, -4, -4], [-4, -2, 2], [18, 8, 6], [-32, 6, 4], [-12, 8, -6], [-12, 3, -5], [-6, 0, 12], [16, -14, 0], [15, -3, -16], [-2, -6, 8], [-30, -16, 6], [9, -3, 10], [22, -8, -14], [-28, 16, 2], [-1, -10, -1], [16, -2, 4], [-9, 4, 5], [24, 0, -8], [-6, 16, 2], [-2, 5, -9], [2, -11, -7], [-33, 3, -10], [0, -8, -12], [5, 20, -7], [28, 16, -10], [-7, 13, -4], [-31, -4, 9], [-4, 19, -11], [24, 11, 1], [-3, -9, -12], [-36, -3, -5], [18, 3, -15], [-36, -10, 8], [-2, -18, 10], [30, 0, -12], [-6, 3, -9], [-22, -8, 0], [-18, 8, 2], [4, 0, -20], [10, 16, -20], [3, 21, -6], [-6, -9, 1], [-34, 12, -2], [24, -21, -9], [4, -28, 8], [-12, 14, 2], [-39, 4, 7], [1, 5, 4], [45, 4, -9], [16, -7, -5], [-16, 4, -18], [-38, 1, 11], [-21, 4, 5], [14, -8, 2], [16, 11, -5], [12, 0, 2], [30, 2, -10], [22, -20, 2], [16, 14, -18], [-9, 4, 11], [24, -9, -7], [42, -10, -6], [32, -11, -1], [24, -18, -4], [2, -10, -20], [7, -13, 6], [-25, 20, 9], [26, -6, 4], [-4, 0, -4], [13, -7, 16], [-6, 22, -14], [-4, 4, 12], [4, -26, 12], [26, -2, 6], [26, -2, 6], [-26, -4, -12], [6, 21, -3], [12, -16, -12], [-44, 6, 4], [32, -12, 2], [-14, 5, -1], [29, -11, 8], [34, 6, -2], [22, 14, -14], [22, 16, -2], [36, 15, -3], [48, -2, -4], [-42, -24, 14], [-26, 2, -16], [32, 9, 5], [30, 6, -2], [23, -11, -6], [2, 0, 4], [-36, -2, 0], [-8, 23, -23], [-20, 18, 16], [-5, 0, -1], [-16, -23, 13], [34, -2, 22], [4, 6, 14], [-14, 5, 19], [-12, 14, 22], [-2, 8, 0], [-60, 0, 4], [55, -6, -5], [-46, 16, 8], [-12, 5, -3], [-24, 10, -8], [49, 6, -1], [-44, 16, 0], [16, 6, -8], [37, -18, -11], [32, 7, -11], [10, 4, 0], [-46, 12, 0], [38, -2, -8], [-8, -7, 15], [22, -20, -2], [-16, -17, 1], [-12, 26, 4], [17, 8, -15], [16, -10, 2], [-25, 20, -1], [-8, 11, -5], [-2, 10, 16], [19, -13, 10], [-32, -22, 14], [-20, -19, 15], [18, 21, -25], [17, 1, 14], [21, 4, -9], [5, 7, 18], [18, -1, -9], [60, -3, -5], [46, -16, -6], [-22, 14, 12], [4, -18, 18], [-16, -17, 15], [48, -16, 0], [2, 1, 5], [-36, -13, 9], [60, -2, 4], [-4, 25, -7], [16, -2, 12], [-30, 0, 10], [-2, -12, 4], [8, -17, 31], [23, 31, -16], [16, -16, 6], [-26, 6, -16], [-10, 19, 19], [-34, 0, -16], [44, 10, -14], [10, 38, -18], [44, -4, -10], [23, 13, -2], [-4, 9, -13], [13, 0, -21], [2, -8, 6], [-1, -16, -1], [8, -29, 17], [-80, -2, 0], [66, 2, 4], [59, 8, -9], [8, -2, 18], [-12, 21, -3], [14, 12, 8], [-16, -17, 9], [-4, -6, 2], [-40, -5, -1], [8, -6, -26], [-14, 35, -9], [8, -6, 16], [0, 15, -15], [-42, 5, -13], [-8, -30, 28], [-3, -26, 9], [6, -27, -5], [11, 7, 14], [4, 16, -20], [22, 2, -2], [-27, 9, 0], [-14, -23, 15], [10, 18, 4], [30, -6, 0], [-20, 17, -21], [32, -9, 5], [-19, 20, -5], [12, -6, 8], [44, -4, 2], [-8, -2, 8], [-34, -5, -11], [22, -28, -6], [-26, -22, 14], [-22, 7, 13], [-12, 33, -9], [52, -6, 10], [-19, 7, -6], [-28, 19, -9], [-1, 19, -24], [39, -2, 11], [-55, -22, 15], [-28, 7, 17], [56, -10, -12], [-10, 9, -37], [-45, 21, 10], [22, -14, -12], [-30, 15, -5], [58, -4, -6], [20, 6, -26], [-15, 10, -7], [24, 6, -20], [9, -21, 6], [-32, 0, -8], [2, -2, -20], [-9, 22, -11], [-9, -33, 20], [32, -11, -11], [48, 4, -8], [54, -27, -9], [16, -20, 8], [-24, -27, 23], [8, 0, 24], [61, 0, -13], [-14, 24, 6], [-28, -17, -5], [26, 0, -16], [-8, -25, 11], [27, 3, -6], [13, -6, 5], [-17, -19, 8], [-22, 14, 2], [-22, 0, -10], [32, 16, -4], [-10, -3, -7], [47, 7, -2], [4, 34, -8], [4, 5, -13], [75, -2, 1], [-48, 21, -1], [-3, -9, 0], [10, 16, -22], [-24, -2, -10], [-23, 23, 18], [-14, 0, 0], [38, 16, 4], [43, 12, -3], [4, 26, -32], [-28, 4, 16], [48, -25, -11], [6, -2, -34], [8, 16, -26], [20, 16, -14], [-57, -8, 1], [-56, -19, 15], [-44, 11, -7], [13, -19, 4], [-9, 4, -25], [24, 9, -19], [15, -21, 28], [-16, 8, -12], [10, -19, 3], [10, 17, -27], [11, 19, 2], [24, 8, 20], [16, -22, 22], [2, -3, -9], [13, -7, 14], [-10, -12, 2], [-56, -13, 1], [-29, 6, 3], [-5, 11, 4], [-4, 18, -8], [0, 14, -4], [4, -18, 10], [26, -24, 2], [-52, 25, 11], [-20, 26, -8], [38, -9, 37], [-9, 9, -10], [10, 16, -8], [4, 11, -29], [75, 16, -9], [58, -7, 5], [-12, 14, 8], [-60, 5, 13], [-3, 10, 9], [-38, -10, 18], [-14, 11, 27], [20, -8, -12], [-9, 40, -9], [50, -32, -2], [12, -10, -4], [12, 18, 8], [-19, -22, 23], [-4, 16, -2], [24, 8, 12], [12, -4, 4], [44, 16, 2], [40, -2, -4], [-56, -12, 4], [-41, -6, 7], [-66, 26, 12], [-32, -1, -21], [9, 15, -2], [-52, 0, -8], [-64, -10, 14], [24, 12, 20], [30, -18, 8], [-12, 2, 0], [-10, -8, -22], [72, -2, 12], [0, 36, -4], [28, -41, 9], [6, 9, -3], [-20, -25, -1], [-1, 8, 25], [-10, 4, 0], [82, 6, -4], [24, 6, -32], [24, -8, 4], [-8, -1, 7], [28, 13, -15], [-55, -23, 18], [-34, 0, -26], [-24, -22, 34], [-26, 18, 26], [24, 3, -9], [6, 38, -14], [10, -25, 17], [-23, -1, -2], [-12, -34, 4], [-56, 12, -30], [50, 1, 15], [40, -38, -14], [48, 17, 3], [8, 4, -24], [11, 32, -13], [-10, -2, -30], [4, -12, 0], [19, -36, -9], [30, -3, 19], [-14, 2, -20], [-12, -16, 28], [-30, -32, 8], [57, -20, 1], [17, 1, 10], [24, 18, -24], [39, -26, 9], [-16, 1, 31], [-30, -16, 22], [-20, 6, 4], [33, -15, 32], [30, -16, 8], [-90, -12, 8], [19, -18, -15], [-19, -16, 23], [-54, -10, 20], [10, 32, -4], [-12, -9, 21], [-30, 23, 5], [-43, 1, 6], [-25, 14, -5], [-8, -7, -27], [4, -4, 32], [-46, 28, 8], [1, 0, 11], [4, -1, 1]];
    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_u();".
// 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_u(: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_u();".
// 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_u( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_9300_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<7,R![-2, -6, -2, 1]>,<11,R![72, -28, -2, 1]>,<13,R![18, -18, 2, 1]>,<17,R![-36, 16, 10, 1]>],Snew);
    return Vf;
end function;