
// Make newform 100.14.c.a in Magma, downloaded from the LMFDB on 04 September 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_100_c();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_100_c_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_14_c_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_14_c_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 := [1, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0], [0, 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_100_c();"
function MakeCharacter_100_c()
    N := 100;
    order := 2;
    char_gens := [51, 77];
    v := [2, 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;

// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_100_c_Hecke();"
function MakeCharacter_100_c_Hecke( : Kf := false)
    N := 100;
    order := 2;
    char_gens := [51, 77];
    char_values := [[1, 0], [-1, 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 := 14;
    raw_aps := [[0, 0], [0, 234], [0, 0], [0, -166516], [-6397380, 0], [0, 7599871], [0, -21557097], [365115484, 0], [0, -28613412], [46418994, 0], [-5682185824, 0], [0, 943592549], [-7336802934, 0], [0, -13443337490], [0, -50919917112], [0, 139365942147], [-59573945772, 0], [-27484470418, 0], [0, -392205027466], [-360365227992, 0], [0, -796317706859], [23161184752, 0], [0, 1025079055218], [3485391237126, 0], [0, -3353333708401], [10653736099446, 0], [0, -5462232766748], [0, -6293782761102], [436641848098, 0], [0, -15915599476263], [0, -19703840170816], [73744029229140, 0], [0, -42705013148469], [79782728036164, 0], [-189340621038054, 0], [283931821277240, 0], [0, -13746590521639], [0, -187325927788550], [0, -63238272126084], [0, -181366064291313], [317214254387772, 0], [455668962760070, 0], [-966029530347072, 0], [0, -91031528379167], [0, -431299062171819], [-324819447518888, 0], [-703122653862556, 0], [0, 754324871508400], [0, -1251530337183642], [1221116802675466, 0], [0, 1768954018198437], [3112798054881744, 0], [-4570914891142606, 0], [-1663317001905300, 0], [0, 1870261418260863], [0, 1253078888210676], [81129982670082, 0], [-2291408802506800, 0], [0, -499480153741363], [-11758003102314054, 0], [0, 1906186819206022], [0, 9491539761474075], [0, -7601048773105186], [19648629162159192, 0], [0, -9997126421188691], [0, 12228230645198793], [-33992443483613572, 0], [0, 1443591517747319], [0, -16800560841617190], [19052688341090290, 0], [0, -34273687966046991], [11515414775891256, 0], [0, 471539480983976], [0, 13717226602057123], [-65132658943109612, 0], [0, -43917222883563072], [40928249341090026, 0], [0, -12688803315123391], [-81198461546163630, 0], [-156903059661641786, 0], [19165867577647884, 0], [22062861443818166, 0], [-136346835968196624, 0], [0, -21747459999596039], [208497563333221672, 0], [0, 124641305616857238], [-145109873387955906, 0], [0, 99063583450013867], [-230381995342550850, 0], [0, 182148180336576712], [0, 10858741101858510], [198718990347079584, 0], [0, -235798931235989668], [-114636339459987300, 0], [-12879360668887556, 0], [0, -136406077172080884], [-408824236278402606, 0], [-468975502839432726, 0], [0, 306179364806774302], [468270288292416974, 0], [0, -558054151378861498], [0, 139486498294194225], [0, -248723054308371294], [-1156535003004963930, 0], [88014962752765868, 0], [0, 77024064897720671], [0, -730556952321980862], [0, 661858600311590409], [1543250474746700040, 0], [266564324178438650, 0], [0, 516406641082975376], [0, -225770640372794309], [0, 934349317634964123], [1237237618430421220, 0], [602949442486809752, 0], [2687833301629079682, 0], [0, -961302570347836118], [0, -774147446468706996], [0, -1059339263859793089], [1713757470500782044, 0], [-339226139764007962, 0], [0, 9980331661640977], [0, 1633722394188714021], [0, 490065009248446254], [-2721452079908411452, 0], [587143117623057390, 0], [3678038066296362154, 0], [2246089731903594864, 0], [0, -3140410043363224252], [0, 2920338980434464199], [6402491090486212300, 0], [0, 3308584826193461028], [1097599476209942576, 0], [0, 4458496241573346461], [-8551667918713393638, 0], [3404202799496751358, 0], [0, 2135933607086557515], [0, 1005100483842572462], [0, 840655821681916569], [-8897418238258646154, 0], [7391518821461146844, 0], [4725754002670149126, 0], [0, 1240449209176113964], [0, 5101302833738502570], [7916032028703180178, 0], [13707611597228931288, 0], [0, 4523003428408541395], [0, -2984707412239999869], [-10355010557739735116, 0], [0, -1979613517746699792], [0, -2192015545157168623], [-4000583698570364238, 0], [0, -4737250982835522878], [0, 6105071978828574516], [0, -1636525469640528862], [25069385557117868112, 0], [-5265471710300882744, 0], [-1827193373979186978, 0], [0, -18630726842501509], [40875511169879907102, 0], [0, 12524469963173563806], [0, 14449027702805088237], [0, -19784642310448697044], [15385483855769992956, 0], [0, 10023243771771846711], [0, -2920033943764295364], [32168704058142394976, 0], [0, -1470867305238471163]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_100_c_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_100_14_c_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_14_c_a(:prec:=2)
    chi := MakeCharacter_100_c();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 14));
    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_14_c_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_14_c_a( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_100_c();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,14,sign)));
    Vf := Kernel([<3,R![219024, 0, 1]>],Snew);
    return Vf;
end function;