
// Make newform 2160.4.a.bt in Magma, downloaded from the LMFDB on 25 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_2160_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_2160_4_a_bt();".
// 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_2160_4_a_bt();".
// 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 := [-5, -7, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0], [0, 12, 0], [-28, -6, 6]];
    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_2160_a();"
function MakeCharacter_2160_a()
    N := 2160;
    order := 1;
    char_gens := [271, 1621, 2081, 1297];
    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_2160_a_Hecke(Kf)
    return MakeCharacter_2160_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 := 4;
    raw_aps := [[0, 0, 0], [0, 0, 0], [5, 0, 0], [8, 0, 1], [-2, 1, -3], [16, -1, -3], [-9, 4, -1], [65, -3, -3], [9, 3, -10], [20, 2, -3], [93, -2, 1], [-46, 2, 8], [22, -12, 1], [-74, 10, 11], [88, -7, 24], [-169, -1, 5], [320, -3, -15], [181, 2, 42], [362, 6, 46], [606, 5, 3], [454, -9, -23], [43, -15, -17], [523, -13, 2], [-590, -16, 55], [-112, 26, -56], [-404, 12, 28], [548, -42, 24], [572, 17, 110], [681, 7, -50], [-182, -25, -80], [66, 56, -90], [278, -30, 56], [-331, -11, 135], [876, 36, -48], [-1974, 16, -37], [8, -9, -110], [-302, -7, -51], [906, -60, -20], [1357, 58, -128], [-2303, -8, -45], [1560, -102, 22], [1313, 103, -18], [1078, -18, -52], [-204, 91, 137], [-487, -127, 21], [-1620, 70, 14], [4059, 8, -73], [-90, 52, 212], [2523, -34, 18], [2643, 39, -100], [-922, 38, -4], [-362, -20, 226], [-529, -31, 96], [-1372, 210, 86], [-643, 129, 197], [2180, -55, 308], [-1254, -4, 26], [-643, -30, 305], [910, -1, 77], [1300, -86, 179], [1798, 148, 93], [-1695, 75, 139], [214, -156, 212], [-1900, -67, -75], [1868, 240, -114], [5535, -46, 189], [2176, 182, -182], [-3992, -191, 69], [572, 78, -48], [6865, 56, 196], [1910, -48, -350], [-4186, 100, -214], [4560, 86, -271], [-308, -92, -450], [-7785, 64, 91], [-423, -148, 126], [5234, 108, 377], [6852, 23, 65], [7618, -32, -236], [-3207, -47, 134], [534, 137, 201], [3119, -150, -220], [-1960, -205, -291], [5800, 285, -721], [209, -190, -81], [-3457, 429, -28], [2716, -60, -467], [-9128, -96, 198], [7870, 16, 142], [4402, 278, -542], [-7589, -52, -130], [-586, 205, 133], [7290, 342, -233], [-1562, -358, 142], [-2523, -234, 143], [-8719, 157, 182], [3388, 68, 560], [-3170, -244, -175], [-11548, 84, -189], [9438, 239, 302], [14326, 198, 279], [-6630, 6, 662], [-11748, -181, 146], [17112, -70, -109], [1409, 84, -645], [-6598, 251, -327], [-7267, -301, 554], [-5007, -205, -147], [5744, -523, -157], [-7911, 389, -676], [8918, 46, -169], [16832, 14, 68], [-8509, 7, 437], [-404, -286, 630], [-2325, -409, -713], [48, 62, -564], [-2424, -632, 147], [-10547, 54, -710], [-7113, -336, -745], [12100, -287, 973], [10134, -91, 1086], [-3896, -333, 661], [16042, -463, -556], [-9149, -668, 280], [-4109, -252, -1317], [-14506, -38, 844], [7930, 143, 362], [15702, 196, 620], [18188, 310, 310], [9488, -224, 644], [-21589, -222, 125], [-3960, 430, 576], [-6829, 677, 443], [-7530, -530, -830], [-11668, 932, -13], [-12091, 865, 430], [-19569, 114, -225], [-946, 134, 61], [-13723, -421, -973], [5134, 50, -851], [-14084, 591, 738], [-23610, 572, -368], [-1490, -876, 179], [-2375, 732, -206], [18658, 345, -636], [27988, 382, -94], [9304, 76, -1450], [7755, -746, -99], [-15941, 126, -171], [1141, 465, 1744], [-22882, -605, 823], [-13180, -582, 1907], [-28008, 290, 845], [9717, -947, 56], [8532, -694, 228], [30068, -297, -17], [-4744, 10, -2888], [11886, -376, 325], [-29636, 154, 966], [5010, 268, -500], [16567, 533, 1206], [-34810, -460, 1064], [-4766, 392, -1820], [8694, -1456, -980], [-32162, -990, 966], [905, -411, 2144], [2511, -819, -1141], [10366, -1637, -821], [-14977, -905, 2016], [-30899, 584, 123], [30940, -132, 380], [19271, -690, 850], [-22968, -51, -2831], [9004, -1510, 404], [-19873, -493, -1637], [5472, -1006, 291], [9285, -335, -395], [-20716, -466, -1685], [-10326, 1032, 199], [21290, 501, 2530], [-13358, -1240, -531], [36164, 418, 2174], [37594, 632, 488], [-8330, 139, -3748], [-17409, 1858, 1132], [27132, -2, -1336], [-188, 709, 395], [-4740, -1130, 626], [15061, 211, -1048], [-3372, 643, -847], [-15322, -518, -420], [-31163, 536, 796], [3207, -305, 3935], [-12224, -1174, -3444], [-43573, -517, 754], [-40047, -82, -427], [-831, 1617, -1296], [-11332, 1258, -346], [29970, 1024, -322], [-27696, -813, 1018], [26182, 194, -3047], [1712, 1296, -3258], [9446, 858, 3360], [-1917, -1562, 408], [-3716, -769, 847], [-21254, -286, 1452], [-19720, 1832, 1206], [855, -2364, -130], [52052, 540, 1556], [-3972, -1264, -2680], [-46464, -905, 65], [1150, -376, 4719], [4656, -1936, -556], [-8772, 617, -3066], [8308, -2214, 1932], [-1903, -1344, 26], [1218, -2046, -581], [13248, -1992, 1088], [-4667, 424, -1586], [-14693, 1282, -967], [34338, -328, -380], [5509, -1979, 395], [8636, 2008, -3225], [37222, -1158, -1187], [27135, 687, 1626], [18403, 1389, -1434], [19473, 1343, -1393], [4870, 51, 827], [-5542, 1180, 3442], [19460, -310, -2136], [54642, -533, -649], [32405, -3473, -2005], [-36640, -536, 304], [50730, 1308, -884], [3924, 1070, 387], [-36225, 588, 1062], [-23027, -37, 2980], [-17207, -1456, -3725], [51102, 1786, 32], [4314, 91, -1989], [-18756, -49, 362], [2817, 749, 1279], [2986, 1562, -1726], [-52567, -831, 370], [-27562, 366, 1378], [-158, 2644, 1850], [41884, 462, 1550], [-47456, -1845, 4559], [2660, 2794, -1812], [28135, -3192, -2704], [-1562, 1540, -4286], [2314, 2356, -4438], [243, 1375, -624], [-14187, -1620, -770], [-37813, -572, 655], [1752, -1640, 2544], [1749, -632, 6028], [-30664, -1848, 179], [20547, 1121, 1437], [20560, -221, -1553], [11222, 1696, 3117], [-47075, -930, 926], [45935, 2361, -982], [55108, -1076, 1904], [-50531, -411, -3171], [35996, -984, -4344], [72128, -666, -1572], [-43614, 1040, 4296], [19718, 438, -880], [39002, -2432, -3078], [28835, 10, -3432], [22730, 6, 1650], [11850, -71, 7605], [79005, 772, 4241], [-6850, -1143, 5901], [42784, -74, 2151], [41589, 977, 4052], [63745, -974, 3968], [-16703, -1465, 4226], [25378, 919, 1549], [12152, -1945, -5242], [5209, 2521, -3521], [-49551, -1616, -1994], [22439, 1352, 4996], [14172, -1916, 3052], [45396, 2091, 1505], [-63826, 1284, -4302], [-1150, 702, 356], [96591, 468, -2955], [36992, -2062, 1244], [-87072, -1276, -704], [-48603, -787, 5520], [-41862, -1250, 888], [-49298, 1808, -3566], [182, -2387, -3857], [-13992, 2430, 4986], [-1291, -1215, 3667], [-90786, 1042, -1308], [15664, 1986, -2856], [-71564, 1108, -3557], [10562, 2937, 7121], [-4645, 298, 4469], [-12496, 2326, 508], [-18853, 397, 510], [-1757, 567, 2167], [100886, 2441, -4025], [-59580, 1211, -1986], [-26621, 943, -5604], [57130, 635, 6871], [-16282, -1695, 7899], [-7893, 56, -3082], [76176, 2576, -4038], [-66652, -4190, 6998], [79760, -3052, -1035], [75659, -1593, -1446], [-65801, 1152, 3750], [76264, -898, 3912], [-81386, -3631, 6163], [-14084, 1291, 1743], [-47974, -2198, -1884], [39415, -249, 4029], [5500, -1102, 10226], [-65536, -1610, -538], [-54700, -1914, -3846], [-94701, 317, -1505], [3038, -2843, -4762], [-25477, -1703, -933], [10772, -288, 5518], [-130880, 1852, 1328], [-32939, 3491, -2603], [-28990, 2212, -6876], [-83534, -2954, 992], [24760, 1571, -3010], [-10936, 2697, -584], [42900, 2586, -4262], [-73132, 1935, -5494], [-92289, -2605, 2152], [-62625, 3446, -3849], [-19534, 147, 3328], [-155778, -854, 1503], [-51012, -3018, 9010], [-38889, -4882, 705], [51280, -3166, -3007], [36267, 938, 7619], [31978, -3275, 128], [22718, 2463, -7349], [97659, -386, -3280], [15168, 1932, -1094], [8736, 744, -2670], [42913, -1814, -6731], [-15052, -4635, -318], [90770, 1132, 266], [56908, 1280, 5081], [-98164, 2264, -314], [-48386, 465, 3548], [30791, 1282, 1371], [-14704, 3865, 3857], [47096, -3379, -6485], [-82990, -156, 7146], [-86519, -2547, 7208], [24380, 4267, 4875], [-57790, 5360, 438], [106116, 2825, -236], [-63342, -1762, -8802], [-19800, 2470, -8382], [-24008, 1289, -963], [93059, -633, 4439], [-134942, 4104, 1356], [31770, -5792, 988], [-25666, 3348, 4550], [9545, -2062, 6259], [-12313, -5587, -1644], [54994, 1364, -1295], [90629, -1008, 209], [177956, 688, 2754], [158006, -1098, 4856], [82206, 892, 7792], [-30942, 3527, -3341], [23202, -1048, -3498], [29210, -3446, 66], [-181808, -624, -3642], [47769, -4481, 4867], [61364, 1310, -3289], [42123, 3574, 8055], [116144, 1842, 602], [53936, 4495, -8312], [-8609, 577, -6403], [-86312, -3967, -6167], [-56186, -726, 607], [-5448, 1040, -2392], [-58926, -7103, 6818], [-19085, -476, 3679], [2814, -4064, 5508], [-210714, 1728, -1520], [110502, 1452, -1538], [22014, -1191, -10433], [-202229, 2326, 1767], [69980, -3226, -6175], [78687, 4979, 1403], [83064, 2296, -1014], [-117646, 312, 2948], [-25318, 1760, -14782], [-108536, -5048, 2315], [-123098, 3192, -5960], [13352, 4412, 3647], [-93823, -4648, -391], [-147346, 2278, -4148], [-81198, -6016, 714], [75088, 1544, -2998], [-90532, 7723, 5927], [-30826, 6510, -836], [65577, -4906, 867], [-24463, -6327, 5184], [-130131, 2806, 169], [-116114, 7316, 3306], [13352, 300, 10997], [73562, -5006, -6914], [-73936, -2384, 6192], [45049, 1553, 2551], [-64117, -3850, -3364], [-2656, 5834, 2978], [38230, -1442, 5394], [-164717, -1726, 2184], [-2866, -5946, 2362], [-94174, 3360, -1054], [-26167, 1179, -8953], [17413, -4922, -7118], [42870, -2584, 8832], [-19169, -2667, 2385], [-83078, -3293, -16639]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_2160_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_2160_4_a_bt();".
// 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_2160_4_a_bt(:prec:=3)
    chi := MakeCharacter_2160_a();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 4));
    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_2160_4_a_bt();".
// 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_2160_4_a_bt( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_2160_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<7,R![3560, -108, -24, 1]>,<11,R![44648, -3480, 6, 1]>],Snew);
    return Vf;
end function;