
// Make newform 27.8.c.a in Magma, downloaded from the LMFDB on 20 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_27_c();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_27_c_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_27_8_c_a();".
// 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_27_8_c_a();".
// 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 := [754412211, -449098992, 513267363, -131054670, 72369348, -8342916, 3002887, -192378, 50808, -1820, 375, -6, 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], [3098815785, -917896869, 943236207, -50887950, 25967781, -630307, 213005, -2494, 631, -5, 1, 0], [180, -3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0], [18976459761, -23328471195, 24728370921, -2825041638, 1475805645, -76444445, 26320567, -721874, 183791, -2215, 443, 0], [1000917153009, -265437133713, 277992051363, -25337744142, 13240426797, -690862039, 238629713, -7180774, 1832911, -25145, 5029, 0], [182728260423, -66534176943, 70650764829, -8325296130, 4393795275, -279749033, 97211743, -3412250, 873305, -13495, 2699, 0], [2867387988937761, -1383240867349824, 593549030077326, 83127551924445, 7856435046999, 5117486083294, -153624091098, 95608029027, -2684366423, 724465158, -9956688, 1958197], [-87187467749373, 1069258078504611, -347350112267085, 249039162917340, -26531282326773, 11260349921425, -653762799151, 195273274808, -6395237967, 1457064271, -21540167, 3916394], [477199570249662840, -210913006206368529, 129378126521627865, 11192627445604809, 6430487977844142, 1138718367264907, 131460986193239, 23137472449883, 1190431529238, 180673452721, 3836540593, 499913231], [16868076430785471, -20396503412810145, 6671454296702895, -4697389961111028, 511097017128423, -217142495718683, 12821003239205, -3831102185704, 126610077957, -28848101381, 427517101, -77730382], [547729371474062220, 346760628858611451, 135414409007778237, 43805614789010805, 4779161322029130, 1976398128186919, 50673438197739, 37001818591575, 86084626714, 299680949037, -683443683, 868001755], [27536223844018512, -80291612552969745, 20568158469989127, -27207425320413891, 2424301324746570, -1485854186786545, 77705950762349, -29116328059993, 894769481542, -236441521415, 3350347411, -674669385]];
    Rf_basisdens := [1, 479986560, 1, 239993280, 479986560, 159995520, 780837815928960, 780837815928960, 780837815928960, 86759757325440, 780837815928960, 390418907964480];
    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_27_c();"
