
// Make newform 6864.2.a.bj in Magma, downloaded from the LMFDB on 06 November 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_6864_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_6864_2_a_bj();".
// 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_6864_2_a_bj();".
// 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, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0], [-1, 2]];
    Rf_basisdens := [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_6864_a();"
function MakeCharacter_6864_a()
    N := 6864;
    order := 1;
    char_gens := [2575, 1717, 4577, 4369, 2641];
    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_6864_a_Hecke( : Kf := Kf)
    return MakeCharacter_6864_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], [1, 0], [-1, -1], [0, 0], [1, 0], [-1, 0], [-3, 1], [2, 2], [-4, 0], [-1, -1], [-1, 1], [-4, -2], [8, -2], [1, 3], [-4, 0], [-2, 0], [-6, 2], [0, 2], [-1, 1], [-2, -2], [8, 2], [3, 1], [-4, 0], [-5, 3], [0, -6], [-1, 7], [-2, 2], [-10, 2], [0, -2], [2, 0], [-7, 3], [-8, 0], [3, -5], [-3, -9], [-6, -8], [-10, 2], [8, 2], [1, -9], [-8, 0], [23, -1], [-8, -8], [-4, -2], [0, -8], [-4, -2], [2, 0], [-2, -6], [-5, 9], [-3, 3], [-4, 4], [10, 0], [13, -7], [-12, 0], [-18, 0], [-8, 4], [4, -10], [-10, 2], [-4, 2], [-18, -6], [-2, 12], [-20, -6], [-5, -7], [-10, 4], [2, 2], [-8, 4], [-4, -6], [3, -5], [13, -5], [0, 10], [12, 4], [6, -4], [17, -3], [-20, 8], [8, -8], [-4, -2], [11, 5], [-10, -10], [-16, 6], [0, 2], [5, -7], [-24, 2], [-16, 0], [26, 0], [-4, 4], [18, 0], [-15, 3], [-8, 4], [-13, -5], [10, 4], [-32, 2], [1, -9], [0, -8], [-24, 4], [27, 5], [0, 0], [19, 5], [-6, 6], [-3, 9], [-10, -4], [15, -3], [-6, -8], [-1, -3], [-18, 12], [36, 4], [3, 3], [23, -3], [22, 4], [-2, 14], [2, 4], [12, 4], [22, 4], [5, -1], [4, 2], [-13, 3], [7, -7], [5, -13], [6, 4], [21, 11], [-12, -12], [4, 18], [2, -2], [-12, -10], [26, 8], [29, 9], [2, -14], [5, -5], [-9, -1], [-18, 12], [-20, 4], [34, -2], [12, -6], [8, -12], [-4, 12], [8, 16], [8, -14], [-10, 8], [-34, 0], [27, 3], [-16, 4], [-12, -14], [35, 3], [-22, 2], [4, -2], [-14, -2], [20, -4], [-26, 8], [-20, 0], [-2, -4], [-5, 11], [6, -2], [-18, -2], [-22, -8], [-2, -4], [-14, 2], [-2, 10], [40, 4], [24, 8], [49, -5], [-45, 3], [2, 0], [8, 2], [28, 0], [-9, -1], [8, -8], [0, -16], [-15, 13], [-40, 4], [2, 14], [4, 14], [16, -14], [44, 2], [-12, -8], [4, -18], [-30, 6], [34, -4], [14, -14], [-28, -2], [24, -12], [-13, 3], [-45, -7], [0, 2], [-53, -3], [20, 4], [24, 18], [4, 10], [0, -4], [46, 0], [-2, -4], [-25, 1], [-10, -16], [-20, 12], [-12, -6], [-36, -8], [-10, -18], [-7, -19], [-32, -8], [0, -6], [6, -16], [46, 0], [-4, -14], [14, -22], [-36, 6], [-19, 15], [-6, 0], [12, -2], [0, 4], [-16, -2], [-3, 19], [32, -8], [-12, 10], [18, 2], [10, 8], [-18, 16], [28, 12], [16, -20], [20, -16], [2, 16], [-51, -1], [55, -1], [-34, 6], [-5, 19], [18, -16], [8, 0], [49, -3], [41, -1], [-10, -6], [52, 6], [20, -10], [12, 4], [19, -23], [-4, -24], [30, -8], [21, -9], [-18, -22], [25, -11], [22, -2], [8, 0], [-36, 6], [-2, -12], [-8, 8], [-4, 16], [-14, -6], [-25, -11], [24, 0], [-4, 14], [-10, 0], [10, 6], [-29, -3], [8, 12], [24, 4], [-38, -2], [-6, 24], [16, 14], [26, 10], [-36, 10], [-15, -3], [16, 24], [28, 14], [-66, -2], [-12, 10], [14, -8], [23, 21], [-18, -22], [34, -8], [-40, -6], [-25, -25], [52, 0], [-35, 1], [35, 19], [14, 14], [51, -5], [6, 24], [-23, -9], [-36, -2], [-11, -1], [-20, -18], [5, -5], [-14, -14], [36, 10], [-4, 22], [-18, 26], [12, 12], [39, -7], [-10, 18], [36, -22], [-8, -4], [-68, 4], [46, 4], [12, -10], [-43, 3], [41, -11], [0, 14], [-4, 12], [18, 12], [64, 0], [12, -2], [-5, -29], [-26, 2], [-2, 0], [0, -16], [-30, 18], [46, -4], [-8, 2], [-37, 17], [44, -12], [34, -6], [-48, 2], [40, 0], [6, 0], [-12, -16], [52, 6], [-46, 14], [35, 19], [25, 13], [8, -20], [32, -8], [-64, -6], [40, -4], [32, -4], [36, 14], [29, -23], [-41, 5], [38, -12], [-61, -13], [53, 11], [-18, 24], [44, 2], [-29, -19], [-9, 17], [-38, -2], [11, 19], [-12, 18], [-18, 8], [-57, 5], [0, 16], [-48, -4], [2, 18], [-12, -26], [40, 14], [-60, 6], [-25, -11], [20, 6], [-44, 14], [-18, 20], [-38, 14], [41, -19], [6, -14], [54, 8], [-3, 35], [8, -36], [-18, -24], [16, -12], [32, -6], [7, 15], [-19, 7], [20, 6], [31, 15], [4, 0], [16, -16], [15, 15], [32, -12], [2, 24], [3, -13], [52, 4], [24, 24], [-68, 0], [-16, -2], [-24, -6], [-14, -26], [-22, 16], [4, 8], [42, 10], [28, 8], [17, -35], [-19, 7], [6, -32], [44, 8], [-38, 6], [4, 22], [-31, -3], [-40, -22], [-43, 1], [-71, -11], [12, -4], [-24, -10], [-2, 6], [2, 18], [-15, -9], [38, -16], [-44, 16], [0, -12], [36, -10], [31, -25], [-58, -18], [-36, -16], [18, 18], [4, -34], [-10, -30], [22, 4], [14, -2], [18, 8], [-54, 8], [20, 30], [-40, -24], [-33, 7], [-28, 30], [-13, 25], [-14, 8], [10, -12], [-19, -37], [50, -14], [30, -4], [-81, -9], [36, -8], [-15, -13], [-52, 14], [-44, 10], [24, 4], [62, 10], [-73, 7], [8, 32], [-40, 22], [22, -12], [54, -18], [-22, -34], [-18, 4], [-53, -5], [-64, 12], [-38, -4], [45, 27], [60, -12]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_6864_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_6864_2_a_bj();".
// 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_6864_2_a_bj(:prec:=2)
    chi := MakeCharacter_6864_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_6864_2_a_bj();".
// 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_6864_2_a_bj( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_6864_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<5,R![-4, 2, 1]>,<7,R![0, 1]>,<17,R![4, 6, 1]>,<19,R![-16, -4, 1]>],Snew);
    return Vf;
end function;