
// Make newform 570.6.a.j in Magma, downloaded from the LMFDB on 25 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_570_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_570_6_a_j();".
// 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_570_6_a_j();".
// 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 := [-6356280, -1407374, -25872, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0], [0, 2, 0, 0], [6019755, 301432, 677, -14], [-2675070, -3392, 288, -1]];
    Rf_basisdens := [1, 1, 30195, 10065];
    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_570_a();"
function MakeCharacter_570_a()
    N := 570;
    order := 1;
    char_gens := [191, 457, 211];
    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_570_a_Hecke(Kf)
    return MakeCharacter_570_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 := [[-4, 0, 0, 0], [-9, 0, 0, 0], [25, 0, 0, 0], [-27, 0, -1, 0], [-61, -1, -1, 1], [159, 0, -1, -2], [-152, 5, 6, 2], [361, 0, 0, 0], [-312, -7, 10, -3], [-1563, -1, 31, -11], [-2830, 21, 6, 20], [-1203, -32, -23, -10], [2305, -9, 23, 25], [-2885, 22, 69, -64], [-7436, 7, -2, 57], [6894, 55, -10, 39], [13738, 26, -6, -16], [5166, 83, 132, -102], [-5000, 64, -144, 122], [21734, -46, -46, 36], [-818, 206, 44, 228], [40992, -266, -8, -112], [-15246, -165, 228, -239], [28409, -57, 499, -81], [19891, 176, 119, 62], [12028, -228, -514, 30], [-17860, -438, -204, -124], [-80112, 0, 216, -86], [16060, 630, 766, 154], [-1352, -57, -1048, 175], [-90748, -352, -392, 698], [-145471, 709, -267, 159], [-220470, 64, 368, 212], [-83162, -1074, -1130, -596], [-78654, 802, 1508, -1200], [41458, 1147, -450, -176], [-35456, -798, -242, 84], [-204731, 80, 1259, -1132], [-498700, -21, -8, -122], [-259816, -1465, -2416, -343], [-217734, -608, -1342, 1240], [284628, -168, -682, -2330], [-12083, -745, -3207, 725], [-302279, 2114, 1037, 1640], [-235192, -2325, -2342, 1326], [-345594, 3122, -762, 1086], [104172, -770, 400, -1012], [22076, -406, 4036, 1440], [-360468, -257, -2548, -1158], [311150, -3205, 2296, -1204], [-309034, -306, 7096, -1898], [-423625, 4945, -525, 879], [324254, -1616, 1976, -174], [-840909, -1877, 47, -2491], [-259600, -101, -6588, 513], [-551642, -2147, 3256, -2201], [-14019, -2863, -1217, 509], [192102, 3480, -1354, -3238], [175158, 2370, -6040, 2904], [-519005, -2939, -5051, 3513], [-777159, -546, 8435, -2730], [-527728, -159, 3352, 2381], [209846, -5574, -3282, -9376], [-498363, -1985, -4543, 3613], [-45096, -2520, -9334, -4892], [-723426, 1737, -342, 8061], [614670, 1891, -12002, -516], [706479, -5518, 7287, -3552], [-36230, 769, -3224, -4101], [706858, -5764, -14140, 6408], [-477538, -5564, -7860, 2424], [649133, -229, -6391, 11321], [-305005, 6234, 14625, 5892], [-53993, 15586, 11571, -3456], [2212818, 3831, -3598, 2072], [-1621488, -74, 3164, -5682], [221982, -7866, -3528, -10184], [1877622, -2612, 12376, 324], [-727341, -1061, -15139, 5093], [689720, 7570, -11482, 886], [-592625, -145, 24411, 81], [-784326, 4144, -7928, 5198], [710042, 11100, 25474, 1946], [-228951, 1330, -3251, -24], [-729932, -13284, -6332, -7876], [-2384712, -5457, -1998, 7779], [3152329, -3627, -7837, -12745], [1965400, 10834, 1266, -6240], [2959074, 1944, -15276, 18540], [-2536909, -10506, 14049, -12556], [-646328, 8373, 1958, -16503], [-3526467, -99, 15549, 10971], [2093890, -19606, 12362, -862], [-573027, -5153, 17549, -24055], [2497566, 10442, -12906, -36], [-4134374, 19689, 9188, 5983], [-421017, -9379, -21263, -781], [6629791, -10617, 3701, -16841], [-4449730, 41342, -13790, 14006], [-1191614, 1428, 16000, -9866], [4740158, -13930, -10010, -2912], [3177310, 4834, 292, 17706], [-4364924, -23601, -4132, -18826], [196713, 24201, 24507, 17175], [-2278938, -27980, -19862, 10438], [146512, 41668, 10770, 47680], [-2748452, -24155, 12250, -15471], [-3874574, -32686, -34956, 4070], [-4313288, -28476, 17732, -15726], [-2528840, -5684, -48246, 23720], [448582, -13752, 24430, -12422], [-9302288, -6104, -1986, 20664], [1098496, 41, -4434, 3294], [-6834910, -19120, -35414, 4628], [2601740, 27636, 41172, 17196], [-2527615, 19611, 66043, -32709], [-11183267, -10762, 38027, -41652], [1050366, 8101, -17836, 51905], [-9518456, -18295, 19926, -29040], [7012972, -7646, 30580, -23658], [-2424520, 1676, 68182, -17776], [781243, 41648, 25439, -29062], [7821846, 33771, 40422, 28899], [-8143396, 71200, 19524, 15102], [-8760010, -33424, -3206, 16058], [3823102, 4670, -1680, 3320], [468626, -15713, -40744, -28726], [-4971389, 21987, -25789, 28093], [6350747, 16238, -85763, 17134], [-8158582, 15358, -4252, 44352], [-11205428, -6996, 105856, -59836], [-7658376, 38310, -11772, 2226], [-5806122, 17137, 36130, -27736], [-3796836, -3238, 17442, 45012], [-2049942, 48722, 14944, 43520], [1756946, -4928, -77740, 47686], [4405362, 20961, 19878, -13503], [4137362, -33202, -79778, 19418], [4420312, -41557, 66696, 10573], [-1473046, 3018, -76280, 16948], [-1771548, 23640, 104840, -16956], [14251492, 76510, 64750, -43142], [4687147, -101124, 13141, -18274], [13316808, 48725, 78388, 34048], [13172792, 6564, 50898, -2838], [-4446074, 34202, 37986, -70644], [91132, 10906, 19266, 46388], [13053850, 4589, 48510, 531], [4507084, 74178, -34376, 130700], [-1203828, -20344, -192296, 25874], [-2213181, -100568, -82565, -73310], [3840656, -37162, -143818, 75590], [4496005, -73988, 100947, -27928], [21607864, -12268, -61032, 5484], [-8125946, 76072, -6846, -34598], [6419088, -8358, -140112, 9576], [-26517192, -22814, 147208, -53500], [9259596, -88938, -66462, -63582], [16138916, 87086, -27410, -29528], [1903573, -12423, -63145, 4765], [-6301118, 74193, -6016, 9271], [13368408, -39957, -15684, -107427], [-11400421, 23132, -172895, -5544], [7846916, -87862, 210500, -33946], [1536170, 43179, -143546, 18763], [-3288804, -93231, -150048, 30414], [-5925772, 55492, -57724, 61452], [3786208, -85670, -116514, -1848], [9104122, 43354, 38748, 107746], [9761194, 190, -18152, -16226], [22306314, 120038, 212854, 14590], [14126162, 98500, 261764, -32100], [7389229, -71871, -30307, 88379], [-24724634, -86456, -27900, -10016], [13119248, -44054, 43736, 25548], [6385572, -51066, -229038, -51462], [25286190, 42416, -11346, -138604], [-11780476, -62946, -38594, -165502], [-50262, -104672, -117398, -144930], [1765978, 106956, 116500, -91144], [577617, 7838, -114429, -135464], [-6219824, 17878, -31784, 17202], [-2284241, 68950, 21579, -48140], [32517996, -57859, -111560, 52037], [-21917888, -21009, -47830, 27453], [-18050706, 23688, -110712, -52968], [-6531263, -73942, 86681, 121580], [-9452250, 6462, 194306, 7542], [5027424, -173372, -74930, -73354], [16111043, 69477, -25457, 101615], [20266977, 126626, 171261, -48664], [-5344012, 45893, 22190, -173569], [-2669472, -98518, -264036, 156832], [-17638051, -19421, 59595, 71931], [45356532, -110267, -84826, 75695], [12524860, -269993, -174092, -59381], [34012814, -74121, -133668, 40192], [-5195310, 214792, -122948, 166784], [20057132, 29683, -159714, 157216], [-22416500, 141617, -57126, 79431], [21975025, 92135, -195921, 202167], [-7146184, 154438, 103736, 139608], [20431043, 18410, 452047, 31128], [-14199930, -53040, -25576, -147546], [-4510963, -44891, 259209, -144237], [45659836, 28951, -219566, 84760], [7339780, -4300, -261232, 180626], [5494988, -24227, 196152, 30336], [13193312, 11244, -89738, 235570], [-750380, 190376, -407320, 55004], [-34504988, 203018, 61982, 140408], [6360620, 74416, -176490, -201638], [12241171, 144194, 117761, 64864], [-12755304, 36811, 17876, 242136], [-26486774, 242202, -122254, 84694], [27477584, -237216, 87762, -242440], [-7050889, -167194, -38267, -135704], [4402955, 57391, -32751, 54183], [1943324, -243693, -278684, 110928], [-9484004, 251169, 71510, 334890], [-2546066, -88386, -124820, -79718], [-15164346, 195113, 243690, 27568], [-35744631, 76823, 197299, 404979], [-40761787, -44832, 213771, -203826], [14451788, 104055, -706028, 182966], [-52150650, -268380, -115156, 105434], [-17654416, -43435, -388492, 18989], [37103606, 211112, 20990, -217986], [-63458992, 167890, 377156, -131510], [-102138163, -74915, 82041, -189213], [32720872, 112456, 403230, -133620], [-17952834, -252123, -180970, -296340], [-37287532, -74728, 291484, 114976], [-35063887, -50473, -339493, 81095], [-36291161, -128660, 29625, 217580], [-60160472, -231365, -582614, -78831], [-64204718, 222739, 74340, 409674], [18746570, 71512, -535548, -173244], [-1243187, -37919, -764471, 84603], [30218378, -22218, 223786, 241650], [-23436508, -122594, 386892, 27362], [-34610400, -272904, -31792, 152034], [-11994451, -87910, -436661, 191474], [-37750556, -253132, -177742, -77960], [56491042, -194199, -175918, 52309], [11217635, 71695, 41883, -390311], [-34585295, 197684, -54241, -158458], [-44906012, 384492, 238400, 122624], [-33596474, 379237, -385002, 94356], [-2346618, -383299, -280892, -14615], [-93728340, -244046, 39922, 264248], [-50904170, 254756, 353916, -137640], [-1320810, 218679, -612300, -3819], [-15724812, 336816, 37346, -267702], [-78344488, 80601, 691594, -269662], [-53120389, -38043, -176741, 317683], [14097590, 228581, -117380, 173358], [-48859448, -121102, 338180, -307636], [-27507702, -249855, 213402, -175785], [13966874, 395032, -402352, 8204], [19595188, 203698, -86556, -53900], [49600768, 186540, 393428, 71276], [-5869786, -374692, 73612, -565998], [9307695, -382428, -241369, -405498], [72450892, 96003, 300662, -260324], [-58976870, 472735, 498354, -135396], [-34003303, -347061, 640663, 222071], [-50023204, 124478, 127514, 32042], [-9090052, 8928, -716352, 368252], [-52909256, 58965, 500810, -104530], [-88110094, 46468, -774388, 19328], [10421992, -106872, 480664, -105594], [-15306760, -365098, 364906, -519280], [-76581266, 19238, 156098, 567828], [58481947, -551202, -691757, 375676], [69197191, 223744, -264171, 451056], [70677798, -474585, -425736, -165847], [-39420420, 153130, -818390, 228808], [-66844044, -667822, -893514, -66300], [-70209331, -47351, -427887, -236161], [-98071624, 343384, 314076, 170682], [-3586152, -352278, -131536, -825376], [-97484420, -76651, 51138, -58509], [30565846, 21048, -384152, 35748], [-11233997, -275430, -254183, 67562], [300961, -142837, 472965, 257961], [95566102, 487096, 285444, 11460], [-75605490, 807959, -404990, 488045], [-40620848, -532876, 384440, 226608], [47946945, 257985, -174477, -253349], [58893228, -600498, 83886, -300942], [-7170914, 622451, 732312, -220895], [84644342, 97331, -48418, -168831], [-83345662, -780118, -1084498, -439450], [94857947, 388586, 162463, 215684], [102513812, -501596, -735738, 242466], [126800644, -138316, 259820, -81684], [-8302616, -306745, 911706, -181922], [-38717272, 643246, 199788, 59900], [-89905525, -309876, -210771, 559572], [225166178, 39858, -521136, 254728], [13550018, 170995, -1091646, 224875], [-31896248, 502374, 487588, 240366], [-115958524, 216349, 573912, -13180], [135583366, 194238, -614930, 67088], [9273223, -73030, -1095649, -407736], [-461288, -347612, -703412, 670824], [-34871778, 925794, 212852, 978146], [53191389, 535783, -1253887, -45271], [227132820, 15142, 467050, -146548], [40340236, -787451, -598022, 259379], [271886, 209592, 186136, -324016], [-51979233, 467395, -1271791, 61925], [194338242, 240686, -25950, 47128], [-27733838, 305413, 83872, -622199], [119054746, 381832, 172068, -726446], [56167381, 83157, -1489735, 10107], [-11788620, 597996, -165276, 229260], [184689520, 20682, 786058, -338332], [187405802, 21534, 667048, -222616], [-114944990, -478149, -1813070, -74456], [125916048, 322680, -1468870, 104844], [56072913, 107, 503479, -498893], [60253406, -262356, 363354, 149480], [12470144, 103545, 1183894, 93882], [108142414, -852296, -548280, 37042], [94542344, -615482, 738164, -3936], [229172330, 553442, 379942, 215606], [-174404264, -144279, 806720, -215104], [100528296, 409499, -1451234, -4592], [-197047142, 244572, 466828, 160268], [119253342, 195303, -573474, 574583], [155334026, 436252, -161938, 620416], [-35441850, 940697, -76268, 583483], [89573970, 542146, 968302, -500394], [-30046374, -217029, 136308, 554937], [-112701234, -66218, -902816, -166200], [19183866, -604341, 1620822, 1595], [72960662, 778875, 1355604, 146996], [195320329, 333962, 1534895, 388086], [149033803, 682068, 607987, -346690], [-51739014, 520896, 1579416, -487400], [-47722197, 895071, 4641, 509121], [-147453186, 886309, 416410, -435360], [-240125638, -695289, -1257014, 62579], [61332768, 240036, -900024, -571350], [-7120122, -710843, 716968, 458360], [-40819400, 154754, 1294928, 710870], [110313584, -40616, 615564, -670434], [44244382, 313138, -697148, -263586], [-27134974, -657327, -1481286, 463924], [39342837, 125128, -353291, -522514], [-103790436, 863584, 814238, -295078], [40840746, -37996, 1177698, 132854], [-326985788, 547664, 69794, 132612], [-16134482, -380137, -1240566, 742515], [6254475, 114035, 398035, -398219], [-196799829, 308793, 741987, -214209], [-105909804, 737451, -159870, 457118], [-44745748, 491076, 715048, -927698], [-140674718, -1016652, -2389100, 192428], [-14405866, -1256396, 137220, -27480], [-23182976, -707548, 42972, 608862], [-230353210, -575220, -940502, -40666], [231665853, 48760, -18245, -715712], [90483581, -1596676, 103453, -554622], [-188166510, 17574, -154728, 476262], [217291214, 765150, 1505334, 863694], [33118020, -1386204, -1205986, 765376], [-225549107, -325373, 1049821, 10857], [-112794844, -524918, -1237864, 239588], [-61057686, -31875, 1666632, -772459], [-63211729, -731793, -126107, -1295499], [106093088, 930542, 1508548, 83574], [-75506048, 381328, -649650, 1110692], [-7146284, -851098, -1329648, 1276472], [80473195, -804799, -1253193, 421439], [-104974706, 147580, -176940, 1134408], [223872704, 292138, 712902, 22382], [-60360661, 459462, -2762805, 2924], [9041995, 325811, -1276767, -606963], [143620396, 1367599, 2620462, -351636], [267886795, 81694, 5301, 1095362], [-71267962, 7310, -209152, 833262], [-105873434, -1371853, 587702, -1141348], [-95085584, 1792199, -279192, 315684], [274239198, -1027678, -958098, 359322], [-172660010, -808766, -3048240, 62588], [-116159227, 357108, 810255, -27986], [71786688, 1107775, 2280980, -81202], [-218877996, 565348, 1805578, -832134], [250270570, 60527, -379542, -556641], [-17117385, -224205, 2048691, 599709], [-185489615, 541664, 1506011, -1120018], [411734578, 429172, -811382, -955346], [-9670911, 748610, 671061, 1103800], [92697110, -167255, 1107986, -799468], [-204925081, 719073, 2514841, -669555], [162530030, 720481, 1008014, -745624], [8474298, -136818, 42420, -434028], [339045254, -534422, -1229152, 976052], [131646140, -186453, -1536698, -953188], [402380806, 370386, -795638, -1189060], [-206516784, 842911, 1140068, -15219], [54496997, -1529891, 2500947, -783061], [256376548, -1818698, -360840, -1852230], [14015632, -888962, -1217034, 547376], [-206078427, 1720297, -546865, 291083], [419774114, 530910, 2018058, 588372], [-167134993, 722939, -151141, -481775], [75739283, 1913158, 606683, 972848], [-156342196, -860313, 3602590, -521886], [72033792, 1219536, 162252, -425028], [8146718, 744852, -3399390, 158586], [-219966102, -341530, -477960, 1829600], [257293698, 1501302, 2242404, 1325852], [127291988, -1091314, -18304, -83518], [355936592, 1235178, 1563276, 576582], [-374188430, -1072716, 208664, -1391400], [52889312, -553774, -1657348, -783198], [95753611, -1141173, 953813, 211307], [178009799, -1300088, 2206175, -765630], [-15934068, 338313, -3264810, -676399], [75637276, -15058, -1279392, 1262816], [-1383831, 465870, -48907, 197688], [-10166284, -1013489, 1273596, -267819], [-393629552, -937392, -2887792, -262822], [154806518, -302704, 30788, 1422720], [435140302, 164500, -401154, -438932], [74205603, -1063379, -1732921, -2426521]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_570_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_570_6_a_j();".
// 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_570_6_a_j(:prec:=4)
    chi := MakeCharacter_570_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_570_6_a_j();".
// 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_570_6_a_j( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_570_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,6,sign)));
    Vf := Kernel([<7,R![314136496, -3731652, -43328, 108, 1]>],Snew);
    return Vf;
end function;