function MakeCharacter_27_c()
    N := 27;
    order := 3;
    char_gens := [2];
    v := [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_27_c_Hecke();"
function MakeCharacter_27_c_Hecke(Kf)
    N := 27;
    order := 3;
    char_gens := [2];
    char_values := [[-1, 0, 0, 0, 0, 0, 0, 1, 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 := 8;
    raw_aps := [[0, -1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [30, 0, 0, 0, 0, 0, 0, -30, 0, 0, 0, -1], [0, 16, -1, -3, 0, 1, -16, -6, -1, 1, -1, -3], [0, -13, -20, -1, 0, -2, 13, 1407, 2, 20, -5, -1], [-190, 0, 0, 0, 10, 0, 251, 190, 5, -9, -10, 6], [-2497, 97, -33, -16, -24, 21, 0, 0, 0, 0, 0, 0], [1131, -1792, 2, -33, -2, 20, 0, 0, 0, 0, 0, 0], [8968, 0, 0, 0, 29, 0, 705, -8968, -64, 332, -29, -104], [0, -333, 155, -120, 0, 137, 333, 68830, -137, -155, 86, -120], [1302, 0, 0, 0, -109, 0, -353, -1302, -116, -196, 109, 354], [16326, 9491, -757, 3, 262, -199, 0, 0, 0, 0, 0, 0], [287339, 0, 0, 0, 266, 0, -2257, -287339, -7, 659, -266, -243], [0, -31098, -251, -162, 0, 537, 31098, 52345, -537, 251, -201, -162], [0, 12862, 3555, -563, 0, 477, -12862, 278570, -477, -3555, -927, -563], [-246738, -20189, -3541, 1671, 134, 545, 0, 0, 0, 0, 0, 0], [337263, 0, 0, 0, 1575, 0, -9912, -337263, -801, -2421, -1575, 4118], [0, -5475, 9073, 2934, 0, -933, 5475, -457148, 933, -9073, 2022, 2934], [628461, 0, 0, 0, -373, 0, -15137, -628461, -2834, -13000, 373, -2301], [-181330, 41121, 9949, 539, 3646, -1265, 0, 0, 0, 0, 0, 0], [-887113, 2217, 11271, -6084, 1464, -3363, 0, 0, 0, 0, 0, 0], [0, -82075, -15072, -1482, 0, 1568, 82075, 961154, -1568, 15072, 1021, -1482], [0, -4646, -2987, -6453, 0, 1135, 4646, -1602512, -1135, 2987, -2441, -6453], [2096188, 84733, -6167, -13625, -6818, 4219, 0, 0, 0, 0, 0, 0], [0, -460167, -17543, 1089, 0, 651, 460167, 1436665, -651, 17543, -8406, 1089], [0, -444894, -28850, -8093, 0, -9446, 444894, 697298, 9446, 28850, 3520, -8093], [-971554, 0, 0, 0, 1729, 0, -492832, 971554, 7031, 43713, -1729, 12597], [-2863563, -381430, 48256, 16923, -6242, -326, 0, 0, 0, 0, 0, 0], [1149078, 622505, -11191, -24423, -11174, 4811, 0, 0, 0, 0, 0, 0], [4953348, 0, 0, 0, -13426, 0, 428260, -4953348, -6634, -9478, 13426, -7279], [-4148022, -297640, 74468, 56154, 2356, -10888, 0, 0, 0, 0, 0, 0], [17162236, 0, 0, 0, -3167, 0, 844642, -17162236, 8221, -5513, 3167, 45295], [0, -82643, 108001, 59745, 0, -36269, 82643, 17597875, 36269, -108001, 25414, 59745], [-1225293, 0, 0, 0, 35753, 0, 913006, 1225293, -4685, -64777, -35753, 55578], [25431770, 0, 0, 0, -21858, 0, -2198813, -25431770, 28857, 137667, 21858, 9336], [0, 1764143, 53610, -12894, 0, 51482, -1764143, -5006572, -51482, -53610, -47735, -12894], [10655290, 0, 0, 0, -11904, 0, 1874646, -10655290, 13302, 102346, 11904, -164421], [13986612, -956668, 30860, -61692, 26848, 22508, 0, 0, 0, 0, 0, 0], [34888008, 0, 0, 0, 65083, 0, 1098920, -34888008, -11351, -138053, -65083, -137827], [0, 3313792, -131020, -86545, 0, -19420, -3313792, 16054212, 19420, 131020, 95684, -86545], [-26229064, 4070058, 41602, -147058, 23068, 118030, 0, 0, 0, 0, 0, 0], [2626308, -8221, -486145, -84507, 14410, -102619, 0, 0, 0, 0, 0, 0], [0, -395420, -100055, -36165, 0, 143935, 395420, 8976274, -143935, 100055, -43475, -36165], [957577, 0, 0, 0, -191142, 0, 1142625, -957577, 47187, -81215, 191142, 99063], [12069208, 889932, 108152, 204934, 135236, -153064, 0, 0, 0, 0, 0, 0], [-33615576, -2469523, 113813, -91527, 184762, -3565, 0, 0, 0, 0, 0, 0], [73143898, 0, 0, 0, 148437, 0, -709881, -73143898, -116502, -223082, -148437, -149562], [0, 4141672, -480709, 194829, 0, 105805, -4141672, -36035790, -105805, 480709, -95869, 194829], [0, 8366761, -228898, 441569, 0, -17884, -8366761, 15122427, 17884, 228898, -201661, 441569], [-95926936, 0, 0, 0, 89188, 0, 5033144, 95926936, 94652, -10212, -89188, 247767], [33242879, 5333590, -682332, -246691, 44922, -214908, 0, 0, 0, 0, 0, 0], [61734652, 0, 0, 0, 211769, 0, -560679, -61734652, 253220, -762880, -211769, 233884], [0, 811292, 652368, 86538, 0, -304720, -811292, 92137715, 304720, -652368, 13612, 86538], [-102319949, 3300642, 604940, -106991, -4870, 18698, 0, 0, 0, 0, 0, 0], [38637935, 0, 0, 0, -247036, 0, -3152746, -38637935, -179782, -87586, 247036, -266214], [0, -2429745, 1758244, -345476, 0, -133952, 2429745, 6027836, 133952, -1758244, 217891, -345476], [5769894, -8460399, -855855, 547077, 8010, -94941, 0, 0, 0, 0, 0, 0], [178089440, 22763454, 458646, -715194, -163356, 33450, 0, 0, 0, 0, 0, 0], [0, -11366426, -276202, -31809, 0, -400526, 11366426, -168133452, 400526, 276202, 65996, -31809], [0, -6104093, -299599, 928832, 0, -458053, 6104093, 60750954, 458053, 299599, 610124, 928832], [-112924324, 0, 0, 0, -279233, 0, -15881572, 112924324, 325553, -1393029, 279233, -566157], [-54273788, 0, 0, 0, -596568, 0, 2403998, 54273788, 66678, 1481802, 596568, 195199], [-78097447, -7701270, -2191992, -882801, -48234, 510762, 0, 0, 0, 0, 0, 0], [71917760, 0, 0, 0, -431279, 0, 17724207, -71917760, 483394, -847886, 431279, -77406], [0, -6525036, -2763716, -1148994, 0, -395100, 6525036, 6288271, 395100, 2763716, -156624, -1148994], [0, 6087853, -1506507, -1327130, 0, 142383, -6087853, -208770382, -142383, 1506507, -258198, -1327130], [0, -9194027, -187366, -635682, 0, 16918, 9194027, -384267954, -16918, 187366, 341111, -635682], [-269994883, 0, 0, 0, -74396, 0, 19509590, 269994883, -233686, -4175970, 74396, 111606], [-372837173, 0, 0, 0, 47429, 0, -28601877, 372837173, -265252, 61790, -47429, 1883587], [0, 28622450, 1766682, 208425, 0, 1014614, -28622450, 502788422, -1014614, -1766682, 126412, 208425], [0, 17309609, 2806005, 1578003, 0, -407697, -17309609, -747102827, 407697, -2806005, 1160886, 1578003], [330777982, -20554666, -515502, 1600132, 1009872, 569898, 0, 0, 0, 0, 0, 0], [0, 39031067, -178938, 1867080, 0, -970798, -39031067, -192048778, 970798, 178938, 775033, 1867080], [603193234, 0, 0, 0, -257646, 0, 20729049, -603193234, -863949, 2143057, 257646, 451656], [631107369, -3414361, 5564429, 3390960, 1266976, -904483, 0, 0, 0, 0, 0, 0], [94374636, 0, 0, 0, -719977, 0, -22251704, -94374636, -707803, -3993145, 719977, -2307847], [0, -43372770, 2840046, 523289, 0, 1079538, 43372770, -591113856, -1079538, -2840046, -2304660, 523289], [-345559254, -40104799, -3174439, -220443, -71150, 1393763, 0, 0, 0, 0, 0, 0], [-562195109, 0, 0, 0, 1540018, 0, -77470583, 562195109, -826349, -456143, -1540018, -265805], [-240997701, 0, 0, 0, 2326904, 0, 15916912, 240997701, -1252520, 308072, -2326904, -2238486], [448286426, 0, 0, 0, 702567, 0, 94805731, -448286426, 401868, 1191132, -702567, -414732], [0, -41399799, 5310097, 3325518, 0, 1024707, 41399799, -329227736, -1024707, -5310097, -1178622, 3325518], [-351275118, 11467250, -9761258, -838644, 136768, -1411922, 0, 0, 0, 0, 0, 0], [912698001, -23754955, 2501711, -3679962, 592012, -410491, 0, 0, 0, 0, 0, 0], [0, 49648479, -9871442, -71424, 0, -177846, -49648479, -252845750, 177846, 9871442, -476859, -71424], [0, -82442216, 4298921, -925384, 0, -55063, 82442216, 843644583, 55063, -4298921, 1970597, -925384], [-129321361, -16811125, -1485823, 1149386, 626948, 1189643, 0, 0, 0, 0, 0, 0], [0, 128740973, 2629569, 30945, 0, 287939, -128740973, 633611285, -287939, -2629569, 2430886, 30945], [0, 78542667, 2604227, -4394580, 0, 1795721, -78542667, -65035094, -1795721, -2604227, -1174042, -4394580], [-261469974, 0, 0, 0, -3237265, 0, 77717113, 261469974, 1033930, 2117774, 3237265, -2382396], [-1206823901, -21527016, 2701418, -2942345, 91934, -2688772, 0, 0, 0, 0, 0, 0], [0, -19000245, 1839076, -1724876, 0, -2493272, 19000245, 1706884784, 2493272, -1839076, 2190415, -1724876], [1287283470, -57560806, 2581382, 2332632, -3152216, 385814, 0, 0, 0, 0, 0, 0], [1722366669, 0, 0, 0, -1563509, 0, -5566672, -1722366669, -593657, -5216561, 1563509, 2619152], [-966460887, 0, 0, 0, -155227, 0, 69277240, 966460887, -444779, 1783553, 155227, 5268450], [-2322577570, 82429587, 6731551, -2655619, -396398, -1328363, 0, 0, 0, 0, 0, 0], [360708988, 0, 0, 0, -2619986, 0, -60396665, -360708988, 6227701, -4845665, 2619986, 1326766], [1517525065, -30433922, -14876000, -2146469, -1601570, 520552, 0, 0, 0, 0, 0, 0], [-112575502, 103420659, 504471, 5528349, -4033974, 2512245, 0, 0, 0, 0, 0, 0], [49472280, 228058772, 8965880, 3807354, 4672540, 18368, 0, 0, 0, 0, 0, 0], [0, -60508995, 6503164, -6181137, 0, 227862, 60508995, -385912169, -227862, -6503164, -763947, -6181137], [2615459060, 272750451, 2262031, 5838857, -4143686, 1999933, 0, 0, 0, 0, 0, 0], [2241120535, 0, 0, 0, -973691, 0, -103967951, -2241120535, -1101974, -6588392, 973691, -9786743], [0, 94284256, 5753992, 1134, 0, 6766456, -94284256, -1332557495, -6766456, -5753992, 1447624, 1134], [-865264665, 0, 0, 0, -2549485, 0, -265215269, 865264665, 159454, 8222780, 2549485, 9293133], [612572795, -185471061, -1523319, 6245874, 585708, -4014285, 0, 0, 0, 0, 0, 0], [0, -223610650, -1238521, 5499646, 0, 4736075, 223610650, 1019951159, -4736075, 1238521, 57185, 5499646], [-351690792, -273594557, 30052511, -8091735, 4614698, -1121059, 0, 0, 0, 0, 0, 0], [3439743120, 0, 0, 0, -2701373, 0, 134240432, -3439743120, -1011143, -2787653, 2701373, 11408141], [0, -228627137, 11403287, 10176837, 0, -3782555, 228627137, 852672387, 3782555, -11403287, 10933118, 10176837], [2551251548, 0, 0, 0, 950341, 0, 152352482, -2551251548, -1397743, -25262805, -950341, -12687627], [-609885154, 37547985, 7364289, -8373303, -1697430, 6652731, 0, 0, 0, 0, 0, 0], [-2610089855, 0, 0, 0, 6557798, 0, -136980741, 2610089855, -7114231, -11176957, -6557798, -1993241], [0, 277982893, -30779872, 5529579, 0, -3207590, -277982893, -666802389, 3207590, 30779872, -434119, 5529579], [929340588, 94631870, -14552482, -22246206, 5165932, 1449842, 0, 0, 0, 0, 0, 0], [0, -361886172, 26184016, 1137754, 0, -292544, 361886172, -812653687, 292544, -26184016, 2562964, 1137754], [-2798720005, 0, 0, 0, 10679671, 0, -10929529, 2798720005, -9145906, 23593572, -10679671, -7214547], [-1874261574, -474663682, 3880594, 3829464, -9586136, 3802258, 0, 0, 0, 0, 0, 0], [-1365948348, 0, 0, 0, 8381936, 0, 177309928, 1365948348, 1280384, 37860056, -8381936, -18404443], [0, 101200043, -450854, -29035630, 0, 4257910, -101200043, 5663410986, -4257910, 450854, -1849475, -29035630], [3068126130, 0, 0, 0, 2503556, 0, 17058274, -3068126130, 7255222, -2757166, -2503556, 3989775], [0, -323434429, -30300759, -6756090, 0, 489491, 323434429, -3042352258, -489491, 30300759, 7186660, -6756090], [0, 347200754, -347466, 15206487, 0, -11516934, -347200754, -3393224714, 11516934, 347466, -1482456, 15206487], [-5373753767, 56203798, -9247340, 7718107, -5243378, 8516302, 0, 0, 0, 0, 0, 0], [0, -24641748, 32460601, 15411267, 0, -706653, 24641748, -47781344, 706653, -32460601, -4724691, 15411267], [1401440676, -422422199, -5346403, -28718697, -3707842, 3193247, 0, 0, 0, 0, 0, 0], [0, 328292680, 55190948, 10758183, 0, -9703532, -328292680, 1932205254, 9703532, -55190948, 3572156, 10758183], [-6766294156, 631905108, -7095764, 6758144, 177664, -9426764, 0, 0, 0, 0, 0, 0], [0, 30963181, 31886240, 24105840, 0, 4436500, -30963181, -7673632116, -4436500, -31886240, 1984205, 24105840], [-3529258926, 0, 0, 0, 2236550, 0, 265731409, 3529258926, 7442095, 45093533, -2236550, -18425112], [2335723869, 132355181, 23849915, -6386838, -10150700, 1435559, 0, 0, 0, 0, 0, 0], [1013516378, 0, 0, 0, 10126503, 0, 253829620, -1013516378, -1407843, 34450371, -10126503, -19008921], [-2198437124, 0, 0, 0, 12046497, 0, 118521456, 2198437124, -17388309, -63495527, -12046497, -15188121], [-4214790670, 3779304, -10691184, -8016156, -16470312, 19227840, 0, 0, 0, 0, 0, 0], [-6145196850, 0, 0, 0, -5450364, 0, 14619567, 6145196850, -5550561, -35576451, 5450364, 24266864], [6073955852, 0, 0, 0, -19758602, 0, 461548046, -6073955852, 5688080, 18968808, 19758602, 12912333], [7482934448, 486103613, -6071479, 20545655, -26724802, 8083091, 0, 0, 0, 0, 0, 0], [-2755645328, 0, 0, 0, 11904087, 0, 747787050, 2755645328, 11717871, -19452827, -11904087, 35913177], [-12574800376, 0, 0, 0, -12298658, 0, 564708627, 12574800376, 25953865, -41975021, 12298658, 16646934], [5846804271, -607629969, -22452219, 30331350, 13211244, -26981577, 0, 0, 0, 0, 0, 0], [-1505141139, -203423212, -77690734, 6765789, 11288554, 2775656, 0, 0, 0, 0, 0, 0], [0, -847729809, -60066429, 16233380, 0, 6892113, 847729809, -5995732650, -6892113, 60066429, -7273446, 16233380], [4424850242, 0, 0, 0, 10828999, 0, -97407505, -4424850242, -1062904, 111017376, -10828999, -30821250], [6851410592, 297533450, 90494594, -38694418, -6800164, 19947086, 0, 0, 0, 0, 0, 0], [-36499272, -502035523, 32344745, -36059541, -26809970, 20199083, 0, 0, 0, 0, 0, 0], [0, 821760498, 7618367, 3299163, 0, 5518829, -821760498, 6650721268, -5518829, -7618367, -181111, 3299163], [0, -506035207, 69755469, -18238488, 0, 19210871, 506035207, -624793282, -19210871, -69755469, -4860530, -18238488], [0, 99749537, -121427665, -52097918, 0, 17740037, -99749537, -10519896490, -17740037, 121427665, 13877528, -52097918], [-273228965, 0, 0, 0, -4599249, 0, -542076543, 273228965, -8640288, -73712270, 4599249, -51126165], [-2585565660, 381718802, 9324946, 34351206, 15757972, 8288542, 0, 0, 0, 0, 0, 0], [5174842028, 0, 0, 0, 13610266, 0, -565774063, -5174842028, -6559093, 68158065, -13610266, 5998578], [721059932, -139065203, -56720487, 8373023, 52306782, -21711045, 0, 0, 0, 0, 0, 0], [1494039729, 971330996, -54475366, 579081, 17560066, -7871080, 0, 0, 0, 0, 0, 0], [-3451079198, 0, 0, 0, 2756733, 0, -1448580157, 3451079198, 5731854, -23022606, -2756733, 8113060], [0, -962703138, 94710529, 39023316, 0, 157065, 962703138, -2306307113, -157065, -94710529, -9683805, 39023316], [0, 408313909, -11248014, 15218836, 0, -4050570, -408313909, 7032925022, 4050570, 11248014, 12484239, 15218836], [-4084408030, -69178494, 33445158, 68254956, 19502832, -17287194, 0, 0, 0, 0, 0, 0], [0, -77019303, 175942467, 48167726, 0, -6599295, 77019303, 2254463514, 6599295, -175942467, -2199996, 48167726], [-5315622000, 878179709, -29954479, -6661401, 19241158, -13042525, 0, 0, 0, 0, 0, 0], [8366669794, 0, 0, 0, 3074860, 0, -1177605260, -8366669794, 22786960, -26843000, -3074860, 26559655], [0, 768240485, -43822938, 7016115, 0, 6859032, -768240485, -7316166191, -6859032, 43822938, -11305857, 7016115], [-4693271369, -1018080481, 18180453, 47354830, 15609756, -11096457, 0, 0, 0, 0, 0, 0], [-2579572324, 0, 0, 0, 7875895, 0, -945693067, 2579572324, 506978, 87625698, -7875895, 56712750], [-2725250022, -345777329, -12341437, 51446601, 16558322, -27156679, 0, 0, 0, 0, 0, 0], [2051270949, 0, 0, 0, -8881704, 0, -1084259358, -2051270949, 4645026, -122520762, 8881704, -49757788], [0, -1496496867, 57242286, -54875188, 0, -5739102, 1496496867, 10936248510, 5739102, -57242286, 6823971, -54875188], [-15773551852, 177820602, 156885594, 20267046, 4540116, -33933666, 0, 0, 0, 0, 0, 0], [0, 1232188234, -20843866, 6653949, 0, 21077098, -1232188234, -10215370782, -21077098, 20843866, -38153008, 6653949]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_27_c_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_27_8_c_a();".
// 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_27_8_c_a(:prec:=12)
    chi := MakeCharacter_27_c();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 8));
    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_27_8_c_a();".
// 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_27_8_c_a( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_27_c();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,8,sign)));
    Vf := Kernel([],Snew);
    return Vf;
end function;