
// Make newform 2100.2.a.f in Magma, downloaded from the LMFDB on 19 June 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_2100_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_2100_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_2100_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_2100_a();"
function MakeCharacter_2100_a()
    N := 2100;
    order := 1;
    char_gens := [1051, 701, 1177, 1501];
    v := [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_2100_a_Hecke( : Kf := Kf)
    return MakeCharacter_2100_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], [0], [1], [-1], [2], [-8], [-2], [-1], [1], [6], [-9], [0], [1], [-6], [-2], [-6], [8], [3], [7], [-16], [1], [6], [-14], [-14], [-12], [-10], [-12], [-7], [9], [-5], [-16], [-10], [-4], [11], [19], [12], [16], [2], [-6], [-20], [12], [8], [-11], [-27], [0], [12], [4], [14], [2], [7], [-12], [-14], [-12], [2], [25], [6], [-2], [14], [-15], [-10], [18], [4], [-20], [-18], [-31], [21], [18], [25], [26], [-10], [3], [-4], [1], [37], [2], [25], [6], [1], [-26], [26], [-17], [-24], [-4], [-26], [24], [23], [17], [-34], [24], [18], [-34], [-7], [3], [36], [38], [-18], [-18], [32], [35], [27], [45], [-26], [41], [-23], [2], [36], [-24], [-27], [40], [38], [-9], [-29], [-10], [29], [13], [4], [30], [34], [-36], [-22], [-18], [-22], [-39], [-48], [6], [22], [-52], [-44], [-28], [-1], [-36], [4], [-37], [40], [-20], [50], [28], [12], [-13], [-2], [34], [-57], [5], [-12], [-16], [-16], [40], [-26], [1], [-14], [14], [19], [-8], [-28], [53], [25], [28], [-40], [30], [-28], [-11], [-16], [-14], [3], [-54], [61], [2], [-5], [-36], [49], [-2], [49], [38], [-52], [48], [1], [-54], [18], [-22], [-39], [-24], [-13], [-22], [-9], [-54], [-23], [-6], [-31], [60], [10], [-53], [-45], [54], [53], [24], [5], [31], [62], [-54], [18], [-26], [22], [-44], [36], [-8], [46], [-60], [-29], [68], [-29], [12], [-31], [8], [20], [4], [5], [-18], [-41], [51], [-67], [-48], [-9], [35], [70], [6], [24], [-39], [-28], [23], [-25], [34], [-44], [7], [-42], [10], [-48], [-27], [31], [-16], [15], [-2], [-42], [47], [-6], [-24], [-54], [-50], [-28], [-56], [2], [56], [40], [-60], [50], [-44], [-11], [68], [46], [34], [-16], [45], [26], [46], [48], [64], [-29], [12], [-71], [3], [28], [-28], [16], [-31], [20], [44], [53], [-46], [-5], [-20], [-4], [32], [78], [36], [16], [-77], [37], [-31], [20], [38], [-5], [2], [3], [-80], [69], [60], [-60], [14], [40], [-2], [44], [26], [69], [37], [-39], [-34], [27], [-54], [-15], [-66], [-48], [-38], [-3], [28], [-65], [56], [6], [-12], [-44], [-15], [-32], [62], [-22], [-77], [73], [18], [49], [-10], [-9], [-1], [46], [23], [-82], [-48], [-52], [22], [61], [-6], [-14], [-80], [-18], [35], [4], [-11], [15], [-29], [24], [33], [-66], [16], [-72], [-67], [-78], [70], [-81], [14], [-6], [0], [-54], [52], [37], [54], [48], [-69], [-62], [-42], [-26], [13], [3], [3], [-38], [-69], [-30], [18], [65], [24], [15], [-12], [10], [100], [32], [-95], [79], [1], [-20], [-84], [51], [-58], [-11], [32], [1], [-18], [87], [-62], [-41], [91], [4], [6], [64], [-51], [-22], [-39], [67], [-38], [-14], [54], [29], [-50], [-104], [50], [-82], [-21], [36], [5], [-61], [-38], [-80], [-28], [92], [54], [-94], [52], [-72], [-80], [-22], [-44], [-79], [-54], [28], [86]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_2100_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


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