
// Make newform 900.3.p.d in Magma, downloaded from the LMFDB on 07 May 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_900_p();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_900_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_900_3_p_d();".
// 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_900_3_p_d();".
// 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 := [43046721, -9565938, 5314410, -708588, 39366, -19683, -47385, 32562, -12150, 3618, -585, -27, 6, -12, 10, -2, 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], [1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [54664552701, -22770652527, 7909790697, -4192459317, 981387819, -93873330, -18730683, 47971845, -18242955, 5995773, -1741122, 361803, -10653, -9679, 12833, -4099], [-19605389931, 2343123369, 109653993, -556143165, 447899787, -100078578, 32011605, -12748995, 203445, 379197, -399762, 205755, -42933, 6649, -3479, -515], [504904556547, -181098618129, 10269743031, -6883715907, 746307189, -329197446, 186610635, 174037815, -72418725, 4435191, -1882494, 344697, -203007, 254923, -16133, -2405], [140184038421, -43981525719, 28262918115, -7560614277, 823057767, -31692546, -235959561, 100605645, -34750755, 11589093, -2954178, 179409, 28569, -60625, 25193, 1817], [100045362573, -107371808199, 23096248713, -11258262657, 4115630007, -640649574, 127040157, 77787945, -55496475, 14112189, -1992870, 1530723, -262149, 34049, -14899, -4759], [4565609631, 841979691, -63595773, 344485305, -5863347, 10003338, 9259515, -5501925, 1430595, -306657, 109782, -49035, -9867, 10591, -1301, 655], [281616431751, -144191103561, 37692807219, -3568311387, 449435061, -329063310, 102553047, 53738235, -44711325, 12814623, -1056834, -535767, 206985, 172367, -50857, 6551], [70544009781, 61719963417, 1835774361, -4866011577, -320550777, -39629898, -177858747, 74682405, 22298625, -3017727, -2217510, -298569, -6897, -98447, 32833, 10129], [71366680449, 53563406949, -8131933035, -5093232129, -47823129, -1381765554, 408639249, -259185015, 86884785, -10942983, 1825038, -150969, -604497, 379645, -106331, 27817], [94768153443, 15092392959, -3183508737, 4989857013, -1594080243, -99649926, 247543371, -53084565, 23644035, -6072021, 705834, -840315, -320619, 120439, -25049, 10603], [-896524492329, 282647427291, -24362495469, 16152401241, -5074480791, 3473622306, -295527609, -398722905, 182796615, -20517417, 5186322, -1145463, 1172577, -346237, -51853, 31943], [-107787395061, 10449724383, -29633681601, 8382576357, -619902963, 372987018, 59595507, -25324245, 12611835, -8984133, 3564810, -164451, 50037, 1207, -14033, -11429], [-90699441147, 99007989741, -18905304987, -947519937, 2902107447, -2016870354, 550802997, -195528735, 76406625, -6302331, -1221210, 2042403, -945129, 216169, -46679, 18241]];
    Rf_basisdens := [1, 1, 1, 36541883160, 4060209240, 18270941580, 9135470790, 18270941580, 2030104620, 18270941580, 18270941580, 36541883160, 12180627720, 36541883160, 12180627720, 18270941580];
    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_900_p();"
function MakeCharacter_900_p()
    N := 900;
    order := 6;
    char_gens := [451, 101, 577];
    v := [6, 1, 6];
    // 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_900_p_Hecke();"
