
// Make newform 9282.2.a.bj in Magma, downloaded from the LMFDB on 11 June 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_9282_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_9282_2_a_bj();".
// 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_9282_2_a_bj();".
// 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 := [3, 8, -7, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0], [0, 1, 0, 0], [-2, 6, 0, -1], [-2, -5, 1, 1]];
    Rf_basisdens := [1, 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_9282_a();"
function MakeCharacter_9282_a()
    N := 9282;
    order := 1;
    char_gens := [3095, 3979, 8569, 547];
    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_9282_a_Hecke(Kf)
    return MakeCharacter_9282_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, 0], [-1, 0, 0, 0], [1, 0, 0, -1], [1, 0, 0, 0], [2, 1, -1, 0], [1, 0, 0, 0], [1, 0, 0, 0], [0, -1, 0, -1], [1, 2, 0, -1], [-1, -1, 1, -1], [2, 1, 2, 1], [0, -1, -2, -1], [3, 1, 1, 1], [1, 3, -2, -2], [3, -1, 1, 1], [3, -3, 2, 4], [0, 0, -1, 1], [-1, 3, -3, -1], [-2, -1, 0, -3], [5, -3, -1, -1], [4, 4, -1, -1], [-1, -1, 3, 3], [1, 1, 0, 2], [-3, 1, 1, -1], [0, 1, -4, -1], [7, -2, -3, 2], [4, -4, 0, 0], [4, -3, 2, 3], [-8, -1, -1, 2], [5, -2, -3, -4], [9, -1, 4, 0], [7, -2, -3, -4], [-5, 2, 3, 4], [-6, -7, 3, 0], [-5, 1, 0, -2], [3, 2, -4, -7], [-3, 1, -1, 1], [-5, -6, 5, 4], [6, -3, 3, 0], [-7, -1, 0, -2], [1, 0, -3, 0], [-6, 5, -2, -5], [0, -2, 4, 2], [-1, -8, 4, 1], [2, 6, -3, -7], [1, 6, 1, -2], [-2, -10, 4, 4], [-3, -1, -1, 1], [3, 1, -3, -1], [5, -3, -3, -1], [8, -7, 7, 4], [-6, 3, 0, -3], [-3, 1, 0, 4], [12, 5, -4, 1], [12, 3, 2, 3], [5, 2, -7, -2], [1, -6, -6, -1], [-5, 4, 3, 0], [-4, 1, 3, 8], [13, -3, 2, 6], [5, 2, -7, 2], [-11, 1, -6, -2], [-1, 2, 8, 5], [-15, 6, -3, 2], [-2, -7, 4, 1], [13, -5, -2, 8], [-7, 3, -8, -8], [-11, 7, 0, -2], [-1, -6, -7, -4], [7, -9, 6, 6], [19, -3, 8, 6], [4, 3, -6, -3], [2, -3, 6, 1], [-8, 5, -3, 6], [11, -10, 4, 5], [16, 5, -6, 3], [-4, 1, 1, -6], [19, 4, 2, -1], [-7, 4, 3, 0], [-7, -2, 3, 2], [-6, 1, -1, 4], [-7, 5, -4, 0], [6, -1, 5, 0], [-14, 3, -2, -3], [12, -4, -6, -2], [14, 1, -4, -9], [-4, -4, 5, 5], [-7, 2, -3, 4], [-3, -3, 6, 14], [-11, -6, 7, -4], [-1, 0, -1, -4], [5, 6, 0, 3], [-6, 9, 3, 4], [13, -3, 9, 5], [-6, 12, -9, -1], [0, 8, 6, 2], [7, -13, 5, 11], [3, 1, 0, 6], [10, -1, -7, -8], [18, -8, 13, 7], [5, 15, -7, -9], [12, -8, -2, -4], [18, -7, 14, 9], [3, -1, 11, -3], [3, -7, -2, 6], [-10, -14, 3, 7], [8, 9, -10, -9], [20, -5, -5, -6], [20, -4, 12, 4], [-4, 7, 2, -1], [11, -3, -4, 0], [0, 10, -8, -12], [12, 5, 5, 6], [-7, 6, -9, -12], [-20, -3, 7, 2], [-12, 6, 4, -4], [23, -5, -1, 7], [0, 5, -5, -10], [7, 7, -10, -2], [-19, 7, -3, -13], [-3, -7, -1, 9], [-5, -1, -13, -3], [10, -2, 10, 0], [16, -10, -3, 5], [18, -9, 8, 13], [4, -5, -3, -8], [-11, 3, -7, -3], [11, -7, 4, 12], [20, -8, -3, 3], [22, -12, 0, 12], [-10, -13, 7, 14], [22, 1, -5, -4], [17, 0, -2, -1], [16, 9, -9, 0], [6, 8, -5, -15], [3, -2, 7, 8], [-9, -5, 1, -9], [-19, -7, 0, 6], [-4, -3, -1, -8], [20, -1, 12, 5], [1, -2, 12, -5], [-7, 15, -14, -20], [-1, -19, 8, 8], [11, -6, 8, 9], [-7, -14, 5, 0], [6, -18, -4, 4], [8, 8, 2, -4], [-6, -10, -6, 4], [24, -3, -1, 6], [9, 5, -4, -2], [5, -10, 14, 15], [15, -6, -6, -15], [7, 17, -6, -2], [-8, -13, -4, -1], [7, -15, 18, 6], [14, -16, 13, 21], [2, 5, -1, 4], [-9, -5, 5, 11], [20, -7, -8, 3], [13, -10, -4, 5], [15, 14, -1, -2], [2, -10, -10, -8], [4, 10, -3, 1], [5, -5, -7, -13], [0, 3, 6, -1], [32, 0, -3, 3], [9, 13, -14, -8], [-8, 16, -6, 0], [-18, 1, -11, 0], [-7, 11, 7, -9], [-8, 3, 11, 8], [-19, 7, -4, 6], [9, 4, -9, 6], [7, 5, 10, 12], [19, 14, -10, -9], [-1, -17, 6, 2], [18, -13, 16, 1], [15, 23, -9, -7], [9, -14, 1, -6], [15, 2, 5, -2], [9, -13, -1, -7], [-4, 11, 4, -9], [-7, 12, 5, 10], [8, 12, 10, 4], [-3, 17, -16, -22], [-8, 13, 12, 3], [-18, 11, 5, 2], [10, 1, -5, 4], [-17, 6, -9, 8], [10, -9, 10, 3], [43, 7, -1, 1], [-16, 14, -12, 2], [14, -8, -7, -3], [13, -6, -6, 7], [49, 3, -1, 1], [-20, 7, 8, 9], [-13, -9, 10, 14], [14, -11, 5, 12], [20, 10, -10, -2], [17, 17, -10, -8], [18, -13, 4, 11], [-35, 12, 5, 12], [-6, 2, -4, -14], [-12, -15, 11, -4], [-26, 12, 4, 10], [-26, 10, -5, -5], [22, 10, -3, -5], [5, -14, 19, 0], [1, 11, -16, -18], [-15, 16, -5, -22], [2, -15, 6, 11], [35, -13, 0, 4], [-20, -12, 0, 8], [10, -19, 0, 3], [1, 13, -13, -9], [7, -20, 15, 6], [15, -18, 0, 1], [-23, 12, -5, -8], [11, -14, 15, 10], [-9, -5, 13, -5], [12, 11, -8, 1], [-15, -6, -5, -8], [4, -4, 5, -7], [7, -15, 13, 3], [10, 15, -5, 6], [-40, 0, 0, -6], [-8, -12, -9, -1], [-33, 4, 9, -6], [15, 7, 7, -1], [16, 11, -8, 3], [-7, 21, -10, -10], [-5, 1, 1, 15], [4, 11, -11, -14], [-23, -19, 9, 11], [-2, 4, -9, 3], [-1, 13, -8, 0], [-7, 5, 0, -4], [27, -12, -1, -6], [-17, -15, 11, 1], [-1, 8, -1, 8], [17, -11, 8, 18], [-10, -4, 15, 11], [-2, -5, 12, 5], [-24, 10, -6, 10], [8, -14, 15, 13], [14, 9, 4, 3], [1, -9, 8, 20], [3, 7, 13, 5], [-2, 9, 2, -3], [11, 6, -9, 10], [2, 14, 1, -3], [9, -2, 0, 1], [13, -4, -13, 6], [-21, 5, 3, 11], [-20, 13, 12, 7], [-4, -12, -9, 1], [-30, -7, -10, -9], [1, 9, 6, -4], [-12, 6, -6, 10], [30, -10, 5, 9], [-8, 8, -12, -4], [-42, 8, 1, -3], [12, 13, -17, -20], [-34, 18, 8, -14], [5, 5, 15, 1], [13, -8, -6, 3], [-7, 16, 10, 9], [-12, -2, 11, 5], [24, 13, 7, 6], [15, -11, 3, 19], [25, -11, 3, 13], [9, -5, 4, 12], [13, -15, -8, 0], [-33, 11, 1, -7], [-43, -5, 1, 5], [-4, 5, -8, -3], [-25, -8, 6, 9], [21, -12, 13, 14], [-6, -10, 8, 6], [-13, -3, -6, -10], [-37, -10, 10, 11], [-21, 15, 2, 12], [1, 1, 6, 8], [0, -25, 13, 24], [31, 12, -3, -6], [-31, 2, 6, 25], [26, -8, 9, -5], [-8, 5, -8, -1], [20, -15, -11, -16], [-32, 11, -24, -15], [-22, 4, -2, 10], [-32, -2, 11, -5], [34, -7, -5, -18], [-27, -6, 1, -10], [-48, -6, 7, 9], [-37, 5, -4, 2], [-4, -8, 5, -5], [-41, -18, 10, 1], [0, -1, 20, 7], [28, 20, -7, -5], [24, 9, -13, -24], [3, 23, 11, -3], [-15, -2, -15, -2], [2, -23, 2, 5], [-38, 18, 5, -1], [-23, -19, 14, 6], [-32, 11, -16, -9], [5, 10, 12, 17], [-2, 8, -22, -12], [-9, -5, 5, -9], [-14, 13, -9, 4], [11, -6, -4, 7], [-15, 6, -26, -21], [-2, 4, 8, 6], [13, 10, -9, -8], [-14, 4, 17, -1], [-13, 19, -12, -14], [24, 1, -6, 3], [3, 27, -8, -12], [-2, 9, -4, 9], [1, -1, -8, -16], [22, 4, -16, 4], [3, 22, -3, -10], [-29, 1, 8, 4], [24, 12, -8, -22], [33, 9, -3, -13], [-24, 2, 12, 10], [49, -2, -2, -7], [29, -24, 7, 22], [3, 6, -5, -16], [-18, 19, 2, -19], [-11, 20, -22, -3], [-52, 2, -4, 10], [-2, 24, -9, -1], [-36, 9, -7, -12], [4, -23, 2, 3], [-43, 7, -7, -11], [2, 7, 4, 3], [15, 10, -7, 10], [21, 7, 9, 3], [34, -3, -3, -8], [-10, -5, -5, 0], [4, -23, 2, 5], [31, -10, 20, 13], [4, 26, -11, -13], [-32, 13, -9, -10], [-35, 15, -22, -24], [-26, 12, 5, 1], [5, -12, 10, 23], [-12, -9, -6, -5], [24, 12, -9, -15], [-2, -11, 1, -8], [-30, 1, 3, -6], [21, -4, 8, -11], [39, -13, 26, 14], [8, -6, 7, -19], [24, -14, 7, -9], [18, -16, -1, -17], [23, -6, -8, 3], [-3, 3, -3, 19], [-47, 6, -10, -5], [-11, -7, 2, 14], [50, -6, -7, -1], [-5, 0, 7, 4], [39, 5, -7, -9], [3, -19, 19, -5], [32, 0, 16, 2], [-12, -1, 1, 18], [-32, 11, -1, -10], [4, -35, 9, 16], [36, 11, -10, -3], [13, 6, 1, 14], [14, -15, -6, 15], [-8, -29, 5, 18], [-14, -15, 9, 8], [26, 18, -3, -13], [-15, -1, 7, 9], [12, -19, 5, -18], [-6, 4, -23, -25], [-21, -10, -7, -2], [-15, -6, -5, 2], [13, 12, -6, -3], [-8, -1, 0, -9], [-43, 1, 5, -9], [17, 6, -11, -26], [17, -4, -12, -7], [19, -15, 18, 10], [-10, 7, -5, 8], [45, -2, -2, -3], [-27, 11, -23, -9], [-28, -17, 8, 5], [-36, 14, 5, -13], [-2, 3, 8, -3], [3, 5, -25, -3], [-9, 2, 1, -8], [-15, 28, -11, 6], [-18, -30, -2, 6], [-6, 15, 4, -5], [-14, -3, -20, -9], [11, 9, -13, -1], [6, -4, 0, 24], [29, 5, -1, 1], [15, -27, 11, 29], [20, -18, 9, -5], [-20, 20, 3, -1], [0, 21, 13, 4], [-21, 3, 10, 2], [-2, 7, 4, 19], [16, -4, 15, 17], [-16, 2, -13, 11], [-49, -5, -4, 0], [7, 31, 10, 2], [-40, 2, 7, 27], [3, 21, -23, -13], [27, -5, -11, -25], [19, -21, -13, -11], [-20, 6, 3, -1], [16, 33, 0, 1], [21, -28, 6, -3], [30, -13, 24, 17], [-51, 6, -3, 16], [-26, 10, -11, -19], [-37, -4, 6, 1], [35, 4, 26, 13], [-30, 23, 13, -14], [4, -12, 15, 11], [-5, -17, 0, 2], [-21, -6, 9, -6], [-21, -15, -7, -13], [-5, -15, 5, 15], [7, -3, 1, -15], [-35, 21, 14, 12], [-10, -22, 1, -1], [38, -2, -15, -5], [9, 10, 7, 18], [-71, -16, 8, 11], [-24, 4, -17, 3], [6, -17, 9, 2], [16, 7, 18, 9], [-21, -9, 14, 28], [42, 16, -12, 6], [-23, -38, 15, 2], [-47, -5, 4, -10], [5, -7, -9, 23], [28, -8, 21, 1], [-32, -2, 4, 0], [-13, 11, 16, -2], [9, 6, 4, 3], [16, -6, 0, 0], [46, -15, 8, -7], [-50, 4, -7, -19], [-2, -8, 10, -8], [-11, 4, -4, 9], [11, 16, -15, -20], [4, -4, 11, -9], [-26, 21, -5, -34], [-32, 3, 6, -1], [-23, -23, 2, 16], [27, -1, 5, -1], [-41, 14, -21, -16], [-19, 10, -19, 14], [0, -3, 10, 11], [-29, -3, -20, -20], [-1, -22, 14, -7], [13, -28, 7, 10], [9, 10, -15, 8], [13, -2, 2, 5], [-28, -6, 4, -18], [31, -17, 21, 7], [44, -25, 10, 13], [-14, 31, -18, 11], [-21, -40, -1, 0], [-53, -2, -15, -12], [11, -31, -11, 1], [-43, 19, -14, -2], [34, 26, -1, -1], [-41, -4, -17, -2], [11, 37, -5, 1], [-20, 19, -4, -37], [0, -1, -4, 25], [20, -5, -3, 20], [-8, 22, 16, 4], [-9, 2, 4, -9], [-42, -17, 5, -2], [28, -17, 0, 27], [-31, 4, -3, -4], [15, -2, -22, 9], [35, 37, -9, -15], [-2, 15, -15, -4], [15, -17, 0, 18], [-53, -1, -21, -15], [5, -22, -5, 12], [-29, 9, -10, -12], [25, 21, 8, 12], [26, -6, 13, 7], [31, -12, -12, 1], [24, 13, 3, -14], [13, 23, -9, -5], [15, 34, -8, -11], [-3, 16, -13, -10], [24, -9, 5, -24], [14, -5, 14, 15], [23, -16, 3, 2], [-30, -14, -3, -5], [-13, -5, -13, -11], [-17, -13, 19, -11], [3, -13, 22, 4], [-36, -25, -10, -3], [-22, 24, 7, -15], [10, 19, -23, -4], [-42, 23, -10, -13], [68, -11, -3, 8], [28, -11, -9, 4], [5, 21, -6, -10], [-3, -8, -3, -20], [2, -19, 22, -1], [8, -7, -10, 5], [5, 5, -11, -9], [-35, -9, 18, 14], [-33, 2, 17, 32], [7, -9, 19, 25], [-36, 16, 10, 18], [-2, 27, -2, 17], [6, -14, 16, 40], [19, -17, 17, 31], [-12, 4, 19, 5], [7, 4, 22, 23], [-49, -7, 4, -6], [31, 24, 3, -4], [-32, -6, -18, -10], [15, 11, -20, 2], [-3, 11, -7, -7], [-12, 17, -3, -28], [-17, 13, -1, -31], [71, 3, 10, 10], [0, -21, 17, -2], [35, -3, -8, -18], [-20, 8, -5, -13], [18, -6, -11, 25], [9, 4, -6, -13], [-19, 5, 24, -18], [-30, 17, -17, 18], [0, -3, -23, -28], [-48, 6, -1, -9], [8, 3, -22, 7], [-3, 16, -6, 7], [-5, -38, 5, 16], [21, -5, -15, -1], [8, -20, 27, 29], [-15, -7, -6, 6], [-26, 11, -20, 3], [13, 8, 3, -26], [-24, 13, 7, -14], [5, -13, 28, 18], [-10, 3, 14, 27], [-48, -9, -8, 1], [-16, 10, -5, -25]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_9282_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_9282_2_a_bj();".
// 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_9282_2_a_bj(:prec:=4)
    chi := MakeCharacter_9282_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(4027) - 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_9282_2_a_bj();".
// 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_9282_2_a_bj( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_9282_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<5,R![-18, 25, -5, -4, 1]>,<11,R![-8, 25, 15, -9, 1]>,<19,R![-16, 37, -22, 1, 1]>],Snew);
    return Vf;
end function;