
// Make newform 9450.2.a.et in Magma, downloaded from the LMFDB on 25 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_9450_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_9450_2_a_et();".
// 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_9450_2_a_et();".
// 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 := [-7, 0, 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_9450_a();"
function MakeCharacter_9450_a()
    N := 9450;
    order := 1;
    char_gens := [9101, 6427, 6751];
    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_9450_a_Hecke(Kf)
    return MakeCharacter_9450_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+1)]];
    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], [0, 0], [1, 0], [0, 2], [-2, -1], [-1, 0], [-1, -2], [-1, 1], [-8, -1], [-2, -2], [-7, -1], [2, 2], [3, -1], [-2, 1], [0, 1], [-8, -2], [0, 1], [-3, 3], [-6, -2], [0, -2], [-8, -3], [1, 1], [-1, 0], [-5, -3], [-9, -3], [2, 6], [6, 0], [1, -1], [-2, 4], [-12, -1], [-11, -3], [5, 1], [-6, 4], [-4, 7], [0, 5], [4, 1], [4, 6], [-4, -8], [1, 1], [7, -4], [20, -1], [-4, 4], [1, 6], [16, 1], [1, 7], [20, 2], [-3, -7], [9, -1], [-6, 7], [1, -1], [-17, 1], [-5, -3], [-12, 6], [-3, 2], [-4, -6], [-6, 0], [-10, -2], [-20, 2], [5, -7], [9, -8], [-13, -7], [12, 2], [16, 2], [-1, 5], [22, 3], [-7, -1], [-5, -8], [15, -2], [-12, 1], [-10, 10], [-22, -4], [-7, 3], [-8, -6], [11, -5], [-22, -2], [0, 13], [-14, 7], [17, 3], [5, -5], [-25, 1], [6, -4], [-18, -6], [6, -2], [-23, 3], [23, -4], [5, -5], [23, 6], [15, -7], [-4, -1], [34, -2], [-10, 1], [6, -2], [3, -6], [21, -3], [8, -2], [-11, 7], [-19, -4], [5, -12], [-11, -1], [0, 0], [14, -7], [-31, 3], [-16, -8], [2, 4], [-16, 0], [13, 7], [-15, 0], [-15, -9], [-10, -2], [23, -9], [15, 3], [-13, 3], [-10, 0], [-4, -9], [-30, -2], [-3, 2], [14, -1], [-4, -9], [-5, 4], [18, -8], [16, 4], [-4, -2], [-8, 4], [-28, 2], [-8, -2], [-14, 6], [26, 1], [23, 1], [14, 9], [6, 16], [18, 12], [-12, -4], [5, 9], [-23, 8], [-32, 0], [-4, -8], [30, -4], [-27, 9], [14, 4], [-6, 8], [34, 5], [16, -14], [33, -4], [10, 1], [-26, 9], [-12, 16], [-29, 2], [8, 16], [33, 1], [10, 6], [31, 6], [26, -2], [-34, 6], [18, -2], [8, -8], [12, 14], [5, -6], [-3, -5], [-13, -1], [-24, 2], [-11, 11], [-22, -9], [-17, 5], [-15, -3], [-32, 7], [-26, -3], [24, 10], [34, -6], [2, -10], [0, -14], [42, -4], [13, -13], [19, -16], [47, 3], [7, -2], [10, 0], [-36, 6], [20, 2], [-36, -5], [2, -13], [-6, 0], [30, 4], [45, 2], [-27, -3], [6, -18], [-15, -13], [35, 2], [-27, -8], [-24, -3], [5, -11], [-9, -14], [20, -4], [14, 2], [17, 10], [-9, 0], [21, -14], [-6, -10], [5, -8], [-8, -5], [-2, 7], [-9, 11], [20, 7], [17, -5], [39, 9], [11, -9], [36, -4], [48, -6], [43, 5], [-13, 12], [-43, -8], [12, -6], [14, -3], [-6, 14], [44, 4], [6, 2], [-16, 6], [-33, 0], [48, 4], [24, -12], [2, 6], [37, 1], [-42, 6], [22, 5], [-19, 3], [-8, -8], [-43, -4], [53, -7], [23, -3], [-5, 0], [-10, -12], [5, -14], [-14, -9], [13, 5], [-35, -8], [-44, 2], [-58, 2], [46, -5], [6, 16], [12, 5], [-7, -22], [39, -10], [-15, 15], [-27, 7], [-9, -18], [54, 3], [32, 2], [22, -16], [8, 12], [56, 0], [-34, 6], [-13, -2], [-47, 5], [-24, 0], [-43, -11], [-25, 18], [-27, 5], [26, -12], [4, -10], [-31, -5], [-14, 5], [-13, 20], [24, -5], [40, 9], [-12, 12], [-21, 2], [4, 11], [17, 20], [39, 5], [-30, 3], [-16, -5], [10, -4], [-59, -3], [10, 17], [9, 1], [-51, -5], [-9, -4], [-13, 15], [-22, -8], [2, -30], [4, 0], [-34, -3], [42, -15], [12, 3], [-8, -12], [19, -25], [51, 8], [-16, -8], [11, 21], [11, -20], [-14, -7], [-30, -4], [26, 14], [60, -2], [-6, 12], [9, 3], [-55, -7], [-23, -21], [1, -31], [46, 0], [40, 2], [18, -7], [26, 2], [-20, 2], [-47, 7], [-26, 2], [-59, -8], [-30, 0], [-24, -24], [-1, 5], [6, 15], [46, -4], [64, -2], [16, 6], [43, -1], [-28, 18], [-60, 6], [57, 9], [-43, 7], [8, -10], [-17, -18], [-1, -12], [13, -21], [26, 7], [-29, 11], [1, 13], [30, -22], [-62, -4], [-22, 8], [-28, -5], [-9, -25], [-16, 10], [-21, -5], [-3, 27], [2, 0], [-23, -19], [-2, 12], [-3, 30], [37, 9], [-35, -9], [-53, -5], [-17, 9], [10, -4], [42, -13], [90, 0], [-49, -6], [42, -15], [34, 4], [-6, -3], [-71, 5], [13, 22], [-29, 20], [-18, 3], [-8, 6], [6, -12], [71, 4], [30, 9], [-26, -8], [54, 6], [34, -16], [-17, 9], [-31, -4], [1, 31], [7, -20], [9, 20], [-47, -8], [54, -8], [-12, -4], [11, -16], [3, -12], [-68, 6], [23, -1], [-18, -9], [-32, 10], [-49, 3], [2, 14], [18, 12], [-25, -13], [13, 32], [14, 28], [-18, 8], [33, -17], [32, -2], [-41, -7], [5, 16], [-24, -3], [-18, 21], [12, -20], [10, -6], [16, 15], [-3, -4], [17, 23], [61, 4], [41, 16], [53, -15], [12, 20], [16, 0], [-53, -14], [-28, -2], [12, -6], [40, -19], [-6, -30], [-30, -10], [-38, -16], [62, 0], [-58, 2], [-45, -17], [13, 5], [20, -14], [50, -14], [27, 19], [-48, -3], [3, 12], [27, -5], [-69, -8], [32, -6], [-32, -10], [52, -10], [2, 28], [-20, -11], [-60, 8], [-32, -6], [9, -15], [-12, 10], [-50, -4], [-21, -5], [48, -22], [-24, -12], [49, -18], [-8, 27], [1, -9], [-44, 8], [-9, 15], [52, 8], [-66, -4], [33, 6], [-45, -4], [-4, 32], [36, -24], [68, 6], [-42, -24], [-50, -16], [-16, 18], [-34, -4], [42, -10], [-36, -12], [56, -12], [-52, 2], [-9, 31], [-12, 14], [-61, 9], [38, 13], [-15, 24], [70, 8], [-21, 28], [-48, 3], [17, 9], [-28, -10], [6, -9], [-25, -15], [39, -23], [-44, -15], [6, 24], [11, 13], [51, 20], [2, 14], [4, 6], [-26, -10], [16, 16], [68, -8], [4, 27], [-7, -16], [-70, 9], [83, -2], [-40, 12], [-86, 0], [-34, 16], [-53, 17], [-14, 33], [-38, -4], [-8, 12], [-11, 14], [55, -9], [-50, -16], [-44, 16], [54, 0], [17, -1], [-18, 12], [37, 24], [-52, -4], [-26, -15], [6, -15], [9, 6], [-8, -4], [-48, -20], [-26, -11], [2, -20], [22, 17], [13, 15], [11, 27], [10, -12], [-103, -1], [46, -14], [-6, 10], [10, 14], [20, 32], [-6, -22], [-68, 0], [-19, 29], [11, -18], [-63, -21], [-26, 7], [23, 35], [30, 21], [22, -22], [-5, -18], [47, 7], [48, 14], [6, 2], [17, -15], [-25, 27], [9, 9], [-73, -1], [30, -6], [14, -10], [22, 22], [-31, 9], [34, 18], [-59, -16], [9, 17], [-86, -10], [4, -2], [-30, -6], [13, 10], [66, 13], [-58, 14], [16, -39], [-19, -2], [-20, -24], [60, -12], [-98, -5], [24, 27], [-5, -9], [-46, 16], [-103, 5], [-79, -11], [-34, -31], [73, -11], [-6, 12], [-51, 27], [-16, -28], [62, 8], [-22, -31], [-26, 21], [25, 32], [-8, 39], [32, 0], [-9, 6], [-23, 4], [-85, -6], [-9, -24], [22, 17], [19, 21], [-62, -9], [-36, 6], [-6, 31], [4, 4], [45, -7], [4, 8], [-77, 16], [-29, -10], [-101, -5], [44, 16], [-102, -6], [30, -10], [-25, -26], [22, -10], [17, -30], [-106, 5], [30, -20], [-73, -16], [-1, -15], [-34, 36], [20, -32], [44, -26], [18, 0], [-20, 18], [51, -15], [-7, -22], [82, 2]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_9450_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_9450_2_a_et();".
// 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_9450_2_a_et(:prec:=2)
    chi := MakeCharacter_9450_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(4297) - 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_9450_2_a_et();".
// 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_9450_2_a_et( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_9450_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<11,R![-28, 0, 1]>,<13,R![-3, 4, 1]>,<17,R![1, 1]>,<19,R![-27, 2, 1]>],Snew);
    return Vf;
end function;