
// Make newform 560.6.a.s in Magma, downloaded from the LMFDB on 18 January 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_560_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_560_6_a_s();".
// 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_560_6_a_s();".
// 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 := [-1890, -463, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0], [0, 1, 0], [-309, -6, 1]];
    Rf_basisdens := [1, 1, 1];
    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_560_a();"
function MakeCharacter_560_a()
    N := 560;
    order := 1;
    char_gens := [351, 421, 337, 241];
    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_560_a_Hecke( : Kf := Kf)
    return MakeCharacter_560_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], [-2, 1, 0], [-25, 0, 0], [-49, 0, 0], [193, 4, 1], [26, 23, -2], [-416, -13, -4], [-315, -105, -1], [-371, -41, -17], [625, 48, 7], [2215, -177, 25], [-1351, 115, 5], [-3195, -319, 17], [4099, 1, -43], [13688, -93, 38], [-12516, -1060, 62], [12564, 644, 28], [-2769, -633, 79], [-23136, -996, -68], [11352, -152, 40], [-15144, 926, -118], [-537, 2168, -229], [3414, -2174, 114], [-74331, -1743, -183], [-53080, -2889, 236], [-24417, 573, 483], [85772, -469, 194], [-52780, -3650, -580], [5341, -1814, 23], [-124089, 6229, 355], [-135748, -8756, 284], [55521, -6453, -189], [-60243, 4393, -879], [-18514, 15488, 510], [-85012, -4334, -1230], [-181223, 14402, -439], [141854, -10216, 772], [-118442, -10452, 1570], [-188816, 25383, 1118], [-30220, 14675, -632], [-192392, 17108, -204], [-3920, -19136, -1018], [-179109, 4410, -61], [227057, 16437, 2357], [-124839, -24007, -1223], [20066, 32714, -578], [-86055, -37330, 2301], [-254742, 35017, -604], [-210812, -28877, 954], [504385, -8811, 2469], [116616, 46524, 3870], [54545, -22514, 1601], [-199109, 1161, -5753], [-505122, -17956, -7498], [962568, -7574, -758], [-90406, 68948, 4386], [-487828, 17978, 1822], [-310621, -44537, 2717], [802996, -24090, 922], [-22225, -24346, 5813], [314168, 90825, -6622], [-1030876, 9239, -7936], [923400, 24689, 8122], [1478397, 25071, 6839], [-881442, -80325, -2950], [1266912, -39862, 3350], [1203200, 89492, 5052], [383538, -58356, -4904], [-210105, 68573, 6433], [-376915, 21239, 5997], [-692090, 20541, 10710], [2166492, 4004, -4804], [-1512892, 36983, -15998], [-220809, 109355, -141], [2417588, 96216, -4008], [1939386, 148854, -762], [303921, 74818, -4061], [2355466, -52095, -9102], [-949417, 5460, -12287], [-1856812, 205606, -1434], [4752772, -156144, -5644], [-1315085, -107344, 193], [-323887, -126148, 11021], [-3443446, 78328, 4696], [1111826, -231960, 3138], [977247, 47525, 9089], [-2445533, -82050, 9569], [-583437, -195845, -18877], [334596, 204024, -15294], [75511, -253973, 5865], [-2283948, -102887, -24474], [6821697, 127283, -4749], [-5160898, 39832, 12646], [2772151, 153480, -8017], [-1286503, 165480, 13217], [3880306, -404581, -14552], [2533050, -251056, -8576], [-5507061, 99657, 18431], [-1667284, -34424, 8404], [4620773, -94420, -2885], [-5172551, 20277, 10515], [6264456, 32180, -19854], [-453188, 232808, 31220], [1565970, -261984, 29272], [-6917798, 238686, 17218], [-5764750, 939, 17022], [8088130, 147218, 29662], [-4365226, -95297, -21910], [-3322555, -204328, -35655], [-1643034, 515176, 18812], [-6985670, -226581, 33800], [3495634, 315544, -55524], [-6252004, 210506, 33966], [-3418513, 287793, -30931], [-6211769, -123470, -601], [-10509526, 199896, -26120], [-2912450, -161351, -20208], [4218150, 335622, 46938], [-5171717, 444949, 25723], [5536171, 131794, 44295], [-8329726, 747062, 30660], [-12862003, 159209, 29817], [-3573132, 391281, -43300], [-10590821, -317169, -11311], [-8300442, -178070, -35734], [-11625303, 589308, -13145], [4779131, 526242, -58779], [8402307, -215667, 70417], [-1993702, 871674, -42826], [7392986, -311149, 76830], [-7767767, 457204, -1695], [-7193122, -680510, 22442], [4712623, 920712, 11723], [-6456990, 771790, 13512], [-5544611, 1065083, 12013], [-4529138, -47192, -64124], [-7188682, -1219693, 97842], [346830, -68739, 13552], [2802208, -952761, 35324], [4160867, 153856, 20621], [6775884, 563602, 101312], [4714887, -37336, -1595], [-11728653, 947259, 35645], [6313018, -315780, -40906], [-10057007, -821067, -84363], [16695769, 480119, -92853], [-613126, -437364, -106896], [-22014982, -124392, -51296], [1348980, 58248, -48116], [7118143, -1350501, 16289], [-11618117, -1093619, -41429], [-8098488, -1501804, 38918], [-14533845, -108813, 22465], [9442404, 1006028, -88932], [-491639, -1444373, 67647], [-1019946, -280442, 90458], [2297289, -1226330, 4985], [11098342, 528158, -43464], [-866526, -72087, 119266], [29931495, 383863, 121719], [13467195, -36777, -64415], [-21203151, 42745, 36277], [-24376652, 607938, -11368], [25208131, -365113, 72765], [-6794189, -1785215, 50551], [-16171194, 1061871, 39468], [-27014600, -419344, -173488], [-10541848, 779867, -12804], [6137173, -605954, -31909], [13380796, 1545050, -19402], [12205396, 989556, -40136], [25129868, -1386990, -109618], [12949637, 473588, 161537], [2751788, -594078, -62178], [19209887, 718185, 103829], [31751228, 1139500, 119426], [-35456173, -1459086, 75471], [-13395171, -481746, -177977], [-26364558, -91298, 66654], [33653257, 1134617, -7483], [2333225, 2505489, -164857], [10195025, 19665, -156953], [-1615639, 1771487, 199421], [-3032214, -647668, 63568], [-15015013, 577283, -114523], [45733139, 1290277, -121089], [-10853134, -2925250, 42200], [-37368046, 2196965, 62020], [46023335, -700524, 16713], [7238035, -2964249, -67515], [-10293090, -1925028, -96628], [6086241, 2790255, -104577], [-9406019, 255982, -70655], [-854391, 2091553, -76675], [26113530, -2958554, 58898], [-22415478, 333251, -296514], [-17464997, 3335134, 99897], [-1097851, 2967953, 55557], [33770260, 3198279, -242304], [-2839152, -1241993, -85818], [-17062050, -2297456, 20128], [491142, -3315444, 3422], [-42709724, -1327894, 23286], [-22741087, -2446957, 332625], [58738181, 2207395, 16415], [-9798082, -1993871, 297198], [2803118, -2269620, -251706], [29572271, -1334521, 58069], [24043430, -467208, -199700], [-2404205, -2318985, 29397], [-638129, -4051349, 37927], [57389270, -727548, 76052], [-49701515, -4272419, 328579], [30508296, -3294129, -166818], [-34539292, 1250586, -272848], [-56234399, 1465341, -66043], [30141377, -4028733, -3765], [42468171, 1055303, 83379], [21775557, 1203087, -3441], [-53438946, 486872, -401984], [-32706656, 1836470, -215418], [-6664762, -4735812, 299982], [-10246755, -3801154, -228605], [38302648, 1627918, -64932], [-8353608, -977073, 194310], [-50213880, -1856998, 121590], [13653246, -3267043, 325638], [44668789, -1199192, -251095], [2111500, -310381, 101066], [18510914, 4025630, -124534], [-43196677, -1724505, -13729], [-58646752, 4125442, 105092], [-33985874, -3860002, -154966], [12996133, 3771042, 402379], [-81668356, 866747, -140070], [-30402534, 3378329, 214292], [-45845659, 733261, -541471], [-77517802, 2614434, 9292], [-114816655, -858566, 78405], [17021419, -2975795, 260409], [21235340, 4395612, 44048], [43087150, -750242, 593186], [-98457682, -103159, -439504], [-65740774, 3103780, 177108], [106356414, 3280639, -348382], [-28266383, -5237969, 171779], [-71938594, 1629294, -530238], [-81980508, 214250, 292000], [64788375, 156764, 226735], [65554257, -2131225, 430819], [-72582023, 158339, -103595], [-18850768, 3168478, -143342], [-58943442, -514758, 117282], [-101308834, 2860330, -135848], [-28193072, -1631558, -176246], [-69794007, 2149552, -102863], [-86533100, 1331974, 133130], [-87207212, -171856, 11812], [52255594, -246345, -606610], [90788768, 2188529, 148656], [-69499713, -5789531, 413277], [-126577844, -4665958, 421452], [-42991454, 3722370, 580796], [47851848, -8451567, -330976], [90111220, -2751622, -297442], [-6390103, -970581, -528429], [-64672819, 5570710, -10601], [121511934, 3255252, -4644], [-20379340, -1280528, -440944], [67296075, 744301, 339219], [-17966275, 4755453, 587481], [-15600879, 3899353, -128589], [-3185446, -3024599, -186982], [-49507132, -4137576, 459188], [90691176, 4181714, -79574], [84831186, -5584123, 43788], [-22205392, -1130916, 420044], [-127940642, -3359036, 540872], [-110395757, 3186112, -437827], [-47977524, -2177646, -511848], [29340808, 4826263, -57258], [-31891661, 7449860, -95849], [-155316588, 464660, -681380], [23144688, -8973702, 199906], [9579176, -9415481, -172226], [9702261, 3755104, -608743], [12848627, -7947119, 44695], [33309175, 3690609, 839471], [50566360, 6391140, 39200], [-106512560, 3766856, 92230], [125798567, 6400696, -673763], [-54815244, 7527857, -253834], [60260857, -7371799, 230029], [62108441, -893775, 304015], [-126944555, 2730135, -70167], [-166479381, -2909221, -52597], [12560312, 1639078, -1115004], [104396634, -6655081, 48278], [35889518, 3991610, -413102], [114328074, 292261, 1261828], [14213306, 721981, -347830], [11815702, 8852376, -656968], [78270877, 9306812, -407311], [-75794308, -2407372, -1320112], [226024147, 4071436, -498645], [50344557, 9309199, 519461], [62006441, -714497, -408769], [-183925552, 3733468, 301278], [-67594230, 10418098, -449906], [19459094, 3145378, -376676], [260015702, -3488762, -176166], [-116438081, -1320150, -990823], [41115234, 11538924, 561480], [-104998510, -4365356, -1496402], [-55219453, 834825, -477783], [-54479525, 60527, -126301], [38293974, 2670772, -33658], [-101324709, 614222, 949067], [45040144, 11230779, -96684], [179463683, -834908, 894013], [715428, 1049966, -1005312], [15476939, -15304725, 228699], [165145296, 4488142, -346910], [202907131, 428731, -199699], [228860574, 3758088, 93908], [-93081110, 7390178, -232412], [-191653491, -1695970, 643801], [49787026, 8383310, -384226], [73967897, 2196429, 241743], [167086281, 5976837, 1146873], [31726290, 11312172, 715244], [133754631, -10860349, 497731], [114638964, 9092478, -1053448], [80627272, 11933857, 95842], [166069626, 3432374, 833290], [-183402954, -5341415, -1010840], [86314783, 2165404, -992203], [-84805778, 13466940, -654196], [-150125005, 11237433, 19295], [-152090014, -10457867, 127484], [46436234, 2903288, -1307236], [125929812, -2084048, -1073342], [-270863021, -9357083, 954479], [139137641, -3175768, -667331], [-160269039, -16187113, 692749], [-353178384, -1475692, 79332], [54319612, -19422826, -1083394], [199274675, 5891427, -363591], [43252431, -12750183, -1190499], [-92014054, -4256879, -534958], [-155548792, 17501192, 288056], [136604359, -1686425, 297999], [107706513, 2278226, -179453], [-77115886, -5151067, -985412], [185611887, -9708768, -89443], [-10992276, -6465346, -1322402], [-207157780, 8067054, 878416], [-124476911, -8025153, -2445405], [791301, 13120991, -1530995], [121800394, 12967216, 848402], [-154538855, -9049767, 397801], [-46251820, -13188128, 1688722], [-131106039, -12078923, -508545], [-56573415, 359416, 868777], [5476728, 10138748, -203152], [10751269, -22204361, -390635], [-169698894, 18244953, 685578], [-369262113, 1007297, 561597], [-175084141, -599300, 487141], [46875797, 12668980, 470165], [-290610789, 946287, -811811], [-120244672, -1220848, -589504], [179284643, 8276974, -612739], [43024406, -9214544, 1446326], [43798582, -9044692, 1457304], [19398246, 1990566, -304782], [233822271, -4902834, -422665], [68512056, 5964529, 1680312], [50887394, 11710564, 1106288], [-324089888, 14665581, 25576], [280901976, -9230318, -777766], [-122298500, 504734, -2442570], [263103636, -19018888, -435508], [157703372, -22290450, 491470], [-164964605, -7225121, -1726083], [-34975134, -10917783, -673964], [-108737273, 13255314, -1005425], [-126088536, 8015029, 464176], [-151850114, 16632442, 24918], [532387284, -66879, 565630], [4722179, 14116104, 1105061], [-183698750, 4359133, -148686], [297652761, 4392518, -1536715], [-39275884, 19660280, -338260], [-32038549, -4673410, 395579], [148674910, 7303674, -548168], [248440307, 19709043, -926995], [-393057807, 3938401, 707485], [226337925, 13771480, -1136299], [500602430, -8420972, 591320], [5666995, -4969921, -451949], [-277568340, -17076732, 1603530], [-12230991, -16673533, -2643941], [-274479908, 19037051, 558304], [89764284, 15094164, 2499882], [87748386, 4573864, 2914042], [-1259602, -16999300, -529520], [-290763991, -14095004, 188555], [-407928540, 15599808, 977756], [-23908600, -7822020, 2531824], [-59452474, 16268725, 1597734], [-442299464, -5212094, 432462], [106924583, -1024835, -2227967], [-18247444, -14167408, 383264], [-199685961, -6538891, -273093], [-264866852, 13222016, -1293878], [-211251129, -17181974, 1009295], [252805194, -5395538, -1154994], [30091608, -5751738, 2257818], [137300684, 19189267, -1601542], [-62305821, 1838144, -2477455], [-392701378, 1852320, -2098540], [126176498, -31898048, -1044966], [337333182, -7285102, 165330], [339979744, -26772899, 220920], [-297964360, 4680135, 386716], [487014378, -2729262, 1654818], [593561736, 10544246, -596878], [291849991, 33819627, -2544879], [-10792035, -17533063, 1113907]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_560_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_560_6_a_s();".
// 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_560_6_a_s(:prec:=3)
    chi := MakeCharacter_560_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_560_6_a_s();".
// 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_560_6_a_s( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_560_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,6,sign)));
    Vf := Kernel([<3,R![-2808, -451, 6, 1]>],Snew);
    return Vf;
end function;