
// Make newform 414.4.a.n in Magma, downloaded from the LMFDB on 25 December 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_414_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_414_4_a_n();".
// 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_414_4_a_n();".
// 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 := [3240, -468, -219, -2, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0], [-1, 2, 0, 0], [-54, -168, -5, 1], [-108, -5, 1, 0]];
    Rf_basisdens := [1, 1, 18, 6];
    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_414_a();"
function MakeCharacter_414_a()
    N := 414;
    order := 1;
    char_gens := [47, 235];
    v := [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_414_a_Hecke( : Kf := Kf)
    return MakeCharacter_414_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 := [[2, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 1], [5, 0, 1, 0], [10, 1, -1, 1], [27, 1, 0, -2], [6, -3, -1, 2], [33, -5, 0, -3], [23, 0, 0, 0], [65, -1, 4, -10], [105, 7, -4, -2], [70, 5, 1, 3], [1, 7, 4, 4], [55, -13, 2, 13], [-2, -14, -2, -8], [-110, -20, 10, -1], [-119, 7, 14, 4], [264, 7, -15, 7], [375, 13, 8, -1], [-229, -7, -20, -4], [267, -11, -2, -6], [395, -6, -27, 28], [-566, 13, -9, 25], [-112, 5, 13, -76], [260, 48, -2, -10], [-545, 31, -34, -26], [341, 42, -25, 38], [-240, 15, -13, -47], [76, -1, -7, -69], [-556, -7, 61, -24], [-126, -8, 18, -108], [74, -4, -18, 14], [-296, -23, -91, -38], [-748, 0, -40, 0], [-972, -24, -32, 151], [-1025, -25, -22, 154], [-1626, -29, -33, -23], [-884, 68, -28, -50], [1783, 49, 72, -92], [-465, -51, 8, -58], [941, -19, 84, 66], [-554, 35, -21, -191], [-230, 100, -86, 102], [-815, -55, 42, 100], [581, -7, -26, -4], [131, -36, -77, -152], [-364, 24, 108, -210], [1119, 31, 122, 146], [696, 15, 43, -147], [-1752, 49, -57, 285], [140, 200, -116, -96], [744, -12, -108, -112], [1366, -58, 18, 362], [1860, 3, 95, -151], [-2089, 101, -56, 32], [-2022, -126, 176, 12], [-1057, -157, -6, 136], [486, 184, -106, 0], [126, -110, 158, 34], [-4330, -139, -25, 52], [-2917, -3, 132, -101], [540, 168, 4, -197], [-440, -100, 168, -486], [713, 11, -262, 220], [1496, -108, 14, 394], [-837, -147, 148, -178], [7136, 24, -152, 198], [-1908, 58, 48, 272], [1685, 29, 28, 66], [3325, -43, 194, -156], [1152, 186, 138, -92], [-860, 70, 30, 14], [2731, 2, -99, 336], [-2266, 231, -21, -187], [6111, 157, -116, 67], [1118, -142, 24, -124], [-3006, 162, -172, -205], [3364, -142, -56, 24], [-4554, 141, 31, -190], [-1335, -107, 166, -132], [2286, 297, -105, -491], [-178, -93, -317, 45], [5238, -408, -214, -130], [-806, -298, -266, 106], [6220, -544, 68, -108], [6902, -70, -200, 80], [-3237, 285, 444, 56], [-4596, -308, -154, 214], [8235, -105, -38, 16], [-7792, 300, -100, 440], [6466, -113, 57, -121], [6820, 160, -264, 380], [-7028, 200, -52, 744], [2051, -1, 120, 530], [790, -202, -96, 330], [4744, -290, 50, -398], [-10015, -25, 196, -194], [-7418, -455, -65, 538], [1535, -69, -146, 505], [5979, -257, 26, -464], [-1998, 706, 44, -6], [-4320, -54, 242, -883], [9346, 283, 313, -133], [-20990, 31, 89, 14], [-9923, -217, -364, 665], [4216, 440, -576, 406], [2996, -334, 214, -834], [4865, 131, 104, -924], [716, -196, 264, 956], [-1560, -392, 288, 334], [10765, 197, 334, -466], [-6790, 471, -161, -11], [-4878, -525, -523, 804], [13401, 151, 472, -83], [-3149, -106, -643, 26], [-6920, 967, -293, -230], [-15865, 243, -278, -299], [-4565, 745, 38, 420], [10901, -403, 314, -730], [-3338, 739, 249, -349], [9258, -245, -5, 105], [-1814, -70, -144, -254], [-12756, -504, -496, 155], [-5024, 694, 126, 518], [13808, -300, -340, -262], [7976, -262, 218, 1643], [1992, 589, 723, -275], [-6169, -103, 490, -712], [7213, 590, 763, -1248], [-13578, 661, -91, 755], [5166, -2, 324, -740], [3040, 520, -280, 1316], [-1235, -418, -193, 638], [8774, -243, -315, 1571], [-22, 920, -46, 0], [1800, 1324, 118, -658], [-11314, -790, 556, -217], [1155, -419, -1376, 627], [5830, 610, 196, 321], [13770, 264, -238, -480], [4038, 106, -352, 930], [-15025, -85, -654, 106], [-13993, -435, -144, 262], [2684, 647, 19, -7], [6465, 217, -22, 1448], [17222, 194, -204, 868], [2964, 334, -560, 1360], [-58, -250, -76, -1720], [-982, -378, 136, 508], [-4219, -793, 594, -36], [13720, -1060, 82, 694], [4924, 31, 551, 944], [14014, -250, -260, -870], [-9252, 456, 150, -1564], [14823, -155, 184, -1885], [-18194, 1264, -414, 582], [-8569, 468, -137, -2256], [16047, 741, -376, 476], [25382, 60, 416, 500], [3550, 700, 1490, -1073], [9381, -363, 292, 1290], [-14156, -287, -667, 958], [6307, -355, 396, -162], [-10792, -505, -1181, 1645], [18534, -1515, -5, 70], [-10556, 1162, 98, -1546], [549, 271, 1048, 678], [-13785, 439, 22, 1448], [-6994, -1938, 414, 810], [25797, -1179, 530, 846], [7396, -1133, -561, -727], [17336, 696, 206, 1690], [29484, 672, 652, -1324], [-28462, -204, -868, 836], [-13778, -196, -1222, 2096], [-29016, 513, -779, -1652], [11036, -300, -816, -1164], [18567, -1143, 940, 880], [-22059, -704, 1369, -1290], [20432, 927, -183, -121], [-4161, -143, 956, 74], [6794, -295, 527, -531], [-2020, 468, -614, 206], [-46440, 66, 298, -1224], [-198, -204, -1470, 338], [-4566, -474, 196, 1289], [-9730, 1320, 1388, -628], [-25577, -721, 926, 113], [-20153, 293, -522, -1742], [35662, -626, -354, 500], [-501, 397, 2274, -106], [-18850, 200, 662, 774], [11923, -679, 700, -2289], [12047, 845, -776, -896], [-17118, -423, 1339, -1127], [-12402, 381, -1205, 3144], [28048, 554, 388, -1208], [-23050, 813, -323, 43], [-8248, -1063, 1757, 220], [34856, -1060, 988, 2444], [11878, 1258, 1256, 47], [8570, -132, 1462, 396], [3290, 90, -830, 2134], [-35788, -1290, -956, 2496], [-23418, 489, 403, 697], [39421, 715, -1044, 1906], [13447, 668, 43, 1460], [35021, -289, -502, 328], [27845, 2147, -612, -1320], [16344, 1012, -360, 2186], [16945, 815, 514, -2666], [40847, -535, -852, 1156], [-37741, 258, 13, -2142], [34258, -749, -195, 419], [-50391, -1293, -116, 652], [25984, 1004, -1010, 1226], [-155, -163, -2122, 3474], [19298, -2464, 122, -1408], [-45042, -726, 744, -1324], [-27019, 911, -584, -4480], [6279, -1499, 1032, 174], [39031, 698, 641, -2254], [-28954, 668, -166, 1332], [-953, -1174, 357, 106], [20886, 1482, 2136, -260], [17403, 1669, 1636, -3626], [-36778, -709, 969, -2236], [-1044, -336, 1586, -5644], [-6253, 468, 979, 1362], [-36784, 2468, 804, 748], [-10445, 2111, -1078, 2072], [-8289, 1585, 860, 755], [40943, 324, 967, 1642], [47839, 151, -246, 752], [5777, -219, 1734, 3327], [-39560, 1102, -838, -3226], [38100, -1676, -486, -3442], [-684, -1014, -2334, -2185], [-14848, 1118, -1026, 1138], [-10640, -680, -738, -3144], [-22184, 2395, -1065, 2081], [26544, -560, -756, 3670], [-16235, 1091, 796, -4794], [10555, -739, -1812, -850], [-20340, -2100, 64, 4420], [20740, 1660, -1424, 3472], [23382, -2828, -1462, -836], [7188, 3381, 313, -937], [-4445, 1283, -2222, 2517], [18158, -34, 1060, -4672], [61180, -1459, 991, 933], [-41462, 2551, 1013, 100], [-46646, -1730, -656, -200], [22950, 2920, -396, 1024], [-1765, 1517, 1148, 1384], [40690, 178, 516, 356], [9118, -1369, -665, 3685], [-4311, 181, 1222, -3449], [46033, 1813, 502, -964], [46179, -1457, -198, 1092], [18917, 168, 1721, 1006], [-3240, -1737, 243, -3307], [318, 1090, -806, 6214], [-19246, 519, -1329, 3897], [3970, 1534, -1504, -280], [54789, -2123, 1226, -813], [56064, -1098, 18, -1209], [39566, 491, -1643, 4564], [-37561, 1749, -736, 295], [36349, 1765, 1882, 196], [57328, -832, 2766, 5090], [-28733, -2815, -1268, 3179], [24424, -898, -1784, -1528], [12259, -82, 1905, -1086], [39162, 1888, 928, 200], [-53028, -1076, 2360, -4512], [-54549, 3345, 1186, 2680], [-53362, -1956, 2048, -4272], [26114, 528, -216, 416], [-52168, -2107, -1775, 1367], [-21067, 1103, -2014, -3996], [-6749, -2092, 2471, 158], [-15352, -2878, 390, 2190], [-67282, -1119, -2595, 775], [43502, -174, 1652, -794], [22699, 4369, -2426, 2076], [3472, 2840, -2834, 866], [-46600, 1322, -2478, -5411], [-51940, -2220, 3472, -6532], [25553, -139, 2050, 692], [11336, -6196, 2000, -5], [-67590, -3021, 193, 2855], [-29491, -511, 1434, -6944], [74222, -649, 1489, -625], [-11349, -1085, 2558, -4008], [43294, -860, -2582, -221], [20095, -694, -4427, 812], [5237, -1363, -3054, 4918], [51620, -2512, -1844, -2116], [-3544, 6000, -1332, -2792], [-8556, -4688, -682, 2558], [26808, 2262, -4098, 3897], [-67475, 1586, 1783, -60], [-25237, 1241, 3678, -1808], [15845, 1209, -2774, 3583], [-12487, -1023, 1406, -872], [6404, 3632, 60, 2040], [103508, 903, 329, -429], [-53160, 1620, 648, -2508], [-83283, 511, 1832, -662], [-25667, -1937, -246, 3476], [79486, 1984, 2174, -3247], [-52240, 4415, 1143, 4978], [-69282, -914, 2080, -2520], [-6346, 3860, 1434, -1202], [27388, -2170, 600, -1056], [55540, -596, -4552, 2716], [24186, 1266, -2874, 2588], [16218, -4904, -920, 1424], [-4613, -443, 2588, 420], [-67657, 867, -3198, -5475], [-109430, -1498, 1182, -2010], [45657, 1431, -3244, 3932], [44111, 651, -514, 1198], [-46258, -517, 825, -6986], [6072, -1604, 2206, 1638], [411, -2231, 1740, 163], [43196, 60, -2044, -2204], [29120, -5236, 2008, 800], [-47936, -1862, -346, 3719], [-73248, 616, -3286, -5066], [-6577, -2533, 154, 526], [19784, 708, 588, -16], [-61674, 276, -246, -426], [77791, -1555, -2968, 995], [3087, -2781, -2124, -1854], [-46562, 473, 1397, -2525], [10910, -979, 7, 1544], [69029, -519, 1770, 4356], [70559, -648, 447, -1414], [-24839, 3035, 408, -4142], [-78128, -269, -1841, 4230], [61425, 435, 400, -4500], [85431, -2054, -203, 2736], [-39954, -846, 420, 2535], [38650, 586, -4324, 4972], [-49365, 2353, -1952, -922], [-28152, -5720, -820, 1458], [87570, -2016, 1182, -7666], [-14816, -1904, -5008, 1595], [18208, 1736, 2776, -8168], [45302, -3978, -236, -1370], [114385, -683, -1202, -1016], [-44717, -1690, -1263, 3144], [16802, -1635, 437, 3147], [-90540, -3198, 1726, 2536], [-8042, -1394, -1540, 6220], [52200, -5403, -815, 943], [-31446, -3912, -894, 3988], [41194, -4718, 266, 4836], [16908, -3215, 1007, -11559], [-503, 2653, -3822, 7664], [12777, -681, -1832, 1276], [91012, -4655, -2155, -925], [-14286, 166, 3356, 5968], [-21809, 4109, -1534, 7598], [56043, 5757, -1580, -1720], [-25399, 3540, -2243, 4412], [117762, -2318, -1130, -5346], [28283, -241, 1128, 8794], [93558, -4754, -1416, -3602], [27743, -3055, 3720, -3260], [78522, -714, 4000, 5505], [-81295, -4512, 2485, -3246], [1596, 1546, -3464, 4880], [-71966, 3136, -454, 282], [-3494, -4136, 338, -4458], [20004, -3482, 420, 4244], [-22968, -1665, 999, -5086], [-6875, -1891, 7126, 1024], [-113756, -3878, -174, -241], [16976, 1061, 1769, -3978], [-47446, -4488, -5486, 9592], [-59745, 741, -3864, -996], [-44525, 635, -450, -6635], [-32492, -1904, 6820, -6616], [-12234, 3904, 1902, -6604], [-54670, 5514, 634, 4190], [-100255, -2535, -1038, -2353], [-130214, 3100, -506, -1158], [21160, -4066, -1820, 1672], [-42373, -1813, -218, -688], [7219, 5053, -6374, -76], [62714, 1110, 104, -9178], [52938, -4980, -1026, 1706], [-174858, -2042, 4586, -2962], [6783, 2764, -1601, 1798], [14086, -203, 5219, 5846], [-52811, 1667, -1604, 10145], [25447, -3455, -4972, 604], [53706, -1724, -1652, 2828], [-114105, 4275, -1498, -940], [-31039, 3492, -59, -6512], [-54840, -4239, 3169, 3822], [-79571, -1757, 5700, -5912], [64389, -3971, 3534, 1474], [7474, -2551, -4419, 3011], [-16089, 1587, -1978, -8892], [3191, 651, -5122, 6365], [-23439, 1917, 2764, -1162], [48144, -1076, 488, 5618], [-73015, 3395, -3552, 64], [107020, 1249, -1203, 371], [-57865, 2847, 1738, -59], [99794, -1068, -132, -4072], [-98651, 2167, -120, -6990], [-82568, 1012, -3126, 11620], [-2631, -6209, 180, 3662], [-176512, -2773, -4005, 1098], [34892, 2318, 1818, -10778], [-47056, -2686, -1522, 8147], [105148, -1369, -219, -1041], [97948, -548, 5584, 8256], [-86561, -6203, -4346, 10504], [96812, -1974, -1108, 3436], [-16517, 1807, -3734, 11994], [40142, 3569, 2719, -5247], [-136800, 252, -340, 5336], [-83806, 4794, 572, 1698], [-27114, 4554, -3614, -2936]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_414_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_414_4_a_n();".
// 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_414_4_a_n(:prec:=4)
    chi := MakeCharacter_414_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_414_4_a_n();".
// 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_414_4_a_n( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_414_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<5,R![23916, 904, -380, 0, 1]>,<7,R![182936, 9840, -1062, -18, 1]>],Snew);
    return Vf;
end function;