
// Make newform 2160.4.a.bf in Magma, downloaded from the LMFDB on 07 December 2025.
// 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_bf();".
// 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_bf();".
// 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 := [-44, -60, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0], [-2, 6, 0], [-118, -9, 3]];
    Rf_basisdens := [1, 1, 4];
    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 := 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]];
    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], [-3, 0, -1], [6, 1, -1], [-7, 1, 2], [-28, 1, 1], [-7, 0, -3], [16, 0, -1], [12, -4, -5], [-108, 5, 3], [11, 4, -3], [-38, 6, -2], [-94, 2, -7], [94, -4, -17], [-74, 8, -6], [-92, 0, 0], [101, 4, 11], [-345, -18, 23], [170, 2, 10], [149, -12, -25], [-259, 9, -22], [26, 2, -36], [108, -10, 20], [397, 16, 19], [406, 0, -53], [-787, -6, -21], [466, -4, -48], [426, -4, 6], [726, 17, 47], [-1136, 46, 14], [524, 3, 83], [-10, 46, 56], [-1821, -6, -15], [950, 16, 109], [249, -3, -34], [2570, -11, 29], [-341, -48, -118], [1736, 4, 84], [1392, -20, -58], [266, -24, -74], [1579, 44, -41], [1824, 18, 2], [2335, 14, -91], [-168, -22, 76], [-1673, 23, -34], [-2577, 70, 21], [1012, 2, 128], [2174, 86, -86], [2582, 66, -122], [1312, 26, -210], [2318, -104, -48], [-735, -20, -148], [-670, -39, -241], [-352, -27, -175], [1204, -28, 24], [4050, 32, -105], [1, -126, -59], [-938, -62, 156], [1444, 16, 178], [-3756, 80, -44], [4430, 18, 112], [2286, -6, -71], [2016, 98, -44], [-4405, 72, 147], [380, 104, -236], [3303, 28, -251], [1593, 170, 109], [9706, -18, 30], [-6183, -92, 187], [3396, -81, 247], [-3486, 250, 154], [4641, -50, 183], [1935, 131, 178], [1113, 170, 69], [1874, -148, -335], [8726, -24, 41], [-2106, -41, -609], [206, 124, -6], [-11, -268, -322], [620, 251, 115], [-7793, 12, -293], [-2874, 104, -290], [-1938, -138, -200], [5520, 136, -88], [32, -114, 296], [-1184, 270, -134], [-9038, 120, 102], [4700, -236, -246], [1533, 10, 415], [7436, 50, 180], [-1610, -302, -138], [6061, -234, -427], [3978, -256, 254], [-6112, 48, 148], [-4476, -44, 187], [14888, 68, -261], [-6346, 38, 102], [9701, 0, -342], [-1641, -110, 777], [6715, 108, 138], [-11876, -90, 308], [-2244, 266, 294], [4884, 92, 876], [-139, -486, 255], [-1137, 154, -229], [6382, 410, -264], [-7702, -115, -905], [-11678, 146, -240], [-4464, -38, -345], [885, 158, -889], [5195, 37, -84], [-13410, 175, 553], [1937, -164, 503], [3569, 538, -131], [-13480, 14, -290], [-1918, -130, -431], [8470, -432, -638], [16024, 138, -448], [-22120, 160, 120], [13213, 64, -469], [3707, 102, -283], [3848, -172, -300], [-13822, 28, -462], [3460, 126, 1014], [-1964, 340, -693], [-9053, 322, 99], [-25690, -152, -104], [3728, 200, 36], [5334, 386, 8], [-4784, -318, 232], [-590, -152, 383], [-13423, 541, 186], [-3087, 59, -432], [2794, -10, -312], [-613, 644, -228], [3474, -42, 1080], [-5435, 424, 280], [-10268, -22, 828], [-16440, -544, 152], [3244, 6, 558], [-14960, 752, 530], [5259, 198, 619], [-1676, 792, 682], [1687, -570, -753], [-10556, -314, 94], [24167, -703, -448], [-23018, 82, 560], [-35357, 288, 213], [-21530, 96, -725], [13091, -97, -714], [-9430, -720, -532], [4893, -338, -243], [16070, 508, 1363], [-13967, -488, 344], [8520, 528, 352], [-24844, -205, -135], [7234, -226, -1150], [13803, 410, -491], [17544, 148, 1827], [-2252, -718, -218], [-26900, 1055, 795], [9951, -1058, -995], [-37496, -307, -211], [-24334, 57, -885], [-12520, 168, 503], [-15433, -537, 754], [9526, 569, 1185], [-11747, 68, -716], [22564, 710, -314], [-30294, 363, -19], [9126, -126, -160], [-2548, -738, -2066], [30661, 262, 885], [-27797, 571, 766], [-6442, -64, 358], [-4128, 746, 384], [19682, 272, -868], [6439, 708, 1247], [3366, 594, -904], [-27769, 262, 1331], [-3276, 400, -1628], [4738, -203, -675], [-59024, 97, -95], [-10356, 184, 1644], [34106, 256, 1216], [-6535, -139, -394], [18955, -28, -1150], [-37729, 26, -955], [-48388, 94, 634], [26893, 608, -1193], [-11376, 326, 326], [3931, 230, 1883], [-7778, -880, 67], [16076, -88, -448], [-6510, -838, -1716], [-11991, -1254, 807], [29685, 1013, -1102], [-5542, -446, 112], [-4246, -528, -854], [20214, 1244, -361], [5189, 606, -1443], [-16987, 648, 1263], [1391, 38, -971], [7902, -637, -619], [-17990, -34, -3110], [-20751, -605, -1456], [19186, -1320, -364], [-5230, 462, -280], [24021, -614, 453], [-8009, -970, 2171], [30274, -844, -437], [10275, 364, 1791], [-32602, -1228, 1144], [5330, 162, -1344], [5323, 444, -620], [50968, -72, -106], [-53054, 660, -364], [42740, 772, 1029], [34102, -680, -320], [-29149, -1166, 739], [-2584, -703, -805], [-4648, 418, -352], [15572, -954, 644], [42846, -1026, -1692], [-12059, -1344, -2181], [-13440, 1757, 1821], [2478, 774, -1012], [-25435, 1628, 1053], [68544, -343, 985], [-5219, -1276, -3169], [-13608, -952, 1754], [44564, 1043, 345], [7466, 1284, -296], [40897, -998, 1001], [-36912, 540, 2508], [-103863, -68, -2], [16860, -2014, -1552], [39086, 892, 2902], [-16304, -854, 1916], [-37146, 962, 1362], [11405, -86, -587], [52675, 274, 1113], [-49851, -138, -1957], [-20040, -78, 3178], [20806, 934, -374], [34923, 342, 2761], [3000, 1431, 1871], [-17900, -790, 1066], [25524, -1632, -745], [-38894, 785, 513], [48844, -1184, 1312], [11848, -1880, -3808], [-21713, 2442, 329], [41746, 442, 4404], [26080, -671, 1577], [6795, -478, -3381], [-66638, 6, 67], [13850, 1880, -1232], [6994, -604, -2484], [29881, 158, -2951], [-98742, 636, 800], [-74405, 348, -1103], [48911, 1013, 464], [12368, 1071, 2943], [-19036, 1896, -492], [-7730, 1248, 1284], [-46174, -1012, -5078], [33586, -30, 529], [26048, 2218, -1888], [25921, 1826, -551], [-19549, -912, 2820], [61466, -2056, -1112], [-10763, 191, -3436], [51878, -828, 180], [67989, 986, -863], [47754, 680, 5106], [-27226, -976, 3434], [24544, -2126, -1257], [57386, -125, -459], [-15200, 176, -1599], [-31280, 1817, 3351], [-19272, 136, -5457], [40789, 226, 2809], [60939, -364, -882], [-30512, -408, -4066], [19865, -2148, -1167], [42956, -636, 926], [-15909, -1797, -2538], [-35090, 1484, 396], [-35360, -712, 617], [11678, -1390, 4198], [-3602, -2297, 1553], [74244, 1100, 2216], [34754, -1210, 1704], [-23820, 240, 1686], [-21117, 198, 2975], [16408, 2284, 674], [85994, 333, -1569], [-40937, 602, -2577], [29815, 1014, 3979], [30366, -224, 5350], [15584, -1387, 3027], [35684, 2692, -2290], [-1309, -2514, -2851], [84226, 1006, 4], [-82708, 110, 1558], [-59169, -1906, 3421], [5700, 1400, 2990], [37535, 951, -990], [-3534, -148, -15], [80, -2428, -542], [-89754, 298, 2836], [15771, -176, 2822], [90184, 492, 3495], [39280, 918, 7365], [-58472, -1861, 2983], [-63294, -2272, 1946], [66030, 2438, -1178], [-9394, 376, -316], [22633, 1020, 5493], [89299, -2102, -1497], [147648, 568, -761], [56048, -1692, 900], [24718, 1325, -4585], [-7443, -2308, -4708], [-63920, -904, -2300], [48828, 2856, 584], [-90608, -104, 3295], [-18102, 1382, -454], [105643, -1972, -1907], [53950, -362, -4892], [58537, 2053, 2850], [-42750, -708, 2548], [-6104, 390, -7336], [49274, -4272, -3988], [-46207, 2896, -1943], [-10678, -382, 4504], [56832, -3066, 353], [-72268, -544, -1202], [-30581, 1611, -106], [143690, 473, -1541], [-128650, -988, -1524], [69117, -1565, 240], [-53624, -2060, -236], [33456, 2535, 4507], [127522, 1724, -1348], [-17708, 1236, -5464], [103092, 768, 1632], [51878, -2576, -4356], [-93259, -1452, -4215], [-29487, 536, 1361], [-34738, -880, 6705], [-46196, 376, -62], [-15459, 1452, 5329], [-29254, 2215, -4531], [-76326, 1240, 2518], [650, 911, -4843], [26458, -2469, 813], [81372, 552, 1031], [-65585, -2032, 601], [-133896, 2612, 2548], [26734, -1624, -1342], [-11416, 2111, -1493], [-77305, 1604, 2326], [72851, 112, -3181], [149360, 1026, 5168], [-38279, -1146, -3621], [-95289, 1292, -1308], [4736, -2181, -301], [-24005, 3268, 6865], [-84462, -1876, 1651], [-119022, -1384, 1592], [-71921, -2106, -4445], [-24455, -2029, -716], [8882, 687, -5383], [-70272, -3506, -48], [-18877, -536, -7445], [-42262, 3122, -2036], [-68111, -3190, -365], [-155950, -312, -2319], [-111534, 799, -3339], [85655, -518, 3123], [87850, 2635, 4709], [-116843, -3168, 2371], [113386, -3848, -3561], [100040, 152, 3704], [11373, 2128, 667], [-11701, 360, 7382], [-197382, 1400, -93], [-164, -1366, -7525], [-65740, -1340, -7458], [129526, 1660, -3358], [-53447, -4236, -1912], [159602, -234, 2434], [30937, -3780, 3161], [-15675, 1490, 289], [75076, -3214, 1884], [17784, 2920, 498], [-53312, -3200, -8335], [-19922, -660, 7762], [7570, 1631, -2343], [-35392, 1760, 8684], [-7646, 2523, 1813], [-17648, 692, 966], [7892, -1508, 8196], [-213787, 359, -120], [-120586, -1480, 1924], [-95351, 394, 297], [-115014, 313, -1757], [-123630, 1242, 3020], [16820, 1646, -6158], [44332, -2328, 1818], [12447, 4862, -3951], [130325, 1996, -2545], [54794, -3396, 2336], [15712, 472, -6894], [-11501, -532, 3907], [77550, 206, 5540], [-129056, 1556, 2979], [-49928, 2912, -3825], [-134706, 1778, 5560], [-151970, -712, -4511], [117624, -903, -3275], [-88178, 2766, -788], [-107500, -1698, 6410], [-162778, -1286, -294], [31058, -3850, -6506], [62560, -4218, -5946], [81142, -3092, -4976]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_2160_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_2160_4_a_bf();".
// 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_bf(: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_bf();".
// 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_bf( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_2160_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<7,R![-5524, -588, 9, 1]>,<11,R![76426, -3081, -18, 1]>],Snew);
    return Vf;
end function;