
// Make newform 6384.2.a.bw in Magma, downloaded from the LMFDB on 19 January 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_6384_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_6384_2_a_bw();".
// 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_6384_2_a_bw();".
// 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 := [-2, -6, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0], [-4, -1, 1], [3, 3, -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_6384_a();"
function MakeCharacter_6384_a()
    N := 6384;
    order := 1;
    char_gens := [799, 4789, 2129, 913, 1009];
    v := [1, 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_6384_a_Hecke( : Kf := Kf)
    return MakeCharacter_6384_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], [0, -1, 0], [1, 0, 0], [1, 1, 1], [4, 0, 0], [0, -1, 0], [1, 0, 0], [1, 1, 1], [1, 0, 1], [3, 1, 1], [2, 0, 0], [0, 0, -2], [1, -1, -1], [1, 0, -1], [-5, -2, -1], [-2, 2, -2], [0, 2, -2], [-1, -1, -1], [-3, 2, -1], [4, 0, -2], [-1, 1, -1], [-1, -2, 1], [4, 0, 2], [9, 1, -1], [0, 1, 0], [2, -2, 2], [1, 0, 3], [2, 2, 0], [3, -2, -1], [-1, 3, 3], [-13, -4, 1], [-4, 2, 2], [-2, 0, -2], [6, 6, 0], [-3, 1, 1], [4, -2, -2], [-1, 5, 1], [-4, -2, -4], [2, -2, 0], [-1, -4, -3], [17, -3, -1], [3, 3, -1], [2, -4, 0], [14, 0, 0], [6, 0, 2], [-3, 7, 1], [-1, -3, 1], [-2, 0, -2], [6, 6, 0], [-6, -2, -4], [7, 5, 3], [5, -3, -1], [5, 4, -1], [4, -2, -2], [3, -7, -5], [4, 2, 6], [-4, 0, -4], [15, 5, -1], [-13, -4, -1], [-12, -2, 0], [6, 6, -4], [-3, 3, 3], [-11, -2, -1], [6, 0, 4], [-9, 6, -1], [15, -1, 3], [18, -2, 4], [11, 1, 3], [6, -4, -4], [-16, -7, 0], [-7, 1, 5], [-12, -2, -4], [6, 4, 0], [-7, 5, 1], [-4, -6, -4], [-8, -4, -6], [12, 2, -2], [-17, -2, -1], [8, 4, 0], [11, 0, 1], [4, 0, -6], [15, -2, 5], [-5, -9, -3], [5, -5, 7], [13, 7, -3], [-3, 8, -3], [-5, 9, 3], [0, 5, 0], [-16, 0, -8], [-11, 2, -5], [9, -2, -5], [15, 1, 3], [3, -7, 3], [26, 6, -2], [13, 2, -1], [0, -6, 2], [-34, 0, 0], [-15, 7, -1], [-2, -4, 4], [5, -1, 9], [0, 4, 6], [-20, -6, 0], [-15, 10, 5], [12, 4, 0], [-14, -4, 0], [7, 2, 9], [-8, 7, -4], [-7, -6, -5], [1, -3, -1], [16, -8, 0], [-1, -7, 7], [10, 4, 4], [2, -4, 2], [1, -9, -5], [-23, 6, 1], [-8, -10, -4], [-9, 2, 5], [8, -10, 2], [5, -12, -1], [0, 4, 8], [16, 2, -2], [20, 2, 2], [5, 2, 3], [-4, -4, 8], [-30, 4, 0], [-5, 1, -9], [11, -2, 1], [30, -2, 2], [18, -2, 0], [9, -9, -5], [1, 0, -1], [3, 7, 7], [20, -6, -6], [4, -9, 0], [2, 4, 8], [-18, -2, 4], [15, -7, 1], [16, 4, 2], [-44, 2, -2], [-14, 6, -2], [-14, 6, -4], [7, -7, 9], [-9, -4, -3], [1, -3, 3], [-2, 14, 2], [-8, -2, 6], [-34, -2, 0], [14, 14, -2], [-1, 0, 1], [-8, -10, -6], [4, 1, 4], [-22, 2, 6], [-6, -4, -2], [-3, -5, -11], [-9, 6, 5], [-12, -4, -4], [-12, 7, -4], [-4, -6, -6], [-26, 8, 4], [25, 1, -3], [13, 12, 5], [-25, -7, -3], [6, 6, -2], [11, 6, 3], [-20, 12, 4], [29, -1, 1], [-12, -2, -10], [10, -2, 8], [16, -11, 0], [-21, 6, -3], [-4, -8, -4], [-39, -1, -3], [11, 1, -1], [-8, -12, 8], [-12, 9, 0], [-9, -7, -3], [-14, 8, 0], [-15, -1, -1], [-2, 8, 0], [10, -6, -6], [-22, -2, -6], [36, 4, -2], [-8, -8, -14], [-17, -1, -1], [16, -15, -8], [10, -2, 4], [-11, -9, -9], [-30, -2, -4], [-5, 12, -3], [4, 8, -8], [-7, -7, -11], [-35, 1, -7], [18, 8, -4], [43, 3, 3], [-12, -2, -14], [-5, 5, 7], [12, -6, 10], [12, 17, 4], [-31, 2, 3], [19, 6, -1], [8, -16, -8], [-13, -17, -3], [0, 12, 4], [1, -6, -1], [-44, -5, 4], [10, 20, -2], [-19, -18, 3], [12, 4, 6], [-9, 9, 1], [-45, -7, 3], [32, -9, 0], [-21, -3, -3], [-50, -4, -2], [-6, 10, -2], [20, 0, 0], [9, -13, 7], [-2, 16, 8], [-13, -10, -7], [-32, 4, 2], [-12, 0, 6], [4, -20, -4], [-15, 8, -11], [-4, 16, 12], [32, 4, -4], [24, 10, -2], [30, 0, 12], [17, 4, 7], [37, 7, 7], [13, 7, 1], [6, 8, -4], [13, 15, 3], [15, 13, 3], [9, -6, -3], [-4, 12, -8], [-63, 0, -1], [0, 12, 2], [-2, 12, 0], [-1, -11, -5], [-8, -18, 0], [19, 2, -3], [-28, -8, 0], [30, 12, -6], [-4, 18, 10], [6, -4, 4], [-53, -2, 1], [52, 2, 4], [-6, -16, -6], [7, -3, 3], [-27, -3, -15], [-4, 2, 6], [-24, 13, 12], [-51, -1, -3], [-12, -16, 8], [8, 13, 4], [59, -5, -1], [12, 10, -2], [-39, -1, 3], [46, 4, 0], [-34, 16, 8], [-33, 5, 3], [7, -2, 9], [6, -6, 4], [12, -4, 0], [12, 3, 0], [25, -1, -5], [3, -12, -9], [-12, 1, 0], [-37, 5, 3], [12, 4, 6], [-9, -13, -7], [-31, -1, -15], [2, 18, 8], [2, 2, 2], [9, -7, -1], [-8, -6, -8], [9, -13, 1], [14, -8, 8], [-16, 2, 2], [-25, 14, 9], [-56, 6, 0], [-25, 5, -7], [13, -6, -1], [43, -5, 1], [-22, 10, 10], [-23, -9, -11], [38, 0, 8], [25, -14, -7], [-46, 0, -2], [-24, -18, 2], [-4, -12, -6], [17, -6, -1], [19, -8, -1], [-50, -10, -2], [8, -14, 14], [-16, 7, 4], [29, 15, -1], [20, 3, 12], [-4, 2, 8], [8, 2, 4], [-6, 12, -12], [-23, -4, -7], [2, 6, -6], [25, -2, 15], [-9, 1, 9], [32, 0, 14], [-23, -14, -1], [-4, 16, -8], [-25, -11, -5], [-43, -5, -11], [-29, -16, -3], [-26, 2, -4], [29, 6, -3], [-15, 5, 5], [-1, 7, -5], [21, -19, -13], [31, -6, 1], [3, -6, 1], [-30, -6, -4], [4, -22, -6], [40, -16, -4], [-39, -9, 5], [-6, 0, -12], [-3, -19, -7], [-6, -6, -8], [-35, -11, -1], [1, -1, 17], [2, -6, -10], [39, 2, -3], [-18, 0, -4], [60, 2, 6], [11, 4, 3], [4, -6, -4], [-23, 0, 3], [30, -14, -14], [17, 22, 7], [4, -6, -10], [-2, 14, 8], [-8, 12, 6], [4, -20, -4], [6, -8, -16], [30, -4, 0], [16, 0, -2], [13, 3, -3], [-1, 14, 7], [31, 0, -3], [-32, -16, 2], [13, 3, 1], [34, 10, -2], [-20, 21, 4], [16, 0, -4], [6, 14, -12], [-8, -22, -2], [20, 16, -4], [-32, -2, 6], [8, 6, -10], [1, -24, -1], [1, 12, -5], [58, -2, 8], [-35, 6, 7], [-4, 18, -2], [-4, 7, 0], [-15, -6, 3], [25, -6, -1], [-38, 0, -14], [4, 10, -6], [56, -1, 4], [19, -21, -9], [2, -12, 0], [53, 17, -3], [-33, -19, -3], [5, 7, 17], [1, 4, 5], [-28, 8, -4], [-44, -2, -10], [0, -8, -12], [63, 11, 3], [-2, -8, 12], [-20, -13, 0], [-29, -13, 1], [-32, 2, -18], [-4, -22, 6], [25, 11, 3], [2, 8, 8], [-19, -5, 7], [4, 10, 12], [-15, -9, -13], [34, -18, -4], [-25, 17, 1], [44, 6, 4], [26, -10, 12], [-10, 6, 16], [43, 3, -5], [80, -8, -4], [25, -16, -1], [-30, -2, 4], [14, 10, 14], [-26, 6, -12], [23, -13, 11], [26, 10, 16], [-28, -20, 8], [28, -2, 14], [31, -3, -9], [-22, -4, 0], [18, 12, 8], [2, -4, -2], [0, -2, -18], [43, -16, -13], [18, -6, -2], [-15, -10, -1], [-13, 7, -3], [32, -8, -6], [-37, 12, 9], [39, 9, 1], [6, 0, 0], [-36, -7, 0], [11, -4, 5], [-19, 11, 11], [32, 9, -8], [0, -4, -8], [19, 8, 11], [-29, -1, -3], [25, 19, -11], [30, 30, -2], [-40, 8, 8], [-22, 6, 0], [31, 20, 5], [-52, 16, 2], [-40, -6, 4], [37, 0, 3]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_6384_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_6384_2_a_bw();".
// 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_6384_2_a_bw(:prec:=3)
    chi := MakeCharacter_6384_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_6384_2_a_bw();".
// 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_6384_2_a_bw( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_6384_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<5,R![-8, -10, 0, 1]>,<11,R![-16, -24, -2, 1]>,<13,R![-4, 1]>,<17,R![-8, -10, 0, 1]>,<23,R![-16, -24, -2, 1]>],Snew);
    return Vf;
end function;