
// Make newform 99.3.k.c in Magma, downloaded from the LMFDB on 25 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_99_k();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_99_k_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_99_3_k_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_99_3_k_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 := [83521, 0, -71672, 43316, 32427, -16804, -1619, 1868, 1520, 578, -577, 88, 77, -4, 3, -2, 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, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [-10624181552957568214, 13020347824350349103, 8378055018470127650, -1059049981018273091, -5550683119927089754, -133037791520559623, 788622311310230084, 122498246567678379, -144385372422156236, -128500627016425958, 12120978905635508, 9450527129283881, -1705096652769584, -300665341738367, -291050501651580, 138203247537734], [87548232770773285, 84006679985420530, 43546075769649555, -74422428601993325, 18238786120480205, 26580224433121053, -3000401551565675, 1143522707363375, -2042076941900150, 970794484128155, 396329540870948, -160608059534630, 37431650235165, -13694873409440, 7612440593330, -1196620054805], [5561216538715898968492982, -10114210902968983105987135, 1663249793505431751688693, 6972042698248130206151734, -811030725865674829791365, -829913842787061972319720, 136183765825282943853761, 95964394821698805650574, 189766153484548192315027, -56158309327266771570697, -13643260700327505255674, 9352590043947181216000, -1181236305529453459044, 817712598296562884653, -414504109012258813809, 79900318483541295869], [-5737747263618475322503230, 6489773955290969592983712, 1584736358268525956493486, -6976139470347708662854381, 1534542665221003166135310, 488650962940974324993039, -246702387055823098949248, -7207303915835648139573, -180048790704766856126064, 68084957445524132210249, 1352851863401509576374, -11122165667396999800860, 1306893009198853700308, -875766486639397095366, 390636691234340826078, -122411618273740428915], [-14395227503745014111293247, 7009039219983139174322425, 8681896656673390953560247, -7289423934676201623932819, 1643119706749150800729097, 131176280566363812419931, -104458453399814352710637, 152854650725265611821303, -223430759423433745295680, 72904516698863990088998, -5186301744109515584546, -10341194991166970946468, 1181001191967106814165, -988352396932402617563, 375227479116253831410, -136359504183385890890], [-10633476167661152687325848, 6767600917775046214158900, -88831069153588802148432, -6440011982471751717571965, 2388290245026519865709064, 269559976623314579423811, -382107707960321190084594, -25618165363271255976237, -159377154247336302510228, 91124937595251030901909, -6409586754553109280864, -14163899845284185510064, 1611262423238216663326, -909817832880658011498, 434330161717510886082, -170240978662162064119], [-12139260995132491579346226, 11349844369944629860390067, 1845484707680277480548616, -11303824104537481334436817, 3044197524673710725500914, 979026668318049167132803, -399468647443749302413782, -55824128700867687245691, -287797606597911626958148, 133720108959147123348880, 5237533698052177949662, -18560750721332235068174, 2263013632083543127888, -1346611723653217936835, 708563165563293316406, -206074168461557516052], [29383283378807446672223354, 2853132220575548469672140, -16802658167616863816782085, 11370877427156155063566520, 239881156011128668612579, -711143038597944288083530, 725446686209137214367935, -401666468771928513101288, 358881589762381071470923, -77205981106427487557846, -11798681872105894888540, 24746729416159566188668, -4478763958971146181708, 2376052169206225011042, -776594441642987820173, 245204915440680156914], [19782979528236067552714073, -10344016932751524448182256, -631699645499098517354817, 11234369776810738073080218, -3190848798199793757451725, -395644720931754611009464, 701839303337308061729221, 124867657205700169186062, 292119947250793672950606, -130800194424547620941876, 7902296848980404937094, 26153841247373778060042, -2850753731085855890079, 1767266717836305278230, -743934382221418472242, 290375359378885003312], [-62351648937184846117813681, 49425586234727022770461941, 27844288339436115275679098, -36719641709862948496729891, 3561481521476851963965096, 4387546501364479788167939, 506700705832317210409544, 388039704245625216000627, -1040119147479516578145527, 292392729702505742733160, 105998876476806512378294, -37867833616479840448874, 7837297929564868783317, -4466190043659119653421, 2293064170187332819187, -318073994808497231570], [-916714740028087519831068, -868849722103095172193017, 334862658377387529702803, -523468395825219908972988, -35902260644185079638963, 5075887138800366711766, -93694473582422293608019, 8451228402253354843526, -20580179620448945951591, 1823706335460357174691, -919597481073259125842, -2164217419437062242990, 274358583941958469564, -176449598889577838775, 39547953338415445145, -20975988167062581733], [-19147500634288685846910169, -22439135362612872985811991, 26803847027910109683168612, 1712964652569758738280733, -9850704470596476333646446, 1009287290081580835466493, 566992698905865867472240, 810871220438588178709463, -157743783882519768425145, -231037252399480846221794, 86155282281315189826046, 17685313247604191574774, 1607794271396129055839, -800114075158984515449, -123523917827887574891, 357782714812193812176], [9148560862865248236217178, -18024602065451566144299597, -1448346950335563611661837, 16674572537573573808687019, -6240010475731289229690247, -2290539345841782308758671, 1194059572369888956687611, 58620806557048961231735, 430971747898100629606361, -254095554940103528613762, -12469513850456023691368, 45185336926506497857202, -6596755340890207762998, 2999350746100514306003, -1473705395402246668575, 476964966549267156748], [27664828216431640824705446, -20004927468191489674451150, -2777676281482766127449851, 21509477402988567555648733, -6069367767126172146850815, -1482438585718953558456509, 1438278968368169116260339, 84055353158510742790295, 564892960196155782707651, -246766753353328108128263, 5500764870110710645582, 53067762013301206658762, -6673310293034086938068, 3751560263724227188644, -1520250623078270404265, 570985375503210482467]];
    Rf_basisdens := [1, 1, 10999895242048793399, 78081122146535134, 4136026610381798610784394, 4136026610381798610784394, 4136026610381798610784394, 4136026610381798610784394, 4136026610381798610784394, 4136026610381798610784394, 4136026610381798610784394, 4136026610381798610784394, 243295682963635212399082, 4136026610381798610784394, 4136026610381798610784394, 4136026610381798610784394];
    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_99_k();"
