
// Make newform 147.6.e.p in Magma, downloaded from the LMFDB on 16 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_147_e();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_147_e_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_147_6_e_p();".
// 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_147_6_e_p();".
// 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 := [5466244, 4339328, 5644794, -1176024, 973971, -99530, 62015, -5290, 2784, -126, 63, -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], [-5312192750520319842951993220, -6192628378330469523706273542, -1593880650876785305074543367, -544742107360979765026223277, -131464912894225437940986791, -40788607526986404577984255, -7006947392310859952472388, -1171977996990008298747354, -177148912886630931899425, -26131237974406419382629, -3038545450186586446973, -22940144244931089763], [-256440602205707239215672, -345446156158343882363740, 144332409961229777524483, -68256831693782948072498, 10066587304087074527078, -4385399005576085002006, 535361150914196233104, -201467508660928760044, 12560312084710410247, -4565510549861301170, 208838138667100562, -74017405486250716], [-19097668648781072, -1419056815456112, -1591256802005214, -1145670345942085, -88679977716417, -57351081264574, -4688491956128, -3055159408682, -116805928632, -58398312001, -2504891733, -1293273694], [132903605090650564529783102, -544912962373405029889955293, 113721738065652181131926793, -54594672875142946730522540, 8006942818707963465784836, -3550550855853717430864559, 424369668155373148326452, -154670545214410850870134, 9978913591470021635823, -3827831175876896702282, 175014220380253722675, -63425667576406489997], [-2342735488567530359831294816, -2584877641169445214629409886, -845459525156435556542761116, -108375708398801026426535425, -109555993754531810357411274, -7893798954478637000317922, -5835522746262072258185282, -61525592714674851748304, -166289753272709259584550, -1140994831888406684677, -2457275938909575867378, 107705297845866006982], [-120597259734034536956553862, 4567357062992053145021959146, -241596680310926293314864925, -122160111944138110022270958, 18184256756799931517438425, -20314656155465719692311752, -155481405079037576662408, -2083265915013574037130072, 2919913422284846941259, -59325880598205734683578, -752737776898658436101, -1359019473038182889734], [13616207669803588250712164, 4285966128820018824518568, 4994584744207813573132530, 1171343352483340064080327, 437944638349477269246807, 106679246496489729800928, 33155097643713254610806, 5685852490593409781154, 940176305087010416676, 147843268240512381655, 20960090940092719995, 2464787564900969652], [-396438298318478959057791752, -21189715433454272363164072, -22768554798280861887279958, -12570471057663436642215767, -428665862085260835685061, -1206671770264567040390556, 33903802215030980761240, -64265428797222686024158, 1348154702247278956700, -1638789529801478055059, 33112687019152545439, -26899152544270397760], [11445832576094451029609406166, -27073204355928645599383246603, 10024044949441703217080053661, -4416213322544644944647051372, 769156302163975883732654245, -266634921403029927539684691, 36165437873058260519733412, -10617174392790390571238974, 839481933538358644807787, -225217127457056777953586, 12342303705178089144622, -3106417486473775610985], [21987494373188120483867077148, 19691445421164430756419627582, 29260859512314453916039824863, -3105134903031672206984220591, 2640684563630434993444170109, -135242794874950703001540196, 140595376219660688131526312, -13657167348010097631902730, 3547878248595484307793965, -313892105838838737820431, 57990014951032465590055, -8633853285626504553874], [-38056249342653968586186866, -89420227193411237320762152, -102273060300388923078867602, -28732598538727146686894997, -7394332013666855949510535, -2907379468371290522165408, -531133525638151136982128, -154910563217250766009794, -13597585346057218772708, -4062290121503241597705, -300073551311318479339, -66189921555356533556]];
    Rf_basisdens := [1, 823792125413448096897931002, 424416344880704841266322, 1879904806270074, 58842294672389149778423643, 91532458379272010766436778, 823792125413448096897931002, 548098553169293477643334, 4932886978523641298790006, 411896062706724048448965501, 823792125413448096897931002, 4932886978523641298790006];
    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_147_e();"
