
// Make newform 6936.2.a.bd in Magma, downloaded from the LMFDB on 22 September 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_6936_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_6936_2_a_bd();".
// 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_6936_2_a_bd();".
// 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, -3, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0], [0, 1, 0], [-2, 0, 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_6936_a();"
function MakeCharacter_6936_a()
    N := 6936;
    order := 1;
    char_gens := [1735, 3469, 4625, 6361];
    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_6936_a_Hecke( : Kf := Kf)
    return MakeCharacter_6936_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, 0], [-1, -1, 1], [-1, 1, -1], [-1, 1, 0], [0, 0, 0], [1, -1, -1], [1, 0, -1], [2, -1, -2], [2, -2, 1], [3, -1, 1], [2, -5, 3], [-4, -2, 4], [-2, -1, 2], [-4, 0, -5], [-3, 3, -3], [-1, -5, 0], [2, -4, 8], [1, 6, -2], [-1, 6, -5], [-1, 6, -8], [2, 7, -4], [-12, 2, 1], [1, 2, -6], [-4, -3, 7], [-6, 3, -6], [-4, -7, 7], [1, -5, 8], [-10, 3, 2], [-4, 3, -9], [-12, 0, -2], [-5, 6, -1], [3, 7, 4], [-7, 2, 1], [4, 4, 0], [0, -8, 3], [-1, -12, 3], [-6, 7, 5], [-1, 9, -10], [-1, 13, -6], [5, -2, 7], [11, -2, 2], [15, -1, -2], [-12, -4, -2], [-12, 9, -4], [-7, 0, 10], [4, -9, 13], [3, -6, -1], [6, -13, -1], [-9, -7, 3], [-7, -9, -1], [9, -3, 7], [-10, -11, 9], [-14, -5, -2], [8, -1, -10], [-1, -3, 12], [-10, -1, 11], [4, 11, -16], [-16, 6, 2], [-11, 0, -3], [-10, -10, 6], [-15, 1, -2], [-10, 2, 1], [-6, 13, -1], [7, 2, 11], [3, 2, -15], [6, 1, 12], [0, 0, 3], [-5, -2, 7], [-3, -7, 2], [-15, 2, 5], [3, -11, 0], [8, -3, -11], [6, -6, 7], [10, 21, -11], [-3, 11, 5], [31, -4, 6], [-15, 7, 3], [-21, 10, 5], [0, 4, -12], [-2, 5, 11], [8, -15, 12], [-9, 2, -23], [28, -2, 7], [12, -10, -12], [-5, 5, -13], [-8, 2, 0], [-9, 8, -21], [-5, 14, -7], [6, 14, -7], [21, 2, -12], [3, 1, -14], [-7, 0, -10], [6, 1, -1], [4, 0, 1], [-1, 0, 3], [-11, 15, -9], [15, -3, 7], [-1, 14, -7], [19, 6, -1], [-17, 1, 10], [-1, -8, 11], [-19, -10, 8], [-5, -17, 4], [5, -25, 5], [22, 5, 9], [-16, -8, 8], [13, 2, 20], [21, 13, -10], [7, 17, -15], [-15, 3, 10], [-15, 19, -7], [8, 1, 11], [11, -4, 1], [-3, -18, 11], [10, 1, -20], [0, -28, 17], [-26, -7, 5], [6, -11, -9], [-1, 7, 2], [13, -2, 1], [-26, -3, 10], [8, -10, 6], [-16, -16, 5], [-6, -27, 12], [13, 15, -13], [4, -8, -10], [16, 13, -6], [2, 27, -17], [2, 25, -26], [9, -12, 25], [24, -6, 22], [14, -15, -3], [21, -3, -13], [-4, 23, -12], [3, -9, 9], [-11, 17, -14], [-14, 10, -14], [9, -3, 25], [-24, 13, 2], [-7, 1, -1], [20, 2, 11], [6, 12, -25], [15, 28, -14], [-16, -1, -5], [-4, -26, 28], [2, 0, -9], [-10, -16, 4], [1, -11, -1], [-7, 17, -31], [16, -24, -11], [19, -18, 11], [-15, 8, -13], [10, 8, -6], [17, -10, 15], [34, -11, 20], [-21, -2, 15], [4, -17, 30], [-19, 10, -20], [7, -9, 33], [11, 9, 4], [-3, 17, -11], [1, 14, 2], [-8, 1, 13], [-16, -12, 5], [26, -8, -2], [14, -12, 21], [7, 0, 29], [-30, -3, 4], [-6, 23, -26], [-21, 5, 10], [-13, 1, 9], [8, 16, -27], [3, 0, 20], [-20, -11, -15], [-21, 18, -35], [-40, -17, 10], [-10, -15, 3], [11, -17, 17], [13, 8, 10], [-1, -20, 4], [-3, 9, -16], [-6, -7, -13], [6, -34, 20], [-7, 24, -41], [12, 31, -14], [-15, 25, 8], [7, 26, -13], [-9, 3, 16], [11, -1, -21], [24, 38, -28], [7, -7, -13], [15, -5, 23], [-6, 32, -13], [-46, 5, -3], [-12, -35, 17], [-9, 13, 27], [9, 12, 14], [9, -10, -7], [0, 24, -6], [-27, 6, 7], [22, 0, 14], [-14, 4, -14], [-6, -9, 16], [42, -6, -9], [-1, 26, -29], [1, 30, -15], [7, -30, -8], [29, -11, 9], [32, -8, -9], [33, -20, -10], [-28, -14, 14], [-4, 13, -12], [-1, 12, 13], [4, -14, 5], [-4, 19, -10], [35, 19, 1], [-13, 23, -44], [0, 10, 7], [-4, 17, -18], [28, 24, -20], [-30, -21, 21], [-23, 13, -15], [34, -7, -9], [5, -18, 9], [-26, -17, 20], [21, -16, 14], [38, 13, -8], [-10, 23, 10], [12, 3, 23], [-3, 17, -28], [-18, -44, 35], [31, -1, 0], [9, 23, -18], [40, -3, -4], [14, -4, 36], [-33, 14, -13], [-24, 7, -20], [4, -29, 20], [48, 15, -15], [38, -12, -4], [14, 14, -9], [19, -15, 26], [-30, -14, 22], [20, -2, 32], [-8, -45, 35], [-5, 12, -3], [-12, -29, 12], [-22, -6, -5], [28, 33, -12], [0, 16, 8], [18, 24, -33], [24, 20, -29], [20, 28, -31], [-19, 19, 9], [15, -7, 17], [20, -16, 18], [-16, 25, -41], [-14, 30, -30], [17, -14, -20], [4, -27, 25], [14, -16, 9], [44, -11, -8], [-3, 17, -36], [11, -23, -8], [17, -2, -17], [1, 33, -36], [-6, 23, 19], [17, -3, 14], [-17, 8, -20], [18, 1, 10], [-5, -7, 37], [-36, -19, 27], [26, -15, 26], [7, 8, -7], [-27, 27, 18], [18, 13, -9], [-51, 8, -15], [-8, 6, 25], [8, 26, 2], [23, -19, 2], [13, -32, 25], [18, 28, -13], [-28, -23, 31], [-16, -6, 11], [-1, 16, -14], [-13, -35, 15], [-1, -9, -11], [-1, -22, 10], [-7, 11, -20], [-1, -42, 11], [-5, -38, 20], [-5, 26, -39], [23, 9, 21], [-7, -15, 16], [1, 25, -15], [12, -15, 27], [45, -14, -6], [-7, 9, 6], [-12, 20, 10], [13, -16, 39], [2, 13, 11], [22, 0, 20], [-4, 5, -33], [17, 6, -24], [14, -10, -23], [2, -8, -8], [-39, 9, -32], [38, -15, 8], [37, 16, -11], [13, -9, 31], [71, -8, 6], [-3, 18, -7], [1, 6, 31], [37, -25, 28], [-11, 8, -11], [-17, -48, 15], [8, -39, 16], [18, 10, 31], [11, -8, -23], [3, -15, 31], [42, -21, 31], [31, -5, 0], [-17, -7, -15], [-22, -6, 9], [-14, -2, -13], [-15, 19, -2], [-55, -33, 26], [1, 12, 6], [-2, 13, -5], [3, 2, -34], [-19, 7, -29], [17, -44, -1], [-35, 8, -14], [41, 6, 23], [-36, 23, -29], [-9, -26, 4], [13, 16, -6], [31, -17, 16], [-7, 19, -31], [-31, 16, -14], [-35, 23, -12], [-23, 8, -14], [-32, 22, -25], [26, -10, 31], [-16, 24, 12], [18, -23, 12], [4, -2, -46], [-30, 25, 5], [20, -36, -3], [31, 18, -14], [-11, 2, -33], [-14, -30, 15], [27, 13, -17], [-25, -35, 4], [-51, -14, 19], [0, -20, 38], [-3, 26, -11], [-24, 35, 13], [0, -15, 4], [14, -7, 8], [28, -26, 5], [34, 49, -37], [26, -15, -20], [-43, 15, 1], [-1, 56, -26], [-2, -52, 8], [10, -38, 34], [30, -27, 28], [-28, 38, -30], [-56, 4, -30], [20, -10, 42], [-4, 29, -4], [-34, -9, 33], [26, -36, -21], [17, 14, -20], [21, -7, 5], [-17, 19, -47], [13, -2, 5], [18, 20, 18], [-31, -31, 13], [-11, -15, 10], [48, -11, 7], [-7, -9, -8], [-35, -21, 28], [-23, 2, -22], [55, 23, -3], [-24, -24, 14], [-43, 13, -30], [-8, 49, -51], [-16, -8, 15], [-49, 13, -19], [-27, -13, -26], [3, -38, -3], [1, 14, 19], [-52, 19, -8], [-65, 8, 16], [-10, -11, -1], [9, -19, 35], [7, -28, 13], [-55, 23, 4], [-46, -15, 11], [-28, -48, 27], [-11, 6, -2], [-8, 38, -59], [39, 46, -21], [-30, -31, 28], [3, -9, 44], [79, -2, 13], [-10, -2, -45], [18, 53, -39], [-48, 8, -5], [-34, 27, -10], [25, -10, -21], [20, 32, -2], [33, -1, 23], [-7, 35, 24], [-32, -20, 37], [11, 8, 48], [14, -24, -16], [2, -23, -16], [12, 14, 11], [-11, -38, -10], [-54, 1, -10], [21, 7, 28], [13, 15, -11], [-31, 16, -29], [-21, -28, 30], [-8, 37, -48]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_6936_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


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