
// Make newform 3392.2.a.bb in Magma, downloaded from the LMFDB on 23 March 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_3392_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_3392_2_a_bb();".
// 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_3392_2_a_bb();".
// 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, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0], [0, 1, 0], [-2, -1, 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_3392_a();"
function MakeCharacter_3392_a()
    N := 3392;
    order := 1;
    char_gens := [319, 2757, 1857];
    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_3392_a_Hecke( : Kf := Kf)
    return MakeCharacter_3392_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, 1, 0], [1, -1, 1], [-3, 1, 1], [1, 1, -1], [1, -2, -2], [-1, -2, -4], [3, 0, 1], [-1, -2, -1], [2, -1, 1], [-3, -1, -1], [-4, 1, -3], [0, -2, 4], [-3, 3, 1], [-6, 4, 0], [-1, 0, 0], [2, 0, 2], [-3, 3, 3], [-3, -1, -7], [-6, 5, 0], [7, 1, -1], [-4, 5, 6], [-3, -2, 5], [-10, 4, 0], [0, 3, 1], [1, 5, -3], [7, -2, -1], [-7, 3, 5], [4, -8, -4], [-6, 3, 3], [-4, 3, 2], [3, 5, 1], [-11, -5, 3], [-3, -5, 3], [-1, 6, 0], [-9, -4, 1], [-3, 7, 5], [-5, -7, 7], [-12, -1, -8], [-6, 12, 0], [1, -10, -1], [6, -4, -2], [-2, 3, 4], [5, 11, -3], [-2, -8, -10], [7, -13, -1], [-12, 6, 6], [-13, 9, 1], [9, -13, -9], [-2, 7, -3], [-6, -2, -10], [5, 11, 3], [-15, 4, 4], [11, 1, -3], [2, -2, 14], [5, -5, 1], [14, -1, 1], [-10, -8, 4], [10, 2, -8], [0, -9, -5], [-12, -1, -6], [2, -4, -2], [2, -2, 16], [-4, 8, 8], [13, 1, 3], [-17, 10, 4], [14, 6, 12], [5, 1, 5], [-16, 14, 2], [5, 3, -5], [9, -3, -3], [7, 4, -11], [-17, 9, 9], [-23, -3, -3], [22, -3, -8], [-5, -3, -7], [-14, -6, 0], [-12, -10, 6], [-4, 16, 6], [24, 1, 7], [-1, 17, -3], [-18, 4, 8], [-9, 3, -3], [7, -18, -8], [-6, -8, -20], [15, -12, 5], [15, -6, 2], [-8, 6, 8], [19, -2, 10], [-21, -4, 1], [6, 2, 10], [4, -11, -4], [2, -14, 0], [4, 11, 8], [-17, -6, -17], [7, -23, -3], [2, 4, -12], [-31, 10, 4], [10, 8, -2], [0, -6, 10], [23, -3, -1], [-13, 7, 5], [6, -11, -12], [-22, 2, 0], [-9, -7, 1], [-14, -12, -6], [15, -1, -7], [8, -5, 9], [-2, 8, 2], [9, -23, -3], [-2, -10, -16], [-16, 16, 6], [19, -13, -11], [9, 5, 7], [8, 1, -2], [4, 6, -8], [14, -10, -8], [23, 5, 21], [16, 10, 0], [-7, 3, 11], [15, -2, 4], [12, 6, 2], [-32, -8, 2], [-16, 26, 8], [12, 1, -4], [29, -1, 5], [4, -6, 6], [29, -1, -1], [-28, 6, 4], [-10, -20, 12], [2, 5, -8], [3, 5, 15], [-4, -4, -10], [-11, 2, -2], [5, -13, -17], [2, -4, 8], [7, 13, 9], [-25, 9, 1], [-19, 3, -3], [19, 13, -1], [-3, -5, -17], [-12, -16, -10], [-8, -6, -16], [7, 0, 3], [14, -12, -6], [12, -6, 12], [-8, 16, 14], [8, -2, 4], [0, 2, 12], [26, -4, -6], [8, -2, 18], [-25, -3, 7], [-27, 3, 11], [-17, -12, 9], [25, 3, 1], [24, 4, 14], [-11, 28, 3], [4, 2, 0], [10, -19, 5], [-6, -4, -14], [11, 11, -5], [2, 24, 4], [-7, -11, -17], [13, -13, 9], [0, 12, 14], [-8, 18, -4], [7, 5, -5], [-13, 6, 2], [-5, -11, -9], [-9, -10, 16], [36, -13, 4], [20, -20, -4], [9, -21, -5], [7, -9, -1], [1, 11, -5], [-3, -2, -30], [-26, -12, 8], [19, 16, 16], [-25, -16, 11], [0, 1, 9], [-7, -8, -23], [-3, -18, -19], [-15, 17, -5], [2, 11, 7], [17, 19, 7], [13, -2, -4], [-9, 18, 8], [-7, -15, -9], [27, 12, 0], [-29, 13, 5], [-10, 28, -4], [7, -3, -23], [-10, 9, -2], [20, -21, -7], [12, -9, -18], [-20, 6, 12], [14, -10, 2], [16, 19, 17], [8, -12, -2], [-44, 4, 2], [11, 4, -8], [-60, -1, -4], [-19, 15, 23], [-6, 14, -8], [-4, -20, 8], [37, -35, -15], [-5, 15, -1], [-3, 25, 5], [26, -8, 8], [18, 3, -6], [-36, -3, -13], [-24, -2, 12], [9, 7, 15], [18, -13, 2], [13, -7, 7], [5, -14, -30], [-45, 9, 13], [-14, -12, -8], [22, 6, -16], [36, -28, -14], [1, -19, -23], [33, 0, -5], [-31, 1, 1], [-21, 9, -13], [4, -6, -12], [27, 11, 7], [12, 0, 22], [-1, 5, 25], [-13, -19, -11], [-22, 7, -10], [25, 9, 13], [7, -13, -19], [10, 16, -12], [22, -2, 6], [15, -7, 23], [-5, -4, -11], [32, -2, -6], [38, -37, -15], [29, -7, 13], [15, -26, -13], [-14, 7, 18], [-3, -27, -17], [-47, 31, 11], [27, 11, 11], [-1, 12, 8], [9, 4, -9], [-8, 5, 24], [-1, 6, 15], [-54, -4, -18], [-13, 5, -29], [-16, -19, 7], [22, -29, -1], [-16, 14, 22], [-10, -26, -6], [4, 0, -20], [-11, -5, -19], [13, 1, -9], [4, -22, -14], [31, -40, -28], [41, 13, 3], [43, -11, -9], [22, 2, 6], [-4, 10, 26], [-28, -2, 12], [-8, 19, 9], [5, 2, -17], [1, 34, -8], [-6, -1, 15], [-25, -10, -29], [0, -14, -36], [-44, 2, -8], [-30, -7, 8], [-4, -23, -11], [6, 0, 0], [-53, 0, 6], [-36, -21, -4], [18, 2, -20], [31, 6, -12], [21, 4, 8], [-34, 30, 8], [-50, 5, 2], [-20, -8, -26], [-14, -29, 10], [4, -11, -7], [4, 11, -28], [13, 7, 31], [-22, 0, 6], [-13, -11, -33], [-3, 13, 7], [2, 28, 6], [-12, 38, 10], [-48, -12, -6], [-17, -17, 3], [-8, 7, 4], [-10, -20, -26], [-12, -14, 10], [18, -18, 12], [32, -4, -2], [53, 3, 17], [-25, 0, -13], [23, 25, -23], [39, -28, -2], [6, -24, -36], [39, -37, -17], [-9, -3, -15], [-7, -29, -19], [-28, 4, -14], [-18, -24, 6], [-4, 0, 16], [-48, 36, 16], [10, -22, -20], [33, -19, -19], [45, 1, 13], [-8, -2, 4], [-18, -21, 10], [-16, -4, 6], [45, 11, -13], [3, 11, 11], [-10, 21, 1], [-39, 4, -8], [21, -5, -21], [21, 8, 34], [-18, -6, -2], [1, -8, -27], [-14, 34, -4], [-5, -21, -1], [22, 0, 24], [-1, 40, -3], [9, -17, 11], [9, 24, 46], [-11, 19, 27], [-46, 16, 6], [2, 8, 36], [6, 4, -10], [-11, -17, -25], [31, 12, -3], [-10, -4, -10], [-4, -9, -15], [28, -16, -2], [-15, 31, -9], [23, 11, 9], [16, 10, -30], [1, 3, 31], [31, -47, -35], [12, 11, -1], [-6, -18, -4], [-21, -6, -8], [11, -23, -1], [33, -9, 3], [-30, 40, 14], [-40, -7, -38], [36, 0, 14], [-16, 3, -33], [-2, -7, 16], [29, -28, -8], [-16, 28, -12], [-61, 22, 15], [-9, -23, 11], [10, 4, 34], [-43, -17, -23], [38, 16, 6], [5, 25, -3], [37, 9, -3], [-39, 23, 9], [-18, -18, -14], [-16, -2, -18], [-15, -5, 11], [-26, -15, 10], [24, 26, -18], [-32, -14, 4], [10, -17, 20], [18, -4, -14], [-26, 16, 26], [-15, 47, -3], [-2, -23, 7], [6, 31, 34], [34, 26, -24], [6, 24, 32], [-11, 33, 19], [-21, 23, -27], [6, 24, -20], [-16, -2, -14], [29, -21, 15], [35, -14, -24], [-2, 14, 16], [13, -31, -37], [-3, -32, -27], [21, -9, 13], [39, -6, -9], [23, 11, -5], [-7, 5, 3], [12, -15, -31], [15, -19, -5], [-51, 9, 5], [22, 13, 14], [-16, 19, 7], [19, -21, 1], [4, 8, 24], [-9, 31, 39], [-32, 10, -6], [-10, 20, 0], [5, -19, -35], [-5, -11, -15], [-23, -11, -1], [-27, -15, -21], [-23, -18, -37], [5, 21, 27], [9, -3, -21], [28, 16, -4], [9, 9, 5], [-2, 29, 27], [17, -38, -36], [61, -40, -23], [34, 6, 24], [42, -16, 22], [34, -5, -13], [-25, 7, 17], [-42, -30, 12], [-11, -25, 17], [-21, 13, 17], [-32, 23, 19], [-4, 12, -28], [38, 21, -14], [61, 7, -9], [-7, 36, 26], [-4, 43, -3], [5, -26, -37], [8, -2, 30], [57, -6, -5], [23, -28, -15]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_3392_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


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