function MakeCharacter_147_e()
    N := 147;
    order := 3;
    char_gens := [50, 52];
    v := [3, 2];
    // 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_147_e_Hecke();"
function MakeCharacter_147_e_Hecke(Kf)
    N := 147;
    order := 3;
    char_gens := [50, 52];
    char_values := [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 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 := 6;
    raw_aps := [[0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [-9, 0, -9, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, -2, 16, 2, 2, 0, 0, 0, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [-107, 0, -107, 0, -6, -8, 12, -8, 0, -3, -7, -7], [215, 34, 0, -12, 0, 0, 34, -8, 2, 0, 0, 3], [-521, 0, -521, 0, 31, -8, 32, -8, 0, -7, -17, -17], [0, -174, 231, -55, -55, 24, 0, 0, -12, -12, 3, 0], [0, 16, -759, 0, 0, 24, 0, 0, -45, -45, -51, 0], [-837, -86, 0, 201, 0, 0, -86, 24, -54, 0, 0, 63], [-673, 0, -673, 0, -215, -56, 94, -56, 0, 88, 63, 63], [0, -24, 3758, -300, -300, -96, 0, 0, 54, 54, -42, 0], [4961, -656, 0, -23, 0, 0, -656, -136, 65, 0, 0, -151], [-1218, 120, 0, 208, 0, 0, 120, 32, -90, 0, 0, -150], [0, 206, 8645, -381, -381, 184, 0, 0, 72, 72, -47, 0], [-13832, 0, -13832, 0, -1614, 208, 996, 208, 0, 132, -58, -58], [-2115, 0, -2115, 0, -941, -280, 1794, -280, 0, -100, -115, -115], [0, 1186, 8803, -74, -74, 200, 0, 0, -328, -328, -225, 0], [-1794, 0, -1794, 0, -148, -304, 2496, -304, 0, 414, 354, 354], [-19359, 3200, 0, 2364, 0, 0, 3200, 120, -243, 0, 0, 549], [-12854, 0, -12854, 0, -787, 32, 6584, 32, 0, 266, 138, 138], [0, 3240, 19592, 3992, 3992, 272, 0, 0, -468, -468, -312, 0], [17178, -828, 0, 622, 0, 0, -828, 16, 764, 0, 0, 142], [0, -4588, -7483, -6481, -6481, -1000, 0, 0, 169, 169, -355, 0], [9896, 6220, 0, 6723, 0, 0, 6220, -32, -22, 0, 0, 432], [-23838, 0, -23838, 0, -7438, 1984, 9210, 1984, 0, -917, -326, -326], [0, 5734, -11435, 3319, 3319, -1480, 0, 0, -880, -880, 885, 0], [0, 10148, -21571, 5862, 5862, -1768, 0, 0, -2139, -2139, 25, 0], [25860, 0, 25860, 0, 11450, -16, -9636, -16, 0, 342, 1008, 1008], [-122818, 40, 0, 2628, 0, 0, 40, -1312, -228, 0, 0, 448], [115606, -1224, 0, 4832, 0, 0, -1224, 2128, -198, 0, 0, 2310], [0, -1772, -15866, -1882, -1882, 720, 0, 0, 2188, 2188, -2598, 0], [40921, 0, 40921, 0, -3501, -248, 7154, -248, 0, -1020, 3101, 3101], [88800, -15864, 0, -6208, 0, 0, -15864, -1440, 2088, 0, 0, -3828], [0, 22132, -185288, 16590, 16590, 1744, 0, 0, 4524, 4524, 2786, 0], [-28506, 0, -28506, 0, 4272, -3264, -21216, -3264, 0, 2106, -2562, -2562], [-222239, 0, -222239, 0, 592, 2168, 14882, 2168, 0, -2140, -843, -843], [0, -37728, -76782, 2720, 2720, 2480, 0, 0, -990, -990, 1518, 0], [279749, 5242, 0, -2763, 0, 0, 5242, -1928, -4500, 0, 0, 937], [0, -25782, 191520, -20128, -20128, 2752, 0, 0, -4925, -4925, -3992, 0], [145023, 0, 145023, 0, -12474, 840, 34156, 840, 0, -1557, -4341, -4341], [269941, 43478, 0, -2040, 0, 0, 43478, 3128, -746, 0, 0, -1479], [0, -19104, -7179, 9132, 9132, -3240, 0, 0, -3465, -3465, -6591, 0], [-35214, 0, -35214, 0, 4892, 7712, -57384, 7712, 0, -1368, -3108, -3108], [-162140, -2076, 0, 29886, 0, 0, -2076, -3824, -528, 0, 0, 3098], [-164312, 0, -164312, 0, 10484, -352, -47536, -352, 0, 2480, 2424, 2424], [385460, 26424, 0, 43176, 0, 0, 26424, -7680, 1620, 0, 0, -2880], [47704, 13184, 0, 13556, 0, 0, 13184, 12416, 928, 0, 0, 14640], [135817, 0, 135817, 0, -18529, 1032, -56014, 1032, 0, -5480, 3657, 3657], [0, -36454, 113537, -43996, -43996, 4360, 0, 0, 7102, 7102, 4005, 0], [0, -36578, -45103, 2475, 2475, -3640, 0, 0, -1284, -1284, 2173, 0], [464081, -64144, 0, 13440, 0, 0, -64144, -232, 10653, 0, 0, -6467], [-258432, 0, -258432, 0, -68547, 6288, 22164, 6288, 0, 11658, 12216, 12216], [35501, 26314, 0, 78349, 0, 0, 26314, -7576, 2096, 0, 0, -8659], [0, 26204, 112463, -3259, -3259, -17272, 0, 0, 8011, 8011, 7223, 0], [485741, 0, 485741, 0, 54000, -3400, -42344, -3400, 0, 3099, 3913, 3913], [23210, 0, 23210, 0, 4064, 3200, -39794, 3200, 0, -8459, -16822, -16822], [0, -6634, -955363, -5073, -5073, 18040, 0, 0, 3592, 3592, -1563, 0], [328570, 0, 328570, 0, 34060, -8576, 28056, -8576, 0, 2952, 19452, 19452], [205049, -60942, 0, -120051, 0, 0, -60942, 4520, -1884, 0, 0, -6347], [-54027, 0, -54027, 0, 16743, 28584, 31050, 28584, 0, 13644, 13257, 13257], [492922, -44890, 0, 45894, 0, 0, -44890, -8752, 6783, 0, 0, -20974], [-603355, -42614, 0, 33701, 0, 0, -42614, 7432, -10828, 0, 0, 24489], [929253, 0, 929253, 0, 6083, -8552, 81570, -8552, 0, -392, -10295, -10295], [0, -42652, 175082, -31859, -31859, -21152, 0, 0, 18484, 18484, -8286, 0], [0, 127164, -156136, -57486, -57486, 12848, 0, 0, -39300, -39300, -10898, 0], [0, -236184, 346100, -1812, -1812, 7200, 0, 0, -24660, -24660, -23520, 0], [-17622, 128580, 0, -40054, 0, 0, 128580, 6160, -43992, 0, 0, 39114], [408285, 0, 408285, 0, -120006, -6600, 6844, -6600, 0, 10773, 15177, 15177], [874323, 10134, 0, -99952, 0, 0, 10134, -24744, -22188, 0, 0, 30735], [229583, 0, 229583, 0, 113543, -38392, -136556, -38392, 0, 4723, 7559, 7559], [0, -83368, 1109603, -81252, -81252, -15832, 0, 0, 4773, 4773, -11033, 0], [24710, 0, 24710, 0, -49770, 11440, 312940, 11440, 0, -2048, -2058, -2058], [0, 108120, -490114, -128276, -128276, -36128, 0, 0, -5184, -5184, -4236, 0], [-313480, 182040, 0, 57628, 0, 0, 182040, -16480, 8280, 0, 0, -23724], [0, -85576, 859664, 192648, 192648, -416, 0, 0, 33060, 33060, 28528, 0], [1095397, 0, 1095397, 0, -94899, 36328, 205198, 36328, 0, 17502, -7927, -7927], [0, 57350, -46891, 91068, 91068, 59608, 0, 0, 25852, 25852, 7017, 0], [0, 47614, -18295, -241893, -241893, 31784, 0, 0, 11172, 11172, -3227, 0], [-1461752, 0, -1461752, 0, 232527, -3664, 52508, -3664, 0, 17414, -41040, -41040], [-3039283, 29554, 0, 289509, 0, 0, 29554, 14056, 1212, 0, 0, -6611], [-732750, 161808, 0, 1792, 0, 0, 161808, 16160, 53352, 0, 0, 4296], [682607, 0, 682607, 0, -306024, -9304, 134736, -9304, 0, -2355, -4157, -4157], [-669710, -252364, 0, -245935, 0, 0, -252364, 79712, 25624, 0, 0, -24582], [0, 4680, -2317068, -197068, -197068, 192, 0, 0, -23136, -23136, -16116, 0], [0, 38844, -2078571, -69870, -69870, -45000, 0, 0, 19665, 19665, 14577, 0], [-323278, 190768, 0, -313728, 0, 0, 190768, -32416, 61836, 0, 0, -14108], [0, 346128, 3881766, -79224, -79224, 3648, 0, 0, 31824, 31824, 8568, 0], [1418756, -179234, 0, 178392, 0, 0, -179234, -68336, -14763, 0, 0, -21764], [1639346, -120000, 0, 107624, 0, 0, -120000, -53552, 11898, 0, 0, -30438], [0, -97898, -1533587, -21205, -21205, 3528, 0, 0, -63368, -63368, -84315, 0], [1797703, 0, 1797703, 0, -70423, 68136, -483370, 68136, 0, 12976, -1749, -1749], [-1963882, 0, -1963882, 0, 7096, 34048, 110160, 34048, 0, 26154, 9030, 9030], [-3547681, -590268, 0, 49374, 0, 0, -590268, 32264, -12711, 0, 0, -20933], [0, 79224, 1444378, -257924, -257924, 10912, 0, 0, -25722, -25722, 13782, 0], [699078, 289428, 0, 17886, 0, 0, 289428, -47568, -47988, 0, 0, 87990], [0, -550074, -4226874, -332368, -332368, -37808, 0, 0, 32455, 32455, 21142, 0], [-1490187, 0, -1490187, 0, -106031, 22376, -539400, 22376, 0, 10391, -74899, -74899], [0, 463532, -1398562, 108606, 108606, 14416, 0, 0, -19616, -19616, 65514, 0], [0, 168840, 1868010, 11068, 11068, -121664, 0, 0, -15552, -15552, -29484, 0], [1646836, -267216, 0, 354396, 0, 0, -267216, -43440, -35352, 0, 0, 43320], [2619092, 0, 2619092, 0, 414714, 5264, -460716, 5264, 0, 10740, 12766, 12766], [4738833, 0, 4738833, 0, -347657, -69400, -192246, -69400, 0, 98828, -33199, -33199], [0, -621198, -755941, -193251, -193251, -26632, 0, 0, 118056, 118056, -16985, 0], [2998184, 0, 2998184, 0, -278596, -34864, 174912, -34864, 0, -82116, 60684, 60684], [-146988, 0, -146988, 0, 295631, -101280, -10944, -101280, 0, -82980, -30300, -30300], [-1679433, -690354, 0, -216385, 0, 0, -690354, 132824, -96752, 0, 0, -6625], [0, -146980, 794519, 324211, 324211, -8328, 0, 0, -103477, -103477, -196737, 0], [4872055, 0, 4872055, 0, -288900, -37496, 68400, -37496, 0, -31251, -87469, -87469], [5335280, 731608, 0, 237617, 0, 0, 731608, -44672, -90556, 0, 0, -37584], [0, 667944, 2990124, 101072, 101072, -112224, 0, 0, -76152, -76152, -145596, 0], [-1581046, 0, -1581046, 0, 138052, 18112, 1220952, 18112, 0, -88074, -28722, -28722], [-2823485, -631506, 0, -723693, 0, 0, -631506, -84296, -113928, 0, 0, -36265], [4268034, 0, 4268034, 0, -13998, -81456, -870804, -81456, 0, 64992, -161898, -161898], [3611970, 239664, 0, 809432, 0, 0, 239664, -44336, 50130, 0, 0, -134934], [2029979, 0, 2029979, 0, 467985, -16360, -1335514, -16360, 0, 44220, 54847, 54847], [1916779, 130022, 0, 139655, 0, 0, 130022, 15128, 42028, 0, 0, 80559], [7001711, 0, 7001711, 0, -9351, -88568, 674350, -88568, 0, 30180, 70723, 70723], [0, 161358, 4363799, -332301, -332301, -44968, 0, 0, 47262, 47262, 152155, 0], [-3436425, -471508, 0, 307014, 0, 0, -471508, -162744, 71901, 0, 0, -136701], [-9603269, 0, -9603269, 0, 538862, 1784, -897298, 1784, 0, -35872, 73623, 73623], [3784620, 252120, 0, -54076, 0, 0, 252120, 87136, 18468, 0, 0, -64920], [0, -307462, 4029824, -199884, -199884, 216064, 0, 0, 50283, 50283, 167272, 0], [6852603, 0, 6852603, 0, 8670, 175368, -601412, 175368, 0, 100863, 4959, 4959], [0, -421188, 7590198, -284558, -284558, 49008, 0, 0, 99000, 99000, -22230, 0], [-5366151, 990662, 0, 434223, 0, 0, 990662, 131976, 106434, 0, 0, 103941], [0, 2604, -508304, -1031842, -1031842, 7184, 0, 0, -121266, -121266, -188508, 0], [0, 905492, -1202350, 654326, 654326, 33200, 0, 0, -205220, -205220, -97798, 0], [-550999, -617294, 0, -856787, 0, 0, -617294, 92824, 32960, 0, 0, -212367], [0, -503642, 8522587, 68950, 68950, 125864, 0, 0, -14194, -14194, -6057, 0], [638402, 0, 638402, 0, -540440, 141904, 1051824, 141904, 0, -22230, -170082, -170082], [557881, -423192, 0, 1596492, 0, 0, -423192, 98488, -114999, 0, 0, 17189], [0, 202824, 1045508, 704864, 704864, -214336, 0, 0, -213120, -213120, -47220, 0], [-8264620, 527028, 0, 190802, 0, 0, 527028, -258992, -112122, 0, 0, 104712], [0, 252496, 10709767, 609725, 609725, -66984, 0, 0, 74401, 74401, 249087, 0], [4759542, 758412, 0, 474813, 0, 0, 758412, -200064, 213216, 0, 0, 21582], [-8189246, 0, -8189246, 0, 381258, -20032, 395870, -20032, 0, 171165, -209254, -209254], [6320322, 0, 6320322, 0, -470738, -52368, 1571004, -52368, 0, -253920, -94482, -94482], [11444276, -121286, 0, 130352, 0, 0, -121286, 34560, -105617, 0, 0, -2676], [-4589750, 0, -4589750, 0, 906960, 95296, 495312, 95296, 0, -3612, 24020, 24020], [9610326, -1308204, 0, -551758, 0, 0, -1308204, -39024, 46848, 0, 0, 47802], [0, 1029028, 1140188, 518694, 518694, 333008, 0, 0, -120300, -120300, 125746, 0], [-7426564, 0, -7426564, 0, 417168, -200496, -1239384, -200496, 0, 17928, 111684, 111684], [2277941, 781348, 0, 838518, 0, 0, 781348, 404600, -32601, 0, 0, 152233], [1821279, 0, 1821279, 0, 1888902, 78552, -730974, 78552, 0, -52026, 21483, 21483], [-11069855, 190082, 0, 133665, 0, 0, 190082, -476392, 11172, 0, 0, -142891], [7620675, -1929354, 0, -761108, 0, 0, -1929354, 112152, 39348, 0, 0, -328641], [235625, 0, 235625, 0, -242765, -151704, -604832, -151704, 0, -52633, 158529, 158529], [0, 161302, -10974179, -51725, -51725, -220216, 0, 0, -27964, -27964, -33183, 0], [0, -1046072, 13066177, 1995408, 1995408, -79112, 0, 0, 150351, 150351, 172469, 0], [0, 1068312, -14153886, -156868, -156868, -132544, 0, 0, -82890, -82890, -29130, 0], [11217011, -2720540, 0, -521339, 0, 0, -2720540, 86168, -121279, 0, 0, -80149], [-7643326, 1352856, 0, 2125340, 0, 0, 1352856, 354592, 188658, 0, 0, 145782], [0, 1553114, -1126909, -1467, -1467, -66968, 0, 0, -5292, -5292, 266287, 0], [-3660974, 0, -3660974, 0, -333900, -221184, 93672, -221184, 0, -47898, 74934, 74934], [12098685, -1146192, 0, 204912, 0, 0, -1146192, -59400, -206055, 0, 0, 22761], [0, 460536, 2196854, -560800, -560800, -166432, 0, 0, 240822, 240822, -22650, 0], [0, 1819800, -9718677, -16455, -16455, -255672, 0, 0, 262737, 262737, 238563, 0], [2185456, 2063024, 0, 357961, 0, 0, 2063024, -321232, 180784, 0, 0, 61152], [-1118732, 0, -1118732, 0, -1144994, -208784, 10730, -208784, 0, -141367, 186628, 186628], [0, -1123084, -2526955, -1084302, -1084302, 100856, 0, 0, -420747, -420747, 77281, 0], [-2768378, 1999944, 0, 402156, 0, 0, 1999944, -8960, 88464, 0, 0, -22540], [5286094, -1760472, 0, 425248, 0, 0, -1760472, -111472, -99630, 0, 0, -27306], [0, -388560, 135012, 1108280, 1108280, 241696, 0, 0, -74792, -74792, 411664, 0], [-5929087, 0, -5929087, 0, 1413471, 201992, 817402, 201992, 0, 72480, -205787, -205787], [-2306856, 0, -2306856, 0, 303080, -478496, 323280, -478496, 0, -293432, -236192, -236192], [19518026, 0, 19518026, 0, 417648, -149760, -2624952, -149760, 0, 26082, -339846, -339846], [-17049469, 0, -17049469, 0, -1662282, 361912, 381934, 361912, 0, 254872, -227841, -227841]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_147_e_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_147_6_e_p();".
// 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_147_6_e_p(:prec:=12)
    chi := MakeCharacter_147_e();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 6));
    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_147_6_e_p();".
// 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_147_6_e_p( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_147_e();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,6,sign)));
    Vf := Kernel([<2,R![2609983744, -217430528, 348755072, -6786304, 34682928, -838240, 1095976, 35152, 22761, 334, 173, 2, 1]>,<5,R![99400148502700385344, 9563304139310807168, 823684539529925792, 22262009855728576, 785817679635168, 7702343637280, 413764540744, 3439946000, 101403192, 624824, 16778, 100, 1]>],Snew);
    return Vf;
end function;