function MakeCharacter_900_p_Hecke(Kf)
    N := 900;
    order := 6;
    char_gens := [451, 101, 577];
    char_values := [[1, 0, 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], [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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 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, 0, 0, 0, 0, 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, -1, -1, 1, 1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, -1, 0, 1, 0, -1, 1, 0, 1, -1, -1, -1, 0, 0], [1, -1, -1, -1, -1, 0, 1, 0, -1, 1, 0, 1, 0, 1, 0, -1], [-3, 0, 2, 3, 0, 0, -1, -1, 1, -1, 1, 0, 0, -1, 0, 1], [0, 1, 1, 1, 2, 1, -1, 1, 2, 0, 1, -1, 0, 0, 0, -1], [0, 1, -1, 2, 0, 1, -1, -1, 1, -1, 0, 0, -1, -2, -1, 0], [1, 0, 1, 0, 3, -1, 1, -1, 0, 1, 1, 2, -1, 0, 2, 1], [3, 0, 2, 0, 0, 0, -1, -1, -1, -1, -4, 0, -1, -1, 0, 1], [-5, 6, 1, 7, -2, 0, -1, -2, 1, -1, 0, 0, -1, -2, -1, -2], [5, 0, -1, 5, -3, 0, 0, -1, 5, -1, 2, -1, -1, -1, -1, 1], [-1, 7, -5, 9, -5, -2, -3, -1, 5, -1, 0, -2, -3, -3, 0, -4], [1, -10, -2, 0, 1, 2, -1, -2, -2, 2, -1, 0, 1, 2, 1, 2], [-7, 5, 1, 8, -3, -1, -2, 0, 2, -2, 1, 0, -2, -1, -2, -2], [3, 7, -2, 2, -8, 0, 0, -1, 3, -1, 2, -4, -3, -1, 2, -1], [-8, 6, -5, 22, -5, -3, -3, 0, -3, -1, 4, 0, -1, -2, 0, -4], [-7, 4, 5, 4, -11, -1, -3, -2, 3, -3, 0, 1, -4, -4, -4, 6], [-1, 14, 0, -8, -2, 1, 0, 2, -5, 1, -5, 2, 5, 3, -6, 4], [10, 9, -1, 13, 4, 0, -5, -2, -5, -3, -4, 1, -3, -4, 0, 4], [13, 9, 0, -23, -16, -3, -4, 4, -5, 2, 3, 0, 2, 3, 2, 3], [-3, -15, 0, 11, 1, -2, -1, 0, -6, -2, -3, 4, 6, -2, 5, -4], [-10, 8, -1, -8, 5, -1, -4, -2, 18, -2, 8, -5, -2, -3, 1, 4], [-3, -1, -5, 16, 10, 3, -5, -4, 6, -4, 1, -2, -5, -6, -7, -2], [17, -15, 0, -43, 16, -3, 4, 2, -9, -2, 1, 5, 3, 3, -2, -3], [-17, -8, 0, 4, -20, 1, -5, 3, 5, -2, 3, -3, 1, -1, -11, -2], [-17, -13, 5, 18, -2, -1, -6, -4, 6, 0, 7, 0, -5, -3, 1, 1], [6, 12, -1, 0, 9, 4, -4, 2, 8, -7, 1, -5, -2, -3, 1, 1], [26, -13, 3, -5, -3, -1, -6, -2, -5, 0, -8, 0, 2, -2, 0, 0], [29, -5, 2, 21, -20, -5, 10, 0, -5, 3, -1, 6, 3, 1, 3, 4], [-12, -31, 2, 3, 33, 4, 0, -1, -7, -1, -1, 2, 0, 2, -13, -4], [-62, -43, 0, 45, 13, -4, -14, 9, -4, -5, -12, 0, 1, -2, 1, -6], [-2, 19, -4, -1, 5, 0, 3, -3, 4, 4, 3, -4, -4, -3, -3, -3], [9, 26, 0, 3, -26, -2, -1, 1, -2, 1, -1, 2, 2, -3, 10, 5], [6, -12, -3, 0, -12, 0, 0, -1, 0, 3, 3, -3, 6, 3, -6, -2], [-77, 33, -2, 25, -19, 6, 6, -4, -2, 0, -9, 0, -5, 4, -7, 8], [8, -4, 3, 19, 36, -4, -9, 1, 3, 3, 3, -4, 3, 1, 3, 3], [29, 54, 8, -40, -55, 9, -15, -6, 5, -2, -5, 1, -1, -1, 0, 1], [1, -12, -8, 0, -9, 5, -5, 5, 1, -2, -1, 5, -7, 3, -10, -8], [-35, -7, 4, -21, 26, 2, -10, 3, -4, 0, -2, 5, 0, -1, -3, -1], [-12, -47, 2, -18, 38, -6, 5, 4, -12, 4, -1, 2, 5, 6, -8, 2], [60, -35, -8, -125, 39, -2, 11, 0, 6, 4, 0, -5, -1, -6, 2, 2], [3, -3, -4, -3, -51, 1, 2, -5, -7, 2, -5, 4, -2, 3, -17, 2], [-9, -33, 6, -1, 22, 4, 3, 1, 0, 1, 1, -2, 0, -2, -8, 4], [-11, 34, 7, -5, -21, 8, -4, -1, 9, 1, 16, -5, -9, 7, -13, 15], [76, -2, -1, 74, -25, 16, 2, 5, 15, -5, 5, -9, -5, 1, -11, -17], [-18, -40, -9, 20, 64, -11, -10, 1, 10, 1, -4, 8, 5, -6, -17, 8], [26, 39, 5, -49, -34, 3, -12, 3, 6, 7, 17, -15, -8, 2, 0, 13], [-79, -54, 2, 59, 4, 0, -15, -5, 15, 3, 25, 0, -8, -1, 4, 1], [23, 18, 11, -33, -23, 11, -4, -4, -16, 0, -13, 8, 16, 7, -7, 18], [-44, 22, -5, 80, -13, -11, -11, 13, -3, 9, -16, 5, 14, 6, -2, 11], [-180, 21, 0, 84, 24, -6, 18, 0, 5, 6, 26, 0, 10, -3, 12, -9], [62, 5, -8, 49, 16, 5, 4, 1, -9, 5, -2, -1, 5, 14, 5, -19], [78, 51, -9, -105, -66, 6, -15, -12, 1, -3, 10, -4, -7, -15, 9, -9], [-2, 5, -2, -7, -34, -2, 9, 8, 3, 6, 9, -1, 7, 4, -5, -12], [-3, -48, -19, 16, -1, -12, -2, 14, 11, 7, -3, -9, -11, 2, 13, -10], [-56, 9, -12, -86, -7, 0, 17, -2, -38, 8, -15, 10, 8, 18, 11, -18], [-18, -18, 26, -41, 37, 8, -2, 9, 2, 9, -4, 8, 13, 13, -9, 5], [-28, -51, -11, 20, 7, 3, -7, 0, -30, 8, -32, 0, 20, 7, 4, -1], [34, 9, -21, -27, 9, 3, 24, -12, -15, 15, 0, 6, 9, 18, 15, -6], [96, -24, 7, -33, -27, 3, -23, -2, 14, -8, 26, 0, 6, -2, -12, 8], [26, 16, -6, -48, 30, 3, 14, 1, -13, 9, -13, 2, 13, 4, -4, 7], [102, -8, 8, 97, -36, -8, 12, 1, -16, 2, -7, -10, 2, -5, 2, 13], [-57, -9, -16, 34, 38, -21, 4, 29, -13, -5, 2, 9, 13, 8, -11, -13], [9, 36, -6, -9, -17, -14, -9, 4, 0, 4, 10, -20, -6, -8, 13, 16], [-300, 23, -4, 137, -25, 8, -2, 1, -3, -5, -1, 0, 10, 6, -13, 10], [-48, 56, -1, 51, -35, -1, -12, -5, 6, 0, -7, -3, -6, -6, -15, -7], [5, -25, 9, 31, 36, 11, -15, 10, 24, 0, 12, 21, 0, 1, -12, -12], [53, 23, -13, -107, -26, -25, -16, 17, 20, -3, -15, -1, -4, 12, -4, -11], [9, -29, 20, -23, 31, 5, 7, 3, -17, -15, -2, 16, 17, 8, 1, 13], [-12, -46, 4, 48, 34, 0, 4, 2, 4, 2, 4, -8, -2, 0, -10, 4], [-36, 12, 0, 0, -42, 3, -3, -2, 48, -6, 42, 0, -6, -3, -15, 5], [-146, -9, 5, 70, 26, 9, 7, -15, 23, 1, 22, 0, -25, 2, 11, 16], [131, 18, 12, 116, 10, -9, 10, 8, -7, 13, 3, 20, 13, 9, 22, 0], [-34, -11, 20, 25, 46, -4, -21, 14, 34, -12, 22, -11, -1, -16, 5, 2], [268, 2, 1, -144, 40, 5, 14, -5, 0, -1, 19, 0, 20, 2, 13, 8], [3, 4, -2, 42, -12, 8, 3, -5, -57, -5, -8, 16, 3, 1, -2, -11], [-190, -5, 14, 102, -31, 10, -32, 5, 25, -29, 18, 0, -3, -2, -25, 22], [30, 5, -7, -21, -47, 2, -12, 1, 15, 9, -1, -12, -15, 3, 0, 5], [-111, 65, -11, 233, -14, 2, -21, -11, 36, -7, -5, -12, -19, -13, -15, -16], [59, 23, 9, -1, -28, -4, 5, -3, 40, -1, 39, 3, -4, -5, -1, 8], [70, -18, -21, -85, 33, -9, 12, 15, -18, 12, 42, 3, 18, 6, 3, -3], [118, 27, 10, 100, -18, -9, 12, 4, 7, 7, 7, -14, 7, 1, 19, 8], [133, -37, -11, -273, 30, -13, 8, 8, -28, 1, -13, 20, 21, 2, 2, -4], [14, 21, 6, 13, -57, 9, -15, -18, -33, 3, -6, 15, 33, -9, 3, 0], [-123, 84, -6, -147, -78, 21, 0, -3, 33, -21, 6, 0, -21, -18, 0, -3], [15, 38, -30, -4, -26, -8, -4, -11, -43, -11, -7, 14, -4, 0, 4, -22], [224, 48, 7, -460, -6, 9, -13, -5, -17, 1, -8, 12, 13, -2, -13, 5], [63, -53, 11, 58, 15, 1, 18, 16, -64, 20, -22, 38, 20, 25, 2, -26], [51, 60, -11, -12, -72, 17, -5, 11, -5, -23, -28, 2, -25, -6, -25, -5], [192, -9, -11, -84, -48, -9, -2, -5, 21, 25, 42, 0, -25, 1, -3, -19], [3, 5, 2, 25, -13, 6, 3, -2, 81, -2, 19, -38, -21, 1, 1, -5], [114, -47, -23, -209, 33, -14, 11, -6, 50, -17, 11, -22, -39, -9, 2, -37], [-300, 20, -1, 134, 41, 5, 28, -14, 0, 10, -10, 0, -20, 3, 20, 7], [-170, -80, -12, 350, 39, -8, 24, 2, -24, 0, -30, 27, 27, -4, 15, -6], [-125, -25, 20, 23, 56, -9, -14, 12, -2, -2, -4, 4, -6, -11, 12, -1], [67, -51, 7, 33, 78, 5, -38, 13, 36, -17, 19, -1, -16, -12, -4, -1], [-53, 42, -18, 34, 40, -8, 14, 3, 0, 10, -43, -5, 0, -5, -10, -13], [204, -29, -12, -377, -14, -8, 7, -2, -4, -8, -6, 9, 1, -4, 13, -18], [-359, 59, 12, 174, 22, -10, 28, -9, -18, 7, 1, 0, 30, -11, 16, -9], [174, 0, 0, 165, -84, 18, 12, 3, 36, -12, 12, -41, -12, -9, -18, -9], [3, -48, 15, -87, -15, -3, 18, 9, -35, 9, -9, 18, 18, -9, 12, 27], [-58, -76, 9, 32, 8, -4, -28, -17, 26, -1, 25, 18, -19, -5, -22, 22], [272, -32, 0, 330, 77, 13, -43, 0, 61, -13, 24, -18, -13, -13, -28, 0], [-4, 47, -21, 19, 21, 2, -15, -17, 8, -9, 29, -14, -23, -23, -18, -24], [-141, 40, -31, 37, -17, 1, 27, 9, -29, 21, -1, 0, 36, 16, -2, -14], [-107, -64, -18, 161, -23, -20, -15, 5, 10, -2, 41, -4, -10, -15, 24, -35], [-15, -101, -35, 18, 78, -31, 9, -2, -53, -2, -5, 10, 3, 4, -17, -8], [17, 73, 20, -11, -14, -10, 21, -29, -36, 0, -36, -5, 5, -10, 23, 39], [-445, -36, 16, 239, 52, 0, 2, -15, -12, -1, -5, 0, 20, -8, 22, 8], [-15, -27, 39, 26, 19, 40, 20, -45, 27, 1, -19, -14, -27, -5, 26, 35], [-49, 135, 11, -9, -102, 16, -7, -33, 17, -43, -26, -14, -29, -27, -23, 60], [-188, 46, -1, -259, -118, -17, 53, -4, -18, 10, -4, 12, 10, 7, 31, 10], [18, 82, -11, 194, -29, -39, -15, 14, -3, 14, -4, 8, 18, 8, 32, 20], [245, 144, -5, -460, -90, 6, -46, -11, 38, -5, 29, -31, -36, -11, -16, -10], [-55, 46, 15, 39, -46, -11, -7, 0, 66, -4, 83, 0, -45, -13, -13, -9], [150, -45, -37, 138, -37, -9, 14, -27, 12, -8, 2, 2, -8, 2, -20, 7], [21, 128, -48, 56, -30, -18, -40, -15, 72, -15, 13, -26, -28, -22, 6, -8], [117, -87, -17, -103, 100, -24, 23, 13, 25, -7, -17, -9, -25, -11, 26, -35], [231, 90, 17, 228, -13, 18, -16, 12, 93, -11, 41, -11, -11, -16, 13, -2], [230, -77, -1, -441, 39, 16, 31, -11, 6, 11, -51, 17, 28, -17, 22, 16], [19, -57, -12, -43, 84, -21, 18, 30, -57, -9, -48, 33, 57, 9, 3, -12], [-180, -151, -22, 377, 60, -22, 43, 12, -36, 2, 48, -7, -5, 0, 31, -8], [125, -94, 13, -92, -65, -6, -30, 18, 29, -19, 95, -5, -29, 12, 15, 6], [74, -65, 9, -201, 113, 13, 26, -6, -29, 5, -6, 15, 20, -4, -13, 12], [7, 128, 13, -53, -10, 1, -7, 3, 20, -12, 14, -4, -20, 4, -49, 5], [9, 14, -16, -103, -16, -6, -3, -5, -36, -5, -11, 22, 6, -11, 4, 1], [160, 33, -4, -27, 84, -8, 35, -13, -58, 20, -38, -5, 25, 12, 55, 1], [-395, 116, 49, 180, 49, 11, 32, -35, 21, -25, 7, 0, -10, -19, 16, 41], [15, -21, -3, 129, -50, 13, 24, -8, 41, -8, 25, -50, -33, 1, 7, -17], [59, -46, -9, 2, -7, -1, -1, -11, -100, 11, -89, -18, 29, 10, -10, 1], [395, 114, 48, -214, 46, 6, 19, -13, 18, -41, -11, 0, -6, -21, 4, 33], [63, 136, -23, 56, -178, 1, 15, -12, 105, -12, 15, -30, -27, 3, 51, -27], [-8, 28, 30, -10, 24, 37, 3, -22, 61, 0, 13, -37, -37, -7, -15, 15], [-33, -140, 17, -153, 89, 3, 11, 7, 90, 7, 11, -22, -4, -18, -26, 32], [-351, -11, 9, 166, 1, 31, 1, -41, -24, 1, -47, 0, 0, 11, 4, 51], [216, -128, 29, -524, 173, 16, 48, -13, -6, -23, -25, 27, 4, 13, -27, -20], [167, 83, -7, -49, -43, -9, 58, -10, 45, 25, 70, 19, 6, 16, 33, -6], [-278, 82, 46, -334, -128, -8, 46, 26, 102, 14, 58, -38, 14, -6, 44, 14], [42, 163, 1, -59, -144, 35, -6, -17, 42, -17, -8, 16, -9, 1, 25, -35], [359, 65, -56, -665, -79, -49, -38, 30, -29, 18, 51, -20, -2, -7, 13, -1], [59, -65, -4, 19, 154, 2, -21, -1, -64, 0, -64, -11, 11, 2, 29, -1], [1, -112, 51, 15, -26, -31, 37, 27, -16, 34, 9, -12, 34, 10, 7, 21], [176, -66, -6, -206, 36, 6, 18, 18, 48, 12, 18, -30, -48, 24, 12, 30], [277, 110, -22, 186, -9, 11, 33, 3, -73, 17, -28, 17, 17, 42, 50, -53], [66, 128, -55, -78, -180, 19, 9, -37, -37, -37, -37, 74, 0, -25, 29, -49], [187, -130, -1, -432, 134, -13, 39, 7, 7, -11, -12, 8, -3, 12, -9, -17], [-27, 19, 10, -45, 61, 30, -30, -10, -64, -10, -25, 50, 15, -10, -37, -10], [-259, -117, -20, 503, 102, -12, 35, 7, 79, 10, 25, -57, -47, -8, 11, 5], [-60, -146, -10, 22, 181, -10, -12, 40, -58, 30, -28, -5, 35, 20, 35, -60], [-606, -94, -26, 341, -58, -28, -51, 54, -14, 0, -48, 0, -20, -1, -28, -55], [-41, 91, -21, 5, 2, -7, 3, 10, -4, 14, 71, -5, 4, 3, -30, -4], [32, -21, -63, 68, 4, 69, -47, -22, 80, -50, 15, -39, -50, -9, -80, -60], [-179, 54, 47, 18, 78, -20, 2, -7, 110, -7, 103, -17, 10, -27, 46, 34], [189, -69, 5, 153, -154, -6, 59, 3, -69, 7, -31, 47, 7, 5, -14, 1], [98, -72, -76, -24, -30, 40, -16, 29, 33, -4, 29, 4, -8, 36, -50, -65], [602, 14, -47, -353, 114, -1, 91, -13, -58, 61, -46, 0, 9, 23, 63, -25], [277, -47, 53, 356, 140, -11, -43, 29, -66, 16, -25, 17, 16, -8, 4, 19], [-81, -36, 9, 18, 165, -18, 6, 33, 7, 21, -20, -4, 17, 27, -45, 36], [-12, -125, 3, 118, 24, 21, 25, -9, -30, -9, -4, 8, -5, -26, -21, 8], [-49, 0, 44, -10, 68, 18, 6, 24, -43, 40, -5, 4, 44, 26, -18, 82], [-149, -138, -6, 67, 185, 24, 14, -8, 22, -10, -6, 0, -40, 15, 53, 33], [273, 134, -14, 170, -171, 26, 51, 2, -50, -8, -29, -17, -8, 8, 28, -34], [61, 88, -30, -44, -41, 19, 25, 11, -5, -8, -13, 21, -29, 11, 4, -22], [205, 14, 31, -242, -13, 34, 8, -12, 23, 3, 77, -13, -23, 22, -7, 56]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_900_p_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_900_3_p_d();".
// 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_900_3_p_d(:prec:=16)
    chi := MakeCharacter_900_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(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_900_3_p_d();".
// 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_900_3_p_d( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_900_p();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,3,sign)));
    Vf := Kernel([<7,R![1115296517776, 406181614664, 455222811324, -75179664908, 76104497504, -5819046060, 3960781930, -209228176, 147133197, -3758746, 2596750, -36030, 33299, -218, 219, -1, 1]>],Snew);
    return Vf;
end function;