
// Make newform 200.6.a.k in Magma, downloaded from the LMFDB on 19 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_200_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_200_6_a_k();".
// 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_200_6_a_k();".
// 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 := [-3, 33, -20, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0], [-29, 40, 0, -2], [-141, -240, 40, 22], [-516, 120, 40, -8]];
    Rf_basisdens := [1, 1, 3, 3];
    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_200_a();"
function MakeCharacter_200_a()
    N := 200;
    order := 1;
    char_gens := [151, 101, 177];
    v := [1, 1, 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_200_a_Hecke(Kf)
    return MakeCharacter_200_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 := 6;
    raw_aps := [[0, 0, 0, 0], [1, 1, 0, 0], [0, 0, 0, 0], [37, 1, 0, -1], [-92, 18, 2, 0], [110, 0, -2, 3], [-168, -44, 4, 2], [-172, 46, -2, 8], [1123, 23, 8, -5], [-734, -12, 20, 0], [528, 84, -12, -24], [2198, -428, 2, 17], [2950, -491, -3, 2], [12069, 189, 0, 54], [3681, 485, 56, 19], [21074, 64, 34, 53], [-11460, -598, 26, 88], [15482, -683, 61, -82], [18175, -73, -32, -26], [-15704, 1560, -232, 24], [33268, -1212, 80, 48], [-5408, 196, 100, -328], [18665, -1679, 352, -166], [5238, -564, 300, 96], [14864, 1860, 172, -402], [84006, 676, -188, 416], [-15509, -1041, -328, 435], [23195, -2581, -640, -428], [67494, -3057, -441, -270], [-40424, -3888, -312, -444], [-83655, -3427, 704, 481], [-103716, -9086, -590, -1144], [-121876, -5688, -444, 1578], [-106724, -6018, 270, -576], [-22914, -9361, 935, 1114], [-136760, -844, -748, 1408], [111466, 1708, -1506, -1657], [-49583, 5041, -1392, -1564], [-63819, 14561, -88, -863], [-205122, 17812, 298, 437], [-156668, 538, -438, -784], [8854, 4188, 1212, 480], [47712, 9784, 1528, -2128], [34528, -15388, -164, 358], [-167994, 312, 2238, -501], [278296, -9768, -936, 648], [-81908, -18870, -966, 4008], [421239, -24541, 1952, -245], [23695, -5233, -16, -1196], [-359526, -19892, 2860, 1664], [472452, 4164, -288, -648], [523648, 2068, -1740, 3800], [-354946, -28319, -2135, -838], [-31468, -25678, 2082, 4432], [-142080, 28688, 3344, -560], [454683, -27329, 1168, 4877], [89814, -24749, -5717, 770], [1080704, 27828, -300, -456], [856254, 23588, -1318, 2845], [-972474, -28023, 6417, -1134], [1155165, -23011, -6736, -1196], [139498, 23140, -3386, 7955], [868391, 23183, 4608, -1718], [793896, -12892, 3716, 9376], [349900, 66264, 7316, -3342], [-245862, -36088, -4126, -1883], [868948, 21494, -6394, -6824], [902968, 9720, 2720, 5928], [-1240925, -26725, -7504, 13042], [-739966, 32380, 1756, 5792], [-459408, 109480, -8312, -12940], [1341128, -38828, 4532, 2528], [1861025, 4533, -1808, -4623], [-12238, -57076, -11610, -9965], [-1094740, 134878, -10514, -5392], [-2048313, -15501, -2736, -11025], [812334, 87671, 7919, -11990], [1995090, -42920, 202, -12871], [427394, 41228, -2964, 6880], [679178, -114389, -14525, -1426], [-4364652, 24442, -4310, 8480], [500050, 153505, 4585, 15158], [373472, -42268, -20604, 8344], [-189768, 179908, -11852, 15914], [2710680, 152524, 8812, 12416], [-2035539, -204979, 6848, -10760], [1089234, 94663, 9919, 8822], [2855628, 161600, -8212, 19918], [3066222, -76, -2860, -29408], [2161199, -216549, -3368, 12693], [-1359561, 137079, -5856, 25512], [1750048, 142112, 16672, -18752], [6445621, 29521, -9936, -4909], [-4345964, 216750, -10114, 4584], [-3656860, 277554, -3294, -16128], [2854931, 58455, -8424, -2133], [1395650, -256908, 4756, 36864], [4420010, 139232, 13536, -8480], [4882997, -147515, 272, 16496], [-1404962, -24788, 17932, 45344], [5688751, 82015, 11568, 3920], [-3114750, -92836, -8122, 39787], [4951545, 16953, -11088, 19764], [4986666, 71995, -2093, -13906], [-2741324, 5850, -16758, 1152], [3569248, -237912, 36344, -17460], [1578251, -307901, -2960, -31342], [-458680, -105072, -168, -15852], [-2138776, -221376, 26752, 38376], [4385766, 125057, -26935, -9422], [8145833, 79533, -60584, -6645], [8555978, 158392, -5950, -48787], [1020220, -415500, -17592, -26940], [-3004628, -442526, 21010, -34216], [1681064, -197580, 24468, -17952], [-980850, 207713, -10327, -8630], [-75039, 12073, -32624, 6734], [-3963547, 326513, 16112, -17153], [-4158546, -142952, 6694, 47735], [-6544380, -162686, -19214, -72160], [-976750, -63547, 12077, -27914], [-2388080, -392276, 19332, -20854], [-10750314, -287712, -1338, 17943], [-8833115, 372861, -21648, -25926], [8226828, 272482, -61934, 4088], [-9234742, 24889, 73025, 43646], [-5885414, 176548, 24388, 42272], [-1154656, -651980, -25516, -9832], [1702173, 466489, -34256, -10093], [-9290442, -67204, -10150, -30731], [5283828, -434158, 27266, -45776], [-8132469, 103199, -50800, -60599], [9272432, 45536, 2144, -67184], [2090126, 305948, -39150, -63599], [-1163830, -694852, -26724, 41440], [-6948098, -73824, 2976, -64032], [-8715302, 202464, 4746, 89673], [4101047, -293969, 17792, 94766], [-3756822, 411232, 63322, 26369], [7998774, -862912, 80192, -50144], [5356836, -532934, 64618, 70928], [5565522, 137325, -33003, -522], [6644723, 324039, 14488, -83697], [-8690253, -224485, -41488, -71522], [-8332538, -838997, -65597, -48526], [-6436632, 262452, -51564, -53664], [11417762, -877216, 29298, -43931], [-4509980, -5680, 51572, -35054], [12298396, -254742, -15270, -54696], [15240471, 40083, -30312, 43497], [-11249822, -1086828, 37454, -82905], [-790450, 1028917, 31517, -136966], [826969, 1119353, -130688, 141928], [4636749, 26201, 50672, 119359], [-10057141, 271339, 72944, 137852], [1038816, 1247868, -103716, 33192], [1568424, 1513440, -5088, -75480], [12180850, -368377, 20479, -121802], [17174812, 451404, 37328, -62328], [4883182, 457276, -91236, -143584], [3931047, 543695, -100720, 120838], [16608012, -372768, 73356, -111138], [7528549, 1769345, 83128, 4393], [-5946252, -765650, -35330, -148024], [7507448, 278492, -208420, -33794], [962659, 173591, -31552, -30635], [-15708704, -641856, 57792, 95712], [-2601738, -279040, -155290, 153775], [2278094, 1499968, -202688, 146912], [20922930, -1742872, 44666, 70249], [-10652564, -224626, 34846, 113680], [-8430498, -1275148, -23020, 125344], [-25696392, 234884, 9188, -22448], [-16392364, -465556, -55608, -34436], [-6040336, -1356032, -143744, 848], [34149254, 207744, 37504, -15072], [2023860, 84018, -191070, 24336], [23757286, 589956, 118820, 98304], [1193803, -440241, 109400, 269835], [-8887098, -235449, 63039, -139854], [-3830887, -598915, -183024, -38051], [-7322436, 406394, 45674, -219368], [-45372294, 480504, 71922, 90357], [-10549620, 2379204, 230472, -83484], [7900719, 1525563, -27960, 58929], [38540330, 476956, 67196, 56672], [282250, -2108084, 68862, -28465], [-3254383, -578839, -141024, -323906], [-7285670, 1637651, 110699, -119138], [-29353152, 23024, -104080, -34496], [207808, 133416, -161224, -303228], [10739829, -1143947, -91232, 42296], [3548140, 1884802, -4046, 72056], [-3202998, 1096449, -21687, 219966], [25907343, -1550057, 105808, -65554], [-32134300, 2224668, 69384, -19308], [-7711250, -181491, 93621, -261894], [-300250, -432512, 21782, 1031], [44934560, -26096, 132400, 216896], [-16503653, 1627375, 56248, -37945], [7915794, -1032948, -246804, 121344], [8725360, 789368, -199240, -476000], [-22548962, -154960, 96286, -84581], [-35093234, -26404, 368060, -18560], [-9446164, 2921074, -23134, 9944], [-7462150, -1733740, -98650, -257981], [21711472, -299948, -416012, -209176], [-6319519, 1378553, -211024, -151718], [39556438, -184672, -148832, -110432], [36539956, -3012434, -25730, 138920], [-45952552, 755740, 40124, -173890], [44727234, -1030847, 145033, -78106], [-256765, -2318345, 35168, 125021], [8699971, 2641675, -79904, -346294], [-16813352, -13328, -119760, -533992], [15402982, -1712147, -59243, 158978], [-48098687, 3340741, -71568, -93955], [-59894654, -618148, 26428, -150368], [50757181, -607783, 72824, -217703], [35390006, 1401720, 271566, 54603], [22896674, 3580821, -296067, 352902], [-27238184, 1775628, 92844, 278784], [22843086, 2724084, 16788, -220512], [10535151, -847909, 73760, 354043], [20187895, -2496737, -153488, 216494], [-18667762, -1567357, 150107, -231446], [-13378500, -2774980, -96352, 390808], [-17237744, -3202780, 108868, 55432], [-39544907, -764031, -228184, 220809], [-22651500, -1669602, 307566, -134712], [22986110, -1179944, 56438, 492431], [4399524, 148210, 42466, 387200], [-8724768, -623848, 96728, 531376], [27319126, 1072289, 339433, -168350], [-30809675, -3209779, 409024, -219482], [70423857, -491419, 136784, -69695], [-27211390, -3539081, -288785, -217018], [-32651934, 4528072, -155030, -32695], [-4375940, 896946, -68254, -693528], [54371736, -965676, -69708, 200496], [26503097, 1136289, -10128, 455646], [10635956, -439318, 302618, -116864], [-5171813, 427375, -379872, -548251], [-42485422, -19028, -72308, 488960], [26702376, 512184, 423600, 471144], [-38329768, -2450140, -226428, 220240], [71131433, -400547, 158672, 9377], [17716140, -490090, -595354, -214208], [56928300, 500882, -173374, -34280], [-92099105, -3075653, -152552, -150751], [-60722022, 392472, -425742, 479733], [-9344238, 528500, -523756, 271744], [-23037243, -1774671, 478368, -158373], [35470186, -2902769, -1721, 319166], [68881870, 2141916, 331314, -894903], [-42781356, -4019906, 126862, 264776], [40965590, -6131324, 158500, 387968], [-70278557, 1751419, -160320, 65894], [54996598, 2568436, 92770, 861641], [-35940204, 2059328, -378412, -757814], [16937063, 6442515, -94040, 320961], [22831679, -1922369, -372512, 458504], [16043578, -1822564, 44540, -447008], [-67572458, 2709836, 47050, -227771], [22320624, 4274748, 149748, -360726], [-70998252, 209850, -142998, 111552], [43036594, -1050484, -144020, -194816], [93724186, 5307680, 116512, 380512], [-37563219, -962083, -108208, -115256], [-42434694, -5370980, -110978, -614137], [-105454322, 3681404, 624092, -13952], [12688183, -765129, 71744, 128688], [-11297572, 4374884, 331128, 208924], [11068336, -5702292, -489012, 24504], [7894056, 2185896, -86112, 435672], [-95184397, -2720825, -229552, -132247], [-10130317, 4329779, 362960, -378644], [-13173726, 5022284, -644308, 32896], [164648982, -1649759, 244969, 226178], [-108695780, -1780554, 138758, 555792], [401207, 294755, 147704, 595069], [-33614552, 6543792, -73104, -710328], [121639693, 420137, -835912, -132503], [51108358, -1427324, 288292, 453152], [59244491, 1046131, 264560, -483058], [20471184, 3764432, 292304, -294800], [56651848, 276868, 473124, -316150], [-29725986, -1323872, -660050, -1103341], [138385384, 1474880, 75392, -831416], [-41340382, -4660093, 103515, -706922], [-15248182, -1753187, -174907, 793982], [-77574905, -2929105, 347360, 785122], [75274604, 910988, 536288, 564496], [-132920748, -458266, -568714, 241048], [-68750226, -1115476, 723746, 54409], [44997990, 5810971, -513101, -458734], [-110554912, -4246256, -436592, 460448], [173163090, -2562492, -362706, -249537], [-65277092, 2483970, 122930, 52776], [253630367, -1111889, 99440, 15128], [-32535116, -6238616, 408396, 754406], [-122677006, -7221956, 371350, -437341], [-48677104, -4934232, 664680, 818592], [126443241, -3585327, -796560, -45282], [50353268, -8232814, -721150, -162512], [68292816, 7362636, 188100, 809874], [13876251, -3246805, 239216, -957800], [-71675918, 11774156, -76372, -205856], [211350648, -1639036, -95260, 93520], [117428762, -1478708, 132110, -501289], [30445743, -1400245, 728336, 1129627], [-27644886, 4213996, -101684, 837824], [-81153502, 4489728, -455936, 245856], [96133009, 5490817, 196320, -71740], [-34189259, 2609665, -241160, -1623067], [-52948122, -27572, 603052, 987488], [-66876876, 9634574, -993058, -295160], [202700080, -10346380, 230932, 300520], [132001824, 6956736, -144384, 988008], [-137299982, 7576147, -366933, -262618], [-29906996, -1558214, 1100458, -775480], [75533540, -5248952, -454756, 205262], [-181522118, 4105213, -515547, -482290], [52290711, 4227187, 64120, -1618903], [85292356, 1659600, -1281612, -380886], [-149056450, 6229073, -448999, -108134], [-16731116, 7322370, 502770, 463056], [11335005, -1656899, 251200, 459848], [-165080951, 1632845, -358600, 259171], [-178207510, -7134936, -67182, 334365], [-186266006, -2411979, -464355, 747198], [3838234, -5964636, -196650, 1674531], [90090688, -1010432, 164608, -124768], [-127715519, 5522889, 803616, 465834], [21870324, 2049998, -943714, -434552], [73816195, -5071597, 577904, -860744], [33073078, -7156817, -367385, -50974], [-28222672, -8042824, 1113848, -1309604], [91539798, -9204775, 258785, -260798], [4162113, 7585765, 571624, -132097], [-20716046, -4338572, -176514, -396769], [-206433196, -1186448, 575332, -221230], [210782, -5605645, -1121973, 865114], [106673944, -2688932, -16004, 1209824], [-213496362, 5668612, -211982, 632225], [113437908, -2292470, -710342, -104704], [-12425198, 66513, -797799, -612906], [150747, 3731955, 30384, -924102], [136309680, -9013088, -178400, -356656], [-190367570, 1051080, -901194, -107409], [-35229908, 6172286, 1086350, 527632], [158447116, -3506056, -464588, 852226], [-245862630, 4660233, 896145, 505614], [11777295, -8782261, -1407520, 1119679], [40292042, -13358140, -545692, 175264], [-116070884, -15005724, -328584, -1518036], [91944560, -4025764, 705084, -1715432], [21381460, -57122, 966702, 348488], [-157112728, 2695596, -1194276, -122154], [-103132813, -11702137, -228544, 1028557], [-65716762, -1551536, 1348358, -898945], [-45853446, -9690924, -1484172, 734688], [66042257, 1835765, -1237264, 297253], [-46561908, -2949666, 478446, 110352], [219975631, 138231, -1106944, 40122], [2921444, -5286100, -841224, 813676], [89569026, 1074304, 643282, 1867805], [32289403, 15899439, 1394720, 86493], [192382262, 12354549, -783651, 952626], [-18188916, 10047950, -2074018, 667792], [-51690596, 1897062, 351030, 755952], [146050047, -3170293, -36616, -1650251], [112867630, 11659107, 1472315, -1304310], [-212324696, -10298860, 276596, -1627232], [3530426, 20856968, 10434, -68507], [219190612, 4966414, 628446, 1014440], [251747808, 7187056, 998128, -1085344], [129991760, -10942528, -1278768, 351736], [41500898, -4768505, -204289, 2054918], [278937140, -3637760, 1178612, 118250], [-46464642, 19989228, -406068, 474144], [340457204, -2010208, -716716, 753898], [-1122563, 1748217, -532408, -606675], [221630096, -7348192, -251440, 580096], [-168726508, -15767830, -749542, 78208], [-145492629, 23690559, 586152, -1159749], [-210954672, -7147608, 1742952, -1132896], [207994318, -2406364, 1739146, -910691], [127430221, -9721507, -362528, 1582540], [216650265, -12027011, 1378984, 1720127], [16371138, -3179085, 772875, -2086218], [174175962, 2118956, 1056206, 282511], [89826332, -2279618, 930254, -1458496], [60224791, 6891111, 1243040, -1615572], [309690040, -6490200, 497576, -1157976], [103967932, -6481368, 1030676, -74454], [-205843808, 16369200, 51888, -219072], [-165666186, -7429680, -1069488, -330048], [9837540, 11891146, -329606, -2312752], [12943106, -9661655, -523855, -688186], [286799142, -1451629, 819179, 1636978], [-193520032, -2526308, 1652932, -1378174], [-67941327, -8283851, -1738976, -647407], [38757028, 10841304, -180660, 68358], [-324450258, -17981521, -1072153, 333034], [-189725752, -9336264, -1584840, -1081608], [239985122, -16717312, -881358, -185843], [157974946, -16713828, 659324, 704160], [160757753, -6130687, -164448, -590870], [83299076, 3008966, 1078998, -1975160], [213643816, -5556824, -1559328, 47240], [-73220802, 2756724, -811734, -1189875], [-281593635, -7818771, 428160, 1794948], [-16172740, -16246926, -1553118, 303720], [-223616420, -7798156, 384040, 1204996], [-22987378, 15519716, -282492, -1260992], [307059504, 4867732, 303412, -784216], [-77410139, 21756097, -676488, 673913], [313717688, -1389148, -448396, 1030258], [55317923, -9741497, 54832, -1108699], [110173078, -10123609, 491935, -2140286], [-300787402, -7013584, -1063626, 2250439], [-147409023, -5049979, 779048, 659335], [217182108, -10905598, 753458, 1388008], [-169496172, 1136720, 1386596, 1690042], [365085330, 10996908, 864774, -1884501], [-91925303, 17427681, -211872, -1342626], [93813850, 127647, -275113, -3538098], [-89374636, 7090506, 173946, 1550976], [136606120, 4664088, -1426408, -4285800]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_200_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_200_6_a_k();".
// 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_200_6_a_k(:prec:=4)
    chi := MakeCharacter_200_a();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 6));
    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_200_6_a_k();".
// 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_200_6_a_k( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_200_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,6,sign)));
    Vf := Kernel([<3,R![18000, -432, -728, -4, 1]>],Snew);
    return Vf;
end function;