
// Make newform 1224.4.c.e in Magma, downloaded from the LMFDB on 24 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_1224_c();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_1224_c_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_1224_4_c_e();".
// 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_1224_4_c_e();".
// 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 := [1152, 0, 1780, 0, 756, 0, 95, 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, 4, 0, 0, 0, 0, 0, 0], [0, -3402, 0, -2159, 0, -284, 0, -3], [17420, 0, 6158, 0, 327, 0, 3, 0], [0, 47900, 0, 33588, 0, 5485, 0, 59], [-22844, 0, -20634, 0, -3781, 0, -41, 0], [0, -15160, 0, -48702, 0, -9989, 0, -109], [35292, 0, 28386, 0, 4217, 0, 45, 0]];
    Rf_basisdens := [1, 1, 172, 172, 1032, 172, 1032, 172];
    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_1224_c();"
function MakeCharacter_1224_c()
    N := 1224;
    order := 2;
    char_gens := [919, 613, 137, 649];
    v := [2, 2, 2, 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_1224_c_Hecke();"
function MakeCharacter_1224_c_Hecke(Kf)
    N := 1224;
    order := 2;
    char_gens := [919, 613, 137, 649];
    char_values := [[1, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0], [-1, 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 := 4;
    raw_aps := [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0], [0, -1, -1, 0, -1, 0, 0, 0], [0, 0, 2, 0, -1, 0, -1, 0], [5, 0, 0, 0, 0, 0, 0, 1], [-4, 2, 1, -1, 2, 0, -1, 0], [4, 0, 0, -2, 0, -1, 0, 1], [0, 5, 0, 0, 0, 0, -1, 0], [0, 0, -18, 0, -5, 0, 2, 0], [0, 5, 14, 0, -4, 0, 3, 0], [0, 4, -28, 0, 1, 0, 0, 0], [0, -4, -2, 0, 16, 0, 6, 0], [2, 0, 0, -2, 0, 3, 0, -1], [-42, 0, 0, -2, 0, -1, 0, 3], [-60, 0, 0, -6, 0, 7, 0, 3], [10, 0, 0, -2, 0, 3, 0, -1], [0, -16, -74, 0, 5, 0, -6, 0], [-76, 0, 0, -6, 0, 1, 0, -9], [0, -29, 31, 0, -27, 0, 6, 0], [0, 20, -6, 0, -26, 0, 6, 0], [0, -5, -64, 0, -16, 0, -11, 0], [-298, 0, 0, -2, 0, 15, 0, -9], [-23, 0, 0, -8, 0, -22, 0, -1], [0, -24, 140, 0, -22, 0, 16, 0], [-161, 0, 0, 8, 0, -2, 0, 9], [152, 0, 0, 0, 0, -16, 0, -16], [0, 30, -15, 0, 4, 0, -2, 0], [0, -4, 2, 0, -69, 0, 18, 0], [0, 20, -74, 0, -58, 0, 6, 0], [156, 0, 0, 0, 0, -40, 0, -4], [0, -6, -91, 0, -64, 0, -10, 0], [541, 0, 0, 0, 0, 17, 0, -22], [0, -4, -26, 0, 21, 0, 9, 0], [-966, 0, 0, -32, 0, -26, 0, -2], [-648, 0, 0, 28, 0, 38, 0, -22], [1524, 0, 0, -10, 0, -3, 0, 17], [0, 26, -152, 0, -15, 0, 7, 0], [0, -11, -311, 0, -59, 0, 40, 0], [0, -36, 224, 0, 65, 0, 60, 0], [-2344, 0, 0, -22, 0, -23, 0, 3], [0, 4, 54, 0, 5, 0, 22, 0], [-810, 0, 0, -46, 0, 17, 0, 1], [0, 20, -202, 0, -72, 0, -22, 0], [0, -148, 58, 0, -161, 0, -6, 0], [0, 19, -132, 0, -116, 0, -43, 0], [0, -62, -221, 0, 20, 0, -22, 0], [-2446, 0, 0, 2, 0, -79, 0, 21], [0, 34, -308, 0, 135, 0, -35, 0], [-2551, 0, 0, -16, 0, -48, 0, 5], [0, -184, 200, 0, -88, 0, -36, 0], [-182, 0, 0, 2, 0, 25, 0, 53], [0, 72, -104, 0, 158, 0, 36, 0], [-1640, 0, 0, 26, 0, -67, 0, -17], [2681, 0, 0, 24, 0, 23, 0, 52], [388, 0, 0, -32, 0, 32, 0, -92], [0, -104, 522, 0, 19, 0, 78, 0], [378, 0, 0, -34, 0, -33, 0, -1], [0, -140, -410, 0, 25, 0, 142, 0], [-2094, 0, 0, 0, 0, -13, 0, 7], [0, 236, 250, 0, -15, 0, -27, 0], [-4206, 0, 0, 64, 0, -12, 0, 68], [1842, 0, 0, -30, 0, -63, 0, -15], [0, 5, 49, 0, 429, 0, 24, 0], [0, -344, -112, 0, -302, 0, 80, 0], [0, 56, 222, 0, -117, 0, -78, 0], [-3870, 0, 0, 94, 0, 99, 0, -97], [0, -28, -406, 0, -322, 0, -14, 0], [0, -150, -544, 0, -97, 0, -27, 0], [3012, 0, 0, -2, 0, -57, 0, -61], [-5326, 0, 0, -96, 0, -53, 0, 7], [7422, 0, 0, -58, 0, -45, 0, -33], [0, 49, 169, 0, -73, 0, 30, 0], [4369, 0, 0, -24, 0, 50, 0, 87], [0, 500, 349, 0, 220, 0, -200, 0], [-6388, 0, 0, -100, 0, -186, 0, -114], [1647, 0, 0, -8, 0, 2, 0, 109], [0, -244, -112, 0, 387, 0, 12, 0], [0, -128, -512, 0, -38, 0, -44, 0], [-2464, 0, 0, -22, 0, -272, 0, -88], [0, 60, -37, 0, -392, 0, 12, 0], [1593, 0, 0, -40, 0, 118, 0, 19], [0, -107, 208, 0, 328, 0, -101, 0], [-7933, 0, 0, 32, 0, 46, 0, 93], [0, -391, -1271, 0, 367, 0, 74, 0], [284, 0, 0, -42, 0, -189, 0, 133], [0, -4, 646, 0, -480, 0, 186, 0], [-5193, 0, 0, -264, 0, 34, 0, 109], [-1820, 0, 0, 42, 0, 209, 0, -107], [-736, 0, 0, 60, 0, -194, 0, -62], [-1848, 0, 0, 254, 0, 167, 0, -83], [0, 285, 396, 0, 396, 0, -113, 0], [0, -455, -467, 0, 267, 0, 198, 0], [-7548, 0, 0, 26, 0, 225, 0, -73], [0, 230, 483, 0, 672, 0, -118, 0], [0, 111, 303, 0, 489, 0, -98, 0], [-5094, 0, 0, -136, 0, -94, 0, -22], [0, 380, 122, 0, 68, 0, -94, 0], [-3108, 0, 0, 62, 0, 83, 0, -155], [0, -372, -202, 0, -233, 0, -2, 0], [0, 582, -757, 0, 576, 0, 74, 0], [-6469, 0, 0, 0, 0, 118, 0, 21], [-1366, 0, 0, 126, 0, 243, 0, 103], [6044, 0, 0, 46, 0, 71, 0, 107], [0, 76, -1651, 0, 236, 0, -200, 0], [2895, 0, 0, 144, 0, 257, 0, -44], [-1632, 0, 0, 262, 0, -281, 0, 37], [996, 0, 0, 142, 0, 135, 0, 315], [11384, 0, 0, 208, 0, 200, 0, -72], [0, -184, 2704, 0, 328, 0, 84, 0], [0, 33, 1150, 0, -632, 0, 179, 0], [-4434, 0, 0, 120, 0, -14, 0, 234], [0, -80, 1676, 0, -128, 0, -184, 0], [0, -122, 1424, 0, 89, 0, -269, 0], [-8098, 0, 0, 286, 0, 39, 0, 155], [0, -176, -4, 0, 594, 0, 272, 0], [0, 60, 157, 0, 504, 0, -324, 0], [-13374, 0, 0, 14, 0, 167, 0, 7], [0, -200, 444, 0, -1369, 0, -84, 0], [7030, 0, 0, -170, 0, -21, 0, -37], [1662, 0, 0, 48, 0, -508, 0, -124], [0, -692, -990, 0, -528, 0, -386, 0], [0, 572, -16, 0, -525, 0, -332, 0], [0, -564, 859, 0, 540, 0, 248, 0], [0, 432, -710, 0, -1391, 0, 209, 0], [3403, 0, 0, -160, 0, -542, 0, 193], [0, 408, 2276, 0, 351, 0, 412, 0], [0, 575, 1643, 0, 685, 0, 102, 0], [-3034, 0, 0, -306, 0, -329, 0, 147], [478, 0, 0, 128, 0, 538, 0, 34], [12132, 0, 0, -178, 0, -369, 0, -15], [0, -281, -370, 0, -1060, 0, 493, 0], [0, -59, 109, 0, 991, 0, -414, 0], [-16639, 0, 0, -176, 0, -42, 0, -29], [7789, 0, 0, 280, 0, -295, 0, -294], [8383, 0, 0, 184, 0, 127, 0, -166], [-5577, 0, 0, 416, 0, 416, 0, -69], [0, -84, 34, 0, 957, 0, -327, 0], [5034, 0, 0, 328, 0, -290, 0, -282], [0, -440, 256, 0, -486, 0, -160, 0], [0, -726, 16, 0, -1019, 0, -125, 0], [0, 524, -1384, 0, 975, 0, -292, 0], [0, 163, 1180, 0, 380, 0, -99, 0], [0, -382, -2771, 0, -660, 0, 146, 0], [-11436, 0, 0, 318, 0, -261, 0, 327], [0, 193, -1667, 0, 709, 0, 460, 0], [0, -960, -404, 0, -453, 0, 516, 0], [0, -176, 1260, 0, -250, 0, 52, 0], [-6598, 0, 0, -166, 0, 549, 0, 205], [4356, 0, 0, -600, 0, -260, 0, 240], [0, 988, -2978, 0, 495, 0, -66, 0], [0, 1356, 1238, 0, 1330, 0, 62, 0], [-13208, 0, 0, 278, 0, -201, 0, 61], [0, -687, -2312, 0, -156, 0, 71, 0], [0, 64, -1462, 0, 501, 0, 477, 0], [0, -491, 917, 0, 601, 0, 712, 0], [11482, 0, 0, -66, 0, 919, 0, 15], [0, 1128, -1828, 0, 146, 0, 464, 0], [14576, 0, 0, -278, 0, 38, 0, 94], [0, -1380, -2296, 0, -875, 0, 620, 0], [0, 556, 3758, 0, -989, 0, 183, 0], [8425, 0, 0, -288, 0, 2, 0, 271], [-8854, 0, 0, 198, 0, -253, 0, -205], [-20770, 0, 0, -42, 0, -549, 0, 155], [-7492, 0, 0, -602, 0, -133, 0, 223], [0, -1365, 1235, 0, 177, 0, 386, 0], [0, -463, -1963, 0, 355, 0, 50, 0], [0, -308, -2194, 0, 629, 0, -458, 0], [0, 1364, 926, 0, 1856, 0, -518, 0], [0, 236, -958, 0, -397, 0, 610, 0], [30098, 0, 0, 222, 0, -5, 0, -17], [12541, 0, 0, 264, 0, 270, 0, -225], [0, -701, 3006, 0, -1944, 0, 397, 0], [-25465, 0, 0, -592, 0, -650, 0, -327], [-5140, 0, 0, -704, 0, -216, 0, 76], [0, -412, 4534, 0, -66, 0, 154, 0], [0, 642, 144, 0, 2405, 0, 91, 0], [0, 140, -7326, 0, 411, 0, -278, 0], [-4962, 0, 0, -642, 0, -649, 0, -229], [-13443, 0, 0, 272, 0, 444, 0, -11], [-2348, 0, 0, -468, 0, 606, 0, 206], [0, -228, -4198, 0, -1401, 0, -741, 0], [0, -696, -3794, 0, -1141, 0, -46, 0], [32638, 0, 0, -312, 0, -816, 0, 336], [8556, 0, 0, -380, 0, -182, 0, 282], [847, 0, 0, -680, 0, 2, 0, -163], [0, 248, 3288, 0, 2093, 0, -224, 0], [21470, 0, 0, -546, 0, -9, 0, -481], [0, 40, 2540, 0, 2070, 0, -156, 0], [0, -2189, 554, 0, -1092, 0, 405, 0], [0, 252, -470, 0, 570, 0, 530, 0], [0, 716, 1767, 0, 2680, 0, 884, 0], [5300, 0, 0, -350, 0, -411, 0, 355], [3123, 0, 0, 664, 0, -520, 0, -201], [0, 1094, 4908, 0, -973, 0, 525, 0], [0, 416, 2464, 0, -1380, 0, -84, 0], [0, 1384, 3380, 0, 1336, 0, 388, 0], [0, -1156, -2488, 0, 1643, 0, 1324, 0], [0, -1588, -186, 0, -934, 0, -986, 0], [-26572, 0, 0, 12, 0, 366, 0, -154], [0, -1156, -442, 0, -1519, 0, 494, 0], [0, -1029, 4788, 0, -396, 0, 9, 0], [-47210, 0, 0, 192, 0, 682, 0, -350], [871, 0, 0, -344, 0, -167, 0, 124], [4574, 0, 0, 342, 0, 387, 0, -125], [-6253, 0, 0, 696, 0, 500, 0, 467], [5204, 0, 0, -984, 0, -572, 0, 424], [-14624, 0, 0, -774, 0, 297, 0, 187], [0, -180, -2550, 0, -2946, 0, -226, 0], [-16738, 0, 0, 890, 0, 177, 0, 5], [0, -1328, -2488, 0, -1418, 0, -604, 0], [-5497, 0, 0, 176, 0, 226, 0, -499], [0, -1879, -254, 0, -1996, 0, 139, 0], [-36848, 0, 0, -390, 0, 509, 0, 567], [0, 2131, 3322, 0, -988, 0, -583, 0], [0, -976, 2812, 0, -58, 0, 100, 0], [24708, 0, 0, -36, 0, -682, 0, -426], [8950, 0, 0, -280, 0, -644, 0, 972], [0, -1617, -838, 0, -304, 0, 689, 0], [-36373, 0, 0, 280, 0, 656, 0, -841], [4156, 0, 0, 574, 0, 263, 0, 419], [0, -1853, 1199, 0, 411, 0, 232, 0], [-6152, 0, 0, 590, 0, -660, 0, -52], [0, 1399, -5781, 0, -1517, 0, 1304, 0], [22836, 0, 0, -986, 0, -257, 0, 49], [28249, 0, 0, 600, 0, 528, 0, 189], [0, -1300, 3078, 0, -998, 0, 354, 0], [0, -361, -2445, 0, 1693, 0, -42, 0], [-50208, 0, 0, -704, 0, -168, 0, 304], [0, 496, 735, 0, -1700, 0, -916, 0], [-3586, 0, 0, 904, 0, 312, 0, -568], [0, -992, -947, 0, 4852, 0, -412, 0], [-5442, 0, 0, 378, 0, 621, 0, -883], [24265, 0, 0, -608, 0, -538, 0, 515], [66416, 0, 0, 134, 0, 515, 0, 89], [5874, 0, 0, 942, 0, -217, 0, 511], [0, -60, -2930, 0, 3452, 0, -702, 0], [0, 2292, -3312, 0, 179, 0, 540, 0], [0, 1622, -6459, 0, -1568, 0, 682, 0], [27486, 0, 0, -94, 0, -863, 0, -735], [0, -748, -2993, 0, 1212, 0, -1160, 0], [7810, 0, 0, -322, 0, -557, 0, -65], [42506, 0, 0, -102, 0, -739, 0, 425], [-7323, 0, 0, -608, 0, -1470, 0, 131], [0, 1812, -2734, 0, 718, 0, -806, 0], [0, 2105, 3741, 0, 205, 0, -1452, 0], [0, -907, 2970, 0, -2304, 0, 383, 0], [0, 1920, -3221, 0, 4916, 0, -1012, 0], [-30166, 0, 0, 826, 0, 1485, 0, -267], [19426, 0, 0, -146, 0, 55, 0, -1217], [3748, 0, 0, -26, 0, -895, 0, 981], [0, 1544, 6848, 0, -532, 0, -776, 0], [31036, 0, 0, 928, 0, -216, 0, -780], [0, -2940, -8582, 0, 1598, 0, 374, 0], [-11669, 0, 0, -784, 0, -1196, 0, -461], [-43300, 0, 0, 802, 0, -1095, 0, 983], [0, 996, 3778, 0, -2095, 0, -942, 0], [0, -2240, 3233, 0, -76, 0, -228, 0], [0, 228, 1524, 0, -353, 0, -680, 0], [19323, 0, 0, 272, 0, -1213, 0, -302], [0, -2065, 5923, 0, -4701, 0, 1464, 0], [39042, 0, 0, -174, 0, 1105, 0, 89], [0, 548, -4448, 0, -2163, 0, -1236, 0], [0, 1216, 2836, 0, -2331, 0, 1140, 0], [0, 1160, -10032, 0, -1074, 0, 1396, 0], [10956, 0, 0, -870, 0, -2119, 0, 279], [-47038, 0, 0, 1320, 0, -416, 0, 416], [11984, 0, 0, 1206, 0, 658, 0, 74], [0, 2526, -4408, 0, -1247, 0, -1485, 0], [-2260, 0, 0, -1150, 0, -857, 0, 1059], [0, 1088, 64, 0, -1055, 0, -1816, 0], [-35670, 0, 0, 1134, 0, 19, 0, -529], [-68788, 0, 0, -310, 0, -455, 0, -11], [-3878, 0, 0, 550, 0, -2565, 0, 643], [68952, 0, 0, 1426, 0, 274, 0, -206], [-66026, 0, 0, -1302, 0, -1947, 0, -219], [-36794, 0, 0, 966, 0, -125, 0, 955], [30141, 0, 0, -1224, 0, 236, 0, 13], [-17569, 0, 0, 1272, 0, 1274, 0, 125], [10742, 0, 0, 1118, 0, 263, 0, -209], [47754, 0, 0, 34, 0, -647, 0, 229], [0, -1285, 3159, 0, -309, 0, -1416, 0], [0, -1917, 8706, 0, -156, 0, -1383, 0], [19012, 0, 0, -1458, 0, -1159, 0, 765], [0, 4470, -3961, 0, 5912, 0, -1238, 0], [38848, 0, 0, -1844, 0, 246, 0, -406], [0, -1028, -994, 0, -4052, 0, 482, 0], [0, -3112, -1832, 0, 4945, 0, 1472, 0], [36676, 0, 0, -444, 0, -798, 0, -686], [32077, 0, 0, 704, 0, 1126, 0, -681], [0, -552, 2082, 0, -2669, 0, -218, 0], [0, -944, -141, 0, -5652, 0, -548, 0], [-97579, 0, 0, -472, 0, 87, 0, 416], [0, 476, 1534, 0, 7871, 0, -309, 0], [0, 1180, -7530, 0, -1761, 0, -618, 0], [0, 1436, 822, 0, 349, 0, -1298, 0], [25448, 0, 0, -268, 0, 1002, 0, -546], [17063, 0, 0, -1336, 0, 216, 0, -341], [0, -2158, -11884, 0, 2307, 0, -167, 0], [10678, 0, 0, 822, 0, -2269, 0, 251], [-5249, 0, 0, -64, 0, -18, 0, -1015], [18307, 0, 0, 1800, 0, 1304, 0, -25], [0, -1395, -4878, 0, -6720, 0, -833, 0]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_1224_c_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_1224_4_c_e();".
// 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_1224_4_c_e(:prec:=8)
    chi := MakeCharacter_1224_c();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 4));
    S := BaseChange(S, Kf);
    maxprec := NextPrime(1999) - 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_1224_4_c_e();".
// 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_1224_4_c_e( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_1224_c();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<5,R![286466048, 0, 16028160, 0, 187712, 0, 760, 0, 1]>,<47,R![134217728, -3407872, -57344, 156, 1]>],Snew);
    return Vf;
end function;