
// Make newform 300.3.f.c in Magma, downloaded from the LMFDB on 16 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_300_f();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_300_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_300_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_300_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 := [256, -512, 512, -448, 368, -208, 72, -20, 9, -10, 18, -26, 23, -14, 8, -4, 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], [1408, 480, 144, -88, -100, 182, 42, -113, 30, 20, 12, -11, -22, -2, 14, -1], [1152, -1312, 1296, -632, -164, 190, -137, 113, 16, -82, 71, -29, 2, 6, -21, 11], [-512, 736, -752, 888, -708, 306, -139, 24, 14, -4, -17, 52, -40, 26, -15, 6], [640, -880, 648, -684, 562, -221, 98, -31, 14, -13, 32, -47, 32, -17, 12, -5], [-2368, 2432, -2496, 2256, -1496, 452, -78, -43, -14, 82, -144, 147, -86, 52, -22, 1], [928, 1120, -432, 360, -960, 382, -141, 100, 30, -4, 9, 24, -52, 14, -17, 14], [-5184, 1920, -1216, 3728, -1832, 628, -438, 225, 26, -54, -144, 199, -46, 68, -62, -3], [4480, 1600, -2016, 320, -2168, 1504, -401, -13, 52, -48, 67, 45, -150, 48, -33, 33], [2624, -4064, 3952, -3752, 2692, -1310, 429, -98, 10, -88, 179, -226, 172, -102, 57, -20], [-6016, 8288, -6320, 4792, -3116, 1106, -35, -57, -120, 234, -315, 357, -210, 106, -55, 21], [64, 6112, -4976, 2728, -3844, 1822, -429, 130, -74, 152, -115, 194, -236, 102, -57, 52], [-6400, 10560, -10272, 9584, -7224, 3012, -867, 114, 34, 126, -469, 582, -432, 244, -139, 52], [-6144, 9680, -7272, 6740, -4902, 1875, -461, 84, -130, 223, -343, 446, -302, 143, -99, 32], [-2432, 4128, -3216, 2904, -2268, 906, -198, 57, -54, 84, -144, 195, -138, 66, -42, 17], [10144, -15712, 11824, -11240, 8832, -3454, 941, -344, 202, -292, 559, -740, 524, -270, 177, -66]];
    Rf_basisdens := [1, 320, 320, 320, 160, 320, 160, 320, 320, 320, 320, 320, 320, 160, 64, 160];
    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_300_f();"
