
// Make newform 9200.2.a.bw in Magma, downloaded from the LMFDB on 25 December 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_9200_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_9200_2_a_bw();".
// 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_9200_2_a_bw();".
// 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 := [-4, -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_9200_a();"
function MakeCharacter_9200_a()
    N := 9200;
    order := 1;
    char_gens := [1151, 6901, 2577, 1201];
    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_9200_a_Hecke( : Kf := Kf)
    return MakeCharacter_9200_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], [1, -1], [1, 0], [-1, -1], [-4, 1], [-3, 0], [1, 0], [3, 1], [2, -2], [0, 2], [-5, -2], [3, -3], [6, 0], [-6, 2], [-4, 0], [-4, -4], [-4, 1], [2, 2], [3, -2], [-5, 7], [3, -2], [-10, -1], [-2, 4], [2, -6], [-1, 3], [8, -5], [0, 6], [-2, -7], [-12, 4], [-2, -2], [2, -5], [8, -1], [-18, 0], [-6, -6], [6, 0], [-6, 5], [10, 0], [1, -9], [2, 5], [4, 6], [1, -9], [2, -7], [-7, 3], [7, 3], [-14, 3], [-2, 10], [20, -4], [10, 0], [17, -3], [-6, -4], [-6, -3], [4, 3], [-6, 8], [-16, 4], [-13, 11], [-14, 4], [17, -9], [14, 4], [4, -11], [0, -8], [-12, -7], [-16, 6], [-16, -2], [-15, -1], [-10, 13], [26, 1], [28, 1], [7, -9], [-9, 15], [15, 1], [-15, 1], [-4, 8], [0, -5], [5, 5], [-26, -2], [10, 2], [8, 3], [-23, 4], [-17, 2], [-26, 4], [-8, -4], [-8, 13], [-36, 2], [-10, 5], [-14, 15], [-2, 11], [15, -11], [20, -6], [-3, 3], [-15, 7], [-6, 4], [4, -4], [2, -14], [19, 1], [-22, 2], [-16, 7], [-11, 18], [-1, -3], [-10, -1], [-4, 6], [3, 5], [28, 3], [36, 0], [-41, 2], [-24, -5], [-15, 4], [26, 2], [-18, -3], [-10, 16], [-16, 8], [4, -14], [12, -16], [-15, -11], [-8, 14], [27, 9], [22, 6], [-37, 7], [3, -12], [-6, 14], [25, 5], [8, 2], [-2, 3], [8, -1], [28, -4], [6, -14], [-20, 12], [-8, 4], [-2, 0], [30, -2], [13, -19], [1, -5], [28, 4], [17, -8], [4, 15], [-16, 4], [25, -9], [20, -6], [29, -7], [-20, 16], [17, -13], [12, 6], [21, 0], [-33, 5], [1, -7], [-13, 5], [-34, 9], [12, 11], [-30, -2], [-18, 8], [-32, -6], [-44, -3], [4, 0], [5, 3], [-9, -17], [-16, 12], [23, 7], [-26, -7], [-2, 14], [10, 18], [44, 1], [-4, 0], [-25, 6], [18, -9], [-17, 3], [-6, 4], [29, -11], [-40, 7], [-34, -2], [7, -20], [-21, 5], [1, 17], [2, -7], [10, -20], [-40, 9], [26, -5], [21, 15], [-19, -5], [-20, -4], [10, -6], [7, 6], [-3, 17], [-17, 22], [-25, 9], [28, 2], [-6, 16], [49, -6], [17, -4], [28, -18], [29, -4], [-28, -5], [3, -12], [30, -8], [-17, 0], [10, -16], [-48, 1], [22, -4], [0, 27], [-34, -8], [10, 12], [2, -16], [-3, -9], [-40, 1], [-27, 27], [-7, -9], [56, 4], [16, 0], [-13, 7], [-4, -12], [-59, -3], [5, 1], [35, -15], [15, 12], [46, -2], [-38, -7], [4, -10], [14, -5], [37, 3], [-14, 8], [-3, -17], [33, 7], [10, -1], [39, -1], [-32, 1], [21, -25], [-2, -27], [-8, -20], [-44, 12], [12, -15], [6, -14], [44, 3], [-9, 19], [-11, -6], [-44, 8], [-21, 3], [40, -9], [-16, 24], [-32, -3], [10, -26], [27, 4], [-44, -11], [22, -16], [-22, 18], [-10, 11], [-24, 28], [-18, 26], [28, -12], [-45, 20], [51, 1], [2, -20], [-2, -21], [-7, -13], [-8, 1], [3, -29], [-2, 23], [-2, 14], [45, 0], [9, 7], [-6, -23], [48, 8], [-21, -10], [50, -10], [-34, -10], [-2, 5], [35, -10], [64, -2], [-34, 8], [63, -4], [33, -1], [11, 1], [-32, 17], [16, -37], [-1, 27], [11, 3], [-12, -14], [-20, -7], [5, 17], [-12, -10], [-24, -23], [32, -14], [12, -6], [-1, 7], [18, 10], [48, -17], [-14, 26], [24, -14], [62, 0], [-64, -6], [5, -23], [18, -18], [-59, 11], [31, -18], [16, -5], [18, 4], [-28, 18], [-21, -25], [-29, 15], [-26, -10], [-34, -11], [-52, 5], [4, -4], [39, 9], [30, 7], [-16, 3], [-23, 22], [-58, 14], [38, -8], [48, -4], [19, 19], [-6, -20], [-12, 26], [58, -11], [48, -4], [-40, -6], [-10, -4], [28, -17], [52, 8], [6, 21], [42, -19], [-72, 12], [-66, 11], [-67, 5], [-34, 4], [38, 4], [38, 0], [-16, 35], [-2, 22], [37, -11], [46, 0], [46, 0], [15, 9], [38, -16], [-14, -29], [-16, 5], [-2, 34], [14, -8], [-16, 6], [23, -28], [-12, -22], [-18, 30], [52, -15], [5, -13], [24, -12], [24, -2], [36, 12], [62, -4], [-42, -3], [-19, 25], [24, 10], [-16, 1], [62, 0], [43, -9], [24, 4], [34, -6], [-5, 6], [-1, -27], [-3, 12], [11, -9], [-38, -18], [-6, -22], [5, -22], [-52, -12], [-29, -15], [2, -3], [10, 7], [58, -16], [-56, -8], [-16, -25], [70, -10], [-22, -19], [-38, 0], [38, -14], [-69, 1], [15, -5], [2, -7], [31, 21], [-10, 29], [-38, 25], [61, 5], [18, 22], [12, -27], [-54, -12], [-18, 3], [-37, -19], [0, 20], [18, 12], [-74, 6], [4, -12], [8, 2], [28, -39], [-35, 19], [16, -15], [12, 23], [-40, 12], [-12, 5], [37, -19], [-10, 13], [-11, 0], [-18, 4], [17, 11], [50, 21], [41, 9], [-14, -29], [22, 2], [-72, -4], [36, -18], [-30, 40], [5, 31], [34, -13], [38, -25], [47, 13], [-65, 10], [-27, -29], [-34, 33], [55, -7], [48, -10], [52, -20], [-44, -3], [-17, 3], [48, -24], [-58, 8], [12, -24], [20, -15], [27, 8], [-5, 19], [49, -1], [23, -8], [-30, -19], [-64, -14]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_9200_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


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