function MakeCharacter_99_k()
    N := 99;
    order := 10;
    char_gens := [56, 46];
    v := [10, 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_99_k_Hecke();"
function MakeCharacter_99_k_Hecke(Kf)
    N := 99;
    order := 10;
    char_gens := [56, 46];
    char_values := [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0]];
    assert UnitGenerators(DirichletGroup(N)) eq char_gens;
    values := ConvertToHeckeField(char_values : pass_field := true, 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+1)]];
    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 := 3;
    raw_aps := [[-1, 0, -1, 0, 0, 1, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [-1, 0, -1, 1, -1, 0, 1, -1, -2, 1, 0, 0, 2, -1, 2, 3], [-3, 2, 0, 0, 2, 0, -1, -1, -2, 0, 1, 2, 2, 0, 0, 0], [6, 1, 3, -4, 4, -2, -1, 10, 9, 0, 0, 0, -1, 2, -1, 0], [3, 1, 0, -1, 0, -1, 0, 0, 2, 0, -1, -2, 0, 2, 2, -2], [1, 0, 0, -3, -5, 0, 0, -1, -6, -3, 2, 0, 0, 1, 0, -3], [-1, 3, 5, -8, 6, 5, -3, -4, 2, -2, 5, 0, -2, 0, -5, -5], [-8, 1, -1, 0, 1, -3, 0, 3, 0, 1, -5, 1, 0, -2, 6, 1], [-17, 3, -1, -7, 2, 12, 1, -7, -2, 1, 8, 0, 1, -1, -15, -7], [-2, 3, -6, -7, -12, -7, 18, 1, 4, 0, 7, -2, 0, -2, -4, -4], [-7, -11, -12, 1, -1, -9, -6, -6, -5, -2, -7, 0, 2, -2, 2, 1], [1, 7, 5, 17, 7, 10, 0, -8, -4, 2, -12, -5, 2, 0, 12, 12], [-17, -2, -11, 5, -11, 17, -6, -23, -40, -4, -1, 4, -2, 2, 5, 6], [8, 1, -2, 4, -7, 3, -4, -10, 0, 1, 9, 3, 7, -8, 9, -1], [-25, -3, 4, 2, -8, -9, 2, -36, -10, -16, -2, 8, -8, 8, -10, -18], [0, -13, -7, -17, 6, -3, -6, 20, 3, 7, 8, -6, -1, 7, -1, -11], [2, 0, 17, -7, 6, 6, -17, 14, -12, 0, -2, 0, 0, -4, 13, 3], [-5, 13, -7, 0, 25, 9, -9, 0, 9, 4, -11, 4, 6, -2, 15, 4], [43, 10, -4, 3, 8, -41, -10, 33, 40, -3, 1, 2, -4, 2, 0, 13], [-29, 4, 6, 4, 10, 22, 7, -6, 10, -6, -13, -8, -14, 6, 12, 2], [31, -5, 1, 18, 0, -38, 0, 10, 16, 0, 18, -2, 4, 2, -1, 5], [14, 0, 19, 28, 20, 24, -19, 30, -32, -12, -26, 0, 0, -10, 8, 12], [-26, -13, -17, -26, -3, 21, 10, -31, -10, -3, 19, -3, -8, -2, -22, -3], [-28, 1, 4, 23, -4, -3, 6, -33, -1, -12, -23, 0, -6, 0, -2, -8], [32, 5, -1, -8, 0, -98, 0, 65, 53, 0, -8, 0, -4, 0, 0, -4], [18, 3, 38, 33, 35, -17, -17, 41, 53, -2, 12, 10, -8, -2, -8, 23], [6, 10, 11, 11, -17, 0, 27, -13, -8, -1, 25, -4, -1, 0, 7, 39], [20, -16, 14, -20, 14, -14, -2, 24, 38, 14, -24, -14, -16, 16, -50, -26], [21, -17, 11, -13, -11, 24, -16, 8, 18, 6, -28, -19, -32, 26, 0, 2], [8, 0, 4, -40, 22, 14, -4, 24, -4, 4, 50, 0, 0, -6, -4, -20], [-1, 8, 45, -12, 45, 17, -14, 1, -16, -22, 34, 22, -8, 8, -12, -46], [38, 30, 12, -8, 9, -45, 24, 74, 82, 6, 1, 2, 14, -7, -2, 6], [15, 18, -18, -10, 0, 29, 11, 13, 55, 18, -3, 20, 38, -18, 44, 72], [11, 0, -9, 19, 17, -9, 9, 47, 9, 19, -7, 0, 0, 20, -32, 3], [65, -5, -3, 18, 9, -32, -14, 87, 19, -2, -8, -14, -2, 0, 15, 22], [-90, 0, 0, -4, -6, 28, -6, -2, -92, 0, 24, -4, -8, 8, -46, -32], [-3, 18, -1, 15, 30, -5, 6, 31, 107, 32, -15, 2, 16, 2, 49, 65], [-7, 21, -40, -23, 0, 33, 0, -67, -36, 0, -23, 1, 19, -1, 9, 10], [-52, -13, -27, 19, 12, 43, -25, -95, -70, 14, -14, 21, 14, 0, 6, -2], [-137, 53, -37, 6, 14, 65, 35, -8, -108, -16, 48, 22, 28, -12, -22, -36], [14, 62, 21, 11, 13, -32, 57, 40, 53, 18, 0, 0, 36, -18, 29, 16], [-3, 18, 5, -37, -13, -52, 10, 68, 46, -11, 54, 24, -13, -11, -13, -61], [29, 0, -5, 21, -7, -7, 5, -2, 15, -16, -68, 0, 0, 36, 11, 8], [-1, -67, 4, -8, 4, -6, -41, -49, -43, 26, 13, -26, 3, -3, 23, 10], [91, -45, -43, 0, -51, -48, 47, 1, -47, 2, 11, 2, -8, -12, -9, 2], [-31, 26, -71, 23, 0, -69, 0, 3, 1, 0, 23, 26, -4, -26, 35, -39], [-34, 23, 7, -32, 14, 69, -23, 16, -25, -30, -41, -2, -34, 64, -57, -23], [46, 27, 12, -50, 39, -64, -35, 25, -14, -12, 42, -2, -14, 12, -98, -60], [46, -20, 18, -72, 0, 10, -40, 8, -24, -36, 72, 10, -18, 10, -132, -150], [1, -71, -8, 11, 0, -87, 0, 85, 2, 0, 11, -7, 11, 7, -17, 28], [-136, -61, -34, 36, 5, 77, -66, -140, -38, -27, -13, -9, -27, 0, 9, 5], [-32, 7, -35, 44, -35, -94, -9, -167, -73, -16, -49, 16, 22, -22, 23, 72], [89, 8, -59, 29, -56, -25, 72, 128, 35, 62, -29, -11, 31, -11, 1, 32], [-53, -25, -102, 75, -77, 34, 24, -137, -140, -4, -40, 7, -3, -4, -3, 68], [-58, 26, -59, 2, -59, -63, 28, -151, -88, 2, -49, -2, 33, -33, -43, 6], [-204, 24, -72, 0, -20, 178, -8, -96, -110, 32, -6, -12, 52, -26, 32, 38], [150, 75, 26, -83, 101, -148, -33, 109, 70, -26, 66, 30, 4, 26, -128, -71], [-9, -36, -1, -49, 0, -49, 0, 19, -33, 0, -49, 38, 40, -38, 29, 11], [82, 0, 60, -60, 20, 74, -60, -32, 24, -36, 164, 0, 0, 8, -112, -104], [-102, -34, -40, 36, -84, 54, 50, -138, -76, 6, -62, -54, 6, 0, 48, 34], [196, 28, 50, -59, 78, -171, 48, 161, 151, -50, 0, 1, -49, 50, -49, -40], [-124, -9, -96, 15, -96, 96, 11, -141, -237, 20, 56, -20, 44, -44, 106, 50], [-65, -41, 57, -21, -17, 228, -90, -12, -134, -16, -56, -5, -26, 42, 6, 14], [-26, -20, -5, 93, 0, -2, -25, -11, -49, -10, 38, 76, 56, -28, 83, 105], [22, -10, 3, -102, 20, 24, -40, 19, -156, 14, 102, -4, 7, -4, -63, -56], [-155, 18, 5, -119, -9, 27, 2, -29, -2, 20, 7, 20, 44, 4, 13, 20], [266, 122, 16, 42, 138, -142, 36, 220, 298, -16, -22, 28, 12, 16, 56, -2], [111, 0, 31, 25, 90, 86, -31, -83, 189, -9, -160, 0, 0, 25, 110, 63], [115, 62, 94, -6, 183, -37, -121, 239, 218, -32, -7, 18, -32, 0, -28, -63], [-78, 50, -28, -66, 16, 228, 6, -234, -6, 56, 60, 56, 86, -26, -4, 56], [-6, -12, -32, 110, -44, -144, 6, -22, -188, 32, -70, 8, 40, -32, 180, 102], [-37, -73, -64, 79, 9, 222, -46, -93, -296, -10, -35, -18, 28, -10, 28, 97], [-11, -84, -71, -93, -71, 31, -30, -21, -52, 54, 19, -54, -66, 66, -113, -132], [86, -54, 57, -45, 13, -48, -23, -20, -9, -40, 2, 4, -76, 38, -85, -78], [148, 32, 81, -88, 120, 4, -56, 159, 250, -42, 88, 24, -21, 24, -149, -170], [2, -31, -13, 102, 18, -152, -16, 309, 156, 17, -88, -25, 8, 17, 8, 127], [83, 120, 25, 73, 107, 63, -66, 3, 66, 54, 129, 54, 96, -12, -75, 54], [-53, -64, 80, -129, 7, 48, 2, -77, -114, -39, 44, 88, 10, -5, -168, -119], [0, 20, 85, -59, 0, -33, 0, 104, 72, 0, -59, 14, -20, -14, -115, 95], [67, -38, 23, 176, -101, 105, 39, -144, -39, 1, -58, 1, -13, -15, 59, 1], [-95, -33, -47, 30, -52, 91, 75, -2, -50, 80, 137, -50, -20, -60, 75, -77], [199, -143, 21, -61, 0, -283, 0, 146, 112, 0, -61, -41, -22, 41, -8, -14], [-36, -9, -20, -17, -11, -243, -25, -19, 171, -52, 70, 78, -26, -52, -26, -95], [61, 111, 12, -19, 12, -177, 111, 56, 233, 0, 46, 0, -2, 2, 8, -38], [-243, -39, -24, 8, -58, 172, 29, -3, -222, 63, -69, -55, -47, -16, -81, 85], [218, -48, -50, -48, -184, -48, 88, 128, 76, -84, 48, 4, -42, 4, 38, -4], [226, 0, -56, -10, -62, 230, 56, -197, 117, -14, 38, 0, 0, -4, -24, -24], [120, 24, 111, -80, 111, -135, 24, 129, 264, 0, 133, 0, -81, 81, -27, -160], [44, 8, 65, -81, -33, 30, -16, -14, 16, -8, -15, -8, -52, -36, 7, -8], [-151, -64, -63, 5, 11, 157, -149, -27, -53, -43, 37, 74, -12, 6, -38, -169], [-165, 0, -70, 51, -167, -144, 70, -31, -174, -17, -106, 0, 0, -21, 76, 55], [-93, -55, 29, -28, 5, 45, 2, 59, -63, 26, -48, -54, -82, 56, 65, -8], [-112, 55, -27, 186, 28, -164, 78, -3, -170, 27, -142, -15, 12, -27, 296, 137], [-20, -9, -60, 91, -51, -42, 31, 55, 2, 20, -170, 16, -36, 20, -36, 75], [-122, 72, 36, -196, -26, 72, 98, -174, -16, 36, 182, 4, 36, 0, -82, 18], [-107, -72, 40, 48, -49, 127, -57, -65, -212, 32, -4, 16, 64, -96, 154, 100], [82, 48, 158, 220, 110, -234, -28, 166, 398, 6, -42, 32, -38, 6, -38, 188], [-58, 0, -44, 26, 69, -24, 44, 220, -229, -44, 48, 0, 0, -34, -40, -29], [-214, 9, 13, -4, 0, 78, 0, 135, -77, 0, -4, 14, 84, -14, 145, -61], [268, -21, -113, -30, -119, -178, 98, 273, -108, 92, -74, -36, 92, 0, 49, 24], [110, -45, -69, -207, -114, 31, 28, 12, 55, 69, 28, -58, 11, -69, -45, 231], [22, 94, -53, -8, 0, -40, 0, -23, 102, 0, -8, -12, -111, 12, -33, -78], [-96, 20, 18, 134, 180, 254, -160, -276, -162, 2, -98, -52, 2, 0, 94, 90], [-127, -9, 45, 42, 45, 111, 13, -130, -241, 22, -57, -22, -70, 70, 49, 106], [79, 32, -5, 195, 52, -9, -77, -198, -112, -36, -34, -68, -140, 70, 159, 185], [-102, 39, -186, -134, -225, 90, 123, -301, -294, -18, 72, 22, -4, -18, -4, -156], [76, 74, -75, 146, -75, -223, -16, -87, 136, -90, -87, 90, 81, -81, 115, 202], [158, 40, -58, 44, -48, -178, 78, 190, 190, 68, -48, -96, 40, -20, 112, 102], [183, -128, 8, -78, -120, 178, 63, 63, 304, -8, 17, 42, 34, 8, 0, 70], [161, -70, 73, -43, 0, -83, 0, 3, 15, 0, -43, -8, 64, 8, 55, 9], [-110, 20, -4, -128, -194, 4, 214, -190, -84, 24, 142, -12, 24, 0, -46, 50], [-200, 91, 77, -98, 7, 27, -42, 15, 42, 49, -51, 49, 106, 8, 100, 49], [-57, -28, -12, 32, 73, -191, 125, 81, 36, 40, -235, -8, 24, -64, 104, 299], [26, 162, 78, 30, -84, -233, 110, 15, 285, -26, -252, -6, 32, -26, 32, 36], [191, 38, -9, -59, 2, -247, -18, 32, 232, -29, -31, -30, -89, 118, -15, -87], [340, -38, -60, -150, -9, -314, -80, 336, 343, -10, -16, -32, -52, 26, -160, -65], [-505, -63, -23, -105, -82, 9, -44, -586, -344, -36, 105, 13, -18, 13, -70, -88], [21, 82, 102, 29, 20, -208, 1, 536, 250, -60, -36, 7, 53, -60, 53, 22], [83, 188, 92, -60, 92, -8, 225, 383, 391, 37, -141, -37, -58, 58, -224, -83], [-2, -75, 62, 75, -264, -84, 101, -17, -101, 26, -46, 26, 4, -48, 72, 26], [237, 263, -101, 72, 0, -482, 0, 134, 266, 0, 72, 10, 102, -10, -115, 217], [271, 0, 77, -121, 328, 194, -77, 341, 133, 69, 110, 0, 0, 77, -66, -59], [-39, 54, -30, -60, 94, -6, -32, 38, 32, 22, -87, 22, 15, -29, 109, 22], [-428, -12, 138, -146, 152, 56, -176, -502, -352, -124, 146, 32, -62, 32, -68, -130], [251, 36, 123, -37, -82, -53, 118, 14, -114, -87, -71, 10, -87, 0, -67, -205], [-416, 50, -100, -274, 35, 414, -120, -222, -199, -10, 12, 24, 4, -2, -284, -275], [-31, -46, 37, 3, 83, 358, -114, -444, -420, -99, 38, 24, 75, -99, 75, -21], [-306, 99, -64, -133, 134, 216, -35, -181, 35, 64, -48, 64, 30, -98, 112, 64], [20, 0, -76, 174, -76, -130, 52, -2, -134, 76, 12, 16, 92, -76, 68, -30], [97, 23, 104, 7, 0, -165, 0, 108, 94, 0, 7, 64, 40, -64, 8, 32], [-164, 0, 34, 38, 239, -143, -34, 342, -102, 22, -73, 0, 0, -21, 56, 58], [235, 17, -5, -78, 32, -11, 25, 98, 338, -12, 79, -66, -144, 156, -113, -235], [-227, -83, -66, -25, 48, 69, -214, -220, -200, 180, 25, 38, 90, 38, -104, -14], [-92, 236, -161, -102, 0, -118, 0, 49, 48, 0, -102, 0, 97, 0, 15, 82], [-77, 290, -53, 31, -53, -54, 278, 70, 124, -12, -5, 12, 62, -62, 45, 50], [-69, 123, -95, 20, -32, -481, 35, -80, -54, -28, -112, 48, 68, -40, 130, 152], [44, 0, 60, -196, 84, -84, -60, 192, -134, -154, 230, 0, 0, 128, -162, -256], [177, -282, 13, 105, -28, -98, -213, -141, -203, -113, 34, 68, -158, 79, -8, -397], [-43, 0, -164, 31, -246, -13, 164, 17, -200, 93, 101, 0, 0, -30, -102, 11], [-380, 41, 69, 328, -23, 360, 64, -829, -380, -28, -202, 86, -28, 0, 107, 12], [40, -66, 122, 221, 56, 147, -254, -79, -11, -122, -4, 123, 1, 122, 9, -334], [255, 65, 167, 58, 214, 72, -84, 260, 436, -120, -58, -30, -60, -30, 41, -19], [636, -108, -31, -143, 0, -338, 0, -152, 214, 0, -143, -177, -52, 177, 124, -176], [-155, -158, -354, -32, -196, -567, 41, 121, 257, 44, 215, -84, 40, 44, 40, 52], [521, -175, 79, -29, 35, -216, 52, 160, 602, 96, -74, -125, -154, 58, -114, 16], [92, 0, -47, -143, -279, 224, 47, -298, -185, -72, 204, 0, 0, -132, 71, -72], [-206, -57, 93, 198, 93, 159, -124, -377, -536, -67, 15, 67, 46, -46, 344, 329], [115, -156, -123, 263, -121, -303, 122, 181, -122, -34, -17, -34, 26, 94, -17, -34], [364, -184, -142, 226, -120, -426, -86, 104, -50, 28, 34, 68, 124, -62, 254, 112], [171, 156, 130, 84, 157, -35, -1, 301, 260, 26, -343, -74, 26, 0, 92, -159], [-520, 3, 32, -36, 16, 336, -24, -312, 24, -21, 320, -21, -53, -11, -341, -21], [-126, -4, -98, 98, -180, 218, 20, -176, -204, 102, 160, -4, 94, -196, 54, 36], [-245, 278, 115, -189, 393, 114, -96, 26, 166, -115, 148, 0, -115, 115, -411, -337], [-210, -308, -171, -7, -188, 120, -103, -126, -370, 34, 56, 112, 180, -90, 27, 119], [-150, -48, -277, 330, -472, -46, 376, -157, -28, 82, -330, -142, 41, -142, 317, 358], [-324, 0, -263, -75, -416, -186, 263, 49, -445, 158, 286, 0, 0, -138, -73, 5], [-434, -54, 60, -164, -53, 479, 112, -532, -514, 26, -71, -142, -90, 45, -138, -40], [-350, -162, 15, -15, 0, 785, 0, -370, -317, 0, -15, -50, -248, 50, -209, -39], [-73, 0, -254, 249, -365, 12, 254, -361, -18, 71, 38, 0, 0, -85, -202, 59], [289, 77, -48, 48, 136, -258, -44, 302, 44, 33, 199, 33, 82, 16, -166, 33], [-68, 56, -92, 286, -36, 222, 276, 86, 394, 92, -80, -132, -40, -92, 120, -74], [-45, 34, 15, -143, 15, 574, -146, 338, -236, -180, 185, 180, -14, 14, -281, -466], [198, -286, 240, 26, 70, 286, -124, 90, 48, 46, -202, -20, 6, -52, 376, 254], [-52, 60, 55, -180, -16, -30, 136, -55, -242, -126, 180, -38, -63, -38, 193, 130], [-30, -64, -46, 110, 18, -52, -48, 122, -8, -14, -78, 40, -26, -14, -26, 70], [693, 66, 217, 277, 231, 72, -224, 152, 224, -158, -333, -158, -180, 136, 175, -158], [-346, -1, 104, 265, 103, 482, -79, -161, 160, -104, -64, 84, -20, 104, 108, -261]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_99_k_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_99_3_k_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_99_3_k_c(:prec:=16)
    chi := MakeCharacter_99_k();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 3));
    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_99_3_k_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_99_3_k_c( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_99_k();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,3,sign)));
    Vf := Kernel([<2,R![3721, -11590, 28523, 28270, -9685, 9870, 29668, 9190, -5691, -4410, -28, 720, 160, -40, -18, 0, 1]>],Snew);
    return Vf;
end function;