
// Make newform 36.3.f.c in Magma, downloaded from the LMFDB on 25 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_36_f();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_36_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_36_3_f_c();".
// 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_36_3_f_c();".
// 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 := [65536, -49152, 28672, -30720, 19456, -9216, 6784, -3648, 1552, -912, 424, -144, 76, -30, 7, -3, 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], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [-1228800, 634880, -258048, 372736, -187904, 58368, -63104, 26384, -7664, 6280, -2224, 204, -394, 83, 17, 1], [-1228800, 634880, 282624, 372736, -187904, 58368, -63104, 26384, -7664, 6280, -2224, 204, -394, 83, 17, 1], [-16384, -430080, 151552, -56832, 88320, -44672, 12896, -14864, 6208, -1688, 1464, -520, 32, -91, 19, 5], [122880, -57344, 7168, -26112, 13824, -3392, 3584, -1616, 176, -328, 72, 8, 22, -5, -3, 1], [-40960, 57344, 11264, 7680, -8704, 192, -864, 1456, 224, 136, -128, -36, -8, 15, 5, -1], [-679936, 647168, -553472, 226560, -209536, 130336, -60224, 33024, -19392, 6112, -3572, 1454, -366, 211, -97, -7], [-819200, 32768, -36864, 120832, -13568, 9344, -18016, 2512, -1472, 1752, -280, 136, -72, 15, -7, -25], [-16384, -2682880, 1638400, -749568, 648704, -429056, 177280, -128208, 59184, -25448, 13168, -5404, 1506, -839, 371, -61], [-1523712, 913408, -75776, 183296, -152576, 27264, -9088, 11216, 4816, -2456, -1216, -972, 358, 51, 73, -63], [393216, 20480, -49152, -83968, 5120, 8448, 10112, 1040, -1264, -1336, -176, 156, 118, 11, -23, -7], [-712704, -10240, -182784, 270592, -51200, 62112, -54848, 14912, -10496, 7312, -1612, 942, -610, 95, -37, 25], [-1220608, 1007616, -739328, 539136, -343296, 201088, -124816, 60304, -29864, 14560, -6300, 2642, -1015, 365, -119, 26], [-3866624, 1183744, -751616, 1309696, -428544, 235648, -237888, 83728, -39184, 29928, -7728, 3692, -2590, 535, -147, 113], [-3080192, 1552384, -2011136, 1593344, -804352, 595968, -377472, 150928, -98160, 49352, -17456, 8940, -3994, 811, -487, 137]];
    Rf_basisdens := [1, 1, 540672, 540672, 135168, 24576, 24576, 135168, 270336, 540672, 540672, 49152, 135168, 135168, 540672, 540672];
    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_36_f();"
function MakeCharacter_36_f()
    N := 36;
    order := 6;
    char_gens := [19, 29];
    v := [3, 4];
    // 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_36_f_Hecke();"
