
// Make newform 98.14.c.c in Magma, downloaded from the LMFDB on 31 May 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_98_c();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_98_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_98_14_c_c();".
// 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_98_14_c_c();".
// 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, -1, 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_98_c();"
function MakeCharacter_98_c()
    N := 98;
    order := 3;
    char_gens := [3];
    v := [2];
    // 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_98_c_Hecke();"
function MakeCharacter_98_c_Hecke( : Kf := false)
    N := 98;
    order := 3;
    char_gens := [3];
    char_values := [[0, -1]];
    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, -64], [1026, -1026], [0, -4320], [0, 0], [8787312, -8787312], [-20420932, 0], [-1719462, 1719462], [0, 109702942], [0, 646760160], [728867274, 0], [-1028049116, 1028049116], [0, -14229390962], [44544458406, 0], [-54689828968, 0], [0, -47868325716], [169986882858, -169986882858], [300765540198, -300765540198], [0, -369996272360], [787010801908, -787010801908], [559441472256, 0], [-121137579650, 121137579650], [0, -290426785064], [-3965105603046, 0], [0, 6025919250630], [11302818199190, 0], [-17141087691360, 17141087691360], [0, -11450898959900], [0, -28787521180092], [6835876748206, -6835876748206], [-23230926547386, 0], [-93328006821712, 0], [0, 66112607301390], [-48082381438194, 48082381438194], [-129911145086002, 0], [0, -126590121115902], [238305988864792, -238305988864792], [-331263463313660, 331263463313660], [0, 309482090257120], [18962425972308, 0], [0, -514033087970676], [138537219537852, -138537219537852], [-879858200754988, 0], [0, -219512885897784], [798168343166770, -798168343166770], [797364406952766, 0], [-17340438865844, 17340438865844], [-1277347446473908, 0], [-1510632403961464, 0], [3785828334386382, -3785828334386382], [0, 2204812569827524], [0, -258261933275034], [4425537557387928, 0], [2491488907895530, -2491488907895530], [-2254475908467090, 0], [0, 5441075353988910], [-4127539038295104, 4127539038295104], [2725803065529996, -2725803065529996], [0, -8990725625077232], [6661881220856122, -6661881220856122], [2115190829277402, 0], [8155789670969014, -8155789670969014], [-13102161422235144, 0], [9484535638893602, 0], [-6030282325809192, 6030282325809192], [0, -15648465364869590], [0, -10503529046620662], [0, -34912919178151640], [44170206115569998, 0], [10624296510371784, -10624296510371784], [-34574832254176732, 0], [-50769951639351570, 50769951639351570], [0, -7667711423613384], [15728765153092408, -15728765153092408], [0, -51894328533584414], [-43847066001485248, 0], [0, -39703585677979140], [34198163675791614, -34198163675791614], [0, 30642782514276652], [0, -69521331773589678], [116045930580869650, -116045930580869650], [140052127502098182, 0], [-96502238705954170, 0], [151333479717078696, -151333479717078696], [197235331866449534, 0], [0, 53828214714755704], [0, -155428794576032484], [252502017478699410, 0], [0, 255752078076742762], [-8909857880064372, 0], [201346672873047872, 0], [0, -101466587449768794], [-144100733056736508, 144100733056736508], [-333007070612297744, 333007070612297744], [141802917806200548, 0], [0, 384702796637866228], [567444881542142016, 0], [0, 629561044832013468], [360434784072112026, -360434784072112026], [0, 247278766818287518], [0, -1389548700111638], [-475093605859565320, 0], [1093282473499439946, -1093282473499439946], [-1025650363577317278, 1025650363577317278], [0, -434266555373358438], [-555274254886825136, 555274254886825136], [-1230427143948859202, 1230427143948859202], [-1562619679758799914, 0], [0, -1095329705754220602], [1470450423954855576, -1470450423954855576], [731234774776900058, 0], [0, 547903716260740384], [376450437312351502, -376450437312351502], [-1609291383819655002, 0], [-1576956616783443962, 1576956616783443962], [396768388489314032, 0], [1058302886419130130, -1058302886419130130], [-445532425466433970, 0], [-521651127656194644, 521651127656194644], [0, 710699816297245086], [678921538633536984, 0], [2180629826303257480, -2180629826303257480], [-135117903327985702, 0], [0, -3219268814042860020], [809935635242923548, -809935635242923548], [0, 1118453704804713934], [-5965205354387949150, 0], [0, 4107583738732399678], [0, 4671993312451702740], [-1833468870703859956, 0], [0, 1915349785225575880], [-6472974137290292000, 6472974137290292000], [2824866175107576504, 0], [0, 6088956441140722216], [8688954254978459954, 0], [0, -3797002487494570446], [4024661108793915758, 0], [-1219051064934675192, 1219051064934675192], [10120608013983587446, -10120608013983587446], [-6891526132912691340, 0], [11164429876009755354, -11164429876009755354], [8007682110815464994, 0], [0, -8203244618168343894], [8646774991842485416, -8646774991842485416], [6187226858611033356, 0], [9341554851179698984, -9341554851179698984], [5159412643664498604, 0], [665104898125244780, 0], [-16155143668013460750, 16155143668013460750], [0, 4545414035794059826], [0, -6026090600154402312], [0, 2942760373318168582], [7227141945146149194, 0], [-8750726772979308892, 0], [0, -18654481979660075004], [-16630628343219644444, 16630628343219644444], [6962836095648712176, 0], [0, 6186314603272726024], [0, 19678057563562476378], [13369550642361123266, 0], [-38508618671336182344, 38508618671336182344], [0, 7960554411010165752], [-3649915779748828182, 0], [-15521590767886514176, 0], [0, 16262528879268016806], [-30475360382471664378, 30475360382471664378], [37730356697412192132, -37730356697412192132], [-27324713659225854800, 27324713659225854800], [-60441954122917038248, 60441954122917038248]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_98_c_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_98_14_c_c();".
// 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_98_14_c_c(:prec:=2)
    chi := MakeCharacter_98_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_98_14_c_c();".
// 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_98_14_c_c( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_98_c();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,14,sign)));
    Vf := Kernel([<3,R![1052676, -1026, 1]>],Snew);
    return Vf;
end function;