
// Make newform 507.4.a.r in Magma, downloaded from the LMFDB on 18 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_507_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_507_4_a_r();".
// 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_507_4_a_r();".
// 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 := [-27648, 0, 44100, 0, -14700, 0, 1645, 0, -70, 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, 1, 0, 0, 0, 0, 0, 0, 0, 0], [0, -210, 0, 35, 0, -1, 0, 0, 0, 0], [0, 0, -210, 0, 35, 0, -1, 0, 0, 0], [-14, 0, 1, 0, 0, 0, 0, 0, 0, 0], [1792, 0, -706, 0, 51, 0, -1, 0, 0, 0], [0, -2940, 0, 700, 0, -49, 0, 1, 0, 0], [8064, 0, -7140, 0, 1168, 0, -61, 0, 1, 0], [0, 15912, 0, -9030, 0, 1309, 0, -64, 0, 1], [0, 20304, 0, -12654, 0, 1603, 0, -70, 0, 1]];
    Rf_basisdens := [1, 1, 96, 96, 1, 32, 96, 96, 576, 576];
    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_507_a();"
function MakeCharacter_507_a()
    N := 507;
    order := 1;
    char_gens := [170, 340];
    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_507_a_Hecke(Kf)
    return MakeCharacter_507_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+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, 1, 0, 0, 0, 0, 0, 0, 0, 0], [3, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 0, 0, 0, 0, 0, -1, 0], [0, 0, 2, 0, 0, 0, 0, 0, 0, -1], [0, 5, -4, 0, 0, 0, 2, 0, -1, -1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [21, 0, 0, 4, 0, 0, 0, 1, 0, 0], [0, 9, -12, 0, 0, 0, -4, 0, 3, -1], [-12, 0, 0, -1, -1, -1, 0, 3, 0, 0], [99, 0, 0, -11, 3, -3, 0, 0, 0, 0], [0, -9, -22, 0, 0, 0, -6, 0, -3, -2], [0, -36, 27, 0, 0, 0, 0, 0, 12, -1], [0, -32, 71, 0, 0, 0, 6, 0, -8, 3], [-74, 0, 0, -18, -4, -10, 0, -1, 0, 0], [0, 47, -4, 0, 0, 0, 4, 0, -3, 1], [33, 0, 0, -3, 3, 9, 0, -4, 0, 0], [0, 26, 52, 0, 0, 0, -16, 0, -6, -4], [275, 0, 0, 9, -7, -3, 0, 1, 0, 0], [0, -36, 106, 0, 0, 0, 14, 0, 12, -3], [0, -95, -108, 0, 0, 0, 4, 0, -1, -5], [0, -72, 57, 0, 0, 0, -10, 0, 0, 0], [110, 0, 0, 63, -11, -13, 0, 2, 0, 0], [0, -35, -172, 0, 0, 0, -10, 0, -37, -19], [0, -118, -136, 0, 0, 0, 4, 0, -6, 10], [0, -81, 250, 0, 0, 0, -32, 0, -3, 22], [-57, 0, 0, 131, 31, 7, 0, -2, 0, 0], [610, 0, 0, -48, 16, 16, 0, 1, 0, 0], [252, 0, 0, 139, 37, 19, 0, 11, 0, 0], [0, -279, -154, 0, 0, 0, -10, 0, 27, 46], [507, 0, 0, 14, 76, 10, 0, -9, 0, 0], [598, 0, 0, 51, -51, -1, 0, -24, 0, 0], [-36, 0, 0, -144, 32, 32, 0, 22, 0, 0], [0, -202, -831, 0, 0, 0, 10, 0, 14, 43], [662, 0, 0, 33, -69, -3, 0, 48, 0, 0], [0, -197, -281, 0, 0, 0, -22, 0, -3, 2], [0, 171, 24, 0, 0, 0, 62, 0, 81, -3], [569, 0, 0, 69, 3, -39, 0, 25, 0, 0], [0, -63, -354, 0, 0, 0, 26, 0, 51, -74], [0, 14, -680, 0, 0, 0, -56, 0, 34, 10], [726, 0, 0, 82, 4, 46, 0, 34, 0, 0], [-1284, 0, 0, 311, 125, -1, 0, 5, 0, 0], [-839, 0, 0, 360, 74, 80, 0, -21, 0, 0], [-60, 0, 0, -286, 66, -78, 0, -20, 0, 0], [0, -288, -193, 0, 0, 0, -100, 0, -24, -66], [0, -44, 164, 0, 0, 0, 100, 0, -96, 124], [190, 0, 0, -240, -112, 40, 0, -27, 0, 0], [-1522, 0, 0, 3, 57, 79, 0, -2, 0, 0], [0, -270, -228, 0, 0, 0, -100, 0, 198, 4], [0, -95, 600, 0, 0, 0, -122, 0, 47, 49], [0, 594, -148, 0, 0, 0, 10, 0, 102, -2], [-906, 0, 0, -276, 148, -56, 0, 60, 0, 0], [0, -233, 1356, 0, 0, 0, 104, 0, 61, -85], [0, 801, -1023, 0, 0, 0, -60, 0, -69, 70], [-1212, 0, 0, -146, 18, -78, 0, 22, 0, 0], [-369, 0, 0, 158, 362, -10, 0, -59, 0, 0], [-1656, 0, 0, -125, 359, 11, 0, 37, 0, 0], [1002, 0, 0, 80, 218, 152, 0, 50, 0, 0], [0, 261, -22, 0, 0, 0, 2, 0, 159, 24], [3979, 0, 0, 30, 264, 6, 0, -49, 0, 0], [0, -586, 745, 0, 0, 0, 106, 0, -206, 13], [742, 0, 0, -582, 104, -206, 0, -47, 0, 0], [0, 329, 35, 0, 0, 0, -184, 0, -85, -82], [0, -414, 1854, 0, 0, 0, -230, 0, 198, 45], [2544, 0, 0, 369, -379, 17, 0, -45, 0, 0], [2384, 0, 0, -75, -167, 137, 0, -94, 0, 0], [0, -1205, 695, 0, 0, 0, 216, 0, -167, 6], [0, -693, -1710, 0, 0, 0, 6, 0, 81, 140], [-209, 0, 0, 66, -40, 82, 0, -72, 0, 0], [1812, 0, 0, 257, -433, -79, 0, 47, 0, 0], [0, -513, -902, 0, 0, 0, 146, 0, -51, 94], [0, 1138, -1611, 0, 0, 0, 220, 0, -286, -35], [0, -613, 3952, 0, 0, 0, 52, 0, 73, -17], [2474, 0, 0, 600, 332, 80, 0, 49, 0, 0], [1253, 0, 0, 429, -71, -79, 0, 115, 0, 0], [0, 1971, 1986, 0, 0, 0, 262, 0, -303, 22], [0, 958, -2764, 0, 0, 0, 0, 0, 118, -42], [-543, 0, 0, -957, -195, 231, 0, 62, 0, 0], [0, 189, -1882, 0, 0, 0, 38, 0, -393, -22], [0, 1394, -261, 0, 0, 0, 66, 0, -18, -27], [0, 504, 2167, 0, 0, 0, -120, 0, -456, -188], [-756, 0, 0, 106, -134, 34, 0, -130, 0, 0], [0, 1503, 1193, 0, 0, 0, -362, 0, 165, -71], [0, 505, 4032, 0, 0, 0, -300, 0, 351, 153], [-2915, 0, 0, -1062, 80, -14, 0, -44, 0, 0], [3658, 0, 0, -672, 444, -72, 0, -75, 0, 0], [-588, 0, 0, -270, 142, -122, 0, -146, 0, 0], [0, 176, 2044, 0, 0, 0, 64, 0, 400, -74], [0, -36, -775, 0, 0, 0, 338, 0, -180, -118], [0, -629, 1623, 0, 0, 0, 90, 0, 537, -126], [0, 252, -4318, 0, 0, 0, -28, 0, -12, 199], [4704, 0, 0, -735, 207, 141, 0, -259, 0, 0], [0, 170, -3080, 0, 0, 0, 368, 0, -474, -130], [0, 2619, -2276, 0, 0, 0, -34, 0, 129, 145], [2412, 0, 0, 125, -573, 9, 0, 189, 0, 0], [0, 1314, 708, 0, 0, 0, -156, 0, 150, 192], [4968, 0, 0, -253, 747, 3, 0, -57, 0, 0], [0, -1439, -6541, 0, 0, 0, -224, 0, 531, -26], [-2697, 0, 0, 120, -408, 300, 0, 55, 0, 0], [2900, 0, 0, 741, -715, 281, 0, -285, 0, 0], [0, 279, -65, 0, 0, 0, -384, 0, 429, -193], [-2014, 0, 0, 996, -34, -148, 0, -215, 0, 0], [0, 1967, -4139, 0, 0, 0, -48, 0, 797, 108], [-1068, 0, 0, 958, 570, 474, 0, -8, 0, 0], [918, 0, 0, 236, -110, 112, 0, -136, 0, 0], [2632, 0, 0, -987, -79, -215, 0, -49, 0, 0], [0, -1035, -3027, 0, 0, 0, 652, 0, -897, -90], [0, -626, -3744, 0, 0, 0, 140, 0, -194, -652], [0, -442, 3467, 0, 0, 0, -676, 0, -46, 263], [-10548, 0, 0, 1224, -236, -428, 0, -10, 0, 0], [5567, 0, 0, 681, 979, 581, 0, 68, 0, 0], [-8440, 0, 0, 468, 660, 324, 0, -140, 0, 0], [0, -1161, -1193, 0, 0, 0, 26, 0, 909, -207], [0, 364, 2583, 0, 0, 0, 76, 0, 764, 157], [0, -801, -3078, 0, 0, 0, 402, 0, 237, 174], [0, -729, -6526, 0, 0, 0, 166, 0, -3, 476], [3801, 0, 0, -668, -1326, 132, 0, -125, 0, 0], [0, -981, -4666, 0, 0, 0, 118, 0, 681, -48], [-3336, 0, 0, -148, 324, -324, 0, 58, 0, 0], [9930, 0, 0, -224, 518, 92, 0, -22, 0, 0], [-792, 0, 0, 2246, -534, -258, 0, 210, 0, 0], [0, -4257, -3451, 0, 0, 0, -424, 0, -75, -147], [7699, 0, 0, -6, 972, 330, 0, -264, 0, 0], [-570, 0, 0, -3048, -746, -44, 0, -254, 0, 0], [0, 2066, 8828, 0, 0, 0, 120, 0, -326, 372], [0, 234, 9650, 0, 0, 0, -338, 0, -66, -721], [-9642, 0, 0, 1476, 674, 524, 0, 30, 0, 0], [0, 1701, 7215, 0, 0, 0, -334, 0, -81, -17], [-13236, 0, 0, -1232, -1252, -136, 0, -370, 0, 0], [2146, 0, 0, 366, 202, -378, 0, 73, 0, 0], [0, -675, 5419, 0, 0, 0, 366, 0, -777, 743], [0, -3834, -1196, 0, 0, 0, -60, 0, 522, 340], [0, 2668, -384, 0, 0, 0, 196, 0, -460, 1162], [-17228, 0, 0, 1071, -1251, -429, 0, 221, 0, 0], [9758, 0, 0, -1680, 188, -216, 0, -292, 0, 0], [0, -1174, 8232, 0, 0, 0, -736, 0, 1138, -22], [0, 2142, -9228, 0, 0, 0, -134, 0, -174, 790], [0, -2852, 2796, 0, 0, 0, 354, 0, 276, 546], [0, -4365, -3662, 0, 0, 0, 6, 0, -255, -594], [2322, 0, 0, 814, 18, -366, 0, 444, 0, 0], [2391, 0, 0, 2410, 890, 686, 0, 345, 0, 0], [0, -9, -2642, 0, 0, 0, -350, 0, 573, 506], [0, 436, -13060, 0, 0, 0, -342, 0, 196, 546], [-5288, 0, 0, -2328, -648, 168, 0, -264, 0, 0], [0, -4330, -4556, 0, 0, 0, -240, 0, -694, -234], [11257, 0, 0, -1581, 425, -761, 0, -379, 0, 0], [0, 1634, 3300, 0, 0, 0, -244, 0, 154, 584], [0, 117, -13911, 0, 0, 0, -492, 0, 303, 69], [-19317, 0, 0, -1242, -1900, -850, 0, -501, 0, 0], [-12010, 0, 0, -36, -182, -724, 0, 165, 0, 0], [0, -179, -2012, 0, 0, 0, -240, 0, -961, -681], [0, -2772, -1607, 0, 0, 0, 1354, 0, -612, -371], [1479, 0, 0, -592, -560, 664, 0, 87, 0, 0], [14074, 0, 0, 3033, -1741, 61, 0, 292, 0, 0], [-14580, 0, 0, -1418, -1638, 330, 0, 228, 0, 0], [-21248, 0, 0, 3126, 266, 94, 0, 126, 0, 0], [-8460, 0, 0, -1026, 122, 50, 0, 454, 0, 0], [5108, 0, 0, 702, -370, 1158, 0, -434, 0, 0], [0, 1858, -10323, 0, 0, 0, -304, 0, -50, 995], [27653, 0, 0, -2343, -299, 269, 0, -74, 0, 0], [0, 856, -15780, 0, 0, 0, 830, 0, -176, -802], [0, -1648, 64, 0, 0, 0, 80, 0, 288, 68], [8982, 0, 0, -2492, 250, -1460, 0, -40, 0, 0], [0, -1881, 11928, 0, 0, 0, 58, 0, 741, 585], [-21156, 0, 0, -2062, 742, -146, 0, -270, 0, 0], [0, -2030, -8053, 0, 0, 0, 98, 0, -274, -91], [0, 3482, 1056, 0, 0, 0, -308, 0, 254, 616], [16640, 0, 0, 2775, -379, -109, 0, 305, 0, 0], [-3889, 0, 0, -1995, -2299, 473, 0, -409, 0, 0], [0, 4149, 7590, 0, 0, 0, 852, 0, -681, 414], [11331, 0, 0, 2211, -659, -353, 0, 578, 0, 0], [0, 145, -2360, 0, 0, 0, -1302, 0, 1667, 81], [0, 72, 6145, 0, 0, 0, -1370, 0, 600, 1209], [-18216, 0, 0, 736, 844, -188, 0, -574, 0, 0], [0, 3834, 4747, 0, 0, 0, -358, 0, -834, 460], [-3380, 0, 0, 2232, 788, -544, 0, 116, 0, 0], [25665, 0, 0, -2338, -186, 366, 0, 269, 0, 0], [0, -306, 7470, 0, 0, 0, -802, 0, 1194, -787], [0, 2315, 6201, 0, 0, 0, 930, 0, -147, -1338], [-1406, 0, 0, 2235, -2283, -729, 0, -260, 0, 0], [12920, 0, 0, -405, -275, -457, 0, 748, 0, 0], [0, -6669, 3188, 0, 0, 0, -526, 0, 2193, -59], [1020, 0, 0, 2268, -2500, -652, 0, 386, 0, 0], [11699, 0, 0, -1863, -3913, 117, 0, -137, 0, 0], [0, -812, -8684, 0, 0, 0, -22, 0, -1680, 254], [0, 1439, -8660, 0, 0, 0, 1232, 0, -1623, 65], [-5439, 0, 0, -3941, 1719, 1155, 0, 44, 0, 0], [28288, 0, 0, -3039, 879, 813, 0, -552, 0, 0], [0, -4536, 1396, 0, 0, 0, -128, 0, 48, -1882], [0, -486, -10371, 0, 0, 0, 210, 0, -810, -790], [0, 2471, -11512, 0, 0, 0, 32, 0, -1291, -865], [3833, 0, 0, 1662, -1650, 30, 0, -218, 0, 0], [0, -6587, -4952, 0, 0, 0, 2018, 0, -765, -199], [11486, 0, 0, -4584, -450, -648, 0, 247, 0, 0], [0, -2470, 14824, 0, 0, 0, 1288, 0, -638, -332], [-31440, 0, 0, -1187, -513, 333, 0, 329, 0, 0], [1866, 0, 0, -3850, 190, 694, 0, 732, 0, 0], [0, 5094, -7165, 0, 0, 0, 1354, 0, -534, -794], [5095, 0, 0, 2049, 213, 1613, 0, 329, 0, 0], [0, -7864, 9973, 0, 0, 0, 68, 0, -1932, 119], [6900, 0, 0, 1638, 166, -962, 0, -824, 0, 0], [0, 6701, 6747, 0, 0, 0, 1112, 0, 475, 380], [-17314, 0, 0, 717, 459, -519, 0, 260, 0, 0], [0, -891, 87, 0, 0, 0, -1846, 0, -921, 1219], [-17599, 0, 0, -3498, 3542, -202, 0, -342, 0, 0], [0, 2939, -6028, 0, 0, 0, -318, 0, 337, 57], [7689, 0, 0, 1861, -2545, 509, 0, -40, 0, 0], [0, -1296, 5986, 0, 0, 0, -1940, 0, -2064, 599], [-30132, 0, 0, 1292, 1876, -8, 0, -628, 0, 0], [0, 994, -15483, 0, 0, 0, -548, 0, -562, -1277], [16636, 0, 0, 1824, -2100, -1024, 0, -312, 0, 0], [25261, 0, 0, -3606, 336, 962, 0, -460, 0, 0], [13134, 0, 0, -2712, -822, -1560, 0, 358, 0, 0], [-10186, 0, 0, -2898, -2302, 1206, 0, 75, 0, 0], [0, -6247, -16208, 0, 0, 0, -166, 0, 1419, 1475], [0, 4546, -884, 0, 0, 0, -196, 0, 2430, -1018], [0, 2043, -2499, 0, 0, 0, -2152, 0, -63, -1152], [-10078, 0, 0, -909, 1789, 1319, 0, 668, 0, 0], [8361, 0, 0, -2536, 1702, 988, 0, 1055, 0, 0], [0, 3514, 19936, 0, 0, 0, -104, 0, 1882, 4], [0, -5758, -6472, 0, 0, 0, -2750, 0, 1014, -1442], [5339, 0, 0, 3309, 1419, -1719, 0, -319, 0, 0], [0, -11079, 18282, 0, 0, 0, 862, 0, 867, -696], [0, 6652, 3701, 0, 0, 0, -204, 0, 1672, -519], [0, 12735, 558, 0, 0, 0, -1618, 0, -1371, -742], [-48792, 0, 0, -3547, -1233, -423, 0, -85, 0, 0], [-9923, 0, 0, 3321, 1407, -483, 0, 623, 0, 0], [16041, 0, 0, -1304, 3876, -816, 0, 631, 0, 0], [-1284, 0, 0, 3206, -3362, -206, 0, 54, 0, 0], [16390, 0, 0, 4155, -3195, -193, 0, -172, 0, 0], [0, -2080, -18808, 0, 0, 0, 144, 0, 1852, 684], [44599, 0, 0, -4239, 1521, -435, 0, -965, 0, 0], [27434, 0, 0, 663, -915, 387, 0, -1072, 0, 0], [0, -5688, -3736, 0, 0, 0, 1128, 0, -2280, -1486], [-26607, 0, 0, -300, -2958, 252, 0, -685, 0, 0], [20798, 0, 0, 4113, -1217, -827, 0, -310, 0, 0], [0, 1612, 27040, 0, 0, 0, 1468, 0, 100, 370], [0, -3501, 2978, 0, 0, 0, 1008, 0, -2655, -1786], [0, 9473, 9229, 0, 0, 0, -644, 0, 1195, -404], [-9120, 0, 0, -3014, 1422, 918, 0, 542, 0, 0], [-32952, 0, 0, 5629, 1925, 1721, 0, -723, 0, 0], [0, 7777, 16308, 0, 0, 0, 930, 0, 63, 549], [17800, 0, 0, 7539, 1675, 135, 0, 157, 0, 0], [26480, 0, 0, 1971, 1393, 1007, 0, -243, 0, 0], [0, -1233, -7445, 0, 0, 0, -620, 0, -1227, -27], [0, 5476, -15995, 0, 0, 0, 286, 0, -1076, 751], [8520, 0, 0, -1554, 3466, -86, 0, 610, 0, 0], [0, 1629, -21478, 0, 0, 0, -930, 0, -993, 2216], [0, 9980, -17784, 0, 0, 0, 576, 0, 348, 1722], [0, 10728, -1610, 0, 0, 0, 1726, 0, -168, -1769], [24516, 0, 0, -5929, -2669, 475, 0, 233, 0, 0], [0, -7785, -18670, 0, 0, 0, -806, 0, -1347, 486], [0, 13288, -6156, 0, 0, 0, 854, 0, -2936, -718], [0, 5678, -17392, 0, 0, 0, 344, 0, 2690, -2044], [-4565, 0, 0, 2142, -3400, 982, 0, 1440, 0, 0], [68634, 0, 0, -1068, -1192, -148, 0, 496, 0, 0], [0, 653, -7788, 0, 0, 0, 902, 0, -4781, -1609], [26882, 0, 0, -264, 4552, 584, 0, 936, 0, 0], [0, -11223, 6380, 0, 0, 0, -144, 0, 1467, 1571], [22854, 0, 0, -6120, 1246, 1456, 0, 1446, 0, 0], [0, -8487, -5589, 0, 0, 0, -1832, 0, 1515, -2068], [25672, 0, 0, -5088, -4284, 80, 0, -668, 0, 0], [30852, 0, 0, 2080, -2840, 4, 0, 1232, 0, 0], [0, -12015, 12933, 0, 0, 0, 1684, 0, -2589, 759], [11447, 0, 0, -9585, 843, 651, 0, -339, 0, 0], [0, -2584, 2645, 0, 0, 0, 2314, 0, 2808, 1453], [-28450, 0, 0, -2298, -2420, -1762, 0, -513, 0, 0], [0, 6790, -4152, 0, 0, 0, 2132, 0, -2054, -1120], [0, -10316, -3345, 0, 0, 0, -1920, 0, 888, -2043], [0, 5751, -29808, 0, 0, 0, 1436, 0, 717, -767], [57675, 0, 0, 3103, -761, 1579, 0, -12, 0, 0], [-31811, 0, 0, -9657, -2689, -509, 0, -1821, 0, 0], [0, -1557, -27970, 0, 0, 0, -2598, 0, 249, 904], [0, -2457, 2467, 0, 0, 0, -3234, 0, 4557, 598], [22612, 0, 0, -528, 4344, 2784, 0, 1224, 0, 0], [10436, 0, 0, 483, 5515, 1487, 0, -298, 0, 0], [0, 13797, 44620, 0, 0, 0, 3122, 0, -753, 435], [0, -7034, 5692, 0, 0, 0, -912, 0, 1922, 2448], [0, 2484, 18985, 0, 0, 0, -184, 0, 1020, -883], [0, -12780, 15669, 0, 0, 0, -2034, 0, 6108, -386], [-37404, 0, 0, -7943, 4419, 369, 0, 507, 0, 0], [-23544, 0, 0, -2183, -6427, -3055, 0, -779, 0, 0], [0, 21852, 6336, 0, 0, 0, -812, 0, -1764, -2062], [13704, 0, 0, -2238, -5210, -2666, 0, 16, 0, 0], [0, -6669, 14341, 0, 0, 0, 184, 0, -1623, 1389], [0, -387, 15708, 0, 0, 0, -364, 0, -4353, 2115], [-5340, 0, 0, 927, -4189, 527, 0, 219, 0, 0], [-4357, 0, 0, -4944, -6512, -184, 0, 548, 0, 0], [0, -713, 26279, 0, 0, 0, -2108, 0, 549, -1544], [0, -6858, -2966, 0, 0, 0, 444, 0, 1482, -1893], [18363, 0, 0, 3532, 506, -1516, 0, 461, 0, 0], [24846, 0, 0, 7456, -7010, -440, 0, 586, 0, 0], [-29976, 0, 0, -1345, -619, -1273, 0, -697, 0, 0], [0, -842, -25267, 0, 0, 0, -1476, 0, 5062, -861], [0, -7996, -8780, 0, 0, 0, 1764, 0, -616, 2022], [-13132, 0, 0, 1473, -4213, 1061, 0, 184, 0, 0], [-4275, 0, 0, 3285, -1003, -1219, 0, 256, 0, 0], [40544, 0, 0, 756, -2700, 60, 0, -4, 0, 0], [37341, 0, 0, 9875, -4491, 1083, 0, 576, 0, 0], [6060, 0, 0, -3482, 8790, 270, 0, 124, 0, 0], [0, -7218, 37374, 0, 0, 0, 1830, 0, -3174, 1901], [35293, 0, 0, -2664, 1886, -328, 0, -920, 0, 0], [0, 4007, -18481, 0, 0, 0, 1120, 0, 249, -4076], [14896, 0, 0, 2289, 3759, -2691, 0, 959, 0, 0], [31392, 0, 0, -11532, -2660, -2828, 0, 146, 0, 0], [-2086, 0, 0, 6522, -1164, -1062, 0, -1303, 0, 0], [0, -8892, 4331, 0, 0, 0, 4114, 0, -516, 950], [21216, 0, 0, 1431, -6435, -1017, 0, 523, 0, 0], [9785, 0, 0, -9894, 4634, -646, 0, -1691, 0, 0], [0, -9094, 39880, 0, 0, 0, 792, 0, 794, 300], [33409, 0, 0, 1638, -10186, -1682, 0, -67, 0, 0], [14940, 0, 0, -11743, 3105, -1575, 0, -549, 0, 0], [0, 616, -48812, 0, 0, 0, 82, 0, 988, 130], [29331, 0, 0, 5334, -5734, 926, 0, -1271, 0, 0], [6266, 0, 0, -9930, 568, -4690, 0, 1249, 0, 0], [0, 25793, 7192, 0, 0, 0, 3272, 0, -1761, -1249], [84605, 0, 0, -7602, -204, 358, 0, -108, 0, 0], [0, -6683, 14184, 0, 0, 0, -3394, 0, 2563, -2599], [0, -7433, -30440, 0, 0, 0, 468, 0, 4109, 1689], [0, 18513, -11778, 0, 0, 0, -480, 0, 1371, -806], [-6939, 0, 0, 6314, 340, -1226, 0, -2167, 0, 0], [19570, 0, 0, 7602, 3436, 3898, 0, 285, 0, 0], [0, -3537, 35074, 0, 0, 0, -862, 0, 6933, 656], [-65031, 0, 0, -2425, -9269, 1747, 0, 42, 0, 0], [0, 4896, -6822, 0, 0, 0, 536, 0, -8928, -1423], [0, 19100, 17356, 0, 0, 0, -2572, 0, 1488, -1666], [-72853, 0, 0, 8040, 732, 640, 0, -100, 0, 0], [0, -13896, 39810, 0, 0, 0, -758, 0, -72, 3189], [0, -4401, -18580, 0, 0, 0, 944, 0, 789, -1719], [62904, 0, 0, 14801, -3859, 173, 0, -31, 0, 0], [63579, 0, 0, -7283, 4165, 1489, 0, -1380, 0, 0], [0, -2664, -4939, 0, 0, 0, -468, 0, 4152, -2967], [67611, 0, 0, 10191, 5001, 3723, 0, 1426, 0, 0], [4934, 0, 0, -1506, -1170, -4082, 0, -1979, 0, 0], [0, 6755, 28324, 0, 0, 0, -3486, 0, 929, 1731], [0, 14256, 250, 0, 0, 0, 3834, 0, -1344, 555], [0, 8011, 15236, 0, 0, 0, -5382, 0, 3517, -507], [0, -11493, 1963, 0, 0, 0, 4044, 0, 2937, 1623], [0, 25208, 24020, 0, 0, 0, -728, 0, 5028, 4030], [0, -4041, 26139, 0, 0, 0, 1474, 0, 1821, 590], [24010, 0, 0, 17715, 1369, 3175, 0, 1748, 0, 0], [0, 9990, 9820, 0, 0, 0, 2220, 0, -678, 1106], [38847, 0, 0, -10390, -3364, -3154, 0, -1051, 0, 0], [0, -5257, 5929, 0, 0, 0, 4768, 0, -5699, 3922], [670, 0, 0, -222, -2034, -3198, 0, 771, 0, 0], [0, -6476, -1668, 0, 0, 0, -1222, 0, 3436, -1930], [-39840, 0, 0, -2589, -527, 2599, 0, 255, 0, 0], [-19507, 0, 0, 11007, -1081, 531, 0, -1329, 0, 0], [0, 6192, 32024, 0, 0, 0, -3576, 0, 2448, -3622], [0, -18409, 1952, 0, 0, 0, 1676, 0, -283, -631], [103158, 0, 0, -14732, -5334, -1944, 0, 1662, 0, 0], [0, 13482, 8542, 0, 0, 0, 2154, 0, 2454, -2317], [0, -6066, -12468, 0, 0, 0, -682, 0, 5946, -2926], [0, 4447, 37853, 0, 0, 0, -4154, 0, 2541, -2348], [128950, 0, 0, 7038, 1618, -1818, 0, -351, 0, 0], [2251, 0, 0, 3144, 5708, 1648, 0, 1989, 0, 0], [-14589, 0, 0, -10626, -2084, 3718, 0, -283, 0, 0], [0, -14683, 17576, 0, 0, 0, -1308, 0, 55, -1863], [0, -23282, 53628, 0, 0, 0, 2292, 0, 354, 846], [16683, 0, 0, -8616, 2140, 2740, 0, 1231, 0, 0], [0, -15059, -9988, 0, 0, 0, 3556, 0, -1437, -1847], [0, 486, 34921, 0, 0, 0, 572, 0, 5826, 1627], [-74403, 0, 0, -406, -152, 2686, 0, 1355, 0, 0], [38784, 0, 0, 466, 5146, -4238, 0, -672, 0, 0], [0, 1432, -6164, 0, 0, 0, -4420, 0, -2952, 842], [-36290, 0, 0, -9639, -2313, 3405, 0, 770, 0, 0], [-6100, 0, 0, -6681, 5079, -669, 0, 3110, 0, 0], [0, -9634, -21048, 0, 0, 0, -2858, 0, -1774, -3458], [0, 25119, 66710, 0, 0, 0, 974, 0, -5091, -2956], [-18371, 0, 0, -5091, -1749, 3369, 0, -982, 0, 0], [-51132, 0, 0, -8962, -2598, 1350, 0, 1550, 0, 0], [-10682, 0, 0, -7566, 5148, -3150, 0, -1027, 0, 0], [0, 6137, -39420, 0, 0, 0, 3640, 0, -4105, -3545], [41217, 0, 0, -11841, 8451, -2961, 0, -1750, 0, 0], [37928, 0, 0, 14529, 5511, -683, 0, 623, 0, 0], [-62755, 0, 0, 20736, 6016, -8, 0, -53, 0, 0], [0, 163, -39064, 0, 0, 0, 230, 0, 2657, -2233], [-16740, 0, 0, 8389, -8027, -275, 0, 839, 0, 0], [0, 8865, 1542, 0, 0, 0, 5478, 0, 531, -520], [2577, 0, 0, -232, -688, -3628, 0, 2663, 0, 0], [-73985, 0, 0, -6180, -1032, 2460, 0, 1644, 0, 0], [0, 602, -71152, 0, 0, 0, -4150, 0, -2914, 1466], [0, -8230, 19643, 0, 0, 0, 5394, 0, -7958, 2967], [0, -9855, -6832, 0, 0, 0, 3950, 0, 1467, 2263], [0, 8056, 46044, 0, 0, 0, 892, 0, 5156, 814], [0, -9045, 61014, 0, 0, 0, -1294, 0, -2271, 3412], [0, 31577, 29844, 0, 0, 0, 880, 0, 3911, -95], [0, 36369, 3728, 0, 0, 0, 3494, 0, -5469, -2541], [-10184, 0, 0, 10023, -4755, -157, 0, 3952, 0, 0], [0, -9531, -53326, 0, 0, 0, 1162, 0, 4815, 496], [-19956, 0, 0, 13418, -2958, -2022, 0, 1220, 0, 0], [0, 7137, -61503, 0, 0, 0, -1466, 0, 1083, 1046], [0, -15605, 34031, 0, 0, 0, -1616, 0, -6975, 3196], [0, -12709, -26060, 0, 0, 0, -1710, 0, 10541, -2745], [5432, 0, 0, -15, 1893, -515, 0, -561, 0, 0], [0, -28342, -45344, 0, 0, 0, 356, 0, 3930, 1118], [24608, 0, 0, 13323, 7271, 495, 0, -514, 0, 0], [0, -26073, -66964, 0, 0, 0, 1370, 0, 4197, 4325], [-108486, 0, 0, 2604, -5122, 3728, 0, -788, 0, 0], [-77212, 0, 0, 5190, -770, -706, 0, 1394, 0, 0], [0, -23671, 31983, 0, 0, 0, 288, 0, -3561, 5184], [0, -13851, -13482, 0, 0, 0, 3504, 0, -1953, 4106], [-113838, 0, 0, -2464, 5188, -1700, 0, 1344, 0, 0], [0, 171, 33546, 0, 0, 0, -306, 0, -4095, 6662], [0, -8668, 63539, 0, 0, 0, -5134, 0, 8468, -499], [0, 10157, 25135, 0, 0, 0, 2958, 0, 4271, 624], [51722, 0, 0, -6762, 5718, 2950, 0, -2991, 0, 0], [0, 3807, 56714, 0, 0, 0, 1656, 0, -2499, -1930], [0, -8996, -39611, 0, 0, 0, 2802, 0, 524, 8001], [0, -7326, 19398, 0, 0, 0, -1830, 0, -5730, -2619], [0, 656, 61208, 0, 0, 0, -44, 0, -4884, -5264], [-70235, 0, 0, 20298, 5580, 3738, 0, -78, 0, 0], [41397, 0, 0, 1603, -5115, -1053, 0, -3526, 0, 0], [-31704, 0, 0, 22241, 2683, 6805, 0, -171, 0, 0], [-94832, 0, 0, -17322, -734, 3118, 0, 698, 0, 0], [23629, 0, 0, -10014, 3600, 1986, 0, 1356, 0, 0], [78789, 0, 0, 3033, 1335, -2319, 0, 1960, 0, 0], [0, 4558, 21460, 0, 0, 0, -3036, 0, -5458, -4806], [18962, 0, 0, 10050, 4282, -2062, 0, 1529, 0, 0], [0, 13118, -25552, 0, 0, 0, 2586, 0, 2086, 3162], [-178488, 0, 0, 12052, 6216, 444, 0, -1188, 0, 0], [-53697, 0, 0, 14123, 10769, 2951, 0, -1902, 0, 0], [0, 12357, -36965, 0, 0, 0, -1992, 0, -8457, -1099], [0, -10079, 41200, 0, 0, 0, 7316, 0, 3735, -2143], [64452, 0, 0, -10809, -9427, -3265, 0, 2561, 0, 0], [0, 22347, -17286, 0, 0, 0, 4068, 0, -4935, -4742], [0, 12145, -42023, 0, 0, 0, 1162, 0, -2105, -416], [-84588, 0, 0, 918, 3406, -1286, 0, 84, 0, 0], [0, 11980, -25133, 0, 0, 0, 5346, 0, -1696, -5049], [0, -19944, 5890, 0, 0, 0, 6494, 0, 3384, -1095], [-59472, 0, 0, -24082, -4990, -3550, 0, -2948, 0, 0]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_507_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_507_4_a_r();".
// 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_507_4_a_r(:prec:=10)
    chi := MakeCharacter_507_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_507_4_a_r();".
// 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_507_4_a_r( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_507_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<2,R![-27648, 0, 44100, 0, -14700, 0, 1645, 0, -70, 0, 1]>,<5,R![-31632011568, 0, 4880780280, 0, -76029795, 0, 441955, 0, -1105, 0, 1]>],Snew);
    return Vf;
end function;