
// Make newform 13.5.f.a in Magma, downloaded from the LMFDB on 24 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_13_f();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_13_f_Hecke();"
// To make the coeffs of the qexp of the newform in the Hecke field type "qexpCoeffs();"
// To make the newform (type ModFrm), type "MakeNewformModFrm_13_5_f_a();".
// 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_13_5_f_a();".
// 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 := [3779136, 0, 100636992, 0, 169417008, 0, 43573680, 0, 4862025, 0, 285720, 0, 9190, 0, 152, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [5545371476736, -50621014857024, 0, -68934581954784, 0, -17198065117872, 0, -1906294858020, 0, -112263516645, 0, -3635180779, 0, -60681659, 0, -403105], [-35916509215296, 90475406179200, -182218604617728, 189141832996704, -144684110994768, 35960915423664, -26905461929136, 2514078351540, -2167037463465, 64569965208, -86530231647, -336194096, -1670382423, -40141192, -12268161, -450212], [-35916509215296, -90475406179200, -182218604617728, -189141832996704, -144684110994768, -35960915423664, -26905461929136, -2514078351540, -2167037463465, -64569965208, -86530231647, 336194096, -1670382423, 40141192, -12268161, 450212], [22901572977984, 32386072836672, 20576677484160, 73741688677440, -18429203735856, 14113769934816, -4928117078304, 1036401623208, -456891538383, 33967214799, -19722145833, 403691033, -399803697, -1946495, -3031335, -53905], [-22901572977984, 32386072836672, -20576677484160, 73741688677440, 18429203735856, 14113769934816, 4928117078304, 1036401623208, 456891538383, 33967214799, 19722145833, 403691033, 399803697, -1946495, 3031335, -53905], [-17722730943936, 0, -41761008777600, 0, 1111509749520, 0, 1357351279200, 0, 142169221341, 0, 6269679835, 0, 127064675, 0, 958933, 0], [-127810286301312, -38119690075968, -236124309230208, 69173551698048, 147897464997600, 35965207159632, 38802395601648, 5435904315744, 3436503751926, 377367280059, 141965775450, 13401654797, 2770864650, 235643173, 20386710, 1611011], [-46660774261824, 12925058025600, 95067845558784, 27020261856672, 118652121636336, 5137273631952, 23121020302128, 359154050220, 1881613092303, 9224280744, 75309720489, -48027728, 1454826609, -5734456, 10690839, -64316], [-121083795836352, 921694995453312, -10688655293568, 1153914652058112, 2193532745904, 310555374841728, -575259720336, 36294499625328, -83390031711, 2217207089202, -3085996905, 73776312574, -34398657, 1257390830, -22455, 8483506], [116719543347840, -38119690075968, 236124309230208, 69173551698048, -147897464997600, 35965207159632, -38802395601648, 5435904315744, -3436503751926, 377367280059, -141965775450, 13401654797, -2770864650, 235643173, -20386710, 1611011], [262228572037440, 765185781986496, 313787054673792, 1144577610929088, 274948280891280, 266224281763680, 55871559620352, 26434213763832, 4811620057209, 1360934568357, 202355357535, 37885091971, 4066826247, 538883915, 30779505, 3060949], [-4839006028608, 118564929748800, 28035201382272, 218257879045248, 37860759720432, 58482708936192, 7560677757024, 6825957638976, 620613013671, 420766469319, 24822766977, 14182744225, 476788953, 244791977, 3478479, 1668943], [-262228572037440, 765185781986496, -313787054673792, 1144577610929088, -274948280891280, 266224281763680, -55871559620352, 26434213763832, -4811620057209, 1360934568357, -202355357535, 37885091971, -4066826247, 538883915, -30779505, 3060949], [4839006028608, 118564929748800, -28035201382272, 218257879045248, -37860759720432, 58482708936192, -7560677757024, 6825957638976, -620613013671, 420766469319, -24822766977, 14182744225, -476788953, 244791977, -3478479, 1668943], [-53168192831808, 452794700306880, -125283026332800, 938832132172032, 3334529248560, 262878864690816, 4072053837600, 31200573373200, 426507664023, 1921681816845, 18809039505, 64086192235, 381194025, 1089833795, 2876799, 7320853]];
    Rf_basisdens := [1, 11090742953472, 33272228860416, 33272228860416, 3696914317824, 3696914317824, 616152386304, 11090742953472, 4753175551488, 33272228860416, 11090742953472, 11090742953472, 3696914317824, 11090742953472, 3696914317824, 3696914317824];
    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_13_f();"
