
// Make newform 338.4.a.o in Magma, downloaded from the LMFDB on 28 January 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_338_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_338_4_a_o();".
// 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_338_4_a_o();".
// 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 := [-41951, -1659, 3703, 85, -107, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0, 0, 0], [9815, 1431, -531, -77, 7, 1], [-139594, -30520, 7574, 1655, -102, -22], [314496, 73955, -16163, -3902, 207, 50], [982345, 200123, -51114, -10347, 657, 131], [1204567, 260211, -62888, -13543, 814, 172]];
    Rf_basisdens := [1, 39, 273, 273, 273, 273];
    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_338_a();"
function MakeCharacter_338_a()
    N := 338;
    order := 1;
    char_gens := [171];
    v := [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_338_a_Hecke(Kf)
    return MakeCharacter_338_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], [1, -1, 0, 0, 0, 0], [3, -1, 0, 1, 0, 1], [4, -1, 0, 0, -2, 1], [4, -5, 0, 2, -3, 0], [0, 0, 0, 0, 0, 0], [18, 3, -5, -5, 0, -5], [-11, 10, 3, -4, -2, -1], [47, 0, -2, -7, 4, 8], [-20, -3, -6, -8, 0, -1], [-106, -3, 4, 4, -8, 3], [46, 14, 9, 1, -5, -7], [182, -2, 10, -8, -7, -2], [98, 48, -13, -29, 6, 3], [-153, -7, -22, 5, -12, 9], [21, 8, 25, 42, 9, 23], [201, 20, -14, 42, 16, -13], [298, 6, -17, -35, 21, 25], [-295, -44, -7, 13, -7, 10], [-208, 15, 31, -31, 5, 26], [-261, 20, 27, 29, 21, -10], [-178, -59, -11, -17, -25, -16], [-43, -17, 7, -12, 66, -24], [-44, -1, 7, 48, 59, 43], [-55, 17, 2, -1, -51, -22], [-442, -47, -43, 17, 49, 46], [343, 12, 41, -22, 21, -65], [-802, -13, 23, -45, -10, 2], [-42, -70, 8, -50, -72, -32], [-480, -53, 5, 14, 85, 37], [211, 141, -84, -53, 26, -33], [-333, 207, 32, -41, 189, 45], [-116, -206, 28, 191, -12, 49], [-648, 121, 19, -95, -12, -93], [661, 21, -33, 10, -7, 88], [-363, -30, 68, 103, -44, 38], [124, 273, -48, -12, -30, -133], [-160, 97, 115, -11, 158, -71], [408, -102, 72, -46, -132, -18], [128, 60, 32, -54, -116, -124], [-965, 131, -97, 22, -6, -55], [47, 19, -27, -230, -33, 44], [227, 52, 35, 162, -67, 39], [151, 50, -150, -73, 85, -168], [1243, 64, 124, 187, 26, -82], [440, -296, 87, 119, -225, -89], [1474, -35, -126, -22, 109, -166], [-2412, -83, 86, 26, 208, 159], [343, 14, 95, -287, 119, -34], [1373, -152, 203, 110, 173, -115], [-56, 173, -245, -192, 379, -51], [-989, 31, -159, 26, -125, -218], [1671, 181, -258, 189, -4, 1], [-65, -194, 158, 105, -91, 195], [-1277, 349, 122, 63, 125, -133], [-1700, -260, -261, 215, -149, 29], [781, -61, 48, -221, 158, 221], [-611, -86, -35, 202, -3, 355], [2745, 494, -149, -78, -213, 163], [3477, 203, -157, -408, 202, 59], [3971, 278, 42, -119, 209, 66], [3975, 25, 75, -206, -141, -184], [-1859, 158, -340, -279, 59, 25], [2612, -219, 148, 20, -244, 185], [3929, -212, -143, 126, 328, -156], [36, 144, -390, 160, 118, 80], [-1685, -1028, 397, 690, -357, 3], [2337, 437, 165, 168, 642, 34], [-2749, -206, -423, 46, -317, 145], [5192, 424, -225, 153, 97, 61], [1763, -585, 112, -253, -155, -44], [-45, 260, -370, -135, 840, -54], [4291, 371, 101, 122, -147, -422], [-1189, -772, 343, -40, -727, 149], [915, 451, -35, 63, 275, -83], [162, 816, 64, -46, 24, -276], [-1298, -818, -170, -272, -368, -220], [1544, 437, -343, -361, -253, -162], [-1680, -433, -588, 126, -389, 40], [-669, -861, -318, -314, -844, -402], [-2812, -1063, -217, -465, 35, 128], [3725, -330, 337, 538, -47, 581], [-3969, 364, -54, -447, 114, -640], [5897, -861, 488, 466, -34, 212], [4073, 227, -347, -618, 705, -216], [-643, -326, 6, -729, 207, 297], [-322, -228, 551, 69, 420, -195], [-758, 467, 205, 529, 565, 292], [1879, 694, 147, 674, 365, -95], [-3942, -482, 419, 101, -491, -641], [1721, -319, 113, 923, 471, 505], [-10357, 291, 145, -200, 169, 238], [1112, 191, 454, 668, 538, -983], [-9450, 211, 329, -660, -589, 343], [2321, 1303, -259, 58, -82, -319], [705, 617, 421, 256, -645, 68], [-7029, -978, -557, -224, -407, -35], [-3725, -1592, 108, 432, 448, 437], [-1264, 64, 257, 659, -724, -132], [1169, -832, 490, -105, 52, 606], [808, -104, 41, -392, -315, -1038], [-1237, 121, -511, 566, -21, 74], [-2415, 345, -552, -121, 222, -425], [2917, 288, 489, 535, -269, -1070], [5992, 903, 509, -334, 167, 163], [741, 470, -553, -14, 186, 381], [1340, -279, 30, 108, -383, 631], [-5735, -1130, -556, 1233, -141, 291], [4592, -1536, 923, 793, -845, -399], [3336, -520, -286, 350, -1905, 100], [11104, 593, -157, -833, 301, -138], [-4941, 588, 259, -684, -313, 789], [6103, -1122, 40, 46, -184, 877], [1105, -390, 155, 226, -459, -1149], [4718, 693, -837, 759, 1321, 246], [1309, 554, -335, -860, 1170, -1369], [1097, 1273, 358, -381, -541, -339], [6726, -1848, -328, 438, -662, 818], [-487, 591, 87, -738, -205, -626], [-2802, -725, -1278, 767, 202, 154], [2927, -395, -408, -951, 1414, -1053], [8962, -1554, -663, -170, -1097, 554], [-706, 32, 606, 382, -992, 596], [-8539, -1518, 117, 166, -174, 45], [12127, 888, -1005, 414, 600, 665], [-1909, -1092, -196, -379, 974, -702], [-1359, -525, -470, -133, -1690, 669], [9547, 1879, -904, -1545, 238, 1227], [12776, 637, 700, 754, -534, -17], [6697, 1174, 873, 1556, -419, -169], [8492, -92, -56, 837, 102, 759], [-11946, -9, 862, 758, -1136, 1045], [4584, 22, 1346, 956, 244, -50], [1877, -1576, -346, 235, 844, -624], [6937, -2108, 101, 314, -840, 60], [3511, -3219, 789, 592, -94, 1], [-21965, 896, -567, -334, 907, -379], [15864, 1257, 381, -1017, 1866, -179], [4972, 859, 416, 758, -68, -759], [8239, 3798, -550, 235, 585, 656], [15849, -449, 620, 1181, -941, -184], [6152, 2726, 191, -609, 1071, 395], [-173, -412, -426, -2575, -1590, 126], [8568, 115, 1155, 1292, -175, -55], [2116, 1230, 517, 55, -1571, -347], [-9934, 150, -20, -1284, 1726, -746], [-3776, -148, 40, 2176, 4, 1406], [11676, -1300, 1081, -97, -1060, 918], [-8408, 1262, -936, 2089, -914, -823], [-13823, 2702, -66, -211, 168, -208], [6378, 3657, -762, 1168, -972, 151], [-16842, 1288, -271, -1315, 1430, -204], [-909, 613, 1299, 190, 2072, -1771], [-9451, -113, 515, 322, -1661, 1638], [-18604, -1289, -1690, -2185, -1390, -1444], [-6461, 132, -33, -1408, 827, -359], [-10471, 1382, 521, -446, -365, -779], [7074, -203, -387, 2383, -252, -1000], [-1551, -1147, -1261, -1682, 1288, 1724], [11383, -20, -608, -1695, 614, 1308], [17178, 896, -518, -314, 909, 726], [5291, -1491, 760, 529, -795, -223], [18635, 2837, 321, -1792, 169, -512], [-928, 856, 1434, 2660, 193, -694], [-7851, 386, 1155, 2106, -168, 1337], [-20735, 957, 688, -313, -550, 1179], [-28235, 2448, 165, -68, 2089, -737], [13360, -1277, -74, -508, 560, 171], [15904, 2696, -372, 396, -689, -690], [-2629, -1815, 1583, 180, 305, 564], [23523, 600, -688, 218, 318, -2299], [16951, -1105, 917, 1752, -681, -1102], [-3618, 381, -873, -169, 677, -1428], [4742, -1426, -220, 1700, -209, -343], [-12399, 2384, -1863, -686, 311, -3207], [4123, -743, -317, 1, 555, -401], [15392, 3830, -1709, -509, 1961, 625], [9224, 250, -1213, -615, -2005, -743], [-1148, 1856, 981, 2435, -353, -805], [3060, 3234, 2122, -574, -1276, -1364], [1528, 999, -397, 2323, 3207, 146], [-4540, 2304, -1444, -1158, 383, -1032], [-8321, -2552, 468, 3393, -526, 976], [19789, 3043, -1170, -1417, 3271, 2094], [-3935, 2672, 747, 3030, -1529, -2655], [14113, -2282, -1304, 1419, -3040, -738], [2641, -368, 1573, -532, -3205, 205], [-4905, -3080, -2092, 2754, -2206, 269], [-22123, -3901, -273, -904, -852, -1511], [10449, 1802, -1176, 2177, -3058, -678], [16413, 849, -1948, 795, 1143, -2907], [1602, 2448, -969, -617, 1474, 98], [-24738, 2265, 1929, -2703, -640, -966], [11686, -3016, 2548, 2578, -590, 328], [28992, -3295, 1723, 3222, 1049, -1411], [6319, 3033, -799, -1874, -958, 2118], [-47770, 215, 734, 1522, -513, 416], [-1637, 1899, -1062, 1063, -592, 2157], [-4631, -4157, -803, 1600, -4506, -2456], [-9089, -1416, -2140, -789, 66, 862], [-2701, -858, -154, -401, 3240, 512], [-31184, 733, 13, -233, -947, 838], [21048, -1495, 232, 3280, -96, -3115], [29855, 3093, 1008, -1545, 1069, -146], [-16626, 1034, -3165, -3689, -2822, 2976], [25281, -8174, 292, 1965, -2956, 2668], [-28122, -2166, 1681, 1369, -251, -993], [7849, 4277, -1006, -4837, -1669, -414], [-5244, 1025, -1000, -2239, 2546, 1930], [6485, -5, -3166, -725, 1027, -1364], [-4604, -4846, -1525, -2267, -766, 522], [14779, 265, 1208, -1193, -220, -205], [-7801, -3430, 1502, 297, -1482, 3292], [39989, 2763, -2688, -783, -149, -2484], [-13546, -2397, 1065, -607, 2905, 504], [14151, 323, -199, -2816, 2209, 194], [738, -3412, 3861, 2939, -4437, 103], [-6309, -5654, 4476, 4067, -2816, 1952], [-26753, -2431, 1365, -2804, 1555, 36], [7479, -3717, -2137, 2158, 135, -930], [-11390, 104, -238, -814, 1066, 882], [-23129, -742, -223, 5382, -2585, -227], [11503, 7026, -502, -3766, 5126, 1129], [4239, -53, 1448, -969, 588, 11], [-14914, 4422, -2882, 900, 2474, -1068], [-33366, -2083, 2568, 3418, 322, 795], [-2059, 5054, -771, -278, 5959, -1271], [-12773, -1777, -199, 3316, 2817, 2698], [47224, 3443, -696, -1618, 4100, 1573], [-320, 3366, 1614, -1791, 56, 1153], [-21698, 1127, -262, -1910, 652, -4571], [870, 2424, -151, -4218, 501, 94], [6741, 3771, 122, -1677, 2820, -27], [-47217, 2670, -1053, -3468, 1282, -179], [-8980, -9834, 3480, 4834, -3443, -83], [23134, 2913, -1875, -5803, 367, -1470], [15993, -1899, 1090, -2660, -392, 1512], [27139, 7477, -2946, -5099, -1776, -3983], [-30599, -3484, 997, 742, -1156, 2175], [-18376, -4526, 3018, 3066, -4180, -768], [16588, 1573, 441, 1249, -1207, -1142], [18331, 4146, 2725, -3128, -2364, -3299], [-13683, 1061, -260, -1461, -2406, 5333], [-40059, -4803, -3038, -3187, -2630, -4683], [13771, -262, 2349, -2400, 1439, -2555], [-24618, 2943, 1461, -1133, 2595, -3120], [-40133, -361, 810, -2087, 1554, -559], [-28459, 4226, -2192, -117, 2276, -4716], [31313, -4454, -2523, -2945, 1477, 526], [3282, -1329, -495, -1825, 3331, -4202], [32801, 6590, 1556, 573, 1058, 2050], [19630, 5100, -2083, -4964, 907, -4222], [-831, -2779, 2432, 5325, -838, -605], [-14746, -5179, 2145, 5480, -1355, -77], [8874, 7503, -1479, -6845, 2231, -236], [-34873, 483, 1919, 1252, 2787, -1376], [-40792, 360, -500, -74, -276, -3106], [20876, -14420, -1798, 6282, -326, 1210], [1502, -693, -1900, -4488, 780, -675], [17672, -4026, -959, 4920, 3559, 2006], [-13556, -6836, -1809, -667, -3061, 699], [-943, 7461, -2037, -2272, 3132, 13], [40025, -4645, -3415, 2618, -3209, -3096], [-14517, -3441, -846, 2765, -3628, -533], [4152, 307, 367, -4339, -6852, -1013], [-7937, 1026, -3200, -6557, -2897, -1191], [30751, -1741, -367, -802, -3493, -4224], [-21320, -3155, 4438, 3576, -5572, -2765], [33756, -10921, 564, 2337, -6388, 2190], [49006, 3090, 5087, -1021, 1347, -1393], [1862, 6583, -4018, -1214, 8820, -41], [-24210, 7882, -5402, -714, 2605, -740], [-22696, 775, -1118, 1846, -4251, -2357], [16044, 2829, -4555, 807, 421, 2158], [10029, -2501, -1444, -897, 2359, 4147], [-12427, -322, -3174, 2381, -1840, -328], [-21256, -4221, 751, -755, 118, 1018], [-4532, 778, -79, -5445, -2031, -4085], [-25616, 5634, 1109, -309, 734, 1462], [-5400, 3462, 3209, -2538, 7141, -3714], [12739, -6172, -237, 5392, -873, -1293], [-30185, 1362, -654, 1571, 1118, -142], [-58317, 6029, -833, -3884, 3399, -6612], [-24285, -2370, 3899, -1028, 521, -3805], [35785, -3189, -2326, -3233, 1999, -264], [23756, 11776, -1546, -5090, 4346, -1346], [5626, -777, 4420, 8046, 2033, 3453], [-21038, 10088, 4008, -3988, 516, -3194], [34509, 6748, 3177, 574, 1799, 1317], [31317, 4733, 807, -2445, 4111, 5583], [-45277, 1412, -4395, -2186, -2877, 2447], [34286, 6695, -3956, -4472, 1529, -436], [19679, 12654, -229, -674, 2313, 871], [-2295, -491, 570, 872, 5818, 2234], [-11315, -530, 282, -1155, 1694, -4158], [-16864, -9303, -1247, 1883, -8767, -2514], [70143, 2631, -993, 4264, 4039, 4528], [-27209, 1462, 3789, -1748, -2371, 2103], [7712, 3277, -2518, 4981, 3058, 2540], [26858, -3178, 4051, 2863, 1898, -980], [62087, -2164, -3328, -2877, -7555, -4045], [74399, 11611, -4564, 583, -3322, -995], [888, 6357, -2995, 1091, 6203, 2454], [22847, -4074, 1190, 6505, 4083, -578], [19740, 3904, 4133, 6152, 4469, 3034], [19432, 6843, 5060, 4234, 475, 2468], [-47224, -3983, 3211, 605, -3958, -4916], [-47243, -3236, 3632, 1399, -2552, -3088], [-38180, 5735, 3577, 8449, 3513, 1092], [27230, 7072, 2636, -4694, 3818, 1236], [55712, 6555, 975, 5895, 7401, 4768], [32992, -12014, -412, -1668, -5054, 3804], [22458, 49, 1174, -3558, 648, -1753], [28050, -3223, -4387, -4968, -5485, -2635], [-39530, 4594, -1927, -5511, -459, 765], [27362, 5796, 3604, -9649, 1800, -2187], [-12923, 10167, -2071, -4964, -655, -7070], [-23860, 186, 4833, 4439, 341, -1417], [-11347, -1280, -2701, -3270, 5422, -6881], [37201, -7190, 213, 6490, -2030, 1876], [37593, 14417, -204, -3306, -1896, 1020], [37193, -14665, -1294, 757, -1901, -1607], [32890, 3028, -2996, 4350, -3678, -1014], [-3449, -10496, -1179, -9242, -1711, -13], [-33785, 3093, 1377, 4154, 6768, 142], [-15889, -6936, -979, 1580, -4176, 4280], [-28386, 9871, -757, -5264, 6633, -429], [-44010, -5760, -118, 2410, -7355, -253], [-21429, 10589, -568, -1151, 5480, 2453], [6228, -7101, 2696, -8492, 570, 3845], [-5065, -13610, -2882, 5273, -3470, -22], [-86548, -2821, 1689, -3743, -2493, 2024], [22325, -8170, -2458, 3693, 432, 4396], [19870, 8802, -109, -4955, 3113, 8701], [-34500, -788, 4181, 6723, 6376, -1588], [-61244, -14175, -3166, -4904, 1213, 290], [-66375, -2198, -6232, -4997, -3972, -4376], [81195, -315, -1694, -177, 4121, -1449], [15084, -1923, -3016, -162, 1025, 4272], [-534, -1034, 2703, -4561, 4961, 7673], [-57560, -8655, 5533, 5517, -4367, -5408], [-64306, 16904, 2168, -4642, 6459, -3602], [-32295, -3407, 2144, -2717, -12246, 241], [36960, 10184, -7545, 5269, 5225, -4257], [10742, -16242, -4508, 5536, -3926, -1554], [-24797, 8859, 933, -7612, 1214, 7294], [-27369, 14845, -10340, -4507, 5258, -5549], [27848, 114, -2008, -1460, 4476, -3278], [-35465, -5579, 7345, 6924, -6283, 4012], [-14218, -4374, -3379, 2119, 2093, 9597], [33775, 914, -2528, -5796, -2506, 6009], [-6161, 1388, 206, -11738, -4942, -2037], [37069, -9613, -5497, -3062, 2887, 3672], [67152, -3838, 966, 1546, 4654, -4620], [34592, -8109, 5166, -1238, 262, -489], [14967, -15070, -803, 11350, -4744, -2689], [-36914, -14135, 4019, 1659, 539, 3530], [24349, -12363, 5997, 10518, -968, 9652], [-2313, 13228, -3559, -1210, -270, -6975], [8585, -1079, 2496, 7821, -1928, -7001], [21920, 10133, -1885, 3987, 3499, -248], [-22697, -4294, -172, 3995, -1032, 5744], [21336, -8615, 10968, 8720, -1906, -197], [67937, 1342, -5254, 1435, 1783, -11262], [78168, 12709, -2419, -453, 7408, 3035], [107175, 1105, 4755, 1088, 2316, 5268], [43047, 2025, -3455, 12152, 9623, -454], [-45687, 14961, 2901, -2448, 2973, -7522], [-42116, -4672, 2395, -482, -1875, 4826], [27257, 6445, 153, -697, -457, 7777], [-14961, 2699, -1352, 5564, -1804, -7394], [-84514, -4815, 3542, -1720, 8604, 2203], [-80999, -6097, -367, 1580, 2531, 6004], [33813, 18876, 8264, 5347, 4894, 4458], [46812, -4564, 5134, 3680, -10040, 2544], [-14699, -237, 1034, -5699, 308, -6881], [-3965, -1905, 3871, 1406, 4507, 10162], [-80406, -4473, 1454, 14772, -10415, 895], [66133, -2165, 457, 4836, -1848, -8692], [-38604, -2783, 22, -8342, -3065, -503], [40724, 9880, 5280, -7766, -6068, -7560], [22318, 5710, 7404, -3724, -3483, -9461], [5132, 4732, -9994, -534, -5030, -3156], [81284, 278, 1968, 7386, 4651, 11733], [-29897, 4231, -3552, -5761, 2867, 2529], [-103668, 20867, 2787, 2285, 3297, -1624], [-50978, -3345, -6433, 5287, 463, 5128], [83167, 1732, -1390, 5281, 512, 7396], [50930, -15385, 1433, 11069, -3442, 13192], [54656, 4342, -328, -3394, 2888, 2402], [-13777, 12356, -6616, -10461, -2837, -1299], [-5643, 8909, -9735, -16206, 4627, 11248], [89023, -1333, -3362, 5190, 10958, -2308], [32019, -16445, -4274, -8983, 4441, 2511], [-31019, 16702, -6708, -11843, -2142, 6944], [10343, -4466, 2068, 3223, 5113, -6023], [-76679, 10745, -9558, -4333, 2706, 741], [-150968, -11799, 2829, -165, 674, -3709], [5058, -14325, 8511, 4079, -7234, -4722], [-789, 5850, -2765, -13866, 4411, 9217], [32746, -19253, 8236, -1908, -5468, 8247], [76824, -4402, 1763, 6570, -7779, -6568], [117322, -18296, -1825, 4131, -11603, 3005], [50432, 3402, 957, 3724, -11457, 662], [19254, -4879, 9783, 3609, -8967, 548], [-30598, -18673, -362, -5738, -2314, -3219], [16071, -10671, 6430, 1797, 1556, 10727], [38519, 20781, -385, -11160, 6430, -1804], [-11674, 4216, 6480, 13935, 4914, 6339], [-28880, -27998, 7521, 5924, -1683, 1224], [16954, -4668, -4534, 2213, 6298, 9591], [-121414, 19093, 3206, 11230, 180, -3207], [74871, 7302, -2659, 1952, 3940, -4235], [37431, -4397, -8955, 7656, 3728, -5137], [-61929, 10144, 3429, -9697, -4877, -2972], [52620, 784, 4657, -10245, -3697, -993], [80229, -2732, 4005, -7936, 529, -2133], [35745, 2710, 1341, -16, 4687, 6303], [29403, 7693, -122, 4401, -6643, -10694], [-52668, -6023, -3628, -10062, 6730, 1245], [30707, -7752, -1244, 2861, 8800, 7362], [-54375, -524, -229, -1372, 2337, -6415], [69196, 12137, 2581, -2009, -3407, 2572], [-5107, 72, -3736, -1, -232, 1982], [-50038, 4145, 6358, 163, -3388, -4606], [75561, -9231, 7619, -5846, -2743, 2766], [-96945, -17779, 8429, 4279, -2945, -4033], [-66502, 21134, 7230, -11896, 5887, 5314], [-72339, 9996, 5600, -11839, -2271, 2365], [37116, -11178, 2121, -12027, -10781, 1655]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_338_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_338_4_a_o();".
// 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_338_4_a_o(:prec:=6)
    chi := MakeCharacter_338_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_338_4_a_o();".
// 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_338_4_a_o( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_338_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<3,R![-11999, -8047, 2313, 731, -97, -9, 1]>,<5,R![-64616, -416208, 44090, 5935, -397, -18, 1]>],Snew);
    return Vf;
end function;