
// Make newform 1050.3.p.b in Magma, downloaded from the LMFDB on 17 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_1050_p();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_1050_p_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_1050_3_p_b();".
// 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_1050_3_p_b();".
// 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 := [81, 0, -36, 0, 7, 0, -4, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0, 0, 0, 0, 0], [-36, 0, 7, 0, 14, 0, 1, 0], [0, 81, 0, 35, 0, 7, 0, -4], [144, 0, -28, 0, 7, 0, -4, 0], [0, 180, 0, -35, 0, -7, 0, -5], [0, 13, 0, 0, 0, 0, 0, 1], [162, 0, 7, 0, 14, 0, -8, 0], [0, -684, 0, 133, 0, -49, 0, 19]];
    Rf_basisdens := [1, 63, 189, 63, 189, 21, 63, 189];
    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_1050_p();"
function MakeCharacter_1050_p()
    N := 1050;
    order := 6;
    char_gens := [701, 127, 451];
    v := [6, 6, 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_1050_p_Hecke();"
function MakeCharacter_1050_p_Hecke(Kf)
    N := 1050;
    order := 6;
    char_gens := [701, 127, 451];
    char_values := [[1, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 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 := 3;
    raw_aps := [[0, 0, -1, 0, -1, 0, 0, 0], [-1, 0, 0, -1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, -1, -1, 0, -3, 0, -2, 0], [-1, -2, 0, 1, 3, 4, 1, 2], [-2, 1, -4, 4, -8, -1, -1, -1], [-7, 0, 2, -7, 1, 0, -3, -2], [18, -2, -7, -9, 7, -1, 0, 0], [0, -3, 1, -3, 1, 2, 6, 4], [9, -1, 13, 0, 0, -2, -1, 2], [-11, 0, -2, -11, -1, 0, -2, 5], [0, 5, -2, 24, -2, -1, -10, -2], [-3, 19, -1, 6, -2, 4, -19, 4], [14, -9, 5, 0, 0, 4, -9, -4], [4, 8, -20, -2, 20, -2, 0, 0], [-8, -8, 0, 8, 26, -16, 4, -8], [11, 0, 14, 11, 7, 0, -21, -8], [16, -16, -2, -8, 2, 16, 0, 0], [30, 6, 0, -30, 9, -16, -3, -8], [1, -7, 29, 0, 0, -6, -7, 6], [-2, 0, 20, -2, 10, 0, 25, -15], [0, 2, -13, 3, -13, -19, -4, -38], [3, -7, 15, -6, 30, -34, 7, -34], [82, -19, 11, -41, -11, 4, 0, 0], [-36, -8, -20, 72, -40, -18, 8, -18], [7, 0, -30, 7, -15, 0, -19, 14], [144, -1, -5, -72, 5, -20, 0, 0], [0, 1, -25, -15, -25, 24, -2, 48], [15, -16, 0, -15, -20, -36, 8, -18], [50, -8, 24, 0, 0, 6, -8, -6], [82, 9, 57, 0, 0, -12, 9, 12], [-60, -20, -40, 30, 40, 24, 0, 0], [-79, -2, 0, 79, -85, 16, 1, 8], [-37, 8, 27, 74, 54, -43, -8, -43], [0, -20, 10, -84, 10, -26, 40, -52], [-54, 0, 0, 54, 68, -12, 0, -6], [52, 0, -28, 52, -14, 0, 76, -22], [0, 14, 86, -120, 86, 12, -28, 24], [71, 53, -11, -142, -22, -20, -53, -20], [12, -58, 26, -6, -26, -18, 0, 0], [-148, 68, 0, 148, -12, 16, -34, 8], [37, -74, -40, -74, -80, 4, 74, 4], [0, 28, 14, 94, 14, -24, -56, -48], [-162, -38, 0, 162, 96, 2, 19, 1], [-83, 15, 47, 0, 0, 28, 15, -28], [-16, 0, -72, -16, -36, 0, -20, 26], [-86, -4, 180, 0, 0, 6, -4, -6], [-34, -18, 28, 68, 56, 70, 18, 70], [-99, 0, 30, -99, 15, 0, -21, -4], [282, 32, 24, -141, -24, -28, 0, 0], [0, 24, 146, -142, 146, 28, -48, 56], [-92, -50, -22, 0, 0, -12, -50, 12], [74, 0, -32, 74, -16, 0, -82, 36], [43, -97, 19, -86, 38, 46, 97, 46], [90, -33, -37, -45, 37, 26, 0, 0], [-176, -72, 0, 176, 158, 44, 36, 22], [-110, 0, 12, -110, 6, 0, -72, 10], [-16, -84, 36, 8, -36, -34, 0, 0], [36, -78, 0, -36, -6, -106, 39, -53], [24, -16, 70, 0, 0, -32, -16, 32], [-80, 0, -182, -80, -91, 0, 47, 62], [-40, -16, -2, 80, -4, -6, 16, -6], [64, 125, -1, -128, -2, -38, -125, -38], [-1, 0, -146, -1, -73, 0, 41, -52], [-140, 9, 4, 70, -4, 49, 0, 0], [0, -5, 17, -17, 17, 2, 10, 4], [0, 0, 11, 363, 11, 1, 0, 2], [-242, -49, -6, 0, 0, -37, -49, 37], [-56, 0, 0, 56, -2, 72, 0, 36], [-152, -100, 48, 304, 96, 12, 100, 12], [-37, 0, -214, -37, -107, 0, 45, 90], [0, 89, 233, -335, 233, 58, -178, 116], [38, 0, 170, 38, 85, 0, -73, 24], [0, 29, -160, -294, -160, -41, -58, -82], [27, 26, -241, 0, 0, 37, 26, -37], [44, -34, -4, -22, 4, 88, 0, 0], [-217, -90, 0, 217, 155, -24, 45, -12], [104, 45, 78, -52, -78, -69, 0, 0], [0, -58, 58, -106, 58, -18, 116, -36], [71, 0, 228, 71, 114, 0, -48, -54], [102, 152, 30, -204, 60, 42, -152, 42], [-41, 0, 154, 0, 0, 72, 0, -72], [148, 52, 0, -148, -6, -84, -26, -42], [4, 71, 60, -8, 120, 109, -71, 109], [236, -110, -62, -118, 62, -86, 0, 0], [0, -80, 152, -4, 152, 6, 160, 12], [-106, -44, 156, 0, 0, -42, -44, 42], [0, 39, 80, 138, 80, -59, -78, -118], [-35, 109, -123, 70, -246, -4, -109, -4], [8, -53, 145, 0, 0, 34, -53, -34], [-344, 54, -16, 172, 16, 72, 0, 0], [-220, 0, -204, -220, -102, 0, -80, -56], [-172, 22, 0, 172, 77, 64, -11, 32], [-168, 32, 270, 0, 0, -14, 32, 14], [0, -6, -115, -75, -115, 41, 12, 82], [-222, 132, 116, 444, 232, -104, -132, -104], [-244, -40, 180, 122, -180, -82, 0, 0], [-102, 0, -300, -102, -150, 0, -38, -56], [20, 327, 83, -10, -83, -18, 0, 0], [0, -40, 100, 305, 100, 52, 80, 104], [-206, 64, -306, 0, 0, -74, 64, 74], [-146, -72, 0, 146, -252, 88, 36, 44], [-38, 0, -444, -38, -222, 0, 8, 8], [0, -15, 131, 211, 131, -60, 30, -120], [-157, 188, 0, 157, 237, 46, -94, 23], [54, 0, 528, 54, 264, 0, -1, -69], [371, -5, 1, -742, 2, 0, 5, 0], [434, -81, 89, -217, -89, 22, 0, 0], [506, -196, 0, -506, 276, -36, 98, -18], [219, 136, 46, -438, 92, -8, -136, -8], [348, 233, -157, -174, 157, 64, 0, 0], [72, 148, 0, -72, 472, -32, -74, -16], [210, 60, -38, 0, 0, 6, 60, -6], [-31, 0, 194, -31, 97, 0, 312, 49], [-162, 4, -292, 0, 0, 4, 4, -4], [-687, -66, 0, 687, 185, 36, 33, 18], [194, -195, 23, -388, 46, -38, 195, -38], [117, 0, 166, 117, 83, 0, -73, 0], [0, 165, 81, 55, 81, -76, -330, -152], [802, 26, -162, 0, 0, -6, 26, 6], [37, 0, -168, 37, -84, 0, 114, 32], [282, 55, 358, 0, 0, -9, 55, 9], [-22, -171, 163, 11, -163, -6, 0, 0], [-345, 42, 0, 345, -141, -120, -21, -60], [150, -100, 151, -75, -151, -3, 0, 0], [-137, 189, -111, 0, 0, -42, 189, 42], [0, -124, -142, 134, -142, -88, 248, -176], [160, 126, -166, -80, 166, -124, 0, 0], [-66, 105, -137, 132, -274, 0, -105, 0], [-288, 109, -134, 144, 134, -135, 0, 0], [-123, 312, 0, 123, 239, -42, -156, -21], [-391, 81, 507, 0, 0, 80, 81, -80], [0, 44, 381, -313, 381, 43, -88, 86], [-622, -36, 50, 0, 0, 86, -36, -86], [346, 309, -91, -173, 91, 164, 0, 0], [143, 30, 18, -286, 36, 30, -30, 30], [-63, 0, -562, -63, -281, 0, 15, -144], [-222, 0, 140, -222, 70, 0, -366, 124], [269, -103, 89, -538, 178, -156, 103, -156], [328, -468, 0, -328, 28, -40, 234, -20], [-118, 30, -264, 236, -528, 52, -30, 52], [0, -13, 149, 597, 149, -6, 26, -12], [-272, 108, 0, 272, 316, -176, -54, -88], [84, -138, -258, 0, 0, -82, -138, 82], [77, 0, -316, 77, -158, 0, -26, -70], [-181, 59, -171, 362, -342, -122, -59, -122], [312, -75, 150, -624, 300, -205, 75, -205], [-253, 0, 262, -253, 131, 0, -21, -92], [-204, -94, -174, 102, 174, 98, 0, 0], [0, -126, 640, 280, 640, 74, 252, 148], [0, -72, 254, -190, 254, 142, 144, 284], [280, 100, 82, -560, 164, 24, -100, 24], [398, 223, 115, 0, 0, -46, 223, 46], [-774, -113, -33, 387, 33, -148, 0, 0], [254, 34, 0, -254, 71, 284, -17, 142], [-895, -61, 271, 0, 0, -2, -61, 2], [0, 108, -707, 27, -707, 3, -216, 6], [-974, 215, 237, 487, -237, 46, 0, 0], [-56, -103, 246, 112, 492, 167, 103, 167], [-299, 0, -374, -299, -187, 0, -43, -72], [0, 33, 217, 131, 217, 4, -66, 8], [252, -60, -438, 0, 0, 56, -60, -56], [-306, -79, -367, 0, 0, 194, -79, -194], [-352, -136, 306, 176, -306, 48, 0, 0], [-165, 14, 0, 165, 339, -168, -7, -84], [49, 0, -466, 49, -233, 0, -143, 240], [-199, -284, 0, 199, 239, -134, 142, -67], [92, 0, 116, 92, 58, 0, 107, -85], [-407, 110, 54, 0, 0, -72, 110, 72], [-1242, -29, 171, 621, -171, 16, 0, 0], [-818, 236, 0, 818, -446, -16, -118, -8], [382, -178, 182, -764, 364, 22, 178, 22], [0, 203, 13, 35, 13, -48, -406, -96], [-722, -354, 0, 722, -258, 62, 177, 31], [-191, 0, 238, -191, 119, 0, 164, 127], [308, 80, 50, -616, 100, -130, -80, -130], [-563, 310, -229, 0, 0, -99, 310, 99], [566, 200, 0, -566, 244, -52, -100, -26], [-276, 136, -84, 552, -168, -36, -136, -36], [-1142, -184, -170, 571, 170, 162, 0, 0], [0, 125, -319, 398, -319, 244, -250, 488], [-373, -9, 129, 746, 258, -190, 9, -190], [66, -223, 546, 0, 0, 5, -223, -5], [-1064, -124, -26, 532, 26, -216, 0, 0], [988, 68, 0, -988, 358, 272, -34, 136], [8, 0, 224, 8, 112, 0, -156, 196], [540, -116, 0, -540, -806, 104, 58, 52], [-318, 0, 842, -318, 421, 0, -11, -192], [0, -128, -626, -487, -626, 116, 256, 232], [359, 0, 210, 359, 105, 0, -235, 218], [-624, -281, -464, 312, 464, 5, 0, 0], [-325, -221, 313, 0, 0, -218, -221, 218], [0, -148, 656, 122, 656, -88, 296, -176], [-160, 280, -252, 80, 252, -106, 0, 0], [-521, 82, 0, 521, 261, -36, -41, -18], [-391, 0, -362, -391, -181, 0, -203, -394], [-461, -184, 0, 461, -340, -136, 92, -68], [0, -18, -184, -80, -184, 316, 36, 632], [746, -144, -32, -1492, -64, 44, 144, 44], [138, -307, -31, -69, 31, 22, 0, 0], [678, -88, 0, -678, -22, 252, 44, 126], [161, 610, -83, -322, -166, -17, -610, -17], [-432, 64, 26, 216, -26, -30, 0, 0], [-440, 0, 1120, -440, 560, 0, -76, 62], [207, -551, 97, -414, 194, 116, 551, 116], [564, 0, -184, 564, -92, 0, 22, -138], [-136, 292, -354, 68, 354, 118, 0, 0], [0, -184, 118, 654, 118, -42, 368, -84], [426, -118, 756, 0, 0, 150, -118, -150], [330, 0, -772, 330, -386, 0, -74, -118], [0, -131, -730, 714, -730, 41, 262, 82], [319, 667, -115, -638, -230, -158, -667, -158], [-402, -308, 410, 0, 0, -42, -308, 42], [804, 162, -178, -402, 178, 70, 0, 0], [-677, 0, -542, -677, -271, 0, 371, 150], [1154, -436, -10, -577, 10, -84, 0, 0], [-592, 668, 0, 592, -126, 96, -334, 48], [-18, 0, 132, -18, 66, 0, -94, 128], [0, -468, 408, -564, 408, -114, 936, -228], [94, 64, -424, 0, 0, 246, 64, -246], [0, -110, -200, 829, -200, -16, 220, -32], [-835, 278, -65, 1670, -130, 171, -278, 171], [0, -361, -65, -131, -65, 128, 722, 256], [0, 182, -406, -380, -406, -272, -364, -544], [40, -262, 64, -80, 128, 534, 262, 534], [346, 108, 466, 0, 0, 132, 108, -132], [-1116, -102, 278, 558, -278, -352, 0, 0], [-16, 612, 0, 16, -390, -256, -306, -128], [-924, 251, -87, 462, 87, 202, 0, 0], [0, -131, 173, 279, 173, 188, 262, 376], [1252, -178, 0, -1252, 240, 94, 89, 47], [224, 0, 1324, 224, 662, 0, -104, 26], [-27, -476, 63, 0, 0, 49, -476, -49], [-171, 418, 0, 171, -127, 148, -209, 74], [-330, -527, 259, 660, 518, -44, 527, -44], [-473, 0, -298, -473, -149, 0, 381, 312], [-910, 46, -508, 455, 508, -2, 0, 0], [0, -95, -227, 1215, -227, -232, 190, -464], [494, 14, -112, 0, 0, 86, 14, -86], [-33, -755, 17, 66, 34, -214, 755, -214], [365, 34, 0, -365, -701, -304, -17, -152], [1294, 34, 307, -647, -307, -3, 0, 0], [-306, 0, 1258, -306, 629, 0, -187, 6], [0, 142, -36, 44, -36, 164, -284, 328], [700, -392, -350, -1400, -700, 6, 392, 6], [-4, -270, -40, 2, 40, -28, 0, 0], [120, -25, -223, -240, -446, -348, 25, -348], [-433, 0, 726, -433, 363, 0, 441, -458], [1068, -556, 0, -1068, 352, -224, 278, -112], [-614, -78, -304, 0, 0, -322, -78, 322], [54, -417, 80, 0, 0, 25, -417, -25], [-1068, 358, -404, 534, 404, -260, 0, 0], [-330, -272, 0, 330, -560, -368, 136, -184], [19, -832, 274, -38, 548, -172, 832, -172], [520, 0, 96, 520, 48, 0, -320, 252], [0, 175, 1107, -1093, 1107, 170, -350, 340], [-601, -188, 0, 601, -632, -344, 94, -172], [514, 0, -322, 514, -161, 0, -317, 170], [219, 449, -583, -438, -1166, 84, -449, 84], [780, -770, -316, -390, 316, 6, 0, 0], [-1206, 30, 0, 1206, -5, -312, -15, -156], [958, -186, 1022, 0, 0, 152, -186, -152], [653, 0, 488, 653, 244, 0, -392, -456], [804, -241, -118, -1608, -236, -9, 241, -9], [574, 0, -596, 574, -298, 0, -48, 494], [426, -376, -217, -213, 217, -675, 0, 0], [-419, 37, -1173, 0, 0, 134, 37, -134], [-178, -304, -26, 356, -52, 68, 304, 68], [668, 334, 4, 0, 0, 136, 334, -136], [1411, -90, 0, -1411, -935, 76, 45, 38], [-2314, 340, -90, 1157, 90, -220, 0, 0], [-1708, -452, 0, 1708, 424, 216, 226, 108], [458, 0, 1792, 458, 896, 0, 173, 119], [0, -22, -735, -351, -735, -179, 44, -358], [-640, 644, -100, 1280, -200, -60, -644, -60], [564, -106, -808, -282, 808, -350, 0, 0], [0, -83, 425, 1371, 425, 94, 166, 188], [-177, -80, 0, 177, 238, -404, 40, -202], [0, 6, 1040, 13, 1040, 128, -12, 256], [-136, -284, 66, 68, -66, -592, 0, 0], [-342, 0, -4, -342, -2, 0, -258, -624], [329, 424, 0, -329, 377, -174, -212, -87], [316, -234, -88, -632, -176, 134, 234, 134], [-579, 44, -396, 1158, -792, 138, -44, 138], [260, 358, -302, -130, 302, -228, 0, 0], [0, 37, -259, 1371, -259, 58, -74, 116], [596, -306, 0, -596, -684, 390, 153, 195], [-1031, 329, -415, 0, 0, -316, 329, 316], [591, 0, 1058, 591, 529, 0, -456, -185], [87, -267, -1, -174, -2, -552, 267, -552], [-688, 64, 0, 688, -1128, 256, -32, 128], [-246, 0, 264, -246, 132, 0, 278, -550], [0, -109, 219, -1839, 219, -74, 218, -148], [359, -405, -609, -718, -1218, -44, 405, -44], [1406, -235, -352, 0, 0, -207, -235, 207], [460, 0, 44, 460, 22, 0, 42, -40], [46, 116, -531, -23, 531, -411, 0, 0], [-193, -5, -27, 386, -54, -430, 5, -430], [1550, 685, 301, -775, -301, -236, 0, 0], [-482, 321, 329, 964, 658, -386, -321, -386], [-740, -294, -394, 370, 394, 48, 0, 0], [0, 8, 362, 666, 362, 218, -16, 436], [-1300, 20, 0, 1300, 748, -280, -10, -140]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_1050_p_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_1050_3_p_b();".
// 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_1050_3_p_b(:prec:=8)
    chi := MakeCharacter_1050_p();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 3));
    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_1050_3_p_b();".
// 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_1050_3_p_b( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_1050_p();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,3,sign)));
    Vf := Kernel([<11,R![22505536, -9715712, 5617504, 576448, 93448, 2896, 316, 4, 1]>,<17,R![15808576, 24428544, 15366112, 4300800, 658056, 58800, 3052, 84, 1]>],Snew);
    return Vf;
end function;