
// Make newform 5.11.c.a in Magma, downloaded from the LMFDB on 25 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_5_c();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_5_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_5_11_c_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_5_11_c_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 := [31360000, 0, 43159076, 0, 456089, 0, 1334, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0, 0, 0, 0, 0], [0, -39423876, 0, -450489, 0, -1334, 0, -1], [-113422400, -127280596, -7002590, -963064, -37625, -1789, -35, -1], [113422400, -127280596, 7002590, -963064, 37625, -1789, 35, -1], [-756212800, -839661812, -56022904, -5122865, -235900, -9218, -196, -5], [-756212800, 839661812, -56022904, 5122865, -235900, 9218, -196, 5], [-65776900, 0, -719464, 0, -1585, 0, -1, 0], [0, -1229515316, 0, -12978341, 0, -38414, 0, -29]];
    Rf_basisdens := [1, 33454400, 12545400, 12545400, 10036320, 10036320, 35844, 573504];
    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_5_c();"
function MakeCharacter_5_c()
    N := 5;
    order := 4;
    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;

// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_5_c_Hecke();"
function MakeCharacter_5_c_Hecke(Kf)
    N := 5;
    order := 4;
    char_gens := [2];
    char_values := [[0, 1, 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 := 11;
    raw_aps := [[4, 4, 0, -1, 0, 0, 0, 0], [8, -8, 1, 0, -1, 0, 0, 0], [-675, 995, -10, 15, 0, 5, -1, -2], [-1785, -1785, 0, -157, 0, 47, -5, 5], [-28158, 0, 2195, -2195, 65, 65, -50, 0], [53496, -53496, -3326, 0, -550, 0, -95, -95], [129477, 129477, 0, 2866, 0, 1946, -670, 670], [0, 1555002, -30546, -30546, 2958, -2958, 0, 666], [3106519, -3106519, 71257, 0, 13971, 0, -3225, -3225], [0, 3626498, 232696, 232696, 8492, -8492, 0, 4294], [-43678, 0, -85515, 85515, 66495, 66495, 10650, 0], [11681656, 11681656, 0, -683868, 0, 65304, 36195, -36195], [13628922, 0, -1644265, 1644265, -62755, -62755, -3050, 0], [-32009710, 32009710, 3102473, 0, -185537, 0, 76850, 76850], [-83991827, -83991827, 0, 1108775, 0, 117963, -82275, 82275], [-164812362, 164812362, 1920956, 0, 182384, 0, -209095, -209095], [0, -131940554, 8624342, 8624342, 201934, -201934, 0, 388958], [-393994198, 0, -3134025, 3134025, -945675, -945675, 64350, 0], [614362562, 614362562, 0, -3172169, 0, 2004991, -276070, 276070], [-546489198, 0, 2287925, -2287925, 1502975, 1502975, 497050, 0], [-88546361, 88546361, 34520352, 0, -4778664, 0, -494490, -494490], [0, -1550075432, -15812464, -15812464, 5171872, -5171872, 0, 1230184], [-1399300588, 1399300588, -63429915, 0, 1652107, 0, 1372000, 1372000], [0, -857631636, -5484672, -5484672, 13020456, -13020456, 0, -4174908], [3118474113, 3118474113, 0, -111519040, 0, -18230032, 874960, -874960], [-4403122518, 0, 69006890, -69006890, 38111630, 38111630, -6045500, 0], [-2890480677, 2890480677, 133370641, 0, 22462379, 0, -838205, -838205], [2340878520, 2340878520, 0, 212146663, 0, -11981593, 257840, -257840], [0, 925905546, 18563517, 18563517, -27780741, 27780741, 0, -991752], [7036159501, -7036159501, 12046654, 0, -23318790, 0, 1171530, 1171530], [15085634689, 15085634689, 0, -451166661, 0, 18516495, 7099245, -7099245], [10898328642, 0, 148274495, -148274495, -40293835, -40293835, 445750, 0], [-23297384429, -23297384429, 0, -500351008, 0, -70112616, -8702190, 8702190], [0, 5683096814, 333997078, 333997078, 64575806, -64575806, 0, -48591418], [0, -18325439330, -565609885, -565609885, -28701995, 28701995, 0, 48413120], [-13099349518, 0, -399965235, 399965235, -67274745, -67274745, -54295350, 0], [-10858210210, -10858210210, 0, 1370322718, 0, -232445678, 10287935, -10287935], [-21612803504, 21612803504, -1195820751, 0, -384985425, 0, -15021960, -15021960], [-74664446713, -74664446713, 0, -1863948969, 0, 209994691, 14266615, -14266615], [128352436184, -128352436184, 164525772, 0, -114912824, 0, 13083115, 13083115], [0, 50015761338, 1257382626, 1257382626, -134059398, 134059398, 0, 105932514], [1947538202, 0, 3599483700, -3599483700, -117032100, -117032100, 59649000, 0], [92783702082, 0, -862052635, 862052635, 250521455, 250521455, -127648550, 0], [2124714945, -2124714945, -2488755122, 0, -209470102, 0, -111767330, -111767330], [-92657376072, -92657376072, 0, -565951580, 0, -1141256152, 98616275, -98616275], [0, -27450524340, -5556979980, -5556979980, -478429260, 478429260, 0, 32353260], [88009427282, 0, 768053115, -768053115, 957183705, 957183705, 123930750, 0], [-296861628391, 296861628391, 6190958597, 0, -754496849, 0, 78751685, 78751685], [-254333003006, -254333003006, 0, 3959622659, 0, 532241355, 230484990, -230484990], [0, -24569558602, 2361377896, 2361377896, 850462292, -850462292, 0, -337338046], [159008100567, -159008100567, 14046590990, 0, 1099193042, 0, -143115580, -143115580], [0, -257587365416, 4833621668, 4833621668, -273898964, 273898964, 0, 194156912], [-150518906998, 0, -4516200825, 4516200825, -965080275, -965080275, 442293750, 0], [210816389202, 0, -10221873025, 10221873025, 2226094325, 2226094325, 586434550, 0], [302565140825, 302565140825, 0, 23994798258, 0, -1834276358, 115998790, -115998790], [-499114262149, 499114262149, -12993810171, 0, 965784535, 0, -946744985, -946744985], [0, 251373928362, 1464231099, 1464231099, -3967324827, 3967324827, 0, 893701716], [-937102820878, 0, -7020295815, 7020295815, 576646395, 576646395, -1394806350, 0], [329391549684, 329391549684, 0, 18512158094, 0, -1397734390, -712293275, 712293275], [-577180105878, 0, 21831392135, -21831392135, -706989955, -706989955, -29087450, 0], [-701801298618, 701801298618, 33812180605, 0, 1187899547, 0, 237255370, 237255370], [184980536770, -184980536770, -32520142622, 0, -774768702, 0, 397273035, 397273035], [-662827917770, -662827917770, 0, 74376053703, 0, 831327, 1291771230, -1291771230], [558198572322, 0, 36255371585, -36255371585, -1076253805, -1076253805, -796610750, 0], [1189509893771, -1189509893771, 1082844974, 0, -1748636750, 0, 1178201000, 1178201000], [891502062142, 891502062142, 0, -33713066674, 0, -1130476974, 208261215, -208261215], [1491584530562, 0, -18875615445, 18875615445, -1329061815, -1329061815, 2625325950, 0], [288474211541, 288474211541, 0, -37483951328, 0, 9761723824, -87350380, 87350380], [793149987428, 793149987428, 0, -92701708005, 0, 11552875723, 167132440, -167132440], [0, 4405218497650, 21941009000, 21941009000, -2665169300, 2665169300, 0, 677783830], [2305272714713, -2305272714713, -89919202944, 0, -24961145216, 0, -1411805000, -1411805000], [0, 313019132556, 19354217712, 19354217712, 16315816824, -16315816824, 0, 2227401348], [-5331801695163, -5331801695163, 0, 22770022331, 0, -1515938209, -2987189615, 2987189615], [3725391329454, -3725391329454, 86381576092, 0, -9274122784, 0, -950978015, -950978015], [0, -4914084232122, -112319687694, -112319687694, 10853840562, -10853840562, 0, 1018121574], [-3406801105343, 3406801105343, 88291512805, 0, 2497748847, 0, 1981863885, 1981863885], [0, -847542990586, 66990458653, 66990458653, -16549804669, 16549804669, 0, -6073362068], [-118442915822, -118442915822, 0, 96339046020, 0, -35273569152, 4945984845, -4945984845], [-6031107865758, 0, 43400406320, -43400406320, 24938823440, 24938823440, -151484000, 0], [0, 9540362018996, -155199888233, -155199888233, -9372130891, 9372130891, 0, 158379338], [0, -6386951853038, 208542786974, 208542786974, -4351268402, 4351268402, 0, -460900414], [7874839081322, 0, 72412457535, -72412457535, -21915817155, -21915817155, 3959341950, 0], [-8556465749358, 0, -11260882255, 11260882255, -30483321085, -30483321085, 9619293250, 0], [3915929469517, -3915929469517, -95805738960, 0, -9415349808, 0, -2514230100, -2514230100], [0, -1771005388796, -290690130592, -290690130592, 1416117016, -1416117016, 0, -9196072628], [-4055840026450, 4055840026450, -46889494467, 0, -908776517, 0, -3578993870, -3578993870], [0, 5435942260440, -89143163895, -89143163895, 38372616435, -38372616435, 0, 13540677210], [3673687356315, 3673687356315, 0, 366722925218, 0, 75826257122, -1618777160, 1618777160], [-18845775630918, 0, -79136795110, 79136795110, -25747902370, -25747902370, -4239297500, 0], [-4428093850659, 4428093850659, 401923613569, 0, -15080243485, 0, -6664438475, -6664438475], [3576532694502, 3576532694502, 0, 315558519691, 0, -3816689629, -3702950950, 3702950950], [0, -10122645738112, -136131383924, -136131383924, -8805063148, 8805063148, 0, -17332970696], [7037884280671, 7037884280671, 0, -177344556933, 0, -7381486041, 12588120795, -12588120795], [17140680523362, 0, 1645131155, -1645131155, 9086212385, 9086212385, -3955447250, 0], [0, -5232832731190, 64496373670, 64496373670, 21678122390, -21678122390, 0, -4433134150], [-1837952292897, 1837952292897, 421146635921, 0, 61053530939, 0, 10038961415, 10038961415], [0, 13142045071906, 314206144712, 314206144712, -52916069876, 52916069876, 0, 17046449318], [17997830187522, 0, 402707996510, -402707996510, 41271480170, 41271480170, -16568186900, 0], [-20110065923006, 20110065923006, 193315260357, 0, 37170111171, 0, -19022020050, -19022020050], [26778636513242, 0, -329693556630, 329693556630, -58757004210, -58757004210, -5982925500, 0], [-12298894897902, -12298894897902, 0, -305740912525, 0, -55218050437, -35729430050, 35729430050], [-5464613728590, -5464613728590, 0, -874567630652, 0, -68898072688, -2998001635, 2998001635], [28572024961876, -28572024961876, -1056401752871, 0, 112644373335, 0, -13656338940, -13656338940], [0, 41107212496052, -367618052471, -367618052471, 62538477083, -62538477083, 0, 20826399406], [-18771492517438, 0, -302121858645, 302121858645, -1156672215, -1156672215, -61498428450, 0], [13658916394489, 13658916394489, 0, -592104669486, 0, 117515246970, 19497871590, -19497871590], [-10878635599304, -10878635599304, 0, 395870319467, 0, 187844657259, -13696370820, 13696370820], [6206921696925, -6206921696925, 146632818608, 0, -152429159392, 0, -40168682260, -40168682260], [0, 55719783657700, 621631708100, 621631708100, 71362582900, -71362582900, 0, 6487018580], [20549196803402, 0, -208231666425, 208231666425, -4388429475, -4388429475, 82122990150, 0], [-27855452594815, -27855452594815, 0, 712678449223, 0, 206385388987, -15660975055, 15660975055], [-23558244316934, 23558244316934, 787612556994, 0, -115061576910, 0, 31114930035, 31114930035], [-50577268312933, -50577268312933, 0, 659944833426, 0, -11786937374, 20136836920, -20136836920], [0, 4469382252382, -1560729256186, -1560729256186, 114541907278, -114541907278, 0, 13885029046], [-30134870418718, 0, 154971857265, -154971857265, -58610521245, -58610521245, 27119326050, 0], [42238410215082, 0, -1248304311385, 1248304311385, 96007192205, 96007192205, -85914802250, 0], [-21209255202720, 21209255202720, -243095859587, 0, 107930433443, 0, 10852960420, 10852960420], [12182352672663, 12182352672663, 0, 856019869435, 0, -65177680057, 34931111315, -34931111315], [10976597384728, -10976597384728, -1451203216004, 0, 113853329064, 0, 10009732875, 10009732875], [0, 138917241863066, 486262140382, 486262140382, -25801285186, 25801285186, 0, 16279771738], [41234901897722, 0, 2631033968535, -2631033968535, 65515105845, 65515105845, 40811164350, 0], [-17129596549231, 17129596549231, -121406071168, 0, -18359305904, 0, 20888380160, 20888380160], [-2114005033376, -2114005033376, 0, 78356771204, 0, -606935072760, -14934534405, 14934534405], [65840661644562, -65840661644562, 2193852615785, 0, -412728458593, 0, -47890683310, -47890683310], [-31424969765518, 0, 415994601315, -415994601315, 104715573105, 104715573105, -104596175250, 0], [-95285112039078, 0, -2781902786065, 2781902786065, -32758218355, -32758218355, -14161590050, 0], [0, -11239443897194, -151504524088, -151504524088, -390532330076, 390532330076, 0, 107707352578], [0, 172988202369192, -1082129720316, -1082129720316, 160327604268, -160327604268, 0, -96867952224], [55494276462099, 55494276462099, 0, -988286392621, 0, -575117075185, -25646124425, 25646124425], [-52039326389028, 52039326389028, 216665073820, 0, -589569046648, 0, 100542472255, 100542472255], [0, -23032242200286, 1564103320578, 1564103320578, 680206114506, -680206114506, 0, -147602195238], [77751458980195, -77751458980195, 1476698564653, 0, -658258516977, 0, 26340366615, 26340366615], [-26560313270878, 0, 2382533337285, -2382533337285, 501894742095, 501894742095, -176922666150, 0], [-80943819508580, -80943819508580, 0, 2395652051838, 0, 497685569082, 74868119805, -74868119805], [-12460129971918, 0, 4131962779640, -4131962779640, -141619876120, -141619876120, -1195278800, 0], [0, -171143130703888, 3205233983224, 3205233983224, 74451341048, -74451341048, 0, -70459276384], [-139338182627166, 139338182627166, 1495523826722, 0, -244986721774, 0, -80961057445, -80961057445], [6077731611566, 6077731611566, 0, -2255755088753, 0, 725124940999, -41211117010, 41211117010], [151865820851558, 151865820851558, 0, -2697434328210, 0, 454065151858, -156702021305, 156702021305], [0, 98886405601956, -6757485377088, -6757485377088, -545500148376, 545500148376, 0, 10754248908], [-99090654113038, 0, -568036058145, 568036058145, -150398804715, -150398804715, 155805492150, 0], [-33599167678518, 0, -2122407082585, 2122407082585, -645035149195, -645035149195, 84454526350, 0], [48376419707679, -48376419707679, 6848782933417, 0, 248367392291, 0, -129149622785, -129149622785], [152454390118764, 152454390118764, 0, 6235321965739, 0, -740587337605, -15169362160, 15169362160], [0, 86422927880898, 4585817566971, 4585817566971, -521155905483, 521155905483, 0, -99865942116], [0, 33249457695404, -3552688888892, -3552688888892, -448909460284, 448909460284, 0, 247013478892], [-104091435273682, 104091435273682, -6919694182414, 0, -116220905006, 0, -59839226665, -59839226665], [73796665804615, 73796665804615, 0, 10643384130368, 0, -186148329528, -75605371770, 75605371770], [0, -127938998306074, 8050291613302, 8050291613302, -437762156146, 437762156146, 0, 20663095598], [288059988149841, -288059988149841, -2845526092231, 0, 499604163515, 0, 138913475585, 138913475585], [-326931850474366, -326931850474366, 0, -4963543466306, 0, 711636507010, -28719523165, 28719523165], [-160843916304678, 0, -128990880265, 128990880265, -796031696755, -796031696755, -91768417850, 0], [-52442227041788, 52442227041788, -311959438215, 0, -237397310793, 0, -58607004780, -58607004780], [-132303843763909, -132303843763909, 0, -12072720476853, 0, 1325257605799, 40087042375, -40087042375], [56727065471760, 56727065471760, 0, 9988844696423, 0, -1045419533113, 225584701000, -225584701000], [-2027463575358, 0, -11295217562155, 11295217562155, 526651139615, 526651139615, -418846274150, 0], [0, -2668551710748, -7381833576996, -7381833576996, 714705846108, -714705846108, 0, 152899476036], [0, 598267168882328, -1169282202569, -1169282202569, -714726370963, 714726370963, 0, -259264917386], [145964859994171, 145964859994171, 0, -8158395848958, 0, 1064241726834, -468780071160, 468780071160], [-365413773928758, 0, -6988798982380, 6988798982380, 1134262556540, 1134262556540, 194771679400, 0], [-5595849847082, -5595849847082, 0, 1484401225655, 0, -44105565297, 119070754830, -119070754830], [436283393120283, -436283393120283, -14444605191874, 0, 2952796116674, 0, 3063120680, 3063120680], [-367197390775153, -367197390775153, 0, 8351532006271, 0, 856431732811, 125350106615, -125350106615], [-359582664751758, 0, 6425117319095, -6425117319095, -995067137635, -995067137635, -71872473050, 0], [547515158135549, 547515158135549, 0, -13414580931696, 0, -331291990160, 133825265500, -133825265500], [100510613476127, -100510613476127, 1742192724525, 0, 576729476287, 0, -322784810285, -322784810285], [-41100658915918, 0, 14066844149865, -14066844149865, -866585553045, -866585553045, 710347993650, 0], [525339504223488, 525339504223488, 0, 8754880570910, 0, -1710552995782, 148770559825, -148770559825]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_5_c_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_5_11_c_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_5_11_c_a(:prec:=8)
    chi := MakeCharacter_5_c();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 11));
    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_5_11_c_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_5_11_c_a( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_5_c();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,11,sign)));
    Vf := Kernel([],Snew);
    return Vf;
end function;