
// Make newform 1936.2.a.bc in Magma, downloaded from the LMFDB on 22 December 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_1936_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_1936_2_a_bc();".
// 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_1936_2_a_bc();".
// 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 := [11, 1, -8, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0], [0, 1, 0, 0], [3, -4, -2, 1], [-11, 2, 4, -1]];
    Rf_basisdens := [1, 1, 2, 2];
    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_1936_a();"
function MakeCharacter_1936_a()
    N := 1936;
    order := 1;
    char_gens := [1695, 485, 849];
    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_1936_a_Hecke(Kf)
    return MakeCharacter_1936_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, 0], [0, 0, 0, -1], [-1, 1, -1, 1], [-1, 1, -2, 0], [0, 0, 0, 0], [-1, -1, -1, 1], [3, 2, 0, -1], [3, 0, -1, 0], [0, -2, -2, 0], [3, 1, 2, 0], [-3, 1, 1, 1], [3, 1, -2, -2], [4, -2, 2, -1], [1, 1, 0, -1], [-3, 1, 0, 2], [1, -1, -5, -1], [-5, 0, -5, 0], [7, -3, 5, 1], [0, 3, 1, 2], [5, -3, 7, 1], [2, 0, -2, -3], [-1, 3, -1, 3], [8, -2, 3, -2], [3, 1, 0, -1], [2, 2, 1, -2], [5, -1, 1, 3], [-9, 1, 2, 2], [8, 0, 4, 1], [2, 0, -4, 4], [-5, 0, -1, 4], [5, -3, 5, 5], [12, -1, 1, 2], [-2, 2, 1, -2], [9, -3, 4, 2], [-1, 3, -1, 5], [-9, 3, -8, 2], [9, -7, 0, 0], [-9, 6, -6, -3], [-11, 1, -13, -3], [5, -3, -8, -2], [5, 2, -1, 0], [7, -3, 11, 1], [5, -3, -4, 0], [-15, 5, 3, 3], [4, 0, 14, 2], [-6, 0, -2, 2], [-2, 4, 9, 0], [3, -5, 8, 0], [-3, 6, -1, 0], [3, -3, 11, 1], [12, -4, 3, -4], [-3, -7, 0, 4], [-4, 1, -11, 4], [11, 1, 7, 3], [2, -4, -2, -9], [-2, -2, 4, -6], [1, 1, 1, -1], [11, 1, 14, 0], [-9, 3, -9, 1], [12, -4, -1, -4], [-5, -9, 0, 2], [13, 5, 8, -6], [-3, -7, 4, -1], [-1, -1, 0, 4], [13, -2, 0, 1], [13, 5, 5, -5], [11, -5, 20, -3], [-11, -4, -3, 0], [-1, 6, -10, 5], [-5, -5, 8, -4], [0, -7, 5, 0], [3, -13, 12, -4], [-17, 5, 10, 2], [12, -6, 0, -6], [-16, 2, -11, -6], [7, 1, 3, 3], [13, -7, 12, 0], [14, 2, 2, -4], [2, -10, 13, 2], [-7, -3, -9, 7], [-15, -7, 0, 3], [7, -1, 4, 10], [-15, -1, -3, 1], [11, 6, -7, 0], [-14, -8, -2, 6], [-8, -4, -24, -1], [17, -6, 4, 5], [-18, 2, -17, -2], [-6, 2, -6, -4], [-16, 0, -12, -8], [-7, -1, 17, 1], [-1, 1, 15, 7], [-25, 7, -12, -4], [6, 6, -8, 1], [0, -8, 12, -7], [9, 1, 0, -8], [7, -3, -10, 2], [23, -2, 29, 4], [-17, 2, -10, 9], [3, -1, 7, -11], [11, -6, 9, -8], [15, -9, 0, -4], [14, 4, -11, 0], [13, 6, -9, 4], [0, 4, 12, 0], [1, 8, -6, 5], [7, -2, 5, 8], [-12, 11, -1, 8], [15, -5, 23, -5], [-6, 4, -2, 9], [1, -7, -5, 5], [1, -1, 22, 2], [16, -7, 17, 4], [-3, -8, 5, -4], [-1, 9, 2, -6], [-20, 2, 2, -3], [-6, 0, -11, 4], [-23, -3, -27, 5], [-9, 1, -14, 6], [0, 1, -13, 2], [-6, -4, -20, -8], [11, -10, 16, -5], [-19, -3, -17, 7], [-16, 12, -16, -4], [3, -4, 8, 1], [-11, 1, -16, -10], [7, -9, -11, -3], [-1, -9, -8, 2], [10, -10, 4, -2], [-21, 5, -6, -8], [13, -2, 10, -5], [21, -5, 3, -7], [23, 1, 14, 8], [-13, 9, -5, -3], [7, 10, -12, 7], [14, -16, 8, -12], [5, -9, -14, 0], [11, -4, 24, -7], [3, -7, 15, 1], [19, 10, 8, -5], [12, -4, 12, -11], [9, 3, 2, -10], [1, 7, -9, -3], [-7, -6, 6, -9], [-13, -5, -8, 2], [-1, 13, -6, -4], [19, -11, 5, -15], [23, 1, 20, -5], [-8, 3, -19, 10], [-11, -7, 15, -7], [-9, 3, -16, -8], [-21, 13, 0, 3], [22, -2, 16, -11], [-21, 13, -14, -4], [9, 4, 16, -9], [27, 3, -7, -1], [31, 5, 15, -9], [-27, 14, 8, 5], [11, -8, -6, -9], [9, 7, 21, -5], [4, -13, 17, 6], [28, -14, -6, -9], [-30, 8, -26, -14], [25, 1, 24, -10], [7, -1, -3, 13], [1, 3, -18, -12], [28, -6, 2, 0], [-7, 7, -22, -2], [-32, 6, -22, -1], [-6, 4, -4, -4], [16, 4, 16, 11], [-15, -9, -9, -1], [1, 7, -6, -16], [20, 3, 3, -4], [-21, 5, -11, 3], [1, -1, 6, -8], [-22, 0, -1, 4], [11, 9, 3, 9], [13, -1, -10, -6], [19, -3, 29, 9], [-9, -11, -1, -9], [45, -9, -3, -7], [-23, 9, 12, 8], [-5, -7, 2, 12], [-23, -1, -2, 6], [37, -5, 15, -1], [-23, 1, -9, 19], [-11, 5, 8, -9], [25, -6, 15, 4], [15, -11, -10, -4], [9, 4, 14, 9], [-5, -2, -39, -4], [-15, 4, 4, 15], [-17, 5, -18, -10], [-12, 16, -20, -8], [35, 7, 5, -15], [-20, 20, -17, -8], [15, -1, -8, -10], [-13, 9, -6, -8], [5, -13, 29, -15], [-13, 15, -12, 16], [40, 0, 20, 4], [23, -7, 3, -3], [28, -4, -1, -12], [-4, 2, -3, 10], [44, 8, 10, -6], [15, 3, -20, 0], [-19, 8, 13, 16], [-23, 9, -17, -9], [-32, -4, -32, 5], [-36, -7, 5, 4], [-9, -5, -4, -14], [-3, -13, 5, 9], [-20, 10, -29, -2], [42, 6, 28, -18], [-11, 15, 0, -3], [-15, -15, -8, 6], [32, -2, 14, 3], [-65, -1, -4, 4], [17, 9, 1, -5], [-5, -13, 3, -11], [31, 1, 13, -1], [34, -16, 4, -4], [-29, 11, -36, 6], [19, -5, -4, 6], [22, 4, 20, 12], [-9, 8, 7, 12], [13, -25, 19, -7], [5, -13, -1, -7], [-7, -11, 16, -5], [-4, 10, -4, -10], [0, 8, -12, 7], [-3, 11, -6, -16], [3, -7, 14, 4], [-2, 4, 15, -8], [1, 1, -17, -7], [-28, 6, 2, 5], [-31, 19, -22, -14], [-6, 18, -32, 1], [13, 3, 10, 16], [33, -4, -4, -1], [-20, 18, -27, -2], [21, 1, 8, -26], [23, -7, 31, -11], [7, 8, -26, 11], [-29, -5, -12, 18], [33, -13, 21, -3], [2, 8, 19, 4], [-21, -11, 3, 15], [-18, -6, 4, -2], [-39, 1, -17, 11], [5, 1, 31, 7], [14, 2, 16, 2], [-17, -8, 19, -4], [-23, 1, 8, 6], [25, -14, -6, -13], [-5, 23, 8, 2], [4, 13, 15, 10], [-45, -13, -19, 9], [13, 14, -13, 8], [45, 7, 9, -7], [7, 9, 23, -1], [-13, -13, 8, 0], [10, 12, 0, 4], [5, 3, -6, -8], [24, 6, 13, -2], [19, -7, -6, -22], [9, -8, -2, -15], [-27, 2, 19, 8], [-21, 5, -15, -7], [-9, 3, -28, -14], [-14, 4, -29, 4], [39, -8, 51, 0], [-12, 4, -28, 0], [-5, -4, -18, -9], [-4, -6, 18, -12], [-31, 2, -2, 19], [35, 5, 6, -4], [5, 8, -7, 0], [45, 5, 12, -6], [15, -11, 26, -10], [19, 17, 1, -5], [0, -2, 30, 4], [13, 3, 5, -9], [-53, 10, 9, 12], [-14, 6, 20, 18], [-33, 2, -27, 0], [-13, 23, -20, 0], [-15, 5, 13, 25], [-5, -3, -6, 0], [-45, 7, 17, 9], [-14, -10, 0, -9], [-23, -5, -4, 13], [-1, 14, -10, -7], [-15, 3, -34, 10], [43, -1, 35, 5], [27, -1, -16, -2], [-21, -19, 6, -2], [17, -3, -32, -1], [-38, 6, -20, 17], [30, -14, 23, -6], [-1, -21, 35, -3], [31, -3, -14, -10], [-43, 1, -40, 3], [27, -12, -12, -27], [-12, 14, -26, -15], [34, -22, 0, -3], [9, 7, -21, -5], [-11, 21, -16, 4], [-5, -15, 2, -8], [25, 7, 35, 9], [-4, -4, 22, 2], [15, 6, 20, -5], [11, 14, 9, 4], [-19, 11, 2, 4], [-19, 19, -8, -7], [-8, -6, -1, 18], [-28, -8, 8, 12], [-25, -19, -4, 7], [-32, 4, 11, 4], [4, 8, 12, 9], [-28, 2, 2, -7], [29, -5, -22, -6], [9, 11, -1, 5], [-3, 2, 35, 0], [6, -30, 5, -2], [0, 8, -16, -4], [21, -3, 16, -6], [-39, -3, -52, 6], [-15, 11, 5, 11], [-34, -4, -8, -16], [-19, -9, -2, 20], [17, -15, -15, -3], [-35, 9, 8, 19], [-7, -16, -11, 12], [-8, 0, -36, -12], [-11, -27, 4, 8], [-11, 4, -31, 16], [-5, 12, 23, 4], [34, -24, 18, 2], [39, -15, 19, -19], [-14, -18, 21, 2], [-2, 4, -24, 0], [0, 0, 16, 16], [12, 4, -14, 2], [45, 1, 24, -30], [21, -11, 5, -1], [-1, 15, -56, 10], [-41, 27, 8, 14], [-29, -13, -20, 22], [43, -6, 42, 5], [37, -1, 24, -3], [-13, -17, -15, 13], [13, 1, -32, -14], [-5, 19, -17, -15], [0, -8, 51, -8], [18, -16, 30, -18], [1, 4, -4, -1], [21, 2, 15, 0], [17, 19, -18, 10], [-3, 1, 3, 19], [-18, 4, -24, 16], [3, -17, -1, -17], [15, -16, 40, 5], [-15, -19, 16, -2], [20, 4, 17, -20], [-29, 13, 1, -11], [17, 1, 45, 9], [34, -2, 11, 6], [27, -1, 8, -19], [39, -3, 7, -21], [-1, 15, 35, 3], [-19, -17, -14, 14], [2, -30, 16, 14], [-35, -3, 25, -5], [-11, 6, -6, -21], [-5, -9, -15, -9], [29, 12, -11, 12], [34, -2, 23, 18], [35, 9, -16, 7], [21, -1, 50, -8], [-28, 10, -26, -11], [-13, 1, 10, -4], [-23, 9, -17, 15], [24, -12, -8, -7], [36, -8, -24, -4], [-15, 31, 3, 9], [33, -17, 6, -8], [28, -9, 41, -2], [-5, -3, 6, -4], [-43, -4, -26, -3], [-39, 13, 13, 19], [-56, 4, 12, 9], [48, 4, 36, 0], [53, -15, 27, 9], [11, 21, 22, 4], [19, -13, 31, 11], [-52, -5, -41, -4], [20, -16, 40, 15], [-37, 1, -43, 5], [-38, 22, -2, 16], [60, 6, 26, -15], [-29, 11, 33, 3], [1, 14, -24, 9], [-51, 5, -17, 19], [9, -13, -10, -24], [27, -27, 18, -10], [-3, -2, -9, 24], [-9, -23, -17, 3], [45, -26, -9, -8], [3, 8, -18, -9], [8, 16, -10, 18], [-39, 7, -23, 1], [41, -16, 40, -1], [2, -24, -2, -3], [80, -6, 20, 10], [13, 17, 24, 4], [-31, 37, -25, 1], [39, -10, 33, -16], [-56, 0, -20, -4], [-47, -11, -11, 3], [-13, 11, 3, -3], [18, 10, 12, 6], [30, 8, 1, 8], [38, 14, -19, 10], [-27, 1, -43, -17], [8, 12, -8, -23], [-4, 3, -9, -32], [9, -19, 40, 3], [-11, 3, -42, -2]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_1936_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_1936_2_a_bc();".
// 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_1936_2_a_bc(:prec:=4)
    chi := MakeCharacter_1936_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_1936_2_a_bc();".
// 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_1936_2_a_bc( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_1936_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<3,R![11, -8, -7, 2, 1]>,<5,R![4, 22, -15, -1, 1]>,<7,R![-4, 16, -13, -1, 1]>],Snew);
    return Vf;
end function;