function MakeCharacter_36_f_Hecke(Kf)
    N := 36;
    order := 6;
    char_gens := [19, 29];
    char_values := [[-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+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, -1, 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, 0], [0, 0, 1, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 1, 0, -1, 0, 0, 1, -1, 0, 0, 0, 0], [0, -1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, -1], [0, 0, -5, -1, -1, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0, 0], [0, 0, 0, 2, 0, 0, 0, 0, -4, 0, 1, 0, 0, 0, 1, -2], [0, -1, 0, 1, -1, -2, 2, 0, 1, -1, -5, -1, 0, -1, -5, -1], [0, 0, 0, 3, -3, 2, 1, 2, 3, -2, -2, 0, -3, -2, 1, 0], [7, -3, -7, 0, 0, 0, 0, -2, 0, 0, 0, 2, 3, 0, 0, 3], [0, 0, 0, -5, 5, -6, -3, 0, -5, 0, 6, 0, 5, 0, -3, 0], [-4, 17, 0, 5, 17, 0, 0, 0, 7, -3, -6, -3, 0, 3, -6, -5], [0, 0, 15, -5, -9, -2, -2, 3, 1, 3, 2, 0, -1, -3, 0, 0], [0, 6, 0, 0, 0, 1, 6, 2, 0, 0, -5, 2, -6, 0, 6, 6], [0, -2, 0, 0, 0, 1, 4, -3, 0, 0, -3, -3, 2, 0, 4, -2], [-8, 9, 0, 1, 9, 0, 0, 0, 7, -1, -4, -1, 0, 1, -4, -1], [0, 0, 0, -2, 2, -8, -5, -6, -2, 6, 8, 0, 2, 6, -3, 0], [7, -25, -7, 0, 0, 6, 6, -12, 0, 0, 0, 12, 1, 0, 6, 13], [0, 0, 0, -3, 3, 6, -5, -1, -3, 1, -6, 0, 3, 1, 11, 0], [0, -1, 0, 1, -1, -22, 22, 0, 1, 5, -18, 5, 0, 5, -18, -1], [-4, 14, 0, 8, 14, 0, 0, 0, -2, 12, -3, 12, 0, -12, -3, -8], [0, 11, 0, 0, 0, 17, 6, 4, 0, 0, 11, 4, -11, 0, 6, 11], [0, 5, 0, 0, 0, -20, -21, 1, 0, 0, 1, 1, -5, 0, -21, 5], [-12, -21, 0, -13, -21, 0, 0, 0, 5, 3, 4, 3, 0, -3, 4, 13], [-17, 1, 17, 0, 0, 0, 0, 9, 0, 0, 0, -9, -1, 0, 0, -1], [-51, 18, 51, 0, 0, -4, -4, 3, 0, 0, 0, -3, -2, 0, -4, -10], [0, 0, 0, 4, -4, -24, -15, 3, 4, -3, 24, 0, -4, -3, -9, 0], [0, -13, 0, 13, -13, 26, -26, 0, 13, -7, 21, -7, 0, -7, 21, -13], [32, -7, 0, -7, -7, 0, 0, 0, 7, -9, 0, -9, 0, 9, 0, 7], [0, 0, 37, 9, 3, -3, -3, -1, -15, -1, 3, 0, 15, 1, 0, 0], [0, 18, 0, -18, 18, -12, 12, 0, -18, -6, 6, -6, 0, -6, 6, 18], [0, 0, 0, 11, -11, -3, -26, 13, 11, -13, 3, 0, -11, -13, 23, 0], [91, 3, -91, 0, 0, 0, 0, -17, 0, 0, 0, 17, -3, 0, 0, -3], [0, 0, 0, -12, 12, 24, 19, 2, -12, -2, -24, 0, 12, -2, 5, 0], [0, 0, 7, -15, -63, -24, -24, 2, -33, 2, 24, 0, 33, -2, 0, 0], [0, -13, 0, 0, 0, -1, -36, -8, 0, 0, 35, -8, 13, 0, -36, -13], [0, 0, 13, -10, 14, 12, 12, 21, 34, 21, -12, 0, -34, -21, 0, 0], [0, -2, 0, 2, -2, -16, 16, 0, 2, -8, -22, -8, 0, -8, -22, -2], [0, 0, 0, 10, -10, 22, 43, 9, 10, -9, -22, 0, -10, -9, -21, 0], [-95, -54, 95, 0, 0, 18, 18, -5, 0, 0, 0, 5, -18, 0, 18, 18], [0, 2, 0, -2, 2, 20, -20, 0, -2, 14, -12, 14, 0, 14, -12, 2], [-52, -45, 0, 3, -45, 0, 0, 0, -51, 3, 24, 3, 0, -3, 24, -3], [0, -26, 0, 0, 0, -41, -2, 15, 0, 0, -39, 15, 26, 0, -2, -26], [0, 0, -41, 41, 65, 12, 12, 3, -17, 3, -12, 0, 17, -3, 0, 0], [42, -60, 0, -4, -60, 0, 0, 0, -52, -6, 28, -6, 0, 6, 28, 4], [0, 3, 0, -3, 3, 42, -42, 0, -3, -3, 72, -3, 0, -3, 72, 3], [0, 0, 0, 38, -38, 57, 44, -2, 38, 2, -57, 0, -38, 2, 13, 0], [0, -38, 0, 0, 0, 15, 6, 15, 0, 0, 9, 15, 38, 0, 6, -38], [0, 9, 0, 0, 0, 13, -16, -25, 0, 0, 29, -25, -9, 0, -16, 9], [0, 0, 121, 2, -10, -6, -6, -15, -14, -15, 6, 0, 14, 15, 0, 0], [-102, 51, 0, 5, 51, 0, 0, 0, 41, 21, -23, 21, 0, -21, -23, -5], [0, 0, 0, 37, -37, 28, 19, -30, 37, 30, -28, 0, -37, 30, 9, 0], [-119, 98, 119, 0, 0, -30, -30, -30, 0, 0, 0, 30, 22, 0, -30, -38], [0, 57, 0, -57, 57, -18, 18, 0, -57, 3, 39, 3, 0, 3, 39, 57], [0, 0, 157, -48, -108, -30, -30, 14, -12, 14, 30, 0, 12, -14, 0, 0], [0, -1, 0, 0, 0, 1, 18, -14, 0, 0, -17, -14, 1, 0, 18, -1], [132, 57, 0, 5, 57, 0, 0, 0, 47, 21, -26, 21, 0, -21, -26, -5], [0, -8, 0, 8, -8, -28, 28, 0, 8, 22, 2, 22, 0, 22, 2, -8], [-35, 16, 35, 0, 0, -18, -18, 45, 0, 0, 0, -45, 56, 0, -18, 20], [139, -132, -139, 0, 0, 39, 39, 4, 0, 0, 0, -4, -24, 0, 39, 54], [0, 0, 0, 29, -29, -15, -58, 19, 29, -19, 15, 0, -29, -19, 43, 0], [0, 0, -131, 42, 90, 24, 24, 23, 6, 23, -24, 0, -6, -23, 0, 0], [0, -3, 0, 3, -3, -66, 66, 0, 3, 3, -57, 3, 0, 3, -57, -3], [0, 0, 0, -45, 45, -64, -29, 8, -45, -8, 64, 0, 45, -8, -35, 0], [-47, -28, 47, 0, 0, 12, 12, -6, 0, 0, 0, 6, -20, 0, 12, 4], [-149, -3, 149, 0, 0, 6, 6, -32, 0, 0, 0, 32, -21, 0, 6, -9], [0, -38, 0, 0, 0, 24, -51, -18, 0, 0, 75, -18, 38, 0, -51, -38], [0, 0, -11, -68, -128, -30, -30, 78, 8, 78, 30, 0, -8, -78, 0, 0], [0, 0, 0, 31, -31, 58, 139, 21, 31, -21, -58, 0, -31, -21, -81, 0], [109, -92, -109, 0, 0, 42, 42, -21, 0, 0, 0, 21, -76, 0, 42, 8], [75, 171, -75, 0, 0, -40, -40, -15, 0, 0, 0, 15, -11, 0, -40, -91], [0, 26, 0, -26, 26, 8, -8, 0, -26, 32, 96, 32, 0, 32, 96, 26], [0, 39, 0, 0, 0, -5, 60, -46, 0, 0, -65, -46, -39, 0, 60, 39], [0, 0, 7, -35, -59, -12, -12, -66, 11, -66, 12, 0, -11, 66, 0, 0], [0, -72, 0, 72, -72, 96, -96, 0, 72, -48, 63, -48, 0, -48, 63, -72], [0, 0, 0, -28, 28, 12, -47, 13, -28, -13, -12, 0, 28, -13, 59, 0], [-147, -156, 147, 0, 0, 50, 50, -39, 0, 0, 0, 39, -44, 0, 50, 56], [-184, 233, 0, 65, 233, 0, 0, 0, 103, -33, -84, -33, 0, 33, -84, -65], [0, 0, 451, 45, 81, 18, 18, -19, -9, -19, -18, 0, 9, 19, 0, 0], [0, 0, 121, -28, -124, -48, -48, 6, -68, 6, 48, 0, 68, -6, 0, 0], [0, 0, 0, -46, 46, -9, -98, 4, -46, -4, 9, 0, 46, -4, 89, 0], [151, -67, -151, 0, 0, 24, 24, 24, 0, 0, 0, -24, -29, 0, 24, 19], [0, -2, 0, 2, -2, 64, -64, 0, 2, 4, -36, 4, 0, 4, -36, -2], [68, 32, 0, 14, 32, 0, 0, 0, 4, -54, -9, -54, 0, 54, -9, -14], [0, 33, 0, 0, 0, -59, -18, 50, 0, 0, -41, 50, -33, 0, -18, 33], [0, 118, 0, 0, 0, 103, 160, 36, 0, 0, -57, 36, -118, 0, 160, 118], [-428, 108, 0, 34, 108, 0, 0, 0, 40, 50, -37, 50, 0, -50, -37, -34], [-65, -133, 65, 0, 0, 54, 54, 45, 0, 0, 0, -45, -83, 0, 54, 25], [-345, 177, 345, 0, 0, -76, -76, 42, 0, 0, 0, -42, 127, 0, -76, -25], [0, 0, 0, -41, 41, 72, 15, 30, -41, -30, -72, 0, 41, -30, 57, 0], [0, 81, 0, -81, 81, -6, 6, 0, -81, -51, -3, -51, 0, -51, -3, 81], [0, 9, 0, 0, 0, -149, -124, -22, 0, 0, -25, -22, -9, 0, -124, 9], [0, -10, 0, 10, -10, -32, 32, 0, 10, 44, -92, 44, 0, 44, -92, -10], [0, 0, 0, 56, -56, 6, 109, -44, 56, 44, -6, 0, -56, 44, -103, 0], [0, 0, 0, -16, 16, -30, 5, 70, -16, -70, 30, 0, 16, -70, -35, 0], [0, -39, 0, 39, -39, 6, -6, 0, 39, 27, 54, 27, 0, 27, 54, -39], [0, 0, -225, 1, 105, 52, 52, 108, 103, 108, -52, 0, -103, -108, 0, 0], [-230, -153, 0, -47, -153, 0, 0, 0, -59, -13, 53, -13, 0, 13, 53, 47], [0, -19, 0, 19, -19, 82, -82, 0, 19, 53, 100, 53, 0, 53, 100, -19], [266, -148, 0, -28, -148, 0, 0, 0, -92, -6, 60, -6, 0, 6, 60, 28], [0, 67, 0, 0, 0, 117, 96, -33, 0, 0, 21, -33, -67, 0, 96, 67], [96, 255, 0, 131, 255, 0, 0, 0, -7, -123, -62, -123, 0, 123, -62, -131], [0, 0, 0, -7, 7, 102, 139, -65, -7, 65, -102, 0, 7, 65, -37, 0], [-167, 168, 167, 0, 0, -84, -84, -50, 0, 0, 0, 50, 168, 0, -84, 0], [0, 0, 0, 101, -101, -66, -97, 1, 101, -1, 66, 0, -101, -1, 31, 0], [104, 38, 0, -28, 38, 0, 0, 0, 94, 78, -33, 78, 0, -78, -33, 28], [0, -86, 0, 0, 0, 61, 82, 18, 0, 0, -21, 18, 86, 0, 82, -86], [-312, 123, 0, -1, 123, 0, 0, 0, 125, -39, -62, -39, 0, 39, -62, 1], [0, 0, 0, 42, -42, -142, -65, -19, 42, 19, 142, 0, -42, 19, -77, 0], [115, 245, -115, 0, 0, -78, -78, 21, 0, 0, 0, -21, 67, 0, -78, -89], [0, 0, 0, -36, 36, 66, 91, -85, -36, 85, -66, 0, 36, 85, -25, 0], [272, -195, 0, -75, -195, 0, 0, 0, -45, 39, 60, 39, 0, -39, 60, 75], [0, 0, 127, 9, 105, 48, 48, -91, 87, -91, -48, 0, -87, 91, 0, 0], [0, -11, 0, 0, 0, 27, -90, 27, 0, 0, 117, 27, 11, 0, -90, -11], [0, 76, 0, -76, 76, 116, -116, 0, -76, -50, 74, -50, 0, -50, 74, 76], [649, -90, -649, 0, 0, 6, 6, -26, 0, 0, 0, 26, 66, 0, 6, 78], [0, 0, 0, 15, -15, 48, 169, 17, 15, -17, -48, 0, -15, -17, -121, 0], [0, -50, 0, 50, -50, -8, 8, 0, 50, -56, -48, -56, 0, -56, -48, -50], [0, 0, -255, 76, -12, -44, -44, -15, -164, -15, 44, 0, 164, 15, 0, 0], [0, 64, 0, 0, 0, -14, 79, 54, 0, 0, -93, 54, -64, 0, 79, 64], [0, 0, 13, 80, 260, 90, 90, 45, 100, 45, -90, 0, -100, -45, 0, 0], [295, -46, -295, 0, 0, 3, 3, 30, 0, 0, 0, -30, 34, 0, 3, 40], [165, 114, -165, 0, 0, -16, -16, 75, 0, 0, 0, -75, -50, 0, -16, -82], [0, 19, 0, -19, 19, -62, 62, 0, -19, -11, 93, -11, 0, -11, 93, 19], [0, -71, 0, 0, 0, -162, -63, 27, 0, 0, -99, 27, 71, 0, -63, -71], [396, -57, 0, 47, -57, 0, 0, 0, -151, 99, 52, 99, 0, -99, 52, -47], [-47, -82, 47, 0, 0, 78, 78, -39, 0, 0, 0, 39, -230, 0, 78, -74], [0, -60, 0, 60, -60, 120, -120, 0, 60, -12, 36, -12, 0, -12, 36, -60], [0, -85, 0, 0, 0, -211, -210, -38, 0, 0, -1, -38, 85, 0, -210, -85], [0, 0, 151, -113, -125, -6, -6, 102, 101, 102, 6, 0, -101, -102, 0, 0], [0, 30, 0, -30, 30, -84, 84, 0, -30, 6, -9, 6, 0, 6, -9, 30], [0, 0, 0, -104, 104, -8, 25, -9, -104, 9, 8, 0, 104, 9, -33, 0], [0, 0, 0, 0, 0, 144, 229, 77, 0, -77, -144, 0, 0, -77, -85, 0], [-70, 144, 0, 48, 144, 0, 0, 0, 48, -60, -48, -60, 0, 60, -48, -48], [0, 0, -221, 6, -24, -15, -15, -4, -36, -4, 15, 0, 36, 4, 0, 0], [0, 0, -95, 89, 263, 87, 87, -147, 85, -147, -87, 0, -85, 147, 0, 0], [372, -177, 0, -145, -177, 0, 0, 0, 113, -21, 16, -21, 0, 21, 16, 145], [0, 0, 0, 51, -51, -3, 46, -79, 51, 79, 3, 0, -51, 79, -49, 0], [0, 0, -17, -63, -231, -84, -84, -64, -105, -64, 84, 0, 105, 64, 0, 0], [60, 180, 0, 50, 180, 0, 0, 0, 80, -114, -65, -114, 0, 114, -65, -50], [0, 213, 0, -213, 213, 114, -114, 0, -213, -63, 165, -63, 0, -63, 165, 213], [247, -165, -247, 0, 0, 42, 42, -122, 0, 0, 0, 122, -3, 0, 42, 81], [0, 0, 0, 45, -45, 0, -125, -28, 45, 28, 0, 0, -45, 28, 125, 0], [0, -26, 0, 26, -26, -116, 116, 0, 26, 58, -132, 58, 0, 58, -132, -26], [488, -273, 0, -117, -273, 0, 0, 0, -39, 93, 78, 93, 0, -93, 78, 117], [0, 6, 0, 0, 0, -131, 68, 95, 0, 0, -199, 95, -6, 0, 68, 6], [199, 103, -199, 0, 0, -42, -42, -78, 0, 0, 0, 78, 65, 0, -42, -19], [-449, 60, 449, 0, 0, 21, 21, 118, 0, 0, 0, -118, -144, 0, 21, -102], [0, 0, 0, -7, 7, -24, -91, -29, -7, 29, 24, 0, 7, 29, 67, 0], [0, -80, 0, 80, -80, 4, -4, 0, 80, 70, -18, 70, 0, 70, -18, -80], [0, 0, -401, 65, -55, -60, -60, -132, -185, -132, 60, 0, 185, 132, 0, 0], [-428, 39, 0, 7, 39, 0, 0, 0, 25, 131, -16, 131, 0, -131, -16, -7], [0, -151, 0, 151, -151, -38, 38, 0, 151, 5, -71, 5, 0, 5, -71, -151], [0, 0, 0, -15, 15, -130, 133, -46, -15, 46, 130, 0, 15, 46, -263, 0], [0, 16, 0, 0, 0, 39, 48, 48, 0, 0, -9, 48, -16, 0, 48, 16], [0, -117, 0, 0, 0, -41, -16, -58, 0, 0, -25, -58, 117, 0, -16, -117], [0, -34, 0, 34, -34, 160, -160, 0, 34, 44, -32, 44, 0, 44, -32, -34], [199, -78, -199, 0, 0, 27, 27, 118, 0, 0, 0, -118, -30, 0, 27, 24], [104, -121, 0, -61, -121, 0, 0, 0, 1, 33, 30, 33, 0, -33, 30, 61], [0, 0, -983, 30, 138, 54, 54, 47, 78, 47, -54, 0, -78, -47, 0, 0], [0, 35, 0, 0, 0, -269, -126, 97, 0, 0, -143, 97, -35, 0, -126, 35], [324, -96, 0, -34, -96, 0, 0, 0, -28, 18, 31, 18, 0, -18, 31, 34], [0, 0, 0, -161, 161, -264, -165, 24, -161, -24, 264, 0, 161, -24, -99, 0], [0, 31, 0, -31, 31, 46, -46, 0, -31, -29, 96, -29, 0, -29, 96, 31], [0, 0, 549, -170, -138, 16, 16, 108, 202, 108, -16, 0, -202, -108, 0, 0], [0, 97, 0, 0, 0, 85, 46, -30, 0, 0, 39, -30, -97, 0, 46, 97], [0, 48, 0, -48, 48, -84, 84, 0, -48, 18, 210, 18, 0, 18, 210, 48], [277, -442, -277, 0, 0, 84, 84, -69, 0, 0, 0, 69, 106, 0, 84, 274]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_36_f_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_36_3_f_c();".
// 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_36_3_f_c(:prec:=16)
    chi := MakeCharacter_36_f();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 3));
    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_36_3_f_c();".
// 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_36_3_f_c( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_36_f();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,3,sign)));
    Vf := Kernel([<5,R![87616, -75480, 49337, -15291, 3870, -351, 62, -3, 1]>,<7,R![4430766096, 0, -13013727948, 0, 37316185677, 0, -2633438061, 0, 141530490, 0, -2674161, 0, 37002, 0, -225, 0, 1]>],Snew);
    return Vf;
end function;