
// Make newform 936.6.a.m in Magma, downloaded from the LMFDB on 16 January 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_936_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_936_6_a_m();".
// 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_936_6_a_m();".
// 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 := [-95, -529, -186, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0], [-124, 312, 12, -2], [-618, -328, -4, 2], [1206, 776, 8, -4]];
    Rf_basisdens := [1, 9, 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_936_a();"
function MakeCharacter_936_a()
    N := 936;
    order := 1;
    char_gens := [703, 469, 209, 145];
    v := [1, 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_936_a_Hecke(Kf)
    return MakeCharacter_936_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]];
    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], [0, 0, 0, 0], [2, 1, 0, 0], [-44, 0, 1, 0], [-24, -2, 0, 1], [-169, 0, 0, 0], [-306, 4, -6, 0], [964, -16, -1, 4], [92, 29, 9, -7], [-66, -21, -9, -21], [2732, -54, -25, -8], [3002, 86, -40, 16], [-8198, -108, -25, 11], [6072, -6, -12, 8], [-3544, -131, -55, 2], [-9346, -171, -83, 51], [-2864, -278, 38, -57], [-3938, -5, -33, -151], [-3508, -388, -47, -18], [-1888, -41, -15, 32], [19026, 142, 96, 88], [15264, -34, 290, 46], [-58464, -298, 262, -23], [-21534, 34, 55, 259], [8666, -420, -6, 150], [2318, 1167, -31, -261], [29188, -396, 478, 158], [-81192, -389, 227, -81], [-29406, 556, 568, 528], [51134, -892, -796, 46], [56760, 460, -18, -980], [-101104, -19, 441, 1], [-134998, -368, 595, -441], [50120, -2228, 260, 278], [4346, 5337, 1394, 34], [-104892, 762, 1265, 836], [-165766, -349, -1749, 701], [270940, -3068, -2123, -376], [-169376, -1587, 777, 418], [42126, 2583, 1861, -169], [-108232, 2737, -1251, -977], [-527342, 1, -575, -1093], [-55340, 1765, -3735, 675], [-451206, 36, 792, 796], [178282, -7761, 1650, 1174], [-298480, 6984, -78, -1268], [-395372, 8574, 630, 30], [-466732, 8438, -1113, -112], [-214728, -770, 5064, 1007], [-434070, 980, 2320, -748], [210726, -3440, -2506, -2998], [150304, -2619, 5223, -2146], [-288294, 9004, 270, 1514], [-372468, -9214, -3106, -1464], [-352834, -2424, 3210, 4662], [-348160, -7382, 3814, 1376], [710342, 5563, -2001, -1657], [78796, 2320, -5895, -512], [-89082, -11494, -8310, -330], [-865734, -6478, 5293, 1633], [205548, -21498, -628, 2522], [-72446, -2641, 5284, 3748], [292980, 9032, 5651, -130], [443732, 30545, 5069, 3985], [382270, -6784, -11288, -788], [312538, -31697, -3830, -1438], [-24060, -4448, 4537, -4654], [116150, -6296, -3292, -196], [-940196, 27230, 11994, -214], [4298, 34042, -848, 324], [796090, 3154, -9275, -3471], [-1535120, 4601, 429, -4882], [-253076, 35980, -16392, -442], [508922, -3930, -12610, 502], [-966924, 4, -1233, 2268], [-1729824, 6753, 5561, -5396], [687622, -2033, 12669, 3233], [1300490, 44200, 8490, -2494], [-1501278, -13368, -18127, 3793], [1596490, -738, 6108, -6248], [-1585944, -7863, 10565, -7415], [-2549766, 15572, 9608, 8292], [-1328280, 24783, -4145, 5070], [1696386, -30419, 21409, 5211], [475036, 55972, 7702, -9394], [2090224, -34203, -10819, 3177], [-1999678, 32928, -21155, -5739], [5332426, -3664, -1958, -4294], [-70134, 57845, 5444, -5972], [37468, -52044, 2953, 1048], [-397396, -42684, -8912, -1130], [-2608096, 20363, -17739, 7618], [-28300, 66574, 21771, 18792], [-2457652, -78566, 2310, -11612], [-2572860, -55656, 4577, 2986], [503800, -70074, 694, -3108], [4112370, -11165, 10442, -90], [97646, -67570, 17398, -9468], [-3670608, -56838, -29318, -1364], [2548882, -19654, 35162, 918], [-6855808, 12110, -12666, 4240], [3561050, 56429, 22134, 10274], [1186192, -93623, -935, -4205], [336182, -105052, 9526, 9526], [-2057028, -53770, 28104, -15314], [1440434, -14702, 25150, -8702], [5180688, 24152, -1744, -13145], [5410346, 106414, 6151, 1199], [4604056, 81340, -22860, 2874], [4319342, 25788, 1292, 4808], [-2415148, 61710, -17898, -39228], [-7411702, -63532, -10, 16970], [-3550766, -20226, -8535, -9491], [935516, 17348, 35111, 12690], [-1469908, 98418, -51007, -15388], [-818794, 22444, 13458, 20508], [530844, 133316, -8007, 1990], [3016248, -117230, -9074, -10714], [10682014, 102131, 14851, 16291], [754476, 64136, 14580, -10412], [2233234, -33800, -17274, 9646], [-3042442, 72459, 4131, -16679], [9340126, 38203, -42185, 8965], [4068880, 114760, 35646, -1729], [-790132, -12344, 50057, -10482], [5555854, 26703, 5909, 12341], [2790890, -46832, -113120, -10316], [-11028820, -152985, 21023, -29545], [10675216, 223978, 20508, 3918], [5026106, -107276, -28860, -50848], [13355652, 111996, 31267, -4230], [-11426576, 83171, 68557, 41940], [2540132, -26506, -3332, 2756], [-5044514, -103685, 27383, 39377], [-8990030, 1416, 56751, 52715], [-4491998, -9148, -75636, -27744], [11933938, 182699, 40640, 14904], [-91172, -2456, 103647, 56162], [-5048170, -243971, -10217, -12061], [-5549146, 92846, 145590, 18712], [17533380, 74556, 49511, -6720], [13158506, 25599, -51520, 6084], [10259260, -154330, -23868, -29832], [-18216832, 40656, -38070, 22803], [-15114274, 128025, 33669, -23093], [-6125952, -39027, 45971, 55732], [-6475318, 175462, 7884, -61696], [-13471794, 33372, 2254, 37490], [4638388, -53088, -43148, -43368], [-15539896, -115133, 43391, 7330], [15777338, 31058, -114304, -19556], [11937590, 127886, 83944, -17436], [-1923396, 196966, -78964, -71666], [14264324, -277303, -149855, -25833], [4313364, -396056, -121046, -26436], [1361228, -17399, 15033, 90315], [1272688, 90892, 5752, 90904], [-11361782, 298424, 124291, -18097], [4657354, -200405, 75791, -54035], [1687026, -358151, 89526, 22406], [-20656592, -69748, -155388, 65981], [-35772178, -197456, -24610, -21814], [9961804, -31946, 73359, 28456], [-12249604, 117688, 193460, 47564], [8243922, 173988, -127299, -5475], [-7835608, -194929, -13423, -144518], [-2975380, 121484, 126924, -31078], [-9094298, 172532, -61308, -18452], [6943658, 188262, -130324, 28492], [-4465138, 104931, -1067, -110541], [-2517784, 231100, 21750, -83795], [-16209222, 201822, 80504, 114784], [-15321460, 229285, -21043, 87297], [19051386, -307864, -85370, -694], [-11408148, -96430, -217720, 56904], [-3814962, 298474, -21222, 111714], [13597508, 358008, 161363, 22378], [-7191366, 606465, 41846, -32678], [-39550964, -316758, -92692, 40936], [-18680958, -258846, -229246, 95498], [9404636, -155672, -69163, -175680], [-8264400, 36761, -91355, 130867], [-33889746, 24451, 28119, -65719], [-19982550, 466178, -123057, -3917], [-19907424, 96615, -773, -66940], [-33915858, -381777, -136739, 63101], [-11607014, -796075, -141139, 9911], [-16765236, 377608, 123595, 10228], [5116722, 232994, 150344, 67660], [27456528, -493569, 170923, 77060], [-22784346, -272757, -95941, -30027], [-5678440, 783066, -120658, -13707], [-12596752, 357736, 265940, 32650], [-30130614, 220045, 84670, 50766], [29488320, 663229, 92569, -56909], [37633822, -58242, 21596, -3168], [-35806694, -280132, -67184, -61008], [35590162, 30368, 102600, 91432], [-35584926, -161174, 122079, 112323], [32038052, 14487, -66637, -154335], [-35696678, 292373, -237340, 18028], [8688908, -434996, 235516, 7834], [-30071142, 85590, -109898, 71322], [-38963098, 132235, 228227, 103669], [-5119112, -572988, -20028, 27469], [33437430, 396783, 22251, -17523], [-41222244, 633402, -129557, -49476], [-21724616, 156777, 305021, 248597], [8778226, -626754, -282373, -175245], [35522644, 164450, 168016, -189114], [-14588062, 546701, -91743, -44037], [-26229882, -154775, 258597, 52571], [331024, -838748, -291564, -99220], [41059312, -595216, -414938, -116641], [19902760, 526149, 132249, 83312], [15900242, -49016, -107752, -115440], [-57375128, 1052002, -124086, -195386], [-5343170, 357262, -287614, -255894], [8240016, -154857, 36353, 284884], [-36090310, -26915, -35158, -47650], [-23047714, -660798, 93578, -77114], [52108308, -116416, 191417, 117980], [-21242782, 374964, -480155, 136417], [22260564, 362550, 219731, 47912], [54823668, 170976, 165472, -27466], [-44478930, -1006640, 9572, -227684], [-27920914, -369718, -225342, 176994], [49031920, -788468, -441688, -5210], [69905048, 300192, 255950, -91152], [-77405184, 164302, -171654, -132869], [52964794, 1497437, -59211, 210191], [25728584, 277846, 298, -164728], [-42346044, 230932, -245721, 272196], [6781366, -1144862, 63872, -147090], [31488688, 658128, 414620, -92266], [636256, 613489, -141821, 144618], [-20383638, 222618, 275472, -108776], [-76067710, 860073, 238618, 50814], [60367648, 76785, 319029, -61285], [-78306284, 966991, -226745, -274991], [32183464, 697592, 142104, 23195], [33679084, -103202, 210000, 2458], [31114536, 1129620, 550224, -27964], [23177842, 697032, 258122, -291110], [-67781566, -547526, -129373, -65821], [-43995676, -333331, 375385, -72819], [7201348, -77536, -396763, -145180], [44850768, 1268, -50608, -328627], [56827068, 852984, -459145, 60036], [-26041436, 632119, -256201, -131869], [41423306, 541310, 414606, -289554], [41617170, 1004898, 165357, 392373], [-32386904, 910583, -656063, -222214], [-93845698, 912676, 108728, -120488], [-71755578, 213843, 367195, -106669], [80858576, -219850, 172644, 199197], [-49815958, 700440, 222528, 23088], [-42434220, -568600, -367129, -114656], [15782806, 427393, 91319, -142901], [52721858, 42756, -295620, -8972], [-7427184, 1818228, 236722, -41360], [17648292, 1383360, 356924, 178864], [-39020534, 8896, 468300, 370892], [18936414, -409064, 232672, 23104], [21408658, 1110776, 712405, -246747], [8973588, -1318872, -97784, 46956], [68577266, -1114039, -327004, 77984], [43386706, 1724778, 400349, -52779], [52346580, -2326076, -92333, 322046], [-145237650, 497365, 245207, 167065], [-108863866, -83915, -278363, 237755], [-42514036, 846460, 561253, 398278], [48007226, -196230, -57852, -84572], [-44647028, 1468020, 143030, 222358], [-22937858, -1917192, -111928, -160520], [40934468, 110056, 448655, -527304], [34190264, -862172, 707738, -204115], [-46206782, 2220234, 273132, -164308], [-91327414, 508642, -307314, 33534], [57645340, -761354, 282106, 316216], [-25716172, -996945, -132237, -40571], [-33788780, -280660, -710983, -289684], [-121443116, -1813913, -529877, 82225], [29428434, 1523028, -247590, -69626], [133272436, -722684, -601, 125906], [-59490776, 250216, 530068, 142156], [52214546, 657153, -311555, -296329], [61744258, -1938767, 498386, 319990], [-58799956, -501154, 242045, 503432], [100035886, 838398, -559860, 228596], [60461486, 1076715, -79337, 512121], [76343940, 210390, 440786, -341366], [-40197590, 2205086, 974727, 194587], [-45519784, -1732680, -579356, 429757], [5597962, 1239403, 46227, 385461], [53070998, 470919, -620031, 203737], [6216148, 2456474, -666690, -45132], [-101461890, 2599317, -721485, -329253], [49001636, -1607134, 522974, 351550], [-35646644, -281132, 97743, -159794], [117466586, -1799892, 759236, 151852], [100060418, 52505, 540256, -58992], [-161105604, -133166, 238040, -72452], [68209092, 242912, 324616, -231196], [152351672, -1269618, 599466, 481640], [86168762, -1996182, 701620, 615572], [-89081536, 2567591, -281865, -614811], [-1999882, -309474, -940866, -56670], [-88071096, 114847, -40775, 478346], [8668378, 579134, 263490, -398646], [-155609112, 598644, 450600, 250722], [-39310438, -3193869, 324566, -81678], [-33555722, 209220, -765092, -301610], [117699980, 1208214, 779354, -132478], [76905192, 496963, -150485, 464112], [-69127466, -2680348, -928372, -206660], [177245976, -923286, -34436, 262511], [-9147624, 2274111, 343399, 220538], [132173682, 1437836, 658606, -168554], [21790526, 1184116, 53130, -177980], [-110906680, -548656, -304166, -215738], [48854602, 463014, 902954, -89498], [103722742, -1076793, -243657, 492017], [-225026732, 909182, 22013, -375436], [-102132870, -485020, 1604689, 286829], [70164418, 1072729, -1280467, -238313], [-53423076, 1207672, -834151, -454692], [49995076, 1548668, 424217, 354342], [-84242376, -276994, -438030, -460998], [38060326, -2260323, 313693, -405615], [36756634, 458724, -964788, 204480], [-45963786, -353511, -722367, 275793], [28165304, 3229518, 594094, 617062], [-114586072, 1432072, -527042, -497853], [58181908, 3436756, 48407, 244180], [-84990016, 1614288, -438148, -37521], [-103120246, 1342266, 451668, 503560], [-4504286, -1450726, -527115, -1264519], [57091930, -3218798, 1146252, 163684], [-23465844, -2025166, 1113708, 530164], [230099138, 510340, 137410, 311474], [67462854, 735816, 553052, 175906], [102066466, 322047, -2018100, -45572], [111202628, -1916450, -775396, -75004], [-157910862, 2125951, -320234, 333438], [-45275760, 1240987, 1699755, 470821], [88675162, -1223600, 970656, 272856], [-17625124, -619044, 44969, -1174372], [-171175824, 1769823, -320757, -790200], [208983854, -984197, 200733, -506167], [-70394148, -2520548, -1355759, 104614], [19816858, 3855098, -790516, 230368], [-62691534, -1692153, 230260, -787976], [-48985128, -314062, -1214032, -1199590], [-5110514, -846599, -568007, -1199937], [-104376682, -793998, -497782, 129400], [122408616, -777407, 58005, -1253246], [76645648, 2011682, -651040, 894151], [46029134, 1187426, -1223936, 748828], [-190289144, -2064311, -1069647, 217836], [177295554, -2930926, -465232, 292332], [12829550, -1182662, 727836, -729314], [-56743280, 1470140, 844772, 1039494], [119189248, 1421058, 644296, 546871], [-62209888, 1532028, -383578, 757826], [16120310, 2553429, -195747, 306743], [-207941782, -956869, 382158, 68310], [-403795300, 100194, -728435, 25968], [-208935714, -637013, -490789, -308599], [-161793992, -3156431, -1570375, 448409], [-317360640, 788960, 137354, -297982], [145824808, 1142713, -691791, -211718], [143844118, -227125, 649307, -330895], [317141496, -195668, 396176, 376700], [-255528506, 1661522, 2106826, 1089758], [253681848, -2164392, -1606996, -302237], [118899952, -551006, 1472270, -434690], [146340986, 4141332, 681040, 221904], [330457622, 210598, 1085458, -249858], [89454710, -2698367, 620941, 80347], [356370714, -2130111, -61494, 281262], [-228376966, 107532, 15619, 940319], [-18079284, 621616, 2517837, 34220], [-366109446, -1429386, -256933, 450247], [-360350660, 468612, -1068579, -440784], [-222997240, -5169, -177775, -1158378], [-15880700, -4921840, -318549, -764980], [-311572634, -199419, 1545849, 724343], [52780972, -3954592, 284179, 1390224], [-184933584, 1113200, -1325576, -6198], [-409559326, 797814, -458556, -566984], [-278806670, 384577, -37174, 717054], [201404488, 2481978, 1246804, -1154823], [241044100, 1783066, 933310, -108682], [-159624600, -66845, -2132713, 162048], [80369994, 2866937, 2285381, -263513], [-154961788, -5072032, -1507797, -296556], [-165902034, -491580, -1509418, -962912], [150712924, 3886180, 33624, -314600], [349319890, 3681685, -747608, 396676], [49057626, 990386, -1609432, -682944], [-27642442, -1721374, 98800, 228494], [-461590644, -1171988, -743027, -493968], [390439378, 2812308, 927509, 250269], [181660858, 2944903, -633878, -1014182], [291831344, -1915766, -1890418, -1210478], [90638866, 1816850, -1359350, -933702], [181494738, -2861132, -663323, 298765], [-97153108, -1881960, 711475, -1164778], [12211888, 275326, 98652, 765801], [-221168718, -3667924, -1841420, 281404], [-25939554, 2155459, -1146049, -1310083], [-62813908, 2825174, -936486, 877258], [-246753400, -929920, -542058, 1232858], [-10838806, -3584396, 2786224, -549840], [-42897522, -2792459, 1928417, -1190629], [414650000, -1222723, 1186855, 283058], [240369376, -8682110, -803290, 644618], [309729898, 1779272, -1229879, 342841], [-13607804, 2251005, 2686421, -61527], [-70077586, -3419625, -1383, -493413], [-404022686, -4146824, 1079782, -496062], [-436591720, 543071, 697925, 166448], [-312810184, -3772627, -635671, -1863451], [89221050, -7399044, 1660160, 452448], [86881282, -1801053, 1439568, 1453004], [8091828, -4845758, 1285782, -259484], [128471170, -933602, -2655089, 570335], [-29872644, 6554540, -442295, 217572], [-649157044, 1524615, 185703, -185951]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_936_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_936_6_a_m();".
// 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_936_6_a_m(:prec:=4)
    chi := MakeCharacter_936_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_936_6_a_m();".
// 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_936_6_a_m( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_936_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,6,sign)));
    Vf := Kernel([<5,R![4627584, 91808, -9160, -8, 1]>],Snew);
    return Vf;
end function;