
// Make newform 360.4.s.b in Magma, downloaded from the LMFDB on 04 January 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_360_s();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_360_s_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_360_4_s_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_360_4_s_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 := [256, 0, 0, 0, 5504, 0, 0, 0, 9456, 0, 0, 0, 209, 0, 0, 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], [1035124, 0, 0, 0, 5749352, 0, 0, 0, 128747, 0, 0, 0, 619, 0, 0, 0], [0, 0, -1379200, 0, 0, 0, -1849900, 0, 0, 0, -40783, 0, 0, 0, -195, 0], [-1527344, 0, 7368496, 0, 622268, 0, 9093933, 0, 15368, 0, 200073, 0, 76, 0, 956, 0], [1527344, 0, 7368496, 0, -622268, 0, 9093933, 0, -15368, 0, 200073, 0, -76, 0, 956, 0], [0, 7110912, 0, 30397088, 0, 19743536, 0, 65848504, 0, 438566, 0, 1458559, 0, 2102, 0, 6983], [0, -7110912, 0, 30397088, 0, -19743536, 0, 65848504, 0, -438566, 0, 1458559, 0, -2102, 0, 6983], [0, 44467456, 0, 50904352, 0, 82338168, 0, 45145496, 0, 1820703, 0, 988421, 0, 8711, 0, 4717], [0, 44467456, 0, -50904352, 0, 82338168, 0, -45145496, 0, 1820703, 0, -988421, 0, 8711, 0, -4717], [0, 0, -62855296, 0, 0, 0, -201136588, 0, 0, 0, -4468303, 0, 0, 0, -21411, 0], [11885904, 0, 46770176, 0, 46409792, 0, 121682708, 0, 1026632, 0, 2698253, 0, 4904, 0, 12921, 0], [-11885904, 0, 46770176, 0, -46409792, 0, 121682708, 0, -1026632, 0, 2698253, 0, -4904, 0, 12921, 0], [0, -20092416, 0, 394370848, 0, 36427872, 0, 738139464, 0, 817332, 0, 16328199, 0, 3924, 0, 78143], [0, 20092416, 0, 394370848, 0, -36427872, 0, 738139464, 0, -817332, 0, 16328199, 0, -3924, 0, 78143], [0, -75727616, 0, 666342368, 0, 79752832, 0, 1047929384, 0, 1820752, 0, 23137529, 0, 8784, 0, 110673], [0, -75727616, 0, -666342368, 0, 79752832, 0, -1047929384, 0, 1820752, 0, -23137529, 0, 8784, 0, -110673]];
    Rf_basisdens := [1, 90660, 290112, 181320, 181320, 2901120, 2901120, 1450560, 1450560, 1450560, 362640, 362640, 2901120, 2901120, 2901120, 2901120];
    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_360_s();"
