
// Make newform 2106.2.a.k in Magma, downloaded from the LMFDB on 23 December 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_2106_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_2106_2_a_k();".
// 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_2106_2_a_k();".
// 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 := [-3, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rfbasis := [Kf.1^i : i in [0..Degree(Kf)-1]];
    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_2106_a();"
function MakeCharacter_2106_a()
    N := 2106;
    order := 1;
    char_gens := [1379, 1783];
    v := [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_2106_a_Hecke( : Kf := Kf)
    return MakeCharacter_2106_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 := [[-1, 0], [0, 0], [1, 1], [1, -2], [-4, -1], [-1, 0], [0, 4], [0, 1], [1, -3], [-8, -1], [4, 2], [-6, 2], [-3, 1], [-2, 4], [-4, 2], [0, -5], [-2, -7], [-2, 3], [-2, -6], [-7, -2], [-10, -2], [11, -3], [-6, -5], [9, 3], [11, -1], [-4, 7], [4, 2], [-5, -1], [-5, 9], [1, 4], [-8, 2], [-2, -4], [6, -4], [-5, -3], [-21, -1], [-3, -6], [-4, -1], [-10, 2], [-3, 6], [-2, -3], [-6, 2], [6, -9], [2, 4], [-1, 3], [6, 12], [-4, 0], [-7, -7], [-9, 12], [-6, -5], [-6, -4], [-7, 6], [9, -4], [-9, 1], [3, -3], [3, -2], [21, -1], [18, -4], [-5, 6], [0, 9], [-10, -12], [4, 2], [-4, 0], [-16, 4], [18, -8], [23, 0], [-3, 7], [2, 2], [-4, -8], [21, -1], [-20, -2], [5, 9], [-6, -8], [11, -9], [14, -7], [16, 11], [3, -6], [0, 8], [20, 8], [9, 3], [-20, -2], [9, 5], [13, 13], [-33, -2], [13, -6], [-28, 0], [0, 16], [8, 0], [31, -5], [-33, -3], [-17, 10], [13, -7], [-3, -14], [11, -6], [14, 10], [-2, 3], [5, -15], [14, -2], [-3, 14], [-3, 13], [23, -7], [34, 4], [6, -14], [37, 3], [-28, 0], [-33, -1], [6, -2], [4, -6], [1, 5], [-7, 17], [-11, -18], [18, 6], [-4, -4], [-7, -1], [-2, 17], [25, -12], [29, -4], [-34, -1], [29, -5], [-12, -14], [-6, 2], [2, -2], [-29, -10], [0, -5], [-28, 10], [-8, -21], [6, 11], [-10, 2], [-35, 1], [40, 4], [17, 17], [-24, -11], [11, -10], [-6, 0], [6, 5], [-24, -12], [-12, 16], [-20, -8], [44, 3], [6, -15], [-9, -12], [-10, -5], [-26, -6], [36, -2], [0, 12], [10, -1], [-8, 18], [37, -11], [17, -12], [-13, 13], [-7, 28], [-15, 9], [-18, 14], [-29, -3], [23, 3], [-6, -4], [0, 20], [-6, 22], [-12, 14], [30, -6], [-4, 22], [-18, 18], [-2, -32], [11, -6], [3, 13], [-27, 1], [-23, 18], [-3, 9], [20, 11], [20, -14], [-32, 14], [-18, 6], [6, -14], [29, 7], [16, 4], [27, -5], [29, -16], [8, -26], [14, 20], [-23, 9], [-16, 6], [15, 12], [38, 0], [-2, -33], [34, 8], [29, -10], [50, -4], [-32, 4], [-12, 7], [-43, -1], [-12, -18], [-14, -6], [18, 5], [-11, 5], [-35, -1], [17, -9], [-15, 12], [20, -24], [-8, -13], [-20, -24], [2, -20], [24, 26], [-19, -17], [-40, -14], [34, -14], [2, 9], [54, -5], [10, -16], [-45, -1], [6, 12], [18, 6], [23, 14], [-60, -1], [-19, -1], [-16, -29], [27, 16], [-2, 6], [7, 23], [-11, 24], [-34, 8], [24, 20], [-32, 6], [-19, 6], [-30, -10], [13, 4], [-9, 15], [20, -1], [-56, 4], [-3, 19], [-11, -1], [0, 4], [-32, -14], [4, -38], [3, 14], [23, -26], [-1, -1], [25, -18], [16, 18], [2, 14], [27, -23], [4, -2], [-12, -23], [25, 15], [45, 5], [-7, -3], [-56, 10], [-45, 13], [2, -36], [50, 5], [-16, -7], [0, 0], [-1, -19], [-38, -2], [23, -12], [-1, -4], [-10, -35], [8, -39], [-24, -16], [-16, 24], [-18, -5], [-23, -21], [-38, -12], [27, 9], [20, 0], [-2, -3], [21, -1], [-41, 13], [-7, 33], [-11, 37], [36, 19], [12, -12], [10, -31], [-44, -5], [-45, 5], [-1, -9], [-43, -10], [18, -20], [-8, -29], [3, -21], [-29, 3], [9, 13], [-32, -14], [-9, 6], [-32, -12], [-19, 23], [-54, -10], [-10, 8], [35, 12], [4, -18], [-31, -4], [-11, 8], [18, 25], [73, -1], [-3, 1], [-20, -26], [-20, 26], [30, 19], [-12, -12], [28, -3], [41, 15], [56, -8], [-61, -10], [13, 15], [18, 24], [-29, -5], [-32, -22], [-28, -14], [-13, 13], [0, 16], [-16, 0], [24, -37], [-33, -27], [-14, 36], [-15, 2], [-44, 22], [67, 10], [23, -16], [6, -39], [10, 40], [-49, 1], [-41, -8], [-49, 23], [-29, 9], [-24, -8], [47, -12], [-5, 19], [-41, -6], [16, -23], [-24, -3], [2, 36], [-50, 15], [-5, 3], [-2, 16], [50, -10], [-12, -4], [2, -11], [52, -12], [11, -17], [22, -14], [-33, -19], [-67, 15], [-15, -21], [54, 0], [-16, -6], [7, -7], [-38, 16], [11, -5], [-14, 19], [44, 9], [-29, -12], [-12, -1], [16, -18], [-41, 15], [-42, -12], [-7, 19], [-18, 15], [33, -10], [9, -22], [6, 7], [75, -6], [3, 8], [13, -15], [-30, -4], [-32, -34], [4, 15], [-37, -1], [-11, 20], [-51, 23], [22, -8], [18, 10], [6, -36], [7, 47], [-71, -14], [-30, -20], [-39, -33], [12, 11], [-6, -15], [-15, 11], [14, 6], [-17, -14], [19, 10], [0, -12], [-26, 6], [-27, -16], [77, -3], [28, 26], [-15, -8], [45, 28], [20, -23], [8, -10], [55, -3], [54, -14], [56, -14], [-18, -17], [-70, -6], [-24, 6], [25, -40], [21, -22], [-59, -18], [21, 33], [36, 30], [-41, 1], [-47, 8], [22, 8], [8, 22], [-30, 14], [-1, -19], [7, 13], [-51, 7], [64, -10], [24, 11], [1, -14], [-72, 14], [-65, -21], [10, -6], [14, 22], [24, 27], [15, 22], [58, 4], [-18, 44], [24, 18], [16, 6], [-14, -26], [27, 34], [-36, 10], [-25, 39], [-19, 1], [22, 16], [-12, 2], [-56, -15], [11, 51]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_2106_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


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