
// Make newform 2856.2.a.f in Magma, downloaded from the LMFDB on 14 December 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_2856_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_2856_2_a_f();".
// 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_2856_2_a_f();".
// 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
        Kf := Rationals();
    end if;
    return [Kf!elt[1] : elt in input];
end function;


// To make the character of type GrpDrchElt, type "MakeCharacter_2856_a();"
function MakeCharacter_2856_a()
    N := 2856;
    order := 1;
    char_gens := [2143, 1429, 953, 409, 2689];
    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_2856_a_Hecke( : Kf := Kf)
    return MakeCharacter_2856_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], [1], [-1], [-1], [-3], [1], [1], [-1], [5], [-6], [4], [-10], [5], [-9], [4], [0], [-8], [-10], [0], [-8], [-10], [-4], [-2], [0], [-8], [-2], [-15], [1], [14], [1], [17], [-3], [-8], [2], [-6], [-8], [-7], [2], [19], [-13], [6], [-18], [14], [-24], [13], [6], [24], [19], [-27], [18], [-9], [18], [-4], [-10], [14], [16], [-11], [7], [-10], [0], [0], [20], [-28], [-24], [-6], [22], [25], [-12], [4], [35], [8], [30], [-16], [-26], [-16], [26], [8], [-14], [-29], [-17], [12], [-9], [0], [-11], [-30], [-4], [34], [1], [24], [8], [-22], [-21], [10], [-6], [28], [21], [0], [-15], [24], [-20], [22], [12], [6], [12], [4], [3], [-30], [-36], [-18], [32], [40], [23], [-18], [-24], [13], [5], [4], [-2], [-39], [48], [-13], [26], [37], [11], [6], [-4], [-30], [29], [20], [-10], [-23], [-8], [12], [5], [18], [43], [-14], [2], [36], [11], [-22], [33], [14], [31], [-34], [33], [-52], [38], [16], [34], [16], [-6], [13], [-3], [-22], [-27], [-55], [-57], [-2], [-10], [36], [-14], [39], [-38], [38], [-19], [12], [-14], [-48], [-54], [-16], [-9], [-47], [39], [-5], [47], [-10], [51], [-3], [9], [35], [-36], [-44], [-16], [-10], [-14], [58], [9], [-40], [-20], [-28], [-24], [-47], [-26], [-29], [-42], [58], [-36], [62], [-58], [-37], [-20], [-9], [19], [-14], [48], [-24], [-12], [35], [44], [4], [-16], [-16], [-44], [-35], [0], [-53], [-40], [63], [-26], [-55], [-40], [40], [-8], [-30], [10], [-61], [25], [45], [36], [75], [-8], [-24], [-36], [4], [-48], [-10], [3], [37], [-40], [-63], [-32], [11], [-61], [-33], [-57], [34], [-63], [-61], [-28], [53], [-54], [-54], [12], [-14], [-78], [0], [-58], [-29], [50], [-38], [24], [-30], [-64], [-43], [-13], [76], [18], [56], [-44], [42], [59], [13], [48], [26], [-53], [-16], [17], [81], [-8], [38], [34], [0], [66], [20], [16], [-44], [-42], [71], [-36], [13], [-61], [18], [-19], [-14], [-33], [8], [16], [-21], [28], [87], [56], [-68], [-51], [-20], [-38], [12], [50], [36], [34], [48], [-30], [17], [33], [40], [-7], [6], [-9], [-42], [-38], [82], [70], [68], [-47], [-30], [-59], [-86], [4], [-56], [-9], [-36], [-9], [0], [-46], [-22], [91], [-23], [7], [12], [-11], [-31], [-90], [39], [-27], [28], [-15], [-10], [-47], [-57], [-54], [13], [54], [-54], [54], [67], [-54], [6], [76], [-63], [-34], [12], [21], [54], [76], [85], [61], [85], [-20], [12], [42], [-4], [79], [74], [-88], [-28], [-55], [20], [45], [-16], [79], [-45], [-30], [22], [93], [24], [-29], [-17], [-38], [2], [12], [-8], [-3], [-66], [-41], [20], [46], [-4], [-12], [-22], [60], [-38], [66], [23], [6], [-16], [34], [78], [-26], [49], [-33], [-2], [-6], [88], [-92], [-23], [-30], [57], [-10], [63], [96], [2], [-84], [-53], [-44], [22], [48], [108], [-69], [69], [13]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_2856_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


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