
// Make newform 10.14.b.a in Magma, downloaded from the LMFDB on 25 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_10_b();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_10_b_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_10_14_b_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_10_14_b_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 := [10914144768, 975553632, 43599609, 160950, 2, -2, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0, 0, 0], [1444881606555456, 123915151592604, 252252560280, 467184200, -38332616, 2902156], [8279858082468816, 722940932399175, 717491956170, 53829158030, -124928126, 8857615], [11635391903364851652, -203160410986305897, -1322005625015190, -24595132422850, 730507083298, -8853546833], [86914657131672672, 4563380738283957, 23032569783630, 15870764330, -586906082, 117783373], [-4139867393445834288, -613155973504765707, -3008911425433890, 5659609021850, 279534354118, -14657213123]];
    Rf_basisdens := [1, 21586271220765, 34538033953224, 949795933713660, 5276644076187, 474897966856830];
    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_10_b();"
function MakeCharacter_10_b()
    N := 10;
    order := 2;
    char_gens := [7];
    v := [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_10_b_Hecke();"
function MakeCharacter_10_b_Hecke(Kf)
    N := 10;
    order := 2;
    char_gens := [7];
    char_values := [[-1, 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 := 14;
    raw_aps := [[0, 1, 0, 0, 0, 0], [0, 1, -1, 0, 0, 0], [-412, 90, 15, 1, 1, 2], [0, 57, -163, 0, 19, -19], [112504, 208, 0, -676, 26, 130], [0, 136200, 16458, 0, 819, -819], [0, -438020, 11208, 0, 6462, -6462], [23770128, -8400, 0, -7284, 16242, 12042], [0, 1992077, -466971, 0, -12519, 12519], [233699526, -188784, 0, 85752, 240300, 145908], [-3711799064, -174048, 0, 163848, 179148, 92124], [0, -63677700, 12825518, 0, 237607, -237607], [-26591361812, 197320, 0, -1328878, 368459, 467119], [0, 444976377, -21436373, 0, -82654, 82654], [0, -851657179, -18028263, 0, -2540817, 2540817], [0, 894558024, -31252362, 0, -7323147, 7323147], [-21581469008, -3957488, 0, -14383516, 13127990, 11149246], [368061078560, 5167104, 0, -20768574, 2633631, 5217183], [0, -15734278419, 317678671, 0, -13917202, 13917202], [169439525640, -11978880, 0, 40721376, -2392368, -8381808], [0, 13785698244, -92547572, 0, -20801872, 20801872], [-3923935992, 25923744, 0, 119991096, -98881164, -85919292], [0, 25902259349, 180468135, 0, 8585838, -8585838], [-183808237150, -5054320, 0, -45884120, 30523540, 27996380], [0, -37797913764, 1313113120, 0, 252891458, -252891458], [-3772787644642, -241121104, 0, 882755752, -79696220, -200256772], [0, 35071122981, 1112055005, 0, -63808175, 63808175], [0, 133279185453, -6039979749, 0, -1348605180, 1348605180], [-9005031561016, -1029335184, 0, 959915898, 1064044827, 549377235], [0, -63587343408, -29583213816, 0, -320806044, 320806044], [0, 597970474473, 18099298241, 0, 1771347565, -1771347565], [23205450514368, -629905872, 0, 2726666892, -418474638, -733427574], [0, 1123146960840, -48373227108, 0, -889222698, 889222698], [-52015384378408, 3250059792, 0, -2730537156, -3509821110, -1884791214], [-98716730487440, -2836092896, 0, 7915287770, 296495459, -1121550989], [-42474613834928, 6647846880, 0, -6494971560, -6724284540, -3400361100], [0, -2317172525388, 193963081042, 0, -5623575151, 5623575151], [0, 2256126935433, 266051912015, 0, 5825057692, -5825057692], [0, -1864632407955, -200817065379, 0, 8730933237, -8730933237], [0, -125915481884, 40391816970, 0, -8334337635, 8334337635], [-145434192967496, -14526562640, 0, 33948614228, 4815536846, -2447744474], [189360502900766, -1915914480, 0, 2270938008, 1738402716, 780445476], [135877214692080, -24517970880, 0, -3571984464, 38562948552, 26303963112], [0, 6452107165188, -147949037360, 0, -30393018058, 30393018058], [0, -4245381418864, 845688537486, 0, -984435147, 984435147], [-307481001566424, -3246208896, 0, -5060558208, 7399592448, 5776488000], [213289109250432, -30808427664, 0, 37742970300, 27341156346, 11936942514], [0, -8255711415039, -516822328079, 0, -18758464495, 18758464495], [0, 22866423219097, -1137796954257, 0, 74576908404, -74576908404], [961285552165822, 37745075760, 0, 186362570184, -149798898732, -130926360852], [0, -21396179783228, 1002358480572, 0, -66159534024, 66159534024], [3212110587585608, -11669670688, 0, 77929264216, -21460126076, -27294961420], [-1693925076835508, -4613366808, 0, 31406554890, -8783227233, -11089910637], [771189492141192, -194066495472, 0, -45577409220, 313888447818, 216855200082], [0, 6576003653088, -250475402112, 0, 268770028320, -268770028320], [0, 8770355156321, 4405609186941, 0, 66071075175, -66071075175], [4783395428119584, -204397348608, 0, -105971983182, 359582014503, 257383340199], [1464349157855608, 537551216736, 0, -618784911768, -496934369220, -228158760852], [0, 29321920343724, 2652705121142, 0, -373289131589, 373289131589], [-2283513291196668, -302338470600, 0, 618628263930, 144193573935, -6975661365], [0, 19420670326869, 2352788111651, 0, -597738219572, 597738219572], [0, 17315826893268, -12164404466610, 0, 314262799947, -314262799947], [0, -123622277708787, 10729132187415, 0, 430997053410, -430997053410], [-8950230120386544, 321893067168, 0, -279037878792, -343320661356, -182374127772], [0, 66756425308488, 11610344511172, 0, 133390230962, -133390230962], [0, -243599184617360, -7054884014574, 0, -361928322693, 361928322693], [13496419929523744, -976571522352, 0, 1360959284484, 784377641286, 296091880110], [0, -137403919030920, -28756198026760, 0, 308005026952, -308005026952], [0, 236188937883009, -11139708099981, 0, -946235839014, 946235839014], [-24177355244715658, -370685766480, 0, -673563203736, 892810251588, 707467368348], [0, -267182628601880, 18959778305328, 0, -2153972904876, 2153972904876], [-6139712104107024, 622593329376, 0, -520058763288, -673860612420, -362563947732], [0, 360318100107297, 8852011655273, 0, 1009613027629, -1009613027629], [0, -19837838004612, 44464904676870, 0, -383618359413, 383618359413], [-44437113890708504, -2192880213168, 0, 1374732798492, 2601953920506, 1505513813922], [0, 3731886770185, 37345930942017, 0, 189153536589, -189153536589], [9660278814260432, 4982309161568, 0, -4403408593526, -5271759445589, -2780604864805], [0, 301986022650528, 19765520844074, 0, -4946553961145, 4946553961145], [-48835303756195414, 1787310852080, 0, 835370259928, -3098651408084, -2204995982044], [-6329888289604004, -1876413405720, 0, 7691721336402, -1031240559621, -1969447262481], [47485670347214792, -8149168236304, 0, 909793162804, 11768855773054, 7694271654902], [-99410556491186528, -2334319340160, 0, 3747897725370, 1627530147555, 460370477475], [85829889394837432, 4442812141984, 0, -4712725638520, -4307855393716, -2086449322724], [0, 1303913969723988, -10942139328488, 0, 4384765282442, -4384765282442], [-8992657067158224, 5823461930400, 0, -11966392436328, -2751996677436, 159734287764], [0, 679688520539997, 121131826585203, 0, 5839478036136, -5839478036136], [88068686877529548, -1576556547480, 0, -5549254124934, 5139461883687, 4351183609947], [0, -4191889341744624, -59862897641380, 0, -182274038702, 182274038702], [-86259114156096378, 2466643306224, 0, -12658656100920, 2629363091124, 3862684744236], [0, 2547023003823141, -3826896686007, 0, -10939773745065, 10939773745065], [0, -1573842217101735, -141933271181769, 0, 3682642520232, -3682642520232], [-87888288867300640, 22713555375680, 0, -7083708629120, -30528478748960, -19171701061120], [0, -1765327994103471, -2786727436467, 0, -16165552804089, 16165552804089], [99795986257039536, 2461269589008, 0, 5825188415988, -6604498591506, -5373863797002], [131321365111915656, -11135090492880, 0, -18355846017948, 25880558748294, 20313013501854], [0, -2157915633252579, 377837221560117, 0, -6196267006695, 6196267006695], [199091741938395558, -9683784940272, 0, 6686191240056, 11182581790380, 6340689320244], [-406697128527049558, -25379126408512, 0, 21934428314560, 27101475455488, 14411912251232], [0, 324266725510005, -125979152941333, 0, 26315401553344, -26315401553344], [-588520480101729530, 11521996124880, 0, -5408405757384, -14578791308628, -8817793246188], [0, 6429953064045873, -380489868921937, 0, -2937938457920, 2937938457920], [0, 4153041688733988, -531258283494966, 0, 2124038142765, -2124038142765], [0, -7730740069000367, -815478890288793, 0, 8171002295532, -8171002295532], [-727875731967183268, 35020438442024, 0, -37149960572366, -33955677376853, -16445458155841], [914840044681670872, -42228052183536, 0, -5444191651380, 66064174100994, 44950148009226], [0, 93864177865944, 672436991806208, 0, -44989210078124, 44989210078124], [0, -1931498968074471, 661376475352731, 0, -7814681514054, 7814681514054], [0, -5673028670721696, 452524765180248, 0, 54760153028868, -54760153028868], [-1194904895043637176, -33746139456384, 0, -493580972592, 50865999670872, 33992929942680], [-61021398210693196, 66122795194584, 0, -81429881922966, -58469251830393, -25407854233101], [0, -18186566415768435, -150044240162207, 0, 42646622585447, -42646622585447], [0, 23318003086138992, -433314973829186, 0, -32496949827619, 32496949827619], [0, -5401765852678820, -1884091795470180, 0, -31415810518548, 31415810518548], [-1465830948929097200, -49745942113200, 0, 16829784061140, 66204021139230, 41331050082630], [-30999788439560464, -44815337570592, 0, 147044563549848, -6299275419036, -28706944204332], [-1322154403742604068, 41295015470344, 0, 1885982522570, -62885514466801, -42238006731629], [0, 33263364142958181, 381498995150607, 0, -1290432219750, 1290432219750], [0, -20301148212682311, 1099713744704157, 0, -35190118445949, 35190118445949], [0, -8891071486576768, 726727604232618, 0, 73634608318311, -73634608318311], [-1112642492762081336, 81669673626736, 0, -9134553351292, -117937233764458, -77102396951090], [-2705234946337854184, 22426595615184, 0, 14528752168578, -40904269507065, -29690971699473], [0, 33514791625348428, 259221341444160, 0, -84848122420998, 84848122420998], [0, 13031995261214200, 1292359098215166, 0, 152845599046617, -152845599046617], [0, -31819622232226447, -902077550550069, 0, 31223854777662, -31223854777662], [2068500974369521552, 110558215171632, 0, 35894823226860, -183784734370878, -128505626785062], [223985675993349544, -55343178948752, 0, 275261441005514, -54615952079629, -82287541554005], [-329930981139252882, 146273970740112, 0, -201227721646824, -118797095286756, -45660109916700], [-256869258532202200, -88375223713504, 0, -165085826859560, 215105749000036, 170918137143284], [0, 1133067909267369, 1553347683699957, 0, 167750914404231, -167750914404231], [0, 45516042574739004, -2004027158506606, 0, 81692776162573, -81692776162573], [2422261313172671384, -7260649898640, 0, -39821013493692, 30801481594806, 27171156645486], [0, -71106352684960743, -2485414528374675, 0, 5925447682011, -5925447682011], [2115154419384886928, -17384436455232, 0, -17349325691808, 34751317528752, 26059099301136], [0, 26105259958449444, 3741413034207398, 0, -187854118055849, 187854118055849], [-4511595673532515566, -92036461657488, 0, -102490097051016, 189299741011740, 143281510182996], [13219782502293378, 19451608982400, 0, 80163344562816, -69259085755008, -59533281263808], [0, -6210181924562520, -6647821545755250, 0, -121151540040471, 121151540040471], [0, -51108849210149883, -6032742486583033, 0, -169557727452746, 169557727452746], [0, -60805264142900552, 1304568185247618, 0, -116005494453345, 116005494453345], [2063397115423286538, 74237412876864, 0, 219014950751616, -220863594691104, -183744888252672], [-6099799317654004376, 200731804076496, 0, -832152435918036, 114978511844274, 215344413882522], [4631683669960743176, 259489232032880, 0, -128364743526062, -325051476286289, -195306860269849], [0, 93312935021076213, -5990945358383499, 0, 274043443130757, -274043443130757], [0, -49940399337317879, 4826060224419, 0, -512452082487402, 512452082487402], [-2595938444515122528, 28330440817344, 0, -137907652376766, 26458164962367, 40623385371039], [5416345218512311888, -138935703336800, 0, -309905946438424, 363356528224412, 293888676556012], [0, 64058087358384312, -2999017075227226, 0, 617990141532661, -617990141532661], [0, -142942121939606208, -6559375121418924, 0, 85634677570734, -85634677570734], [-3795494680044092144, -798137601616944, 0, 670530293358372, 861941255746230, 462872454937758], [0, -1039463468572827, -4422794701664703, 0, -125693695171053, 125693695171053], [0, 5213493864242844, 8756872630244170, 0, -1035488941256959, 1035488941256959], [6581419169663774772, -175554784794312, 0, -14266821093390, 270465587738163, 182688195341007], [0, -127663790539276599, -14573912990058585, 0, -97504536137160, 97504536137160], [0, 29480608297113873, -1021903396030395, 0, -193019332487805, 193019332487805], [0, 171487390732716429, 6499292893189131, 0, 295548151427196, -295548151427196], [-13704408310069349688, -37332260400672, 0, -580245063610440, 346120922406228, 327454792205892], [-9837834576669906744, -305954789579520, 0, 139164134130192, 389350117304184, 236372722514424], [-7819179524084691540, 81470472218088, 0, -546170814219270, 150879698782503, 191614934891547], [0, 254482658033987172, -4721861850648740, 0, 671601886189544, -671601886189544], [4254255173960212726, -411727418001008, 0, -1505333056603432, 1370257655303228, 1164393946302724], [0, 67716228671346693, 15146732329347255, 0, -38257063321410, 38257063321410], [0, -19338620034964592, 13859428441189092, 0, 324804667818942, -324804667818942], [0, 228381730565232141, -20092693050929075, 0, -1371541610611987, 1371541610611987], [9341592798316782672, 1290394561346064, 0, -360582364632780, -1755300659702706, -1110103379029674], [0, 281874756767264628, -4035533232327288, 0, 541760215595490, -541760215595490], [0, 141545542926841369, -11483888457539403, 0, 1399228134662223, -1399228134662223], [-22185694366030773728, 14316855890688, 0, 97937439998400, -70444003835232, -63285575889888], [0, -289097958940369080, -10385515761918306, 0, -155446298388303, 155446298388303]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_10_b_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_10_14_b_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_10_14_b_a(:prec:=6)
    chi := MakeCharacter_10_b();
    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_10_14_b_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_10_14_b_a( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_10_b();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,14,sign)));
    Vf := Kernel([],Snew);
    return Vf;
end function;