
// Make newform 100.2.g.a in Magma, downloaded from the LMFDB on 25 December 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_100_g();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_100_g_Hecke();"
// To make the coeffs of the qexp of the newform in the Hecke field type "qexpCoeffs();"
// To make the newform (type ModFrm), type "MakeNewformModFrm_100_2_g_a();".
// 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_100_2_g_a();".
// 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 := [16, 168, 688, 84, 1473, 786, 342, -6, 93, -24, 13, -3, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [112273499910, 521633846125, 442357548822, 677052260712, 224325622533, 129671476953, 3519097812, 25045472937, -4900209927, 3020952123, -576792708, 260325772], [178985069048, 2016280256236, -2849443497756, 3903365483097, 2207600053386, 1125752172738, -127593738606, 339987222837, -97783045044, 48283397793, -11783661403, 3457672033], [391154012184, 2657911506232, 489856121406, 8668716529509, 4299712819554, 1832724711006, 23885891676, 481102476429, -119576878026, 67292419131, -15433734165, 5369632561], [-273874062464, 21091602933640, -5927387741190, 28540425731691, 15333778688490, 7906799179014, -814213247460, 2276267517771, -633522002730, 314418060009, -74034744959, 22373133631], [-5593310307856, -23515293707092, -6601997100420, -46013446580871, -23654460062430, -10403352643614, 95827068690, -2749867795311, 696924743820, -382317412959, 87105581309, -29615632063], [-17878470653712, 67498588603448, -80865862575282, 96648914614131, 56181193046322, 34599514729674, -6581106786312, 10803833121471, -3218484118998, 1484218111509, -361617020679, 99321102659], [2898411243400, 32659532805012, -13230315931086, 63421806854271, 34765432275066, 16674062237514, -1255570461996, 4786319147691, -1308046874814, 666492738129, -157422019691, 48894251523], [-37003359759088, -90978016936148, -39698554795488, -260834151846351, -140798466578802, -55756593480954, -1748332186158, -14810975764191, 3656650156068, -2090376253539, 478101391109, -167923324379], [77595685775224, 336336630781804, -94750243258356, 719350254826743, 399600830367126, 182680683235422, -10432981854546, 52158480741663, -14065746308484, 7294073305527, -1717504490237, 542891618887], [26266096925344, 363489467079144, -43808899935726, 796406422106523, 426485463435546, 197679060702342, -9699921955716, 54915725330643, -14590245523914, 7631251682697, -1777970044487, 572643183207]];
    Rf_basisdens := [1, 1, 438461548785, 1753846195140, 1753846195140, 3507692390280, 3507692390280, 8769230975700, 3507692390280, 8769230975700, 17538461951400, 17538461951400];
    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_100_g();"
function MakeCharacter_100_g()
    N := 100;
    order := 5;
    char_gens := [51, 77];
    v := [5, 3];
    // 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;

// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_100_g_Hecke();"
function MakeCharacter_100_g_Hecke( : Kf := false)
    N := 100;
    order := 5;
    char_gens := [51, 77];
    char_values := [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [-1, 0, 0, 0, 0, -1, -1, 0, 1, 0, 0, 0]];
    assert UnitGenerators(DirichletGroup(N)) eq char_gens;
    values := ConvertToHeckeField(char_values : pass_field := ISA(Type(Kf), Fld), Kf := Kf); // the value of chi on the gens as elements in the Hecke field
    F := Universe(values);// the Hecke field
    chi := DirichletCharacterFromValuesOnUnitGenerators(DirichletGroup(N,F),values);
    return chi;
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, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0], [-1, 0, 0, 0, -1, 1, -1, -1, -1, 1, 1, 1], [-1, 1, 0, 0, 0, -1, -1, 0, 0, 0, 1, -1], [1, 0, 1, -1, 0, 0, 1, 0, 0, 1, -1, 0], [-1, 0, -1, 0, 1, -2, 0, 1, 1, 0, 0, 1], [-1, 1, 0, 0, 1, 0, -1, 0, 3, 0, 0, 0], [-1, 0, 0, 1, 0, 0, -1, -1, 0, 0, -1, 0], [1, 0, 1, 0, 1, -1, 1, 2, 0, -1, -1, -1], [-2, -1, 2, 2, 1, -5, -1, 1, 3, -1, -2, -1], [2, -2, 0, 1, -2, 0, 2, 0, -2, 0, 0, 0], [1, -1, 2, 0, -2, -3, 0, -1, -1, 0, 0, -1], [-2, 0, 1, -1, -2, 3, -1, -2, 1, 2, 1, 0], [6, 1, -1, -2, 2, 2, 2, 1, 0, 1, 0, 0], [-2, 1, -1, -1, -2, 1, -2, -1, 0, 1, 2, 1], [3, 0, 1, 2, 0, 4, 2, 0, -2, -1, 0, 1], [2, 0, 1, -2, -3, 6, -2, -2, -4, 4, 2, 2], [-2, 3, -1, -1, 0, 3, 4, 0, -3, -2, 2, 0], [-6, 0, 1, 2, 1, -2, -6, 2, 8, -1, 0, -2], [0, -1, -1, 1, 2, -1, -2, 1, 4, -3, -2, 1], [-2, 3, -3, -3, -2, 3, -4, -4, -1, 2, 2, 2], [-4, 2, -3, -2, 1, 3, 0, -2, -4, 1, 4, 3], [-6, 0, 0, -1, 0, 0, -6, -2, 4, 0, -2, 0], [1, 1, 1, -1, 1, -4, 6, 2, 3, -1, -1, -1], [2, -2, 0, -1, 4, -5, 1, 2, 3, -1, -4, -3], [4, 0, 0, 1, -1, 1, 1, -2, 0, -2, 0, 0], [8, 0, 1, -2, 1, 5, 2, 0, -2, 3, 0, -3], [-3, 0, -1, 0, 0, -7, -7, -1, 0, -1, -1, 1], [0, 2, -3, -1, 2, 5, -1, -2, -1, 2, 1, 0], [-6, 3, -2, 1, 3, -8, 1, 0, 7, -2, -1, -2], [1, 2, -1, -3, 0, 0, 11, 0, 0, 1, -1, 0], [1, -2, 1, -2, -1, -2, 1, 3, -6, -1, 1, -2], [7, -1, -1, 0, 1, 3, 0, 2, -7, 0, 0, 2], [-3, 0, 3, 0, -3, 1, -3, -6, 2, 3, 3, 3], [3, 2, 0, 3, -3, -5, -5, 1, 0, 1, 2, -2], [-8, 5, -5, -2, 2, -6, -6, -1, 0, -1, 0, 0], [6, -6, 8, 5, -5, -1, -1, 2, 0, 2, 2, -2], [-1, 2, -1, -3, -2, 1, -3, -1, -2, 6, 3, 5], [1, 0, -2, -1, -2, 4, 1, -3, 4, 2, 1, 4], [1, -3, -1, 4, 2, -3, -2, 4, 1, -3, -1, -2], [0, -2, -2, -4, 3, -8, 2, 2, 2, 0, -4, -4], [-3, 3, -2, -4, 1, 4, -3, 0, -3, 2, 4, 4], [0, 3, -1, -2, -1, 3, -2, -5, -2, 4, 2, -1], [2, -2, 1, 1, -1, 8, 8, 2, 0, 2, -1, 1], [-13, 1, -3, -1, 3, -8, -6, -1, 4, -1, 2, 3], [-5, -1, 2, 2, -2, 5, 5, -2, 0, -2, 1, -1], [3, -6, 5, 6, 3, -1, 3, 6, -2, -3, -3, -3], [3, 2, -3, -5, 0, -2, 7, 0, 2, 3, -3, 0], [-1, 2, -3, 1, 2, -4, 3, 4, 2, -5, 1, -2], [3, -1, -3, 1, 5, 4, -2, 1, 4, -5, -2, 3], [2, -4, -1, 1, -5, 2, 2, -1, -4, 1, 1, 2], [3, -2, 3, 2, 3, -3, -1, 6, 0, -3, -3, -3], [3, 1, 0, 0, 0, -1, 0, 1, -3, 0, 0, 1], [11, 2, -3, -4, 4, 1, 1, 3, 0, 3, -1, 1], [6, 3, -2, 3, -3, 8, 8, -3, 0, -3, 1, -1], [-5, -5, 5, 3, -2, -6, 3, 4, 8, -6, -3, -2], [8, -4, 3, -1, -1, -6, 8, 3, -8, -3, -3, -6], [10, 1, 0, -1, 2, 12, 6, -1, -8, 2, 2, 0], [-1, -1, 5, 4, 2, -3, -4, 4, 1, -5, 1, -2], [-1, -4, 4, 0, 0, -8, -1, 2, 0, -4, -6, -8], [-1, -2, -3, -2, -5, 6, -1, 1, 2, 3, 7, 6], [-7, -2, 3, 1, -1, -8, -8, 3, 0, 3, 1, -1], [-6, -2, 2, 2, -2, -2, -2, -4, 0, -4, 0, 0], [-4, 1, 4, 0, -3, 3, -12, -6, 0, 2, 4, 3], [6, 1, -5, -2, 3, 5, -2, -3, -8, 4, 2, 1], [12, 4, 0, -1, 4, 0, 12, 2, -2, 0, 2, 0], [8, -2, 1, 4, -1, -2, 8, 2, -2, -1, 0, -2], [-11, -3, 5, 3, -2, -12, 3, 6, 14, -6, -3, 0], [4, -4, -1, 0, 7, -7, 12, 4, -4, -5, -8, -3], [3, 4, -9, -3, 3, 6, 6, -1, 0, -1, -5, 5], [4, -3, 11, 7, -2, -9, 8, 3, -2, 1, -6, -7], [-15, -3, 1, -1, -2, -16, -1, 0, 14, 2, 1, 2], [5, 2, -3, -10, -1, 6, 5, -5, -18, 3, 1, 6], [2, -5, 4, 3, 0, -6, -6, 0, 6, 2, -2, 0], [8, -2, 4, 0, 3, -2, 6, 2, -2, 2, -4, -6], [-14, 2, 0, 1, 2, 0, -14, 0, 22, 0, 0, 0], [-4, 9, -3, -9, -4, 19, 10, -8, -15, 4, 4, 4], [4, -2, 3, 4, -3, -1, 4, 2, 0, -3, -4, -1], [1, 4, -6, -3, 3, 5, 5, 1, 0, 1, -2, 2], [3, -3, 0, -4, -4, 7, -4, -3, -7, 8, 4, 5], [2, 6, 0, -3, 6, 0, 2, 0, -2, 0, 0, 0], [-2, -2, -5, -1, 8, -4, 13, 2, -9, -6, -4, 2], [-16, 0, -2, 7, -2, 4, -16, -2, 16, 2, 2, 4], [17, -4, 2, 6, -2, -4, 17, 0, -4, -2, -4, -4], [-4, 7, -2, -2, 1, -1, -6, 2, 0, -6, 4, -1], [1, -4, -1, 2, -2, -13, -13, -5, 0, -5, -5, 5], [9, -1, 4, -3, 3, -6, -6, 6, 0, 6, 3, -3], [2, 8, -8, -8, 8, 4, 4, 4, 0, 4, 0, 0], [-1, -1, 13, 4, 2, -15, 0, 4, 13, -5, 1, -2], [5, 6, 3, -1, -4, 3, -1, -7, -6, 2, 1, -5], [11, -2, 1, -4, -1, -2, 11, -5, -2, -1, -7, -2], [8, 4, -3, -2, -3, 21, -6, -4, -2, 3, 8, 5], [3, 4, -7, -5, 2, 9, -5, -5, -8, 10, 5, 5], [11, 2, 1, 5, 4, -7, 5, 5, -6, -10, -5, -5], [-11, -3, 8, 6, -6, 1, 1, 2, 0, 2, 5, -5], [4, 3, 2, 1, -2, 12, 14, -3, -20, 4, 6, 2], [-7, -2, 2, 2, 0, 4, 2, 4, 9, -4, -2, 0], [-7, -2, 3, 4, -4, -12, 2, 2, 2, -3, -4, -1], [4, 3, -6, -5, 2, 10, 10, 4, -12, 0, -4, -2], [-4, 2, 0, -1, -1, -21, -1, -3, 3, 2, 1, -1], [16, 0, -4, -2, -3, 18, 14, 0, -14, -2, 0, 2], [3, -4, 3, -3, 3, 10, 10, -1, 0, -1, -1, 1], [3, 1, -5, -1, 4, 24, -1, 0, -4, 2, 1, 2], [1, -1, -1, 7, -2, 2, 1, -4, -7, 1, -2, 2], [12, -4, 0, 2, 5, 2, -2, 4, 10, -6, -8, -2], [3, -6, -1, 7, 4, -8, -9, 8, 4, -5, -3, -4], [-5, 14, -1, -1, 0, 19, -1, -1, 4, 2, 1, 1], [4, 1, -7, -11, 11, -13, -13, 1, 0, 1, -6, 6], [-9, -8, 5, 8, -8, -1, -1, 1, 0, 1, -3, 3], [-3, 7, -7, -9, 9, 9, 9, 2, 0, 2, 0, 0], [1, 7, -10, -4, 4, 19, 19, -4, 0, -4, -3, 3], [9, -4, 2, 6, 4, -2, 6, 6, -3, -12, -6, -6], [12, -2, -2, -4, -4, 4, 12, 3, -2, 2, 7, 4], [6, -2, 4, -1, 2, -8, 6, 2, 10, -4, -6, -8], [-6, -4, 4, -1, 0, -8, -6, -2, 16, -4, -10, -8], [5, -7, 5, -1, -6, 20, -1, -2, -6, 2, 1, 0], [-16, -8, 8, 4, -4, -12, -12, 4, 0, 4, 0, 0], [-10, -3, 8, 5, 0, -22, -8, 3, 14, 0, -6, -6], [2, 2, -10, -11, 6, 7, 15, -2, -19, 3, 4, 1], [8, 5, -9, -2, 7, 13, -2, -7, -10, 4, 2, -3], [4, -7, 10, 3, 0, -6, 4, 0, 6, 4, -4, 0], [-1, -5, 7, 11, 5, -8, 0, 10, 3, -11, 1, -5], [-10, 9, -6, -4, -5, 11, -12, -10, -6, 0, 10, 5], [0, 8, -2, -5, 6, 4, 0, 2, 12, 2, 6, 4], [0, -8, 5, -8, -13, 20, -8, -8, -8, 16, 8, 8], [14, -2, -1, 3, -3, 0, 0, -2, 0, -2, -3, 3], [-11, 5, -1, 0, 1, -15, 0, 2, 11, 0, 0, 2], [16, -2, 4, 7, 2, -8, 16, 4, -2, -4, -4, -8], [-10, 9, -12, -5, -6, 6, 0, -12, 0, 2, 10, 6], [-7, -2, -2, 3, -4, 4, -7, -1, -8, 2, 3, 4], [2, -3, 12, 3, 2, -18, -16, 4, 16, -2, -2, -2], [20, 0, 2, 10, -10, -8, -8, 0, 0, 0, 2, -2], [15, -8, 3, -6, 6, 3, 3, 1, 0, 1, -5, 5], [1, -2, 2, 7, -7, -3, -3, 3, 0, 3, 0, 0], [-1, -4, -6, 6, 1, -18, -5, 2, 17, -3, 1, -1], [-2, -2, 3, 6, 1, -6, -2, 10, -8, -3, 4, -6], [-1, 8, -8, -8, -1, -6, 3, -2, 7, 1, 1, 1], [-2, 1, -3, 4, 7, 3, 4, 9, 6, -8, -4, 1], [-17, 0, 7, -2, -4, -26, -18, 0, 18, 9, 0, -9], [3, 2, 8, 2, -6, 4, 2, -4, -1, -4, -2, -8], [1, -2, -3, -4, -5, 15, -5, -10, -10, 11, -1, 5], [-24, 5, 5, -1, -6, -15, -28, -5, 18, 11, 10, -1], [-5, 0, 1, 5, 0, -16, -3, 0, 16, -5, 5, 0], [0, 1, -12, 1, 2, -2, 0, 4, 0, -4, 0, -2], [19, -5, 6, 3, -1, 1, 12, 5, -2, -2, -10, -8], [-12, -1, -2, 7, -6, 14, -6, -12, -8, 0, 12, 6], [-5, -5, -1, 5, 9, -14, -10, 5, 20, -11, -10, 1], [-8, 7, -7, -6, 6, -6, -6, 7, 0, 7, 0, 0], [-9, 4, -1, -1, 0, 5, -1, 1, 8, 2, 1, 3], [-24, 14, -11, -4, 7, -14, -4, -2, 20, 8, 4, 6], [2, 9, -3, -16, -5, 4, -6, -10, 1, 12, -2, 5], [-14, 6, -7, -12, -1, 14, -14, -6, -24, 7, 8, 14], [14, 10, 5, 0, 15, -10, 14, 8, 14, -5, -2, -10], [2, -7, 1, 2, 1, -7, 2, -3, 0, -4, -2, -7], [-1, -8, 7, 6, -6, -13, -13, 1, 0, 1, -1, 1], [1, -2, 1, 4, 3, -17, 11, 6, 14, -5, -1, -3], [-11, 8, -2, -5, 6, 4, -11, 1, 4, 2, 5, 4], [-26, 4, -6, 1, 2, -7, -11, -4, 3, -3, 8, 11], [8, 3, -2, -5, -3, 2, -5, -2, -13, 10, 5, 8], [3, 3, -6, 6, 12, 11, 6, 5, 3, -12, -6, -7], [-16, 3, 0, 1, -6, -6, 14, -3, -20, 2, 6, 4], [2, 12, -8, -11, -6, 35, 5, -12, -29, 15, 24, 9], [-16, 4, -7, -4, -3, 14, -16, -2, -28, 7, 12, 14], [-18, 4, -11, -4, -3, 1, 0, -4, -8, -3, 8, 11], [4, 1, 3, -3, 2, 15, 10, 4, -17, 0, -4, -2], [-19, -8, 6, 5, -2, -12, -19, 3, 4, -6, -9, -12], [5, -16, 9, 3, -6, -23, 3, 1, -2, -6, -3, -5], [20, -8, -4, 4, 9, 4, 22, 8, -6, -16, -16, 0]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_100_g_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_100_2_g_a();".
// 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_100_2_g_a(:prec:=12)
    chi := MakeCharacter_100_g();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 2));
    S := BaseChange(S, Kf);
    maxprec := NextPrime(997) - 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_100_2_g_a();".
// 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_100_2_g_a( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_100_g();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([],Snew);
    return Vf;
end function;