
// Make newform 11.14.a.a in Magma, downloaded from the LMFDB on 23 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_11_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_11_14_a_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_11_14_a_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 := [900864, 251749, 1520, -1179, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0, 0], [-1, 4, 0, 0, 0], [177344, 64812, -2689, -75, 3], [-358598, -21128, 1531, 25, -1], [155670, 1264, -1830, 6, 2]];
    Rf_basisdens := [1, 1, 119, 119, 21];
    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_11_a();"
function MakeCharacter_11_a()
    N := 11;
    order := 1;
    char_gens := [2];
    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_11_a_Hecke(Kf)
    return MakeCharacter_11_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 := [[-13, -1, 0, 0, 0], [96, -2, 0, -1, 0], [-81, 87, -7, 18, -1], [-62469, 1827, 51, 89, -37], [-1771561, 0, 0, 0, 0], [-7275597, -32771, 1901, 4871, 2013], [-61838523, -88969, 2443, 3455, -9141], [-29288843, 704109, -4999, -13219, 29093], [135502910, -89460, -32818, 229433, 78716], [471949278, -9323492, 935936, -263730, -141728], [-20180182, -14930296, -438742, 506365, -797404], [-6594950987, -54085055, 1549503, -8232762, -742511], [-14072079313, -89770475, 399269, -1326337, 274261], [-10927742698, -157351090, -10282262, -8246624, 1692394], [-8967147870, 264323866, -1919422, 40791586, -522786], [48810769800, 1203085818, -1456294, -72424754, 10828078], [-76887475122, 348366096, -27508498, 4587755, -32032506], [-159388427858, -1361950092, 4607568, 151624834, 20078080], [-200057378590, 5250930188, -77247086, -106571997, 100583582], [-283557130888, 8450828306, 49132688, -432506863, -25461162], [-823082363681, -3403815731, -46948715, 267401139, -212081995], [-740065878162, -32331398590, 54267806, 523973372, 3574274], [541648434916, -7229623268, 514585824, 1209528446, -82330688], [1602581932971, 48593491439, -529909307, -805266180, -394621579], [-2699048371177, 47722472983, -337551519, 406160822, 283632753], [-3971482996283, -100203496237, -908413753, 2850212547, -48888389], [-5049273554, 4652230646, 300988190, 4411919126, -250100730], [3294471332671, -43995619901, 28370995, -8766248567, -1516441665], [-5857577091242, 83974803824, 3404979576, -7001763804, -2044644492], [9440368029597, -23524959875, 3674108543, -3963999804, 1292589859], [7422549142959, 925875043, 3423516527, 1660323183, -4403919949], [-13250273891295, -530561903747, 2342040973, -1171607561, 3663415745], [-954885119675, -238830804723, 9905427407, -18955675564, 6364368691], [-78585840701809, 62476837571, -5642133053, -5938095055, 98351799], [85543924909839, 606380020381, 12772806561, 22094995833, 3675858725], [-69658012582892, -134774822320, 37279693788, 15274551406, -12319295848], [-54949431445669, 1322057540083, -30022839371, 49491515350, 9474757127], [-142521952511492, -586610065120, 7538912032, -47265536416, 16459277216], [-149215806266479, 3471710311693, 30064329401, 53263615533, -24666547587], [-6418959123854, 1709507101580, -59508906300, -169635536048, 7737496600], [-75590918232992, 1909630580986, 81960836184, -128041279591, -15547709408], [-251764803666697, -2354749906133, -31103694711, 167631650980, 3015514303], [669628277836270, -3457169429552, -29145426610, 325794361243, 29125116988], [340925284097276, -3494878074010, 3396512290, -375766412488, 18150794970], [60591522008078, 3188666355752, -175052590552, -204501244424, 143178786124], [660630552941344, 6006295698856, 66124583144, 70125750424, -25167127348], [91193444008452, -10270441247128, -90326296424, 317705911984, 56299515536], [651902572238952, -10640711583674, -239540684712, -120243455585, 122170770194], [84105085765835, -1419020640473, 95076203543, -626616415275, 76436328459], [-676758856269709, 7409475524999, -203774166571, -1201109930448, -107546338485], [-2046251032320902, -10831161170564, 301765846696, 143448812194, -84161607552], [-132956833256924, 10847449955592, 53860487364, 2052159822030, 142890132328], [-260991671677570, 20899506573960, -37773421196, 953224150918, -66198696564], [684229602412514, -34488521963292, 110657926186, -2043934071605, -159333637378], [-1617653220410340, -33375796008174, -472764081982, -1554727694754, 211190817134], [872215617306299, -34553579643085, -83071637181, 375407668169, -14430084053], [-2711776942628678, -11748937878020, -324293374348, -2486813842816, 974957268768], [3332855207448045, -8775235202815, 738805073773, -742293534519, 452827401297], [2437691202458884, 48772090186214, -1149772820482, 2737163135806, -462296935166], [-8346866423211416, 4716534192894, -318194187426, 422179128762, 228166966390], [300665145229698, 43267276437286, 560830474190, -8625796637530, -334017567930], [-3222694956635499, -55946522013497, 845251933015, 1572316983589, -410094953305], [12537786760750777, -57737537566239, -1251427614355, 1122700123033, 467165712585], [9754375717177018, 105690389481218, -2239994520270, 1045983953518, -25759354082], [-2598040322630413, 23559083696663, -2414518085923, 8545453396364, -769097259899], [11414257862009439, -15035660307465, 3059860365073, 6570359314270, -1774957925601], [387489926600838, 262328851212676, -2047760810402, -1216264067523, 2980847128798], [-2536830545565703, -251381775376701, -1577060452065, 11644525916535, -3821587512945], [2917421616501075, -342068082541773, -4745238335889, -4505867520073, 2206272335443], [-20361130378532071, 146691436243991, 1946569183107, 369824043035, 3969057268559], [-7918010339031057, 246287429586947, -1292102304799, 9457541344748, -5013774723287], [-2515045855689151, -97271247563011, -6414418273191, 20601989881077, 1237027914525], [2903476032294050, 47831574520016, -3319353998494, 18454061359213, -403782276172], [-1019204783077139, 212667213930915, -553988401953, -15686996168665, 5592337286811], [-24290402558397828, -117623457327622, -2518597010316, -8798098623489, -2252234777596], [-14364953058256720, -44214581618978, 8971808461192, 42572497904291, 2953597447446], [18120020364649693, -525560473082267, 5014090940287, -13749070456328, 11914684035441], [12394225533599460, 556259492550502, 5316644867278, 14810969491590, -8026252320086], [15327694251785872, 363648596284990, 5949834704742, -21943020119826, -5777029627062], [-74780037842458646, 708799317864880, 1374586678368, 31821279673416, -2253070939328], [-59143743207389554, 139230906767066, -7284920729342, -7534581137438, -11480476251222], [-40653626018953612, -282941633764322, 2042702998374, -24519100916834, -12446581457486], [-33593197466939395, 341165889605781, -16740252505891, -52051865350421, 20213631457437], [76134656712687407, -796978468542169, 3243709678969, -7189236078406, -12345702533703], [-92265936845135206, -303318827531702, 27582003302450, -10461328540462, -4510468267822], [-17677684986079926, 622392214000420, 7132114762866, -98800233050273, -1979675016242], [-27304421141845917, -25926590652881, 31560843394141, 117309337892696, -1398667567487], [218883833352540870, 956069449461856, 8883537655476, -37038927441582, 796726954188], [-22447335124266902, -608623083669952, -5792716599316, -75656436009394, -842196611476], [9289930239234476, -1503589537198714, -4968283124636, 13396306421117, 6865114233582], [106705235168960774, 650488686579904, -17999422000562, 8506286608051, -5163985894706], [-16929506136237573, 1311095861581527, -56744101451685, -44035169385833, 26215392760007], [-84418976189448204, 508081146045498, 1108244420084, 153021688468735, -13510835698558], [-155818559019883292, -75952190629976, 72294194054448, 83118978958540, -6255082460224], [15566164072745536, 631060646609268, 23036719987012, -40658484529468, -26739479770124], [-117382561166669170, 520345733216362, 38206162367190, -69700798652132, 37688554088370], [29015784739598303, 1688864689631091, -32141794425023, 26924065222100, 8684503296139], [13596358051727315, -329608991238901, 87524379647037, -102590673177482, -38422279243183], [-70806868362248269, -360924642362069, -136425043719873, -870482606341, 44912780845251], [214584801886323457, -3352042566645861, -80548267946837, 5926605408385, 72538070763851], [-466242120215527718, -598267556030242, 8051327627694, 42163458186802, -64409401465378], [-55734884331555253, 3623564941862449, -151615971910363, 122415847250093, 54268382169481], [207329353183628446, -5385268517183942, 25304451951458, 484875483226946, -108805251458046], [-260091809325819494, -2933968936329300, 104620770227144, -354765503883062, -54778420360864], [-175976264980188600, -1861487032159244, 119274494483572, 39125339269180, 69894581365884], [-301430459368583663, -2082694530939711, 213770357393651, 154766231055464, 19577097533663], [-119452491634066058, 2023277698231842, -264973078959878, 334928337417970, 117137620479286], [688471033410381496, -1315947432327550, -17750649551426, 299547029264428, -57619262832538], [924105764004661324, 1768294091670900, -117533256752044, -379900853387988, -98974668705936], [-591415690269161773, -389686297989235, -89101265701519, 468444739735577, -88039550542871], [581866415910120538, -3900867253195962, 234950867370090, -252457534025892, -66275578059130], [-953620592895839440, -460605988589026, 6564228556378, -268420773039072, 169956737396114], [-10962687194974542, -504545421324752, 17802245373232, 776356215978256, 191276799951116], [-149283944835279572, 10563498334857362, -212737993981996, 529129313920955, 18957504352908], [53140832096380650, 16078465096248240, 17937617307874, -68499483980387, -64697215985204], [-505218231975543003, 16198152610057457, 33584186331151, 455590045358694, -166417080036229], [-69542626549334072, -21071946469799982, 154310513938008, -530446439220795, 5940625966604], [322951565663984902, -15892801392675792, -49423452738162, -527211636465557, 148253273287644], [287530993786521047, -2474661805335029, 257839961522505, 374460705802228, 64015538649315], [1202799581371224730, 80018827108186, 292910016455670, 615062669110756, -61481521980274], [-1280201068846245527, -18214496239156703, -24299670872525, 63233485456632, -10582598895583], [1493881651651142694, 21293678232374108, -246208328404124, 444387928086984, -76324162119612], [-1097536280335887825, -8511140024998339, -8186871090335, 69733497537129, -199361287623355], [108609409549957066, -21107285449138794, 113749402925414, 620842143960602, -483476724168218], [591461033523407944, 31408371804813258, 428054212975752, 103022189176377, -78701527832524], [-1264593594075576619, -11129628743828469, -368160456738353, -91418442938445, 70904615570259], [1380751288417963563, -6645314409009873, -35167179222483, 1406973948686496, -262464645539405], [3103397151065287640, -16378398170949810, -283536464515368, -618107965269021, 268026785401298], [-767944153053113064, 41944585578447166, -130950918664832, -1178606820979777, 718892718140234], [-2245711567247468770, -37744766020814460, 144320294339616, -557995961341166, 383836778403008], [159743591015683688, 29322662011898656, -206993876960540, 206739816854506, 186688126589756], [406666360093108576, -6571473829586208, -545109728283224, 427936033007764, -220843192838312], [-751141746616767388, -19164980687029146, 227585843865468, 2223974599969385, 169481291575486], [-336355348335293014, 63893360467221572, 111295788261964, 1222868075427456, 70130889699032], [568596423163713037, -36220218521705357, 65120679048611, 2422545013803705, 248013094735307], [315136289593157291, -10342130628362623, -470100176541879, -2939520012693521, -611271771503679], [-315926700112804114, -52691393460024416, -1190485671320344, -1697788340426028, 39280412774328], [-1434218511535996494, -42653979726820074, 392835856327638, -355608202900942, -167939461547506], [-2016465577288549755, 44430117110077581, 646806938533823, 385770526211756, -529033859457951], [3674345974951392415, 36209282552638853, -1285187913314427, 75593240329639, 678968953734445], [-5296778537571986278, -12324443252238254, -544129452256898, -3518926587763020, 36233892857094], [-1892089204227217338, 21225898124510000, -1092418457341760, 4235322333868280, 43920068256060], [-2321925558185315076, 19086152758274802, 680962954540572, 3814167432433279, 173758160028186], [3402737980038628259, -2411020870860173, -1009811299748689, -5998687245326345, -553299880540957], [-413155152998221093, 30578763925917051, -980571790044419, 4880436542597518, -48919658644725], [-3444544882763556028, 33614244171142546, 149390138413188, 2866246890801427, 894815909640378], [-7276495627046410674, -6617354887851288, 1080513451771112, 4966804203050488, 800557739310956], [10114238850294997856, 41881644166670954, 148552075962350, -2209479617384232, 486685537974350], [304358920694871400, -3885654474646862, -2408092391696144, -8801024957086735, 167911539430932], [7904785858764557400, -6886792225176936, 766293536615128, -7240232871975832, 116102331899564], [1945321349537923937, 113223738295292291, -91434414690421, -623637623312091, 695012883112227], [4053323520445385537, -46118900283026559, -2819178693309141, -2075472451065836, 1152644053061347], [-1780571964693028982, 19011982501177902, -1888799054328106, 1224162658966590, -368919400881878], [612118818090458226, 13798670499820710, -2210113528290854, -9896997788757084, -455540483173802], [-5575477435859912076, -84031419178469600, 433862303408272, 3646159253979896, -36775906454464], [1091373994872029102, -135487067605644114, 284654377788926, 4613602415928418, 1588008296008890], [-9511163778285448810, 39587447754958074, -1892186524768386, -4063878171107128, 2617930974366730], [-2689848292265611484, 42543669447344450, 2042710857241786, 7818879117692322, -1896772640645466], [11468566974713245015, 33406618582863725, 2017351392874173, 4687830693927847, 521593246243949], [-19050580385447506224, 33080373028740322, -2040899349249166, 2220800522845950, 310233132170038], [-1030393575857909392, 48452946911080466, -29616108847432, -733502637418603, -2689528733606616], [14503068813758242209, 58186231468528803, 1525817816223743, 5947496991907287, 2154520362680759], [9448721919155389142, -39565437001049530, 2696596866579310, 18745262328830534, -881620026292170], [14428675584215643190, -23300923865390284, 4329100737088862, 9070477700567445, 1709144707654054], [8643053303531558929, -40479675336377055, 5642899042485947, -11996338779958964, -1346810393329789], [-5083149323176970172, -17063606889704070, 2826910951226612, -11329922305984481, 2901674318820706], [1453044308219916736, 148962329815684912, 6891516604590704, 5381307843760880, -1660615792045892], [2700772549566280479, -158409843877871315, -1920494851317551, 1896847280587129, -1074725784117363]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_11_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_11_14_a_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_11_14_a_a(:prec:=5)
    chi := MakeCharacter_11_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(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_11_14_a_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_11_14_a_a( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_11_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,14,sign)));
    Vf := Kernel([<2,R![-195385344, 54095104, -755648, -17232, 64, 1]>],Snew);
    return Vf;
end function;