function MakeCharacter_13_f()
    N := 13;
    order := 12;
    char_gens := [2];
    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;

// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_13_f_Hecke();"
function MakeCharacter_13_f_Hecke(Kf)
    N := 13;
    order := 12;
    char_gens := [2];
    char_values := [[0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]];
    assert UnitGenerators(DirichletGroup(N)) eq char_gens;
    values := ConvertToHeckeField(char_values : pass_field := true, Kf := Kf); // the value of chi on the gens as elements in the Hecke field
    F := Universe(values);// the Hecke field
    chi := DirichletCharacterFromValuesOnUnitGenerators(DirichletGroup(N,F),values);
    return chi;
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 := 5;
    raw_aps := [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0], [-1, 0, 0, 0, 0, 0, 0, 0, -1, 1, 0, 0, 1, 0, -1, 0], [4, -8, -5, -2, 0, 1, 0, 0, 1, -1, -1, 0, -2, -1, -1, 1], [8, -7, 7, -6, 0, 0, -2, -1, 1, 0, 0, 1, 0, 2, 2, 1], [-26, 29, 33, -8, -4, -6, 1, -4, 3, 4, -7, 0, -2, 1, -4, -1], [37, -43, 17, 31, -28, 3, 0, 3, -11, 3, 1, -3, 9, 0, 12, -2], [69, -33, -3, 81, 25, -2, 6, 0, 6, -3, -3, 9, 16, 0, -17, -3], [-40, -83, 41, 94, 2, -13, -8, 1, 1, -10, 10, -12, 0, -8, 5, 12], [-45, -56, -52, 0, -24, -34, -14, 2, 11, 11, 0, 0, 47, -4, -21, -14], [146, -99, 247, -494, -31, -23, -2, 11, 25, -25, 22, -16, -11, -8, 59, 2], [181, 102, 355, -308, -34, 4, 15, -17, -55, 72, 55, -15, 51, -19, 21, 4], [-472, 860, 801, -245, -1, 31, -16, 59, 25, -59, 34, 2, -11, -14, 59, 14], [-7, 484, -514, 499, 30, 30, -8, -30, 38, -30, 8, 30, 110, 38, -30, 38], [-44, 50, -21, 924, 34, -181, 70, 0, 42, -21, 14, 35, 6, 0, 189, -35], [85, 56, -149, 94, 130, -54, -49, -9, 1, -10, 1, -49, -73, -43, -129, 6], [388, 0, -61, -215, -144, 144, -13, -35, -154, 0, 35, -36, 36, 36, -36, 0], [-386, 555, -331, 366, -134, 126, 26, 55, -55, 134, 134, 29, -252, -26, -94, 29], [-160, -225, 830, -360, -56, -127, 0, -320, 0, -110, -160, 53, -104, 106, -391, -55], [-494, -489, 545, -1164, -407, -56, -34, 56, 69, 56, 125, -62, 325, -28, 758, -28], [-504, 437, 595, -220, -506, -163, 98, 91, 91, -126, 126, 2, 0, 98, 407, -2], [-356, -1826, 2129, -334, 751, 330, 139, -22, -31, 9, -31, 139, 317, 94, -782, -45], [-774, 0, -86, -90, 744, -744, -68, 164, -4, 0, -164, 34, -232, -34, 232, 0], [573, 546, 1335, -912, -269, 779, -60, -93, -123, 216, 123, 60, -656, 216, -146, -156], [2804, -2459, -2685, 116, -181, -1570, 221, 226, 9, -226, 217, -171, 889, 50, 226, -50], [1876, 2537, -1629, -2656, 354, -125, -113, 247, 247, 366, -366, 54, 0, -113, -113, -54], [285, 101, -3182, 0, 157, -460, -55, -434, 184, 184, 0, 0, 119, 277, -710, -55], [-536, 2192, -480, 600, 737, 737, -33, 440, 120, -240, 440, -1, 203, -1, 443, 66], [4251, -4254, -968, 1936, 528, 768, -128, -314, 625, -625, -628, 516, -1493, 258, -457, 128], [821, -306, 481, -1029, -682, -906, -118, 276, -242, -34, 242, 118, 1148, -216, -440, 334], [-181, -3747, 1167, -635, 741, 48, 0, -362, 0, 103, -181, -267, -922, -534, -1055, 379], [-57, 548, -2326, 0, -574, 1588, -38, 376, -605, -605, 0, 0, -409, -226, 1359, -38], [-4014, 0, -3058, -2624, -1861, 1861, 473, -268, 434, 0, 268, 281, -471, -281, 471, 0], [138, 5048, -1110, 6397, 101, 1050, -50, -1248, 1248, -101, -101, -457, -2100, 50, 735, -457], [-124, -1646, 879, -54, -1798, -557, 0, -248, 0, -771, -124, 35, 1674, 70, 993, 69], [-7578, -2084, 7774, 1891, 1215, -743, 246, 196, 196, 389, -389, 170, 0, 246, -606, -170], [-1095, -2790, 5191, -2400, 648, -1706, -789, 1305, 1, 1304, 1, -789, 903, -257, -647, 532], [3694, 0, -10199, -10612, 517, -517, 752, -200, -413, 0, 200, 237, 1620, -237, -1620, 0], [-6142, 6875, -5525, 6044, -214, 748, -400, 617, -617, 214, 214, 419, -1496, 400, -1240, 419], [-1036, 17193, 17785, -17868, 466, -74, -215, -592, -527, 592, -65, 274, 268, 59, -592, -59], [3057, -2620, 492, 12081, 45, 3542, 544, 0, -984, 492, -1199, 151, -170, 0, -4571, -272], [-13825, -13968, -13270, 0, 1501, -1166, 251, -660, 143, 143, 0, 0, -478, 555, -1683, 251], [-1958, 5210, 3389, -1914, 5119, 5119, 36, -828, 1475, -2950, -828, -207, -2272, -207, 678, -72], [948, -5298, 20295, -9998, 394, 2396, 0, 1896, 0, -299, 948, 34, 554, 68, 3898, -1346], [-10259, 7886, 6026, 6519, -3902, 896, 68, 1860, 426, -1860, 1434, 130, 56, 198, 1860, -198], [-10124, 12275, -13971, 5918, 2229, 1696, -35, -1696, -375, -1696, -2071, 337, -7051, 372, -2762, 372], [-6600, 4562, -381, 14108, -3304, -2418, -524, 0, 762, -381, 1762, 368, -2304, 0, 6484, 262], [11103, -15606, 2224, -4448, 744, 1848, 992, -1226, -2051, 2051, -2452, 772, -1505, 386, -5125, -992], [10006, -12091, 14145, -5892, -1339, -2054, 210, 2054, -301, 2054, 1753, -152, -1757, -362, 624, -362], [21726, -23841, -23153, 23646, -1948, 3993, -1634, -1427, -1427, -1232, 1232, -664, 0, -1634, 163, 664], [7407, -17670, 13629, 6803, -2634, 1470, -1560, 604, 2762, -2158, 2762, -1560, -84, -50, 5396, 1510], [-18286, 32448, 10826, -12732, -1570, -1570, -604, -156, -1906, 3812, -156, 1110, 4962, 1110, 1150, 1208], [17725, -24902, -7565, -14384, 6393, 1405, -678, -2565, 2953, -388, -2953, 678, -4358, 626, 3440, 52], [-1128, -10488, -1964, -8359, 1293, 2736, 430, -836, 836, -1293, -1293, -109, -5472, -430, 531, -109], [6444, -534, -3393, -9756, -338, 3022, -1128, 0, 6786, -3393, -1410, -1092, -8534, 0, 4102, 564], [-347, -1121, -17250, 0, 2602, -2544, -178, 3518, 774, 774, 0, 0, -832, 1754, 1748, -178], [-10297, 8352, 5782, -11564, 341, -4220, -821, -1174, 403, -403, -2348, -1378, 1810, -689, 3449, 821], [385, 7272, -4812, 1369, -1231, -344, 0, 770, 0, 2074, 385, -2395, 1616, -4790, 1657, -782], [-6688, -7205, -6887, 8712, 4920, -268, 1703, -318, -4545, 318, 4227, 44, 4520, 1747, -318, -1747], [-20856, 8203, 1458, -26760, 3486, -5003, 3338, 0, -2916, 1458, -1534, 335, 4868, 0, -1399, -1669], [45690, -22060, -24361, 45721, 3600, -4191, 786, -31, -700, 669, -700, 786, -3553, -209, -4300, -995], [27215, 27216, 30790, 0, 479, 4456, 247, -1284, -1, -1, 0, 0, -4934, 1973, 3171, 247], [35157, -44052, 35367, -42744, 1518, 3273, 552, 210, -210, -1518, -1518, 477, -6546, -552, -2969, 477], [-39693, 38978, -5339, -35112, -30, 6502, -599, -4581, -1473, -3108, -1473, -599, -1187, -1489, -1443, -890], [17188, -33272, -1276, 4560, 5537, 5537, -845, -2732, 3284, -6568, -2732, 511, -7653, 511, -1085, 1690], [7162, 0, 3390, 4526, 5888, -5888, 1822, 1048, 1136, 0, -1048, 1998, 5206, -1998, -5206, 0], [9864, -23160, -11659, -11307, 3523, -4344, 1661, -1831, 194, 1637, -194, -1661, 4150, 2612, 3329, -4273], [55234, -17041, -56191, 14332, -11250, 4070, 748, -957, -957, 1752, -1752, -107, 0, 748, 3792, 107], [8870, -22218, 36243, -39844, 3448, 3448, 771, 1362, -3601, 7202, 1362, -110, -2561, -110, -9763, -1542], [1642, -52074, 104943, -48728, -3844, -6542, 0, 3284, 0, -7487, 1642, -820, 5486, -1640, 586, 3682], [-20358, -16879, -14349, 32044, -10777, -26010, -2437, -2530, -133, 2530, -2397, 1565, 11873, -872, -2530, 872], [38622, 28698, -26763, 67749, -6030, -1935, -1575, 1935, -4299, 1935, -2364, 942, -7246, 2517, 10125, 2517], [3719, 70282, -64087, 308, 2911, 8917, 1666, 3411, 6503, -3092, 6503, 1666, 9236, 1396, 3592, -270], [56599, -52586, 23318, -46636, 5096, -764, -5960, 1716, 581, -581, 3432, -5660, 8711, -2830, 3061, 5960], [1071, 13497, -109755, 57151, -1133, -7339, 0, 2142, 0, -4547, 1071, 1700, 2204, 3400, -4064, -6052], [35932, 18291, -17719, 56368, 2613, -572, 1274, 572, -3289, 572, -2717, -338, 12063, -1612, -5798, -1612], [-14436, 9229, 12513, -13934, -15660, 14396, 2438, -1923, -1923, 2782, -2782, 5565, 0, 2438, 4516, -5565], [-37520, 81398, 17877, -21954, -3873, -3873, -260, 7256, -4077, 8154, 7256, -5035, -1122, -5035, -9276, 520], [-32914, -84385, -36637, -75386, 5276, 3573, -1235, -3723, 3723, -5276, -5276, 2478, -7146, 1235, -2831, 2478], [-34248, 28038, 31905, -7239, 6740, 21091, 2691, -3867, -5715, 3867, 1848, -6534, -6764, -3843, -3867, 3843], [-53739, 19674, 50325, -26960, -4712, -9716, -934, -3414, -3414, 3872, -3872, 3520, 0, -934, -2994, -3520], [-45805, 56376, 86698, -173396, 5306, 4030, 2536, 4478, 1615, -1615, 8956, 4388, 8617, 2194, 2063, -2536], [32816, -30666, 2287, -39605, -3765, 18416, -3829, 6515, -6652, 137, 6652, 3829, -11764, 3556, 2887, 273], [68740, 2117, -17723, 89168, 9210, 15606, -4861, -15606, 12901, -15606, -2705, -462, -29650, 4399, -2814, 4399], [83456, -39047, 3470, -9782, -1990, 7366, -7456, 0, -6940, 3470, 12302, -2774, 17252, 0, -12316, 3728], [3223, -2794, 23306, 0, -21457, 22942, -91, -2230, 6017, 6017, 0, 0, -7502, -3493, 26729, -91], [-106580, 0, -5284, -9824, 11016, -11016, 2648, 154, -4540, 0, -154, 2352, 19848, -2352, -19848, 0], [-25066, -21761, -16877, -38458, -8508, -591, -2247, 8189, -8189, 8508, 8508, -2434, 1182, 2247, -20555, -2434], [-82483, 68930, -73680, -5739, 10522, 4750, 4728, -4750, 1686, -4750, -3064, 3722, 60, -1006, -16294, -1006], [1836, -78240, 5268, 88215, -5509, -3005, 1314, 7104, 7104, -2871, 2871, -342, 0, 1314, 11294, 342], [-5487, 87414, -89125, -3184, -7103, -15487, -424, -2303, -4895, 2592, -4895, -424, -15198, -756, 2208, -332], [16560, -27708, -17664, 14886, -18648, -18648, 3468, 5484, -2778, 5556, 5484, 5538, 31722, 5538, 26166, -6936], [36770, -15097, -21127, -2072, -15393, -18750, 1926, 6030, 7541, -6030, -1511, -5608, 4849, -3682, 6030, 3682], [116558, -73541, -123175, 62000, -5998, -10768, -582, -6617, -6617, 4924, -4924, -5601, 0, -582, -6080, 5601], [-10133, -13478, -67968, 0, 26287, -14220, -493, 1916, 3345, 3345, 0, 0, -15412, -4177, -8959, -493], [-102901, 59206, -41743, 99096, 14362, 4700, 511, -99, -1853, 1952, 1853, -511, -2847, 2901, 16215, -3412], [-10616, -103410, 126867, -65798, -13372, 20689, 0, -21232, 0, 4729, -10616, 3785, 2756, 7570, 12829, -5687], [-57205, 42004, -37200, -38327, -15711, -4804, -3229, 4804, 13518, 4804, 18322, -1852, -1177, 1377, 26618, 1377], [66732, 0, 10073, 12802, 6530, -6530, -9247, 7880, 2729, 0, -7880, 3434, 13605, -3434, -13605, 0], [79279, -88490, 102518, -205036, 12479, 5926, 4495, -5580, 1949, -1949, -11160, 11806, -6556, 5903, -9557, -4495], [37178, -40242, 27239, 18079, -45669, -15140, 243, 19099, 5076, 14023, 5076, 243, 17982, -5980, 50745, -6223], [-35148, 0, 53280, 35304, 5593, -5593, -7365, -1846, -17976, 0, 1846, -1031, 29871, 1031, -29871, 0], [88799, -122756, -114606, -5389, -24331, -2068, 1709, -8150, -23046, 8150, 14896, 3240, 20005, 4949, -8150, -4949], [-196318, 92146, 3887, -76686, 16552, 9605, 2854, 0, -7774, 3887, -4252, -4891, 20074, 0, -33931, -1427], [51332, 49580, -39903, 0, 16854, -43511, 2650, 13651, 1752, 1752, 0, 0, 24905, -395, -28108, 2650], [68738, -119828, -36046, 29824, 11048, 11048, 1556, 15046, -6222, 12444, 15046, -7824, 12450, -7824, 6, -3112], [16856, -72608, -48707, -18008, -16003, 19694, 4977, -12938, 5893, 7045, -5893, -4977, -25587, -3264, -21896, -1713], [-70254, 20313, -21451, -46968, -4530, 1138, 4487, -1138, -697, -1138, -1835, -5798, 260, -10285, 10198, -10285], [74704, -144398, 58635, 80198, 3897, -14552, 10835, -5494, -5565, 71, -5565, 10835, -19975, 6774, -9462, -4061], [-218024, 0, -90868, -100370, -31821, 31821, 1205, -410, -9502, 0, 410, 525, -19665, -525, 19665, 0], [30790, 3837, -162911, 325822, 42454, 3443, -12985, 5331, 23965, -23965, 10662, -7126, 25708, -3563, 25853, 12985], [8474, 77102, 40971, -26080, -30620, -4828, 0, 16948, 0, 11189, 8474, -582, 39094, -1164, 42740, -6176], [121902, -74062, 58383, 47147, 9361, 15679, -6414, -15679, 32051, -15679, 16372, -8988, -64689, -2574, -3043, -2574], [-62046, -106658, 61714, 99421, 39081, -5852, -1884, -332, -332, 6905, -6905, -12835, 0, -1884, -23325, 12835], [-163659, 9166, 128443, -149360, 17179, 12871, 7774, -14299, -11751, -2548, -11751, 7774, -3976, 9374, -28930, 1600], [-27746, 141007, -29825, 137436, -5650, 10600, 11378, -2079, 2079, 5650, 5650, 4483, -21200, -11378, -1922, 4483], [201181, -115411, 18463, 150009, -26573, 19320, 5258, 0, -36926, 18463, 7285, 7039, 17638, 0, -29673, -2629], [466, 75823, 13981, -59508, -43146, -45100, -12228, 14447, 14447, -1868, 1868, -13353, 0, -12228, 36954, 13353], [54943, 48030, -38102, 0, -10698, 20784, -1742, -498, 6913, 6913, 0, 0, -16999, 8136, 27199, -1742], [109388, -143460, -32771, 65542, -15952, -42845, -5954, -14017, -6038, 6038, -28034, -7282, 4897, -3641, 22790, 5954], [10078, 134946, 204771, -111152, 21938, -3977, 0, 20156, 0, 17533, 10078, 8759, -11860, 17518, -5759, -5999], [41762, -808, 11439, -70639, 48007, -4579, 6052, -12247, -5191, 12247, -7056, -12028, 1357, -5976, -12247, 5976], [-88274, -73305, -95513, 0, 3308, 17299, 5829, 7019, -14969, -14969, 0, 0, -5638, -14293, 9349, 5829], [257474, 0, -72760, -77576, -17900, 17900, -11044, -19986, -4816, 0, 19986, -4106, -6210, 4106, 6210, 0], [-92216, 221125, -113701, 257510, 14900, 27783, -13808, -21485, 21485, -14900, -14900, -3036, -55566, 13808, 11097, -3036], [-280352, 100117, -110515, -162980, 18536, 10398, 149, -10398, 3541, -10398, -6857, 14406, -15612, 14257, -26674, 14257], [21724, -44208, 246982, -248196, -55424, -55424, 1234, 834, -1214, 2428, 834, -612, 36222, -612, 33794, -2468], [18564, 11386, 8646, 51435, 30131, 38711, -17936, -9918, 9918, -30131, -30131, -5632, -77422, 17936, -44602, -5632], [-160628, 77316, -2291, 342750, 21734, -13255, -12614, 0, 4582, -2291, -10578, -20361, 6574, 0, -3897, 6307], [-124440, 279872, -145380, 154664, 71940, 71940, 12612, 6212, 9284, -18568, 6212, 6888, -25908, 6888, -7340, -25224], [256140, -116074, 127341, -254626, -18606, -54291, 8132, 23936, -11211, -12725, 11211, -8132, 65502, -6485, -7395, -1647], [52608, 107203, 113881, -200924, -66022, -19420, -4277, -6678, -27757, 6678, 21079, -14806, 34128, -19083, -6678, 19083], [329264, -290807, 298989, 32800, -26070, -8182, 11261, 8182, -10707, 8182, -2525, 1892, 14024, -9369, 43958, -9369], [-74657, -67100, -144612, 0, -24875, -29158, -6169, 21226, -7557, -7557, 0, 0, 61590, -5381, -15489, -6169], [-195974, 144678, -37501, 75002, -37284, -18879, 21950, -4875, -41546, 41546, -9750, -2582, 13391, -1291, -27542, -21950], [-185648, 61311, -206731, 79164, -3230, -31011, -4111, -21083, 21083, 3230, 3230, -1216, 62022, 4111, -13117, -1216], [-160752, 103603, -95841, -37798, 55925, -7762, -11211, 7762, -34875, 7762, -27113, -3707, 14421, 7504, -119612, 7504], [-239994, 67313, 261603, -41932, -51668, 2073, -13907, 21609, 21609, -3772, 3772, -15744, 0, -13907, 49329, 15744], [-84422, 178651, -80141, 194300, 19930, 37259, 9792, 4281, -4281, -19930, -19930, -2326, -74518, -9792, 47245, -2326], [219335, -99608, -22864, 18381, 113575, -35986, -4724, 0, 45728, -22864, -25609, 18419, 42238, 0, -31861, 2362], [-194, 46995, -111191, 222382, -24356, -1891, 10909, 14877, 17047, -17047, 29754, 26278, -9758, 13139, 33815, -10909], [-81065, -244420, -300927, 61630, -52080, 55016, 11455, -29681, 5123, 24558, -5123, -11455, -60139, -4861, -57203, -6594], [-117594, 16785, -23201, -83838, -60573, 6416, -16199, -6416, -4139, -6416, -10555, -7195, 23759, 9004, 127562, 9004], [-194480, 97678, -8185, -351216, 65682, -89815, -6502, 0, 16370, -8185, -15494, 505, 33818, 0, 40503, 3251], [-216933, -76646, 268825, -216916, 46823, 13501, -17634, -17, -24737, 24720, -24737, -17634, 38204, -11044, -71560, 6590], [-114855, -121763, -136640, 0, -43381, 72840, 9925, -41578, 6908, 6908, 0, 0, -36367, -3377, 38170, 9925], [70960, 95513, 99593, 80068, 13188, 13617, -9246, 28633, -28633, -13188, -13188, 2662, -27234, 9246, 39751, 2662], [321464, -104218, -197259, 297380, 39738, 9845, 24736, 24084, -4097, 28181, -4097, 24736, 62110, 19521, -43835, -5215], [39304, -87106, 196503, -192063, -28011, -28011, 1534, -8689, 4440, -8880, -8689, -29071, 16065, -29071, 24945, -3068], [405770, 0, 107006, 148588, 3265, -3265, -11237, 12384, 41582, 0, -12384, 9053, -10059, -9053, 10059, 0], [-372565, 519926, 161865, 353888, 43319, 1379, -6368, -10331, -4173, 14504, 4173, 6368, 2794, -22468, 47492, 28836], [-12893, -23396, 26541, 82366, 37956, -21879, 5560, 13648, 13648, -45322, 45322, 16969, 0, 5560, 17331, -16969], [86995, 102297, 159112, 0, -76224, 19386, 3844, 54756, -15302, -15302, 0, 0, 72140, -9330, 58840, 3844], [122504, -298576, -300036, 304948, 42217, 42217, -10245, -31696, 4912, -9824, -31696, 21847, -81953, 21847, -72129, 20490], [200119, -253110, -82028, 164056, -48665, -80698, -18917, -7818, -37355, 37355, -15636, 5182, 53752, 2591, 35525, 18917], [-127677, -135270, -133742, 0, -43283, 105962, 1719, -810, 7593, 7593, 0, 0, -70272, 13033, 112745, 1719], [-242038, 0, -67318, -74756, 13816, -13816, 18212, 25932, -7438, 0, -25932, 4270, 28320, -4270, -28320, 0], [8268, -119442, 160347, -65450, -49016, -50986, 0, 16536, 0, -29447, 8268, -15556, 57284, -31112, 14566, 12650], [-149571, 206256, 131599, -190686, 18506, 85602, 7060, -17972, -17972, -33542, 33542, -17542, 0, 7060, -10454, 17542], [-179630, 0, 248089, 226371, -29327, 29327, 8134, -23555, -21718, 0, 23555, -2719, 61631, 2719, -61631, 0], [-216203, 400768, 161013, 238333, 38124, -5776, -24808, 24974, -1422, -23552, 1422, 24808, 7198, 28708, 39546, -3900], [365906, -266911, -241171, -160136, 22311, 45420, 20328, -25740, -9661, 25740, -16079, 17156, -25919, 37484, -25740, -37484], [-255897, 119202, 17478, -560871, -56177, 7708, 12300, 0, -34956, 17478, 17463, 32865, -3758, 0, 13513, -6150], [45021, -295766, -273953, -9656, 30162, -104562, 21287, 11051, 12157, -23208, -12157, -21287, 92405, -1849, 18005, -19438], [-10788, 440292, 112797, -35984, 121378, 33350, 0, -21576, 0, -40829, -10788, -278, -132166, -556, -109604, 33772], [241829, -57680, 49732, 196129, 68112, 7948, -16872, -7948, 3916, -7948, -4032, 484, 13304, 17356, -128276, 17356], [197869, -175906, -78533, 218860, 96220, 1962, -16105, -20991, -35579, 14588, -35579, -16105, -4441, -10741, -131799, 5364], [-86641, 127802, 183744, -367488, 129280, 85418, 3186, -11026, 63213, -63213, -22052, 8716, -41403, 4358, -33231, -3186], [-5730, -59851, 425274, -236218, -31672, -22463, 0, -11460, 0, 47162, -5730, 15955, 25942, 31910, -2251, 14311]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_13_f_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_13_5_f_a();".
// 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_13_5_f_a(:prec:=16)
    chi := MakeCharacter_13_f();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 5));
    S := BaseChange(S, Kf);
    maxprec := NextPrime(997) - 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_13_5_f_a();".
// 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_13_5_f_a( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_13_f();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,5,sign)));
    Vf := Kernel([],Snew);
    return Vf;
end function;