function MakeCharacter_360_s()
    N := 360;
    order := 4;
    char_gens := [271, 181, 281, 217];
    v := [4, 4, 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_360_s_Hecke();"
function MakeCharacter_360_s_Hecke(Kf)
    N := 360;
    order := 4;
    char_gens := [271, 181, 281, 217];
    char_values := [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 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]];
    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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, -1, -2, 0, 0, 0, 0, 0, 0, 1, 0, 0], [-4, 0, -4, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, -4, 0, 0, 0, 0, 0, 0, 0, -1, 0, -1], [14, 0, -15, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, -3, 3, -1, -1, 0, 0, 0, 3, -3, 1, 1], [0, 0, 14, -5, -5, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 3, 3, -5, 5, 0, 0, 0, 8, 8, -1, 1], [0, 0, 0, 0, 0, 0, -30, 4, -9, 0, 0, 0, 11, -4, -2, 0], [14, 4, 0, 5, -5, 0, 0, 0, 0, 0, -1, 1, 0, 0, 0, 0], [35, 9, 34, -17, 0, 0, 0, 0, 0, 9, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, -113, 0, -3, 21, 0, 0, 0, 21, -3, 0, 0], [108, -14, -106, 0, -18, 0, 0, 0, 0, 14, -2, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 40, -40, 2, 2, 0, 0, 0, 19, -19, -3, -3], [0, 0, 0, 0, 0, -66, -66, 3, -3, 0, 0, 0, 25, 25, 3, -3], [0, 0, 0, 0, 0, 0, -4, -20, -16, 0, 0, 0, 11, 20, 5, 0], [-284, 10, 0, 7, -7, 0, 0, 0, 0, 0, 3, -3, 0, 0, 0, 0], [154, 16, 160, 14, 0, 0, 0, 0, 0, 16, 0, -6, 0, 0, 0, 0], [0, 0, 0, 0, 0, -138, 0, -16, -10, 0, 0, 0, -10, -6, 0, 10], [152, 17, -148, 0, 16, 0, 0, 0, 0, -17, -4, 0, 0, 0, 0, 0], [0, 0, -288, -25, -25, 0, 0, 0, 0, 64, -1, -1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 96, 96, -24, 24, 0, 0, 0, -9, -9, 1, -1], [0, 0, 0, 0, 0, 0, 115, 27, -29, 0, 0, 0, 23, -27, 6, 0], [-80, -21, -86, -6, 0, 0, 0, 0, 0, -21, 0, 6, 0, 0, 0, 0], [0, 0, 0, 0, 0, -352, 0, 32, 47, 0, 0, 0, 47, 30, 0, -2], [184, -20, -188, 0, -85, 0, 0, 0, 0, 20, 4, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, -12, 12, -44, -44, 0, 0, 0, -63, 63, 7, 7], [0, 0, -328, 49, 49, 0, 0, 0, 0, -84, -10, -10, 0, 0, 0, 0], [0, 0, 0, 0, 0, 52, 52, 40, -40, 0, 0, 0, -18, -18, -11, 11], [460, 8, 440, 49, 0, 0, 0, 0, 0, 8, 0, 20, 0, 0, 0, 0], [0, 0, 0, 0, 0, 42, 0, -10, -68, 0, 0, 0, -68, -39, 0, -29], [0, 0, 0, 0, 0, 344, -344, 35, 35, 0, 0, 0, -51, 51, -1, -1], [0, 0, -928, 66, 66, 0, 0, 0, 0, -60, 13, 13, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1198, -43, 36, 0, 0, 0, -30, 43, -6, 0], [-1514, -8, 0, 2, -2, 0, 0, 0, 0, 0, 13, -13, 0, 0, 0, 0], [-243, -57, -210, -9, 0, 0, 0, 0, 0, -57, 0, -33, 0, 0, 0, 0], [438, -68, -448, 0, 66, 0, 0, 0, 0, 68, 10, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 31, -31, 59, 59, 0, 0, 0, -114, 114, 11, 11], [0, 0, 0, 0, 0, 474, 474, 38, -38, 0, 0, 0, -80, -80, 5, -5], [0, 0, 0, 0, 0, 0, 190, 60, 86, 0, 0, 0, -73, -60, -13, 0], [-1892, -60, 0, 3, -3, 0, 0, 0, 0, 0, -34, 34, 0, 0, 0, 0], [0, 0, 0, 0, 0, -670, 0, 36, -102, 0, 0, 0, -102, 62, 0, 26], [1337, 138, -1291, 0, 134, 0, 0, 0, 0, -138, -46, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1099, -1099, 20, 20, 0, 0, 0, -3, 3, -24, -24], [0, 0, -1740, -28, -28, 0, 0, 0, 0, 4, -39, -39, 0, 0, 0, 0], [-4954, -20, 0, 20, -20, 0, 0, 0, 0, 0, -3, 3, 0, 0, 0, 0], [1394, 92, -1368, 0, 97, 0, 0, 0, 0, -92, -26, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, -300, 300, -28, -28, 0, 0, 0, 186, -186, -22, -22], [0, 0, -1130, -168, -168, 0, 0, 0, 0, 20, -15, -15, 0, 0, 0, 0], [0, 0, 0, 0, 0, 711, 711, -226, 226, 0, 0, 0, 194, 194, 7, -7], [0, 0, 0, 0, 0, 0, 896, 102, -146, 0, 0, 0, 62, -102, 84, 0], [-1320, -162, 0, 148, -148, 0, 0, 0, 0, 0, 60, -60, 0, 0, 0, 0], [0, 0, 0, 0, 0, -110, 0, -10, 400, 0, 0, 0, 400, 3, 0, 13], [0, 0, 0, 0, 0, 1550, -1550, -85, -85, 0, 0, 0, 27, -27, 43, 43], [0, 0, 0, 0, 0, 1427, 1427, 151, -151, 0, 0, 0, 68, 68, 35, -35], [0, 0, 0, 0, 0, 0, 1210, -189, -36, 0, 0, 0, 96, 189, -60, 0], [-3806, 252, 0, -58, 58, 0, 0, 0, 0, 0, -15, 15, 0, 0, 0, 0], [-450, 64, -473, 309, 0, 0, 0, 0, 0, 64, 0, 23, 0, 0, 0, 0], [0, 0, 0, 0, 0, -4005, 0, -41, -183, 0, 0, 0, -183, -85, 0, -44], [1454, 238, -1466, 0, 332, 0, 0, 0, 0, -238, 12, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, -763, -763, 37, -37, 0, 0, 0, -68, -68, 46, -46], [2586, -278, 2570, 490, 0, 0, 0, 0, 0, -278, 0, 16, 0, 0, 0, 0], [0, 0, 0, 0, 0, -1334, 0, 162, 176, 0, 0, 0, 176, 114, 0, -48], [3235, -360, -3215, 0, -558, 0, 0, 0, 0, 360, -20, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 2533, -2533, 105, 105, 0, 0, 0, 90, -90, 52, 52], [-4938, -262, 0, -59, 59, 0, 0, 0, 0, 0, -62, 62, 0, 0, 0, 0], [-1240, 277, -1294, -404, 0, 0, 0, 0, 0, 277, 0, 54, 0, 0, 0, 0], [0, 0, 0, 0, 0, -1388, 1388, -180, -180, 0, 0, 0, 364, -364, 12, 12], [0, 0, 458, -209, -209, 0, 0, 0, 0, 506, -7, -7, 0, 0, 0, 0], [0, 0, 0, 0, 0, -555, -555, 72, -72, 0, 0, 0, -14, -14, -95, 95], [0, 0, 0, 0, 0, 0, 2, 414, 48, 0, 0, 0, -12, -414, -36, 0], [2222, 224, 2360, -253, 0, 0, 0, 0, 0, 224, 0, -138, 0, 0, 0, 0], [2561, 293, -2564, 0, -35, 0, 0, 0, 0, -293, 3, 0, 0, 0, 0, 0], [0, 0, -152, 470, 470, 0, 0, 0, 0, -228, -51, -51, 0, 0, 0, 0], [0, 0, 0, 0, 0, 2666, 2666, 114, -114, 0, 0, 0, 65, 65, -89, 89], [0, 0, 0, 0, 0, 0, 3432, -243, -128, 0, 0, 0, -32, 243, 160, 0], [-267, -95, -216, 461, 0, 0, 0, 0, 0, -95, 0, -51, 0, 0, 0, 0], [0, 0, 0, 0, 0, -1857, 0, 116, 80, 0, 0, 0, 80, 142, 0, 26], [0, 0, -2270, -18, -18, 0, 0, 0, 0, -82, 11, 11, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -274, -368, 14, 0, 0, 0, -29, 368, 15, 0], [-936, -304, 0, 248, -248, 0, 0, 0, 0, 0, -65, 65, 0, 0, 0, 0], [0, 0, 0, 0, 0, 2704, 0, 584, -492, 0, 0, 0, -492, 556, 0, -28], [2483, -72, -2539, 0, 238, 0, 0, 0, 0, 72, 56, 0, 0, 0, 0, 0], [0, 0, -8132, 250, 250, 0, 0, 0, 0, -52, 31, 31, 0, 0, 0, 0], [0, 0, 0, 0, 0, 902, 902, -282, 282, 0, 0, 0, -150, -150, 152, -152], [0, 0, 0, 0, 0, 0, 1719, 258, -64, 0, 0, 0, -36, -258, 100, 0], [-2552, -311, -2400, 414, 0, 0, 0, 0, 0, -311, 0, -152, 0, 0, 0, 0], [0, 0, 0, 0, 0, -2696, 0, 164, -443, 0, 0, 0, -443, 216, 0, 52], [-1366, 520, 1360, 0, 183, 0, 0, 0, 0, -520, 6, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, -3166, 3166, -6, -6, 0, 0, 0, -465, 465, 107, 107], [0, 0, 0, 0, 0, 0, -3710, -22, 468, 0, 0, 0, -346, 22, -122, 0], [2628, 188, 2420, -31, 0, 0, 0, 0, 0, 188, 0, 208, 0, 0, 0, 0], [0, 0, 0, 0, 0, 5848, 0, -284, -420, 0, 0, 0, -420, -217, 0, 67], [0, 0, 5822, 3, 3, 0, 0, 0, 0, -658, -160, -160, 0, 0, 0, 0], [0, 0, 0, 0, 0, 5438, 5438, 334, -334, 0, 0, 0, -649, -649, -39, 39], [0, 0, 0, 0, 0, 0, 1710, 488, 613, 0, 0, 0, -491, -488, -122, 0], [0, 0, 0, 0, 0, -891, 0, -320, 148, 0, 0, 0, 148, -110, 0, 210], [-2396, -298, 2534, 0, 716, 0, 0, 0, 0, 298, -138, 0, 0, 0, 0, 0], [5708, -512, 0, 305, -305, 0, 0, 0, 0, 0, 164, -164, 0, 0, 0, 0], [6000, -456, 5820, 744, 0, 0, 0, 0, 0, -456, 0, 180, 0, 0, 0, 0], [0, 0, 0, 0, 0, 2066, -2066, -572, -572, 0, 0, 0, -114, 114, 227, 227], [0, 0, 0, 0, 0, 502, 502, -558, 558, 0, 0, 0, 136, 136, 62, -62], [0, 0, 0, 0, 0, 0, -2043, 562, 428, 0, 0, 0, -272, -562, -156, 0], [-2222, 74, 0, 41, -41, 0, 0, 0, 0, 0, -128, 128, 0, 0, 0, 0], [-4245, -664, -4145, 332, 0, 0, 0, 0, 0, -664, 0, -100, 0, 0, 0, 0], [0, 0, 0, 0, 0, -5626, 5626, -698, -698, 0, 0, 0, 69, -69, -199, -199], [0, 0, 0, 0, 0, -6562, -6562, -334, 334, 0, 0, 0, 354, 354, 47, -47], [0, 0, 0, 0, 0, 0, -4920, 228, 264, 0, 0, 0, -200, -228, -64, 0], [13376, 274, 0, -480, 480, 0, 0, 0, 0, 0, -29, 29, 0, 0, 0, 0], [-3704, 432, -3436, -255, 0, 0, 0, 0, 0, 432, 0, -268, 0, 0, 0, 0], [-1289, 311, 1372, 0, 537, 0, 0, 0, 0, -311, -83, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 3663, -3663, 625, 625, 0, 0, 0, 223, -223, 49, 49], [0, 0, 4580, 356, 356, 0, 0, 0, 0, 448, 107, 107, 0, 0, 0, 0], [6934, -668, 0, 991, -991, 0, 0, 0, 0, 0, -125, 125, 0, 0, 0, 0], [0, 0, 0, 0, 0, -4723, 0, 717, 131, 0, 0, 0, 131, 431, 0, -286], [-2214, -74, 2210, 0, -476, 0, 0, 0, 0, 74, 4, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, -3574, 3574, 464, 464, 0, 0, 0, -485, 485, 87, 87], [0, 0, 0, 0, 0, -4263, -4263, -248, 248, 0, 0, 0, 605, 605, -88, 88], [0, 0, 0, 0, 0, 0, -8232, -280, -656, 0, 0, 0, 561, 280, 95, 0], [8548, 862, 0, -775, 775, 0, 0, 0, 0, 0, -59, 59, 0, 0, 0, 0], [-5755, 126, 5585, 0, -78, 0, 0, 0, 0, -126, 170, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, -1063, 1063, 213, 213, 0, 0, 0, 540, -540, 56, 56], [0, 0, 0, 0, 0, -5404, -5404, 700, -700, 0, 0, 0, -297, -297, -275, 275], [10342, 66, 0, 243, -243, 0, 0, 0, 0, 0, -14, 14, 0, 0, 0, 0], [0, 0, 0, 0, 0, 520, 0, -453, 710, 0, 0, 0, 710, -553, 0, -100], [0, 0, 12814, -500, -500, 0, 0, 0, 0, -424, -127, -127, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -5794, 172, 98, 0, 0, 0, -160, -172, 62, 0], [536, 516, 228, -713, 0, 0, 0, 0, 0, 516, 0, 308, 0, 0, 0, 0], [-7538, -260, 7649, 0, -1685, 0, 0, 0, 0, 260, -111, 0, 0, 0, 0, 0], [0, 0, 1566, 485, 485, 0, 0, 0, 0, 510, 248, 248, 0, 0, 0, 0], [0, 0, 0, 0, 0, -1028, -1028, 560, -560, 0, 0, 0, 425, 425, 261, -261], [17190, 720, 0, -685, 685, 0, 0, 0, 0, 0, 25, -25, 0, 0, 0, 0], [-8094, 58, -8129, 95, 0, 0, 0, 0, 0, 58, 0, 35, 0, 0, 0, 0], [0, 0, 0, 0, 0, 4837, 0, -360, -68, 0, 0, 0, -68, -130, 0, 230], [0, 0, 7814, -658, -658, 0, 0, 0, 0, -406, -175, -175, 0, 0, 0, 0], [0, 0, 0, 0, 0, -10655, -10655, -160, 160, 0, 0, 0, 911, 911, 194, -194], [1184, 500, 844, -78, 0, 0, 0, 0, 0, 500, 0, 340, 0, 0, 0, 0], [0, 0, 0, 0, 0, 226, -226, -881, -881, 0, 0, 0, -843, 843, -155, -155], [0, 0, 0, 0, 0, 0, -3791, -1303, -207, 0, 0, 0, 159, 1303, 48, 0], [1850, 176, 0, 900, -900, 0, 0, 0, 0, 0, 205, -205, 0, 0, 0, 0], [0, 0, 0, 0, 0, -312, 0, 509, 470, 0, 0, 0, 470, 745, 0, 236], [-10702, 108, 10792, 0, 753, 0, 0, 0, 0, -108, -90, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, -9268, 9268, 1064, 1064, 0, 0, 0, -6, 6, -178, -178], [0, 0, 9280, -169, -169, 0, 0, 0, 0, 1692, 114, 114, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -21930, -706, -372, 0, 0, 0, 308, 706, 64, 0], [-1295, 447, 794, 0, 447, 0, 0, 0, 0, -447, 501, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, -5979, 5979, 15, 15, 0, 0, 0, -1085, 1085, 269, 269], [0, 0, 16588, -1360, -1360, 0, 0, 0, 0, 320, 161, 161, 0, 0, 0, 0], [0, 0, 0, 0, 0, 7787, 7787, 87, -87, 0, 0, 0, 166, 166, 269, -269], [891, 245, 1182, 257, 0, 0, 0, 0, 0, 245, 0, -291, 0, 0, 0, 0], [0, 0, 0, 0, 0, 8423, 0, -953, 497, 0, 0, 0, 497, -1009, 0, -56], [1310, 120, -1876, 0, 378, 0, 0, 0, 0, -120, 566, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 3805, -3805, -1003, -1003, 0, 0, 0, 390, -390, 221, 221], [-3758, 374, -3678, -1314, 0, 0, 0, 0, 0, 374, 0, -80, 0, 0, 0, 0], [0, 0, 0, 0, 0, -11916, 0, -238, -858, 0, 0, 0, -858, -384, 0, -146], [0, 0, 8756, -13, -13, 0, 0, 0, 0, -1532, -133, -133, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -7555, -64, 792, 0, 0, 0, -794, 64, 2, 0], [3581, 286, 3751, 276, 0, 0, 0, 0, 0, 286, 0, -170, 0, 0, 0, 0], [0, 0, 0, 0, 0, 13986, 0, 280, -2035, 0, 0, 0, -2035, 134, 0, -146], [0, 0, 0, 0, 0, -8980, 8980, 452, 452, 0, 0, 0, 102, -102, 274, 274], [0, 0, 0, 0, 0, -1120, -1120, -604, 604, 0, 0, 0, -198, -198, -445, 445], [194, -1324, 256, 1109, 0, 0, 0, 0, 0, -1324, 0, -62, 0, 0, 0, 0], [0, 0, 0, 0, 0, 11878, 0, 1802, -1112, 0, 0, 0, -1112, 1411, 0, -391], [0, 0, 0, 0, 0, 1321, -1321, 939, 939, 0, 0, 0, -309, 309, 69, 69], [0, 0, 0, 0, 0, 8358, 8358, -642, 642, 0, 0, 0, 379, 379, -219, 219], [6022, 252, 0, -1206, 1206, 0, 0, 0, 0, 0, -513, 513, 0, 0, 0, 0], [-213, -1131, 266, 37, 0, 0, 0, 0, 0, -1131, 0, -479, 0, 0, 0, 0]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_360_s_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_360_4_s_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_360_4_s_b(:prec:=16)
    chi := MakeCharacter_360_s();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 4));
    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_360_4_s_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_360_4_s_b( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_360_s();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<7,R![287641600, -89006080, 13770752, 380928, -2944, -384, 512, 32, 1]>],Snew);
    return Vf;
end function;