
// Make newform 22.14.a.c in Magma, downloaded from the LMFDB on 25 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_22_a();"
// To make the coeffs of the qexp of the newform in the Hecke field type "qexpCoeffs();"
// To make the newform (type ModFrm), type "MakeNewformModFrm_22_14_a_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_22_14_a_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 := [-11442, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0], [-2, 4]];
    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_22_a();"
function MakeCharacter_22_a()
    N := 22;
    order := 1;
    char_gens := [13];
    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;

function MakeCharacter_22_a_Hecke(Kf)
    return MakeCharacter_22_a();
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 := [[64, 0], [-463, -1], [1457, -48], [-85280, 1155], [1771561, 0], [-3474458, -27285], [-140072144, 26787], [-174615894, -453753], [-75639147, 2138661], [-385810964, -6597054], [-4313241035, -4337487], [-13166949245, 16483008], [-1780495918, -101787201], [-8164997966, 159822924], [4756675852, -71686146], [145681949326, -351052074], [356009505591, 19558743], [69459291472, 1248591462], [456299597787, -357146649], [-780424171861, 1042775529], [203691208998, 1766329659], [-24051338234, -2887412976], [-3156910275506, -3544871850], [488846162731, -12836101782], [-512488651751, 12244042032], [-6593920933372, -26178787269], [-5179426548260, -15376991094], [5978459896764, 16902050751], [9897953392898, 13986870996], [4188470413005, 2508815262], [-47163425749186, 15273652905], [4449216713172, 223074285225], [-55218386226803, 17021907750], [-59650658981628, -56072495721], [-87627286982452, -90248322903], [26262286571750, 88907040222], [202005699740337, 38320992276], [110276379916228, 755815030032], [325687635819558, -195982254957], [-196159292591382, 444401622120], [50169682751391, -580581419463], [484132039604171, -748756578858], [-655480483370333, -566024512569], [-175464569287636, 449776484364], [-157221468477426, 1536130121736], [-555789978327616, 1138963794552], [-747756463217796, 1134385539096], [-240987119623435, 6279800376999], [264573824696724, 861473084403], [1842958280896699, -3953216537670], [214372106023356, -3075226289754], [-4854660947884826, 801931509582], [2991201492281508, 4457415746610], [-1890583350653285, -640196015985], [3590295382600722, 357405928974], [-1465372041622576, -6733280419533], [-5118385715772662, 1448579833560], [-323088512372354, 10622234691519], [-581972910468718, 7892814805374], [688573807203466, 11398043900154], [-8499496520998400, -7558785709398], [-6064056200822050, -4825022408031], [3853611283178282, 47432317141803], [-4837726768339144, -1097197459926], [-4856903731525605, -45178454917566], [691002498223141, 7366432808508], [-17491476505516315, 16514895447033], [41177293528002860, -224904749685], [10902480587526666, -87560460313251], [-53353197440343632, -27457896237453], [-44969553658140921, -44174630082678], [-25247367311521250, -122198344916877], [39476212883384285, -78531622963599], [-28969537214179232, -131487847419201], [31952081298696541, 154299270185415], [58097964072980217, -108758638175445], [59323744786809061, 35080217885742], [-18943369780631502, -50995089097530], [3581656191919014, -74944841968986], [-69861756713762926, 75993023625912], [-18718326719792328, 48782784827622], [35332497491329050, -402896766420402], [112836213493486004, 40513978056297], [-8624780478477027, -526076622830796], [16646669578212940, 277999046092134], [97488461813986143, 176342769181779], [-86464002156995481, -116080981329114], [-193401842042431928, 157833064021230], [-125663765986315320, -301907618443542], [-167120415164720309, -522986120597043], [-75731997784581929, -56709912590385], [-52047487401860870, -428638481757951], [-18219265245612647, 580946305440735], [205158895755972192, -350672355105684], [307122183879875452, -450299825670468], [77271806668076710, 811151358332280], [-261364398090837053, -445412998517514], [251822233302948957, 788992584553680], [187655327647649414, -731933733267495], [451717914321297942, 1495179248186229], [-241304134250651828, -1396119832349994], [-296516363485616164, -228474244749147], [-709668998002498680, 403170244237494], [676238416232450180, 283018191017574], [-480670127466783604, 1000265303946684], [51802284412864381, -1748346614345958], [-1243978107517397920, 351188515292358], [-230926683440228164, 2919207087172488], [1696196119574864688, 154110014088516], [-1688245688857531728, 796661290127421], [1406502611675007962, -369712928856096], [498514681131847544, -1294057983291012], [129479398674251858, -2170019193054096], [-803369571488624687, 1700820436065267], [-619475402660475, -6313760993885535], [-2223767667630911433, 185798872885740], [-933577776012066493, 2052075836084133], [-1773943454043458917, 3863942959335303], [-919346793866060277, -571138479937098], [-199161311800136054, 358022525593368], [1677337952819274441, 3567556931948718], [1816790809724655422, -5793305348092968], [-1480252957900819876, -4520952488743167], [-2316260643497650924, -2123606122199370], [1237502860095899695, 1225662208224825], [-1810612179480776460, 7725763311631539], [4247588726896765075, 276457928479626], [-120375589116347015, -2253206704332981], [-376953148706904395, 7398498587615415], [1220073420066108448, -8553041168396202], [7171274522237758526, -1314156202399782], [-6556285716194648500, 4475898784045212], [5213657801370014695, -904412444361975], [6946395591608684394, -2061039224610408], [-412489410330733454, 13811534763875169], [2859767782796724910, -14581534397934225], [-1614429259727918702, 630585801307116], [1529727506517340820, 8915592782779758], [-1879354514932384031, 7004714974249626], [-10444019133514863878, -10086658663921137], [-13166641575955365750, -1980583816098768], [739314559368837814, -852245183078304], [583156504405727001, -4701569756916945], [-7748073474380998422, 3073459923529509], [9252506534045274561, 16998048106749252], [7155902986616162517, 2698064957674851], [-6069723922877191410, 25056592532241696], [-16264738694565307744, -5266827816833868], [14639542319913247, 15075802730956497], [11864682597993287160, 11613357130594344], [-6337869749985147062, -45711745209948135], [-6122815107857751287, 9259845820164270], [7848964734527480672, 25214626277272122], [18194123987575799178, -16907487200686968], [2681576097846757956, 44672902896146136], [11736321667834959104, -37134019112441034], [-4292657104653545038, 13609672907553204], [6002091650488770270, -29760569661749910], [-32017757617472407646, 18945838611701487], [24883575842205989214, -18064287590868594], [4723076377577853835, 71968384213792293], [-455037527680386588, 28621350397275051], [11332352221275603644, -18429073314399462], [-3265011156091604707, -15878063115936687], [-14772112551439263799, 72592247492005806], [2087046830369113193, -1600643602486929], [-1464209113910390840, -52381039503097680], [15746002481458794572, 5115451978403265], [10616574325535037578, 42673489088997966], [-17552097654526235453, 80058934925378202], [8455136429008949298, -57339948156800382], [-2389065779725049258, 118118539585111560], [-15321318564714626562, 5184843454249749], [2155579390864353666, -25946639000900829], [-26102686880064174349, -81962832571221375], [-32158881702945985647, -113362260959385972], [-30283013331190213352, -74221553519631423], [60136461182238779187, -4043619486734448], [-26847049217404156228, 24983700652430232], [47738549363736332316, -19519680689517192], [54126032445056832136, -82730802940743432], [4073229657380312922, -58221005429708442], [-36947615273958321963, -53118892455220764], [62193282420656758282, -118292275572399426], [-34663463894035374637, 53226844610458845], [-16878700081355949738, -91044146067379578], [28590317003992058746, -114918297586207401], [-18318221930398992724, 9598408851119598], [-60311208152293902760, 144704789400731889], [96528475996376001510, 6437537590620126], [-77561620141542816755, -17895973393895766], [74469416614714340492, 188491884066849999], [55984633106445745327, -69102772382150121], [5733757041285596310, 106584671022556260], [13939384184643269326, -173870030562640401], [-41113175297392880921, 57257033536253250], [37708085844541409188, 129637570143055467], [101213733839210841683, -226460456493610566], [-28589221769461310142, -435606950126383038], [-92259066294719203940, -223157937736020459], [113745022927429065830, 254995638516439479], [1281860055662741382, 82343147296580412], [-88190132185660044870, 347376793932279108], [24803197228315087588, 201257782948049994], [-16810489706194487563, -348284870169142767], [-15303477063793354471, 195692591875043628], [-67756093285364496025, -283490035246133811], [-128956604458921899704, 143574530615651586], [-259629289442147357652, 35188454606724258], [132184446999081146300, -242951499909957018], [106853000927035941968, 266574952268839680], [-118576833955484541213, -18164772987805116], [16074102663838428317, -383809508728375443], [-96219848171829143728, 233925136855469598], [8912913842155972572, -17153819967170217], [11916978511426217831, -166220188949410836], [199056065778375253898, -246993391382308911], [107003368715343882504, 528429284353809354], [50936683004332980188, -569417881753452690], [-49939447613364742077, 564277325562715002], [373884775965429470666, 77369680560815997], [-24006924094102026210, -277357126175082165], [-204120436953002166055, -665388065701930716], [219015238549860417447, 311149369702422051], [38622126809060717606, -1190640508306058253], [-58381249412976328178, -557923625128069554], [-85114025662329903658, 740099391746880864], [166137249897355115316, 837471003415999686], [-363288764437838828454, -38071262330914011], [-233036850418909706826, 168912114065670603], [85580015262592474625, 1117980382282681212], [-31638153533693729654, 921085688013257205], [-600054815415970478426, -99094929806876256], [310027611727967254620, 233084894821478490], [380307866851436022791, -957182627271728259], [384840321432367813622, 653400421498512594], [-339218974381911176371, -401516087717099070], [-297401930500094814490, -209339156384262537], [-493615761539457959727, -450489967806371709], [156544235776604652663, 309118848279198135], [162504161270003489853, -1060201787712447243], [-595605061250127052360, -163118998053652908], [532721965919277164240, -294121423196788410], [82785374938607057185, 23469495668866320], [312899996940775673672, 1663263339483789264], [-337684656893255100112, -266391816874946382], [405629273437458742840, 329900348195755818], [245517286788032139588, 1031360082881218704], [-255500008577482502770, 699188636943406650], [-403977202670628252030, -1241427677157369672], [14904956755762345136, -1336583329387310856], [235555670338942089800, 478795206450315825], [443597697069755435023, -1391701301290206735], [-23783996924938994446, 1573025786622869562], [-164397001635368523264, -294423145380470175], [723946449383494372032, -1082341762436352162], [166903371461446498126, -1675762581686376084], [-657079068863223291040, -370553644770733413], [-295188492056122619871, 2687040957618498552], [-1064613202588777538852, 689608646065273461], [-532829016555572969216, -737456724255047670], [13208496646291395506, -2184286543276808613], [-418234978140871465248, -513274538339085843], [-158728062591172493404, 1924637214489612855], [621638512316794466922, 858605336476958286], [-7492853344539560988, -1230781812711695958], [173233775545005880515, 187389628476206712], [-123530959759330427163, -3027128485409461932], [-877031095824073014374, -600492891027107724], [-384002379711350055514, 766425119949338706], [-494388580590113290179, -2240038793517359046], [-230259669157381691515, -4552620849617671575], [454099321776611469030, -989642301127317018], [-149792342320426920922, -1762086171495058611], [-105748065980855704434, 297742012113339057], [-1289856846341044327983, -702364837189541115], [1600075560675679322193, 244154215488320835], [-1229509514818987472386, 2560298439123981342], [1120112568255807379802, -192937494268935999], [-1087682388291416995810, 2081542113672373203], [862696255200999206306, -3670017183129223713], [-206244363882803036841, -659543775849168153], [-1555748482935582477930, -1246054878979677945], [143269304797817227082, -510085425698663214], [237760504525036721352, 4222303825908537810], [1544912883088703547867, 2697054260184588705], [428578420313485615146, 2251959802713846504], [-1444676043961059637520, -83247550224983787], [1400412247199715385467, 4831604032875927657], [-169340218718666605884, 2396193818208346965], [-2090359600514436345195, -495683527337413500], [-333006625781019491272, 1799067294233598786], [-293522479556025790556, -3139980555133870452], [252851532206246818424, 934562766641262399], [-223356741024870982728, 168455439347263083], [3652855902567600837558, 1403162152565918037], [532319537225709148591, 844726428175811349], [-2010003930455248431537, 7302602472274921488], [1626611854966049025728, -4694083683234315693], [-514310386334456174158, -2296172351471997516], [717378742706159526048, 10673350000271004411], [-1511959238654530460934, 474525555969031179], [1175686021158410197296, -8348041022002188954], [-1916134532576212136364, 8564847995943963000], [-1289062297175653531971, 3830501314531002891], [-1763420841598491500525, -8027451613408064010], [1725714261299289148701, 2582903583490262913], [-4639043997280937484739, 1158231972392971344], [2896189806462218101896, 298094808145347546], [-2119166151473876546814, 1057105732255762173], [-622165705991686878892, -5449205254469215110], [190609223662224160046, 5976063415058920404], [4931705745542980663198, 2192747726496532824], [-331917675926453174701, 6151810673018096667], [-303993559661597734608, 6836496805303492608], [1797617223820895624608, -913764672853678425], [3084429960300141035801, 1909990468388335701], [-1154360569903500469902, 534601698616072140], [779473701599714286182, -7995087742131595638], [4887174289827354304194, 64405534400914317], [387586141768806300198, -373280813077004553], [4699741581074726144297, 7495306808627918208], [2749925266494950849768, 5793965915134834635], [-2002828299158123042985, -1040691104469130401], [-3638453458438540925094, -1601036769000314562], [-341248400218711353661, 14286214332055680360], [-3313212072610358116215, 7309106061393672357], [7482424351684073694505, -316533639510026589], [4103122907928967068842, 4052747438162604159], [-6151667762017720598004, 7958348100353307468], [4151381135296647883662, -239408086652353836], [4761349988584823973834, -8885507530269904686], [1586810947828212645208, -3442114287627199731], [-2703580850355992052612, 10906420778119538622], [-3300384368433373540580, -3709245008542286574], [-7338011417375138231493, 8520143871609388377], [3023757887344843562301, 11962972323316113654], [1715767647441372005004, -483506048160525972], [2417992345833926725363, 23682320541808675698], [-8721387445459962630556, -1275776844918781251], [10177470125069598985589, -2644549221653039268], [-1824648718155958237297, -18200758640247278700], [3042886238090451164222, -17458190900433914805], [4842900170049024540137, 9703452874430959965], [-3956160077368478803269, 7627914622900172160], [-4833759093093009607450, -16602359851446545118], [-1046871428158824916745, -10554911063029150218], [4426413040012568687425, 7904673459193962501], [95644644535056835274, -5065433580442828929], [-1523986164235857173069, -5367175192532235438], [-6031508613573552911438, -13575970889474161491], [3367343436404845495203, 21872656703113733520], [-2731545954466618600530, -4316930718917739720], [8813764490442884623932, 13133527713030886512], [-2641249780241318108780, -500641653971779839], [6206154960076457560418, -22961143635481252782], [3266979260988818833647, 2928223547159579067], [-1490513820451711381294, -21356618157324232506], [-6306972599351996932146, 13859540533409724006], [7003100244471135096131, 18620472393969028071], [-2670402670882783536186, 28609728861309953124], [1867153481444503621648, 33183376001752210833], [-5137189989168799552275, 1141306749645850899], [-1741703107854212641428, -10713052753501751667], [-1414770011364208420959, 21234291072652573401], [-8115915146567407760499, 19736833032712731348], [4908003585022618077922, 4940503239129214995], [-15485648951578662277018, -13344090554912444292], [-3737982081328760539530, -28392223960946430963], [-6068650666743241249641, 45399064076317386537], [-7883074707116159420756, -42559057329092756814], [-5711678446892739252216, 348261235909663305], [-2178958204585874109998, -51076598146011357855], [-236510639800368522382, 21754126189847755830], [-2398188438891321658879, -5148984054161446962], [-8452376869525626659568, 41262227476442720058], [6496488758900134706576, -26069911361652688737], [3836085357394219596574, -33402353567836366824], [10691727645012242396574, -31631222170905755046], [18834309282454088340868, 8813843763670940931], [-8355375478316174555358, -6267621540387814998], [-759485185263696212773, 52011880556011203198], [-22131947556003835314836, -3631779609055715511], [-13162796182667775157648, -41488111742370745257], [25633073084522621807160, -2329535413773101400], [8550643314046139219661, 2012874001104684765], [-19578785766004658487396, -23398218360682378074], [23391631665664395656349, -15637195535791095738], [-2503163121982143823222, 51160187446557068319], [828839643148083444413, -6628584733241236611], [-7505442830389061190619, 26209998470251718136], [19952904312667739688651, 41135917050569177790], [-29884792599737086397625, -17175843269639212311], [4580767603248176979785, -1133012164312355757], [1266960003646822483977, -39845201367884502609], [-3595691980989275879726, -7994140705482979689], [-12546138620320218719440, 8573339684803979265], [20345687018815628648290, 35245109664793262406], [-18954339042585597959104, 22121970446765349798], [297337730526976986270, 300773315016165588], [-279167409765204165908, -79560973532292234801], [8989121222715902112249, -29848891256814360012], [-25763368827024626781760, -30503745747076716792], [-2288464097045801184390, 9095765239614561174], [15393147887396289965784, 48550186987931932770], [24520664465029952328652, 5219410850776549587], [25037729746275543975150, 41987714891267157900], [-10746757525443328204106, -3241071440243419029], [-2797782298288285527428, 47298694228390917720], [-10945001940084027315559, 56505637295819035815], [32222927876542424720654, -33278419167761481666], [34274605166209926388696, 41033768736476522505], [30381507238850821070108, -50612615215030542924], [-5038953523251512954004, 60673643255106486591], [-24264711152467335088932, -71695073250486914499], [29034305115089997075757, -13111422791268786774], [8722162045871184323148, -27795587961475610418], [28989686564250301859185, -2724555938199887493], [-10297936000909076912722, 95221027137159587340], [-12097844747563405845778, -31725364004716239300], [-11592028155739767217309, -98276200490202187854], [-1971642662527225649708, 97581032721496708314], [-2306731182947758378596, 19623062018094795822], [-6141268304791284796824, -56739084732251008473], [28298150874986455835562, 39847895126169015984], [5607386624320965611743, -89773466068399865934], [36610393160491360806553, -23378620466579259909], [32487841139512446248340, 6384372978110127981], [-25535145048554463616315, -29968591394295592101], [-20087156374629426800000, -38010895670840682600]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_22_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_22_14_a_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_22_14_a_c(:prec:=2)
    chi := MakeCharacter_22_a();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 14));
    S := BaseChange(S, Kf);
    maxprec := NextPrime(2999) - 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_22_14_a_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_22_14_a_c( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_22_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,14,sign)));
    Vf := Kernel([<3,R![31293, 926, 1]>],Snew);
    return Vf;
end function;