function MakeCharacter_300_f()
    N := 300;
    order := 2;
    char_gens := [151, 101, 277];
    v := [1, 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_300_f_Hecke();"
function MakeCharacter_300_f_Hecke(Kf)
    N := 300;
    order := 2;
    char_gens := [151, 101, 277];
    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]];
    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, 0, -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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, -1, 0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 1, 1, 1, 0, -2, 1, 1, 0, 0, 0, 0], [0, 1, -1, -3, 0, 0, 0, 0, -1, 0, 0, 0, 1, 0, 0, 0], [0, 2, 3, -3, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0], [0, 0, 0, 0, 0, 0, 1, -1, 0, -1, 2, -1, 0, 0, 0, -1], [0, 3, 1, 2, -2, 0, 0, 0, 2, 0, 0, 0, -1, -1, -1, 0], [6, 0, 0, 0, 0, -5, 0, 0, 0, 6, 0, 2, 0, 0, 0, 1], [0, 0, 0, 0, 0, -4, -3, 4, 0, -3, -1, 4, 0, 0, 0, -1], [0, 2, 8, 4, 0, 0, 0, 0, -2, 0, 0, 0, 2, 0, 8, 0], [0, 0, 0, 0, 0, -5, 2, 4, 0, 6, 4, -2, 0, 0, 0, -1], [0, 1, 1, -2, 9, 0, 0, 0, -4, 0, 0, 0, -3, 3, 1, 0], [0, -6, -2, -2, -18, 0, 0, 0, -6, 0, 0, 0, 2, 4, 2, 0], [0, 0, 1, 5, 0, 0, 0, 0, -4, 0, 0, 0, 0, -4, -4, 0], [0, 0, 0, 0, 0, -2, -4, 4, 0, -2, -2, 4, 0, 0, 0, 2], [23, 0, 0, 0, 0, 0, -8, -1, 0, 18, -1, 7, 0, 0, 0, -4], [0, -11, -3, -18, 3, 0, 0, 0, -4, 0, 0, 0, 1, -1, 5, 0], [0, 0, 0, 0, 0, -1, 3, -5, 0, 4, 1, -5, 0, 0, 0, -4], [0, -10, -8, 16, 0, 0, 0, 0, 6, 0, 0, 0, -10, -4, 4, 0], [0, 0, 0, 0, 0, -4, 0, 2, 0, -8, 6, 2, 0, 0, 0, -4], [0, 4, 0, 4, 22, 0, 0, 0, 16, 0, 0, 0, 4, -12, -4, 0], [-16, 0, 0, 0, 0, -8, 4, 0, 0, 0, 0, 0, 0, 0, 0, 4], [0, -8, 4, 28, 0, 0, 0, 0, 0, 0, 0, 0, -8, -8, 1, 0], [12, 0, 0, 0, 0, -17, 8, -6, 0, -6, -6, 4, 0, 0, 0, 13], [0, -16, -4, -42, -24, 0, 0, 0, 6, 0, 0, 0, 0, -14, 8, 0], [0, 3, -1, 26, 36, 0, 0, 0, 0, 0, 0, 0, 7, 5, -5, 0], [59, 0, 0, 0, 0, 0, 8, 1, 0, -18, 1, -7, 0, 0, 0, 4], [0, 4, 4, 0, 0, 0, 0, 0, -8, 0, 0, 0, 4, -4, 8, 0], [0, -2, 2, -44, -20, 0, 0, 0, 12, 0, 0, 0, -10, -18, 6, 0], [0, 0, 0, 0, 0, 19, 13, -7, 0, -4, 11, -7, 0, 0, 0, 6], [0, 8, -14, -34, 0, 0, 0, 0, -4, 0, 0, 0, 8, 4, -26, 0], [0, 0, 0, 0, 0, -18, -2, -8, 0, 24, -16, -8, 0, 0, 0, -16], [-42, 0, 0, 0, 0, 10, -4, 2, 0, 0, 2, -2, 0, 0, 0, -6], [0, 0, 0, 0, 0, 14, 1, 12, 0, 3, -15, 12, 0, 0, 0, 13], [0, -17, -29, 13, 0, 0, 0, 0, 9, 0, 0, 0, -17, -8, -2, 0], [0, -5, 3, -46, 15, 0, 0, 0, -12, 0, 0, 0, -17, 1, 11, 0], [0, 19, 5, 36, -28, 0, 0, 0, 4, 0, 0, 0, -1, 5, -9, 0], [0, 2, 11, -5, 0, 0, 0, 0, 10, 0, 0, 0, 2, 12, -12, 0], [0, 0, 0, 0, 0, -16, -10, -6, 0, 14, -8, -6, 0, 0, 0, -6], [-35, 0, 0, 0, 0, 18, 0, -7, 0, -30, -7, -3, 0, 0, 0, 2], [0, 0, 0, 0, 0, -41, -7, -1, 0, 34, -33, -1, 0, 0, 0, -34], [0, 10, 24, 8, 0, 0, 0, 0, -14, 0, 0, 0, 10, -4, 3, 0], [0, 10, -24, -40, 0, 0, 0, 0, -14, 0, 0, 0, 10, -4, 0, 0], [0, 0, 0, 0, 0, 0, -3, -10, 0, 13, -3, -10, 0, 0, 0, 3], [0, 0, 0, 0, 0, 24, -5, 17, 0, -27, 10, 17, 0, 0, 0, 29], [0, -8, 0, -45, -55, 0, 0, 0, 5, 0, 0, 0, -8, -13, 8, 0], [0, 17, 9, -42, 64, 0, 0, 0, 28, 0, 0, 0, -19, -29, 1, 0], [7, 0, 0, 0, 0, 8, -8, -3, 0, 6, -3, 5, 0, 0, 0, -4], [0, 18, -3, -61, 0, 0, 0, 0, 4, 0, 0, 0, 18, 22, 22, 0], [0, 0, 0, 0, 0, 17, -11, 5, 0, 0, -5, 5, 0, 0, 0, 28], [-135, 0, 0, 0, 0, -12, 8, -6, 0, -12, -6, 2, 0, 0, 0, 12], [0, 0, 0, 0, 0, 46, 26, -6, 0, -44, 50, -6, 0, 0, 0, 20], [0, -28, -6, 66, 0, 0, 0, 0, 12, 0, 0, 0, -28, -16, -8, 0], [0, -21, -3, -56, -168, 0, 0, 0, -16, 0, 0, 0, -9, 1, 15, 0], [82, 0, 0, 0, 0, 11, 8, -8, 0, -42, -8, -6, 0, 0, 0, 9], [0, 0, 0, 0, 0, -14, -2, 4, 0, 32, -36, 4, 0, 0, 0, -12], [0, 5, 11, 17, 0, 0, 0, 0, -21, 0, 0, 0, 5, -16, 18, 0], [182, 0, 0, 0, 0, -5, 6, -28, 0, -42, -28, 14, 0, 0, 0, 27], [0, 7, -1, 24, 99, 0, 0, 0, 22, 0, 0, 0, 11, -13, -9, 0], [0, 2, -26, -42, 0, 0, 0, 0, 10, 0, 0, 0, 2, 12, -44, 0], [0, -19, -11, 40, 161, 0, 0, 0, -14, 0, 0, 0, 25, 17, -3, 0], [0, 0, 0, 0, 0, -56, -18, -8, 0, 22, -14, -8, 0, 0, 0, -38], [0, -4, -2, 10, 0, 0, 0, 0, 0, 0, 0, 0, -4, -4, 1, 0], [0, -4, 26, 30, 0, 0, 0, 0, 8, 0, 0, 0, -4, 4, 4, 0], [0, 0, 0, 0, 0, 42, -6, -10, 0, -20, 30, -10, 0, 0, 0, 48], [0, 18, 8, -64, 0, 0, 0, 0, 18, 0, 0, 0, 18, 36, 35, 0], [0, -44, -16, -44, 46, 0, 0, 0, 0, 0, 0, 0, 20, -12, 12, 0], [26, 0, 0, 0, 0, -28, 0, 32, 0, 72, 32, -8, 0, 0, 0, -20], [0, -42, -31, 51, 0, 0, 0, 0, 44, 0, 0, 0, -42, 2, -12, 0], [0, 0, 0, 0, 0, -39, 13, 1, 0, -20, 19, 1, 0, 0, 0, -52], [0, -20, -16, 49, -87, 0, 0, 0, 27, 0, 0, 0, 44, -15, -12, 0], [0, -3, 3, 17, 0, 0, 0, 0, -5, 0, 0, 0, -3, -8, -10, 0], [0, 0, 0, 0, 0, -32, -1, 15, 0, -3, -12, 15, 0, 0, 0, -31], [0, -22, -6, -40, -52, 0, 0, 0, -4, 0, 0, 0, 2, -6, 10, 0], [-304, 0, 0, 0, 0, -9, -8, 10, 0, 42, 10, 4, 0, 0, 0, -11], [0, -1, 45, 39, 0, 0, 0, 0, 9, 0, 0, 0, -1, 8, -10, 0], [212, 0, 0, 0, 0, -19, -34, 8, 0, 114, 8, 30, 0, 0, 0, -23], [147, 0, 0, 0, 0, 22, -20, -8, 0, 12, -8, 12, 0, 0, 0, -10], [0, 0, 0, 0, 0, 17, -9, 23, 0, -20, -3, 23, 0, 0, 0, 26], [-78, 0, 0, 0, 0, -62, 40, -2, 0, -24, -2, -6, 0, 0, 0, 38], [0, 0, 0, 0, 0, 49, 43, 17, 0, 2, -19, 17, 0, 0, 0, 6], [0, 22, -28, -92, 0, 0, 0, 0, -2, 0, 0, 0, 22, 20, -93, 0], [0, 0, 0, 0, 0, -20, -37, -2, 0, 47, -45, -2, 0, 0, 0, 17], [0, 14, 14, -84, -40, 0, 0, 0, 0, 0, 0, 0, -42, -14, 14, 0], [292, 0, 0, 0, 0, -42, 28, 24, 0, 12, 24, -20, 0, 0, 0, 6], [0, 10, 62, 58, 0, 0, 0, 0, -26, 0, 0, 0, 10, -16, 40, 0], [-36, 0, 0, 0, 0, -63, 20, 2, 0, 30, 2, 8, 0, 0, 0, 23], [0, 60, 24, 22, -108, 0, 0, 0, 14, 0, 0, 0, -36, -2, -12, 0], [0, 9, -3, 122, 246, 0, 0, 0, -44, 0, 0, 0, 21, 59, -15, 0], [0, 0, 0, 0, 0, 58, 0, -2, 0, -62, 64, -2, 0, 0, 0, 58], [0, 36, 12, 59, -291, 0, 0, 0, -11, 0, 0, 0, -12, 23, -12, 0], [0, 0, 0, 0, 0, 96, 36, 28, 0, -88, 60, 28, 0, 0, 0, 60], [0, 0, 0, 0, 0, -114, -89, 47, 0, -41, -6, 47, 0, 0, 0, -25], [0, 39, 5, 84, -64, 0, 0, 0, 56, 0, 0, 0, 19, -27, -29, 0], [-286, 0, 0, 0, 0, -2, -36, -34, 0, 48, -34, 50, 0, 0, 0, 6], [286, 0, 0, 0, 0, 55, 2, 4, 0, -66, 4, -26, 0, 0, 0, -13], [0, -39, -15, -64, -65, 0, 0, 0, 34, 0, 0, 0, 21, -43, 9, 0], [41, 0, 0, 0, 0, 2, 24, 25, 0, -30, 25, -35, 0, 0, 0, -6], [0, 32, 8, -30, 128, 0, 0, 0, 102, 0, 0, 0, 0, -86, -16, 0], [0, -22, -54, -2, 0, 0, 0, 0, 14, 0, 0, 0, -22, -8, 4, 0], [0, 13, 17, -134, 190, 0, 0, 0, 12, 0, 0, 0, -55, -33, 21, 0], [338, 0, 0, 0, 0, 33, 18, 24, 0, -54, 24, -42, 0, 0, 0, -15], [0, 0, 0, 0, 0, -8, 23, -33, 0, -19, 52, -33, 0, 0, 0, -31], [0, 36, -28, -100, 0, 0, 0, 0, -36, 0, 0, 0, 36, 0, 23, 0], [0, 47, 23, 26, -84, 0, 0, 0, -44, 0, 0, 0, -45, 45, -1, 0], [0, 58, 79, -47, 0, 0, 0, 0, -48, 0, 0, 0, 58, 10, 62, 0], [0, 0, 0, 0, 0, -30, -50, 14, 0, 28, -42, 14, 0, 0, 0, 20], [19, 0, 0, 0, 0, -34, 52, 40, 0, -36, 40, -52, 0, 0, 0, 6], [0, -14, -14, 98, 124, 0, 0, 0, -14, 0, 0, 0, 42, 28, -14, 0], [0, 54, 74, -122, 0, 0, 0, 0, 34, 0, 0, 0, 54, 88, -16, 0], [0, -34, -99, 19, 0, 0, 0, 0, -16, 0, 0, 0, -34, -50, 14, 0], [0, 0, 0, 0, 0, 4, 1, -17, 0, 99, -82, -17, 0, 0, 0, 3], [0, 0, 0, 0, 0, 38, 47, -50, 0, 77, -27, -50, 0, 0, 0, -9], [92, 0, 0, 0, 0, -22, 4, -4, 0, 12, -4, 8, 0, 0, 0, 10], [0, 88, 16, 306, 204, 0, 0, 0, -42, 0, 0, 0, 24, 98, -56, 0], [0, 40, 0, 128, -68, 0, 0, 0, 72, 0, 0, 0, 40, -32, -40, 0], [0, -58, 62, 230, 0, 0, 0, 0, 6, 0, 0, 0, -58, -52, -20, 0], [0, 0, 0, 0, 0, 125, 79, -17, 0, 0, 17, -17, 0, 0, 0, 46], [270, 0, 0, 0, 0, 116, -24, 38, 0, -36, 38, -50, 0, 0, 0, -68], [0, -30, -12, 4, 0, 0, 0, 0, 74, 0, 0, 0, -30, 44, -124, 0], [0, -58, -75, 53, 0, 0, 0, 0, 46, 0, 0, 0, -58, -12, -48, 0], [0, 4, -16, 248, -80, 0, 0, 0, -52, 0, 0, 0, 68, 88, -36, 0], [0, 0, 0, 0, 0, 54, 42, -46, 0, 48, -2, -46, 0, 0, 0, 12], [-322, 0, 0, 0, 0, -7, -76, -44, 0, 138, -44, 90, 0, 0, 0, -9], [-237, 0, 0, 0, 0, 24, 64, 37, 0, -138, 37, -83, 0, 0, 0, 4], [0, 0, 0, 0, 0, -61, 1, -69, 0, 22, 47, -69, 0, 0, 0, -62], [0, 132, 36, 269, -9, 0, 0, 0, -5, 0, 0, 0, -12, 65, -60, 0], [0, -24, 20, 100, 0, 0, 0, 0, -8, 0, 0, 0, -24, -32, 158, 0], [0, 0, 0, 0, 0, 100, 40, -28, 0, -28, 56, -28, 0, 0, 0, 60], [0, -44, 0, -292, -236, 0, 0, 0, 72, 0, 0, 0, -44, -116, 44, 0], [0, 0, 0, 0, 0, -186, -110, -22, 0, 44, -22, -22, 0, 0, 0, -76], [0, -55, -71, 111, 0, 0, 0, 0, -17, 0, 0, 0, -55, -72, 62, 0], [444, 0, 0, 0, 0, -88, 0, -8, 0, 96, -8, 40, 0, 0, 0, 24], [-339, 0, 0, 0, 0, 138, -20, 8, 0, -108, 8, -44, 0, 0, 0, -46], [0, -28, -29, 19, 0, 0, 0, 0, 36, 0, 0, 0, -28, 8, -156, 0], [0, -47, -15, 30, 165, 0, 0, 0, -100, 0, 0, 0, 13, 83, 17, 0], [0, -8, 2, 58, 0, 0, 0, 0, -32, 0, 0, 0, -8, -40, 60, 0], [756, 0, 0, 0, 0, 21, 30, 16, 0, -78, 16, -42, 0, 0, 0, 1], [0, 0, 0, 0, 0, -90, -75, -29, 0, 45, -16, -29, 0, 0, 0, -15], [-362, 0, 0, 0, 0, 128, -28, 2, 0, -84, 2, -30, 0, 0, 0, -44], [0, -90, -34, -147, -179, 0, 0, 0, 71, 0, 0, 0, 46, -93, 22, 0], [0, 31, 7, 106, -340, 0, 0, 0, -28, 0, 0, 0, 3, 45, -17, 0], [202, 0, 0, 0, 0, -40, -40, -30, 0, 108, -30, 66, 0, 0, 0, 8], [0, 0, 0, 0, 0, 51, 9, 35, 0, 82, -117, 35, 0, 0, 0, 42], [0, -33, -93, 53, 0, 0, 0, 0, -47, 0, 0, 0, -33, -80, 76, 0], [0, -72, 18, 194, 0, 0, 0, 0, 40, 0, 0, 0, -72, -32, -20, 0], [0, 0, 0, 0, 0, -74, -46, -42, 0, 120, -78, -42, 0, 0, 0, -28], [0, 74, 26, 152, 8, 0, 0, 0, -68, 0, 0, 0, -30, 90, -22, 0], [0, 61, -7, -193, 0, 0, 0, 0, 3, 0, 0, 0, 61, 64, 12, 0], [-168, 0, 0, 0, 0, 22, 52, -24, 0, -180, -24, -36, 0, 0, 0, 46], [0, 15, 23, -180, 165, 0, 0, 0, 2, 0, 0, 0, -77, -33, 31, 0], [0, 2, 18, -190, -78, 0, 0, 0, 2, 0, 0, 0, -70, -36, 34, 0], [0, -4, -12, 40, -20, 0, 0, 0, 72, 0, 0, 0, 44, -52, -20, 0], [0, 0, 0, 0, 0, 102, 104, 18, 0, -122, 104, 18, 0, 0, 0, -2], [0, 0, 0, 0, 0, -40, 53, 28, 0, 17, -45, 28, 0, 0, 0, -93], [434, 0, 0, 0, 0, -57, -70, 28, 0, 270, 28, 62, 0, 0, 0, -53], [0, 48, 138, -2, 0, 0, 0, 0, -4, 0, 0, 0, 48, 44, -1, 0], [238, 0, 0, 0, 0, 24, 44, 22, 0, -108, 22, -58, 0, 0, 0, 4], [0, 69, 25, 150, 74, 0, 0, 0, -80, 0, 0, 0, -31, 99, -19, 0], [0, 64, -60, -308, 0, 0, 0, 0, 56, 0, 0, 0, 64, 120, 0, 0], [0, -102, -22, -222, -508, 0, 0, 0, -46, 0, 0, 0, -14, -12, 58, 0], [0, 0, 0, 0, 0, -160, -90, 78, 0, -26, -52, 78, 0, 0, 0, -70], [0, 12, 54, 86, 0, 0, 0, 0, -68, 0, 0, 0, 12, -56, -58, 0], [0, 76, 24, 180, 148, 0, 0, 0, -64, 0, 0, 0, -20, 92, -28, 0], [0, 0, 0, 0, 0, 22, -13, 134, 0, -159, 25, 134, 0, 0, 0, 35], [0, -16, 124, 196, 0, 0, 0, 0, -24, 0, 0, 0, -16, -40, 134, 0]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_300_f_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_300_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_300_3_f_c(:prec:=16)
    chi := MakeCharacter_300_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_300_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_300_3_f_c( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_300_f();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,3,sign)));
    Vf := Kernel([<7,R![961, 0, -9532, 0, 6470, 0, -188, 0, 1]>],Snew);
    return Vf;
end function;