
// Make newform 528.6.a.z in Magma, downloaded from the LMFDB on 11 June 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_528_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_528_6_a_z();".
// 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_528_6_a_z();".
// 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 := [1092672, 1518, -2117, -2, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0], [-1, 2, 0, 0], [-2544, -1094, 1, 1], [-60996, 1004, 59, -1]];
    Rf_basisdens := [1, 1, 15, 45];
    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_528_a();"
function MakeCharacter_528_a()
    N := 528;
    order := 1;
    char_gens := [463, 133, 353, 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_528_a_Hecke(Kf)
    return MakeCharacter_528_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], [-9, 0, 0, 0], [-11, 1, 0, 0], [-10, 0, 0, -1], [-121, 0, 0, 0], [74, 2, -1, 3], [102, 0, 3, -2], [5, -15, 0, 5], [-138, -28, 1, 13], [2984, -18, -11, -8], [-2503, 37, 9, -13], [3422, -96, 22, -4], [7453, -73, -26, -3], [-6413, 163, -6, -7], [1398, -112, 19, -73], [-1977, 35, 52, 18], [-7318, -102, 92, -144], [8592, 116, -91, 127], [-20723, 341, -3, 79], [-5278, -40, -123, -11], [6616, 438, 52, -238], [-25422, -208, -10, 417], [-16157, -525, -7, 177], [9610, -32, -188, 88], [-4971, 715, -41, 515], [-28096, -818, 133, 416], [-66525, -325, -41, 287], [-80780, 1400, -78, -316], [33602, 106, -21, -525], [4622, -1772, 26, -160], [-19476, -3566, -172, 415], [-35801, -609, -133, 1129], [-139686, -828, -252, -38], [-127939, -359, -152, -623], [-238022, 964, -437, -664], [-155686, -304, 118, -359], [-176372, -3126, -36, 1204], [-85054, 94, -32, -1886], [169926, -358, -410, 956], [-367114, -700, -81, 1002], [205496, 6352, 70, -634], [-419278, -1976, 626, -1694], [133992, 2322, 637, -127], [-272046, -4, 666, 990], [-107262, -3960, -333, -650], [-135317, 6195, 1, 2919], [-232467, 3629, -138, 991], [7467, 5831, 173, 125], [326088, 2508, -14, -2236], [-153598, 3296, -492, -970], [-142065, 6377, -564, 3239], [-38280, 4844, -512, 3162], [647002, -5180, -780, 326], [246122, -8094, 516, 5428], [-56852, 12258, -958, 2446], [407122, 26, -1140, -6230], [-197327, -21267, 1058, -4088], [-100634, 3112, -2002, -4729], [105788, -4592, 3387, -2689], [-227214, -2940, 277, 2106], [-1225683, -10043, 1472, -6233], [137408, -13990, -2323, -2282], [-1126541, -14865, -2106, 883], [941840, 11870, -881, 8079], [-216684, 1122, -2668, -8866], [34571, -13405, 1456, -1232], [-1101596, 9368, 2102, -900], [-227200, 16158, 2824, 598], [436837, -2403, -3125, 14723], [1019258, -8774, 7005, -5401], [548214, 45564, -1204, 2744], [146440, 48460, 1158, 1126], [353683, -4937, -1495, 14801], [1139338, 26834, -1583, 7791], [-973208, -15004, -1102, 9788], [1783960, -27234, 1043, -3833], [507183, 39667, 6138, -7842], [1049128, 29526, -1874, -3608], [431004, -12498, 5414, 14244], [1477464, -26638, -1190, -17968], [-398846, -10750, -4176, 15220], [-2509088, 47674, -2194, 4826], [2616794, 5218, -6116, -8298], [-1670852, -14406, 5932, -24078], [1104402, -5792, -2060, 15669], [1120250, -30958, -752, 10884], [-1111792, 26114, -6432, 216], [-365638, -88924, 480, -13270], [3563746, -42540, -3317, -14824], [1283331, 45195, -3033, -19477], [-1309630, 48422, -5482, -5418], [3437398, -13978, 9572, -3666], [395739, 15675, 13545, -7773], [1222878, 81298, 96, 11758], [2369816, 14436, 10824, -23608], [-1626546, -13710, -3290, 612], [-2011937, 3603, 7552, 5234], [-1587050, -9280, -1300, -17178], [2124195, -45397, -13242, 20853], [-301294, -36334, 7251, -30089], [-7215975, -63435, -2542, 7217], [-1228602, -96576, 4239, 5280], [-6249210, 75642, 8802, 898], [2138106, 6156, 13179, -3062], [-2688989, 58839, 16224, 42523], [-4615733, 48537, 12351, 4725], [307764, 15108, -1342, -41062], [-1426218, 48896, -367, -53042], [-4856562, 102132, 14041, 45329], [-7587706, -17172, 440, 24044], [95700, -37926, 6448, 17735], [1090844, -9096, 2473, -14477], [9798562, 13816, -338, 7168], [-4563389, 107227, -15651, -35903], [5674535, 9827, -9273, 14045], [909614, -96856, -722, 37682], [-10784141, 50363, 18997, -3355], [-3537314, 2908, -16391, -62107], [-5568745, 80119, -27342, -10432], [-3833742, 61862, -32402, -26626], [3509816, 54798, 31280, -62000], [803554, 236, -23702, 39806], [1381904, 208742, 7477, 3876], [-12770652, -59060, 16382, -61322], [-4102987, -140355, -5825, 67671], [1003112, 115282, -11127, -14086], [6600254, -75380, 15720, 31562], [8520738, -3232, 31633, -43219], [-14221561, -50889, 11381, -32129], [-13208842, 16702, 14735, -41681], [-8118171, 15805, -29580, -19213], [716534, -37390, -10876, -9080], [6698695, 186987, 2227, 54493], [-966218, 31440, -23968, 8288], [13075198, -7808, 15675, 12998], [-3547810, 319096, -2654, -5790], [-5769239, -84851, 742, -51816], [-11614283, 52597, 10944, 95999], [3162135, -20261, 53870, -18374], [3207955, 37261, -4766, 17747], [-19690109, 48971, -11540, -13395], [-9148658, -161172, -33441, 68390], [5627775, 220211, 8513, -42743], [-69959, -175711, 20871, -60769], [-1058244, -136090, -8472, 74650], [7365234, -47412, 3131, 65087], [-2301216, 272084, 2509, -6565], [7419843, -215043, -18338, 32091], [-7318828, -100544, -19222, -42000], [15446548, 208910, -42855, 130901], [2552152, 249152, -15897, -129383], [14528270, -152876, 27406, -44512], [5907495, -47041, 44859, -18143], [6413642, -122514, 19096, -90200], [1239175, 96647, -32179, -168135], [25460880, 125646, -6141, -37965], [8084776, -1822, -37780, -55455], [7230346, 77988, -44680, -53578], [6906332, 524362, 40738, -89498], [-15405306, 211780, -13621, 51682], [-10887298, 159378, 17902, -19046], [-23767837, 262189, -35770, -365], [3123984, 299926, -21668, 58359], [20787016, -340912, -63642, -91910], [-13706406, -150980, -38068, 155378], [34496936, 26950, 19635, -25393], [-17743051, -157935, 22845, 129783], [4995368, -624720, -12493, -34339], [10759346, -79900, 42808, 89378], [-15416513, 64063, 3654, 50532], [14463853, 244669, -58691, 45935], [10495416, 42382, -58566, 181284], [-19254732, -2776, -646, -125990], [9496364, 151738, -18416, 93022], [33817855, -218237, 20953, -42627], [9753104, -345642, -32156, -50986], [6081701, 315433, 20462, 108093], [5086685, 423837, -67536, 4626], [583600, 51218, -28230, -24467], [32968940, -387132, -26749, -45835], [17174063, -10389, -6425, -91031], [-9776991, 445185, 57569, 63023], [1546092, 52926, 88422, 95250], [631449, 650843, -32112, 58981], [11209124, -287070, 58875, -3817], [8963491, -825365, 16114, 35852], [19925752, -226396, -22829, -176365], [1624817, -356751, -110741, 193447], [-12910142, 104356, -39332, -109986], [-10219342, -253270, 62220, -269154], [28264493, 70987, -41039, 172471], [-8261209, 226767, -68939, -266627], [23447478, -212014, -45838, -282730], [12766621, 491721, 19776, -152388], [-50033140, 125432, -24428, 115044], [-5566960, 678582, 92022, 79750], [5335140, 383394, 27726, 92002], [-33670404, 512602, 13816, 3524], [-17067415, 413075, -46084, 229869], [-21932856, 410320, -840, -90256], [9600176, 382722, -63695, 186974], [-34801556, 133806, -118910, 147981], [53368110, -109244, 32422, 16158], [-35908504, -654234, 1516, -114186], [44701668, -440028, -24722, -15038], [-21933101, -133325, 1076, 314604], [17081523, -133685, 71367, -174981], [1859975, 263783, 82779, -57075], [32627782, 454192, 93123, -197654], [25808925, 24709, -33587, -169981], [-9241154, 499920, -17326, 75350], [2847369, -67431, 67932, -183234], [29912295, 184483, 145011, 79917], [1169144, 531732, -2704, 50340], [-31809778, -440710, -112080, 148856], [4464169, 356839, 162407, -229081], [-32880920, 5214, -9134, 3219], [33885130, -735612, -118115, -7894], [-40243776, -537306, 45159, -35477], [-37262867, -480859, -144496, 425458], [-34250520, 310564, 86643, 184407], [81142840, -821370, -33760, -74341], [-44010902, -222596, 12352, -329678], [-1289153, -322077, -288707, 347821], [-36654268, -127256, 160216, -230992], [29741266, -516830, 163901, -215013], [-21295480, -192322, 133364, -258314], [-39640914, 665448, 83831, -147833], [-20466666, -326964, -197656, 5893], [-10227246, -1241322, 20832, -336918], [-44130928, 1043546, 55012, 171382], [-2835327, -350479, -28122, -232485], [-9418440, -279070, -54390, -182363], [13982594, 1329772, 117903, -374378], [47816674, -918234, 212790, 47410], [-63277500, 46604, 168492, -256176], [-56577562, -575036, -50000, -161940], [-62994284, -797954, 122749, -377814], [-55019384, -205616, -75122, 444834], [-64444922, 284256, 132167, 96867], [97036230, -494982, -96466, -237358], [60941207, 58583, 138730, -122867], [42115849, 985965, 9069, 346179], [25829168, 599062, 224132, -649100], [-18728634, 991600, -115955, 18286], [-62236182, 719246, 66952, 197896], [-53663951, 711961, 40351, 469537], [21092768, -172468, -245392, 4984], [5277607, -175085, 153680, -419917], [1096570, 409862, 84368, 130408], [-74337476, -873952, 178715, -559453], [50438207, -598735, -171964, -67449], [-31537650, 270264, -78805, -67149], [-96255111, 280679, 112483, 72431], [-69556302, 834572, -196949, -82004], [6557143, 1078039, -196759, -124019], [129238008, -122790, 35660, -85562], [18600463, -126041, -388236, 476473], [3542237, -383227, 133014, -445058], [-14787084, 91622, 277936, 272816], [111015370, 282988, -149438, 95763], [-3773613, -565949, -58913, -378687], [-81529880, -644184, -231815, 489665], [29898304, -106888, -287949, 411265], [17243466, -273252, 119906, 162650], [54816603, 448619, 59591, 384457], [26824697, 101161, 166820, 567170], [193405898, -377472, 141186, 63792], [57095253, 285425, -20048, 519393], [-2114192, 571438, 222913, -559784], [15095474, -991168, 132084, -387286], [-120135141, -58453, -40691, 123401], [7495817, -1700865, 13293, 3315], [68129664, -1709146, 28238, -133605], [-121849868, -748374, 90316, -32474], [-40238473, -9849, -367715, 455167], [14267320, 406828, 208492, -150128], [12369998, 589538, -61797, 538957], [-3954956, 570602, -103690, -185262], [-3038818, 1038026, -57206, -94506], [43915214, 214006, -95036, -140622], [11015079, -1915865, -113475, 347967], [111775900, -416888, 108942, 556246], [57445988, 637812, 46287, -251683], [59824811, -409265, -87828, -351533], [-32663560, 845294, 134819, 29847], [-65233983, 1330183, -57797, -102609], [-4755186, -109972, -198197, -663754], [-76018035, 510421, -172717, -648359], [-50654746, -1195328, 164957, 432062], [55069509, -239439, 273856, 685596], [81354470, -90034, -434132, 723620], [-18374798, -1085548, 282505, 179234], [-80684232, 1848636, -95996, -412304], [-190961430, 133626, -164379, 353031], [47975360, -342438, -27047, -403062], [-91201421, -1346301, -184703, 406207], [102368213, 1643489, -132902, 749808], [-6257373, 2008787, -103951, 748309], [-39233719, -1323111, -76702, -426997], [-117823594, 210216, -48814, 77730], [-23910726, -173516, -9341, -1200140], [-169998166, 934836, -378760, -525705], [192128928, 119580, 160472, 570776], [-142499841, -89785, 115335, 85045], [16599484, 340122, -102436, 191210], [-179993982, -1717538, -106066, 732574], [40128770, 1209148, -312328, 376912], [53723658, -2801756, 286491, -113185], [115631758, 270366, 306685, -786881], [11612696, 1835908, 317920, 594630], [-134764149, 1991307, 226396, 702328], [17503121, 2315939, 145970, 378801], [-37779890, 976978, 550330, -112230], [17917060, 551596, 10670, 394932], [95046242, -841352, 74374, -918224], [29392232, -25332, -226844, 595028], [110367908, 1704716, 5968, -393432], [-146819998, -483600, -344308, -383336], [-54037103, -162421, 70136, 1147397], [51158843, 842575, 112146, 919175], [-110472959, -2841025, -167963, -20625], [-40610902, -4639788, 125299, -309276], [-97376233, 2163703, 70553, -172197], [-137050682, 1395208, -360207, 186942], [175452233, 1622671, -99203, 255135], [-110841507, -1858563, -107859, 583035], [-6756136, -2555492, 179468, 513304], [-111666772, 614072, 311588, -608670], [-86695922, -123572, 17091, 1123422], [148825886, -1055030, -36051, 757337], [-33598123, 3014153, 285572, 146040], [62571164, 780006, 61950, 637497], [162039868, 527888, -247022, -266048], [-169005385, -1679737, 162326, -913267], [143064322, -650882, -422754, -732346], [-45884782, -3736904, -186072, 394238], [-64979362, -4828744, -1179, -372138], [-343534, 989784, 334768, 276688], [-75053224, -2983346, -36328, 523803], [57920352, 3776094, 506498, -1002284], [7411708, -99074, -4236, -426256], [-66305188, 949710, 336497, 346366], [-42389413, 3925935, -151279, -1021779], [-184091347, -605271, -478618, 1186284], [-122259165, -1410813, 457205, -1592271], [245087144, -356562, -172500, -609136], [-124320440, -1878252, 103214, -354916], [167222224, -2115092, -177122, 719774], [7470059, 784119, 334216, -457186], [50410923, -310861, -278644, 208065], [67058758, 1315988, -286160, 2012408], [-157690475, 412737, 151014, -41612], [-133698316, 297674, 468608, 966183], [-42171950, 1893950, -494505, 274033], [-68248535, 704155, -336016, -947931], [190336008, -1308114, 264291, 953095], [26485648, -5085476, 210838, -144044], [-171280825, 119753, 467498, -731721], [66037596, 846414, 444381, -816683], [-49239206, 2778894, 69331, -1086411], [225813410, -3462892, 538473, 849810], [-157007820, 2509554, 157971, 1602391], [-69129028, -729904, -144586, -1653524], [-167313319, -2511471, -851347, 1493379], [46508554, 62416, 785936, 356392], [74331584, -2035206, 214469, 244882], [-63721742, 583128, -173102, 1023377], [42111452, -1991586, -66204, 2032640], [103160254, 955174, 358684, -48396], [-380424172, -1737632, 272214, -560296], [-126151614, 1965106, -366046, -1144502], [-62283642, 262452, 750343, 37958], [66802044, 1351866, 11382, -2015889], [172584990, -2987168, 452176, 500424], [-55106924, 995392, 158784, 2087556], [64154558, -1389166, -101386, 1761872], [-201132806, 855416, -432416, -1360920], [-69527161, 3737049, -146594, -1378545], [163352658, -3309476, -348500, 317946], [-34272529, 3668099, -31066, -1120598], [555184, 4003938, 809424, -921548], [-262599482, 3977708, 127102, 161021], [114776962, 927668, 579919, 1536286], [83884873, -274879, -35012, -1489497], [205114620, -1363290, -31839, -1049655], [-94211169, -3509301, -489573, 1924185], [142016618, -4200716, -415082, -807276], [-300383681, -987305, -669830, 1441089], [-47533502, 854908, 253263, -902821], [-157779593, -1577971, 179965, -2272755], [-94031015, 4582161, 206892, 466474], [-407594708, -1182044, 137054, 532470], [-371908824, -305732, 590936, -300580], [36845952, 5450338, 504413, -206335], [41515034, -2783604, 132252, 1086902], [290491724, 1932390, 195506, 467329], [114212238, 1634352, -293734, -422238], [57502764, 713056, 430766, 1710404], [235628396, 3864274, -609043, 2559424], [370865896, -2344420, 264265, -30289], [-36532754, -1614768, 646064, 311678], [171224092, -4174042, -383518, 728193], [121482342, 1604784, 107810, 3548166], [124988292, -339066, 1178393, 224478], [-39470374, -1835500, 964516, -642581], [-35246766, -946292, -1194702, -626088], [46730049, 1642483, 422042, -109751], [-71280027, 509373, -254507, -2845577], [-270034798, 3145438, -648114, 88146], [-180627852, 127722, -467650, -653378], [247945030, 2561416, -324233, -903040], [107610256, -2287316, -834740, 12588], [193280583, 4109387, 400540, -109877], [167180786, -670984, 60006, 986600], [13385073, 4432569, -199022, 2701662], [-325157224, -3994348, 187268, -1207178], [52601859, -842141, -1318685, 1292307], [-53711230, 374668, 16370, -1775386], [49381592, 934940, -433352, 1482886], [52203731, -3395901, 674230, -223124], [118020114, 2977750, 1219631, -2628299], [294497816, -1626266, -813573, 1842531], [-292478238, -2215186, 279616, 2372918], [160410171, 615089, -350257, 739045], [-522036241, 4915123, 481132, 778066], [295638194, 1156590, -154750, -1858974], [-56721913, -90879, -712748, -2425993], [-27631394, -586534, 1009048, -561814], [-58385802, -832882, 1308572, 1062430]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_528_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_528_6_a_z();".
// 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_528_6_a_z(:prec:=4)
    chi := MakeCharacter_528_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_528_6_a_z();".
// 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_528_6_a_z( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_528_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,6,sign)));
    Vf := Kernel([<5,R![16422912, -185904, -7748, 44, 1]>,<7,R![572028800, -922520, -52836, 38, 1]>],Snew);
    return Vf;
end function;