
// Make newform 380.2.u.a in Magma, downloaded from the LMFDB on 25 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_380_u();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_380_u_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_380_2_u_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_380_2_u_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 := [9, 135, 819, 2649, 5949, 10005, 13978, 13878, 11637, 5700, 486, -741, -134, 72, 36, 3, 0, -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, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [-93468141871554998285173833861, -724820953738053752312865986643, -2079805066868622893127635890107, -4594195196132758725916285640297, -6893402601950139853407587360982, -8371284501364384832505708957972, -7597964985987669865304021738517, -4645145281589102147013300825927, -1372603081518822273455517698208, 146700786197641007166642360739, 207492395843744952615724230528, 3652170209608927941590351160, -28110054430217622150128255619, -9794519403131638766351044047, -35259195860322802131384636, 754451987251829617693613317, 389488635224348211306582021, -231667570354872196288782201], [42473161608363356652161376045, 174118689851659309586610929895, 448599006470879866260842212611, 1555597775787327760469102806360, 2585843437669590078289979596122, 5476091241485392246427824624081, 5638806059763457689981530357466, 6283146946918122114431660747100, 4202942863098206765227775666769, 786397483721716848008874249031, -511297681362483201488696840775, -142210181709551486691443966756, 38231611828007321887478658966, 27491556962166055159584220869, 1872146384745245363395544859, 1867134315360308741890730413, -2986838739776381567581894698, 807839106278777849009544823], [-1125829928136219537092382779400, -7632714788422950749050149857136, -25697125146828966347819863988076, -52734366035525201525416390588620, -93113696997188752021658139742551, -116186278391742293875602560844578, -118182272846585061463821669844143, -88517720476447807117081195674810, -33526262422953324128398272683790, 1204973689785979136472301560222, 4671603490342689808772463505917, 382497897260625740583745348186, -553196771225424350242177704678, -197551343744754797559938310306, -23905807425362658095768011503, 19262761143237546207843032094, 9681353074242183377921426397, -5056680892738733138987859440], [-15170042678216199416963578320, 147726002538830187776340585000, 1163764379089976102739697658592, 4100659153988020754213674777172, 7550723801540826027192538260020, 14173868221779242322028202015117, 15167997624346760686276753864086, 16001885139052307653649385511941, 9891041642549056526226491790510, 1567727111447515078722491291930, -1220840201219001147340133749354, -308200982941096184260819886959, 98365780788788166680209272258, 63038582316078521411683941666, 5170277202053468185458456822, 2911921582382152892934811061, -6420920381079182069281010698, 1829563201324672013014050641], [-1709886947115762396, -15738989858455126452, -62431169231720649660, -145783314394989192354, -263844419857316268116, -378292079701243787365, -392225643626669668809, -347746927977772126974, -175348207542851549889, -15290748700288928310, 22642405411909503703, 4191654100641764381, -2161022396547272742, -1078183524913991538, -108503893341585330, 6253022931308790, 89982817832438707, -30103266206878174], [136842401503388517133286809758, 1401825661972236631277972365740, 5636976593543755718081028754596, 14238217546395200812155448068131, 24959225289339265167818515585577, 38966703955178806804966846380378, 39213883648824552384755713403175, 35617030686888582634964968403676, 19448384398452141897836541341535, 2415947337928304110549428763523, -2465836184704645536770366989816, -535279020919672186464908408868, 219988240913339033861968672866, 124141909103749983691694315628, 9758629102280018401481148780, 3280809811429364816273280074, -11606077193716845543735118000, 3536302434880648031879629866], [298892682009739571794194805110, 318677330702219001240573098697, 2639446136111125377872051718177, 9231516801203950741097039548813, 15887024892114604236697882455699, 32591589108106884786549048930397, 34180682744244520276659443944434, 37760730451739470522652875178577, 24809030795358045390030609259893, 4447277475580313475751806858292, -3024696734804781109543805746167, -823917634880641106998089274391, 232057455274442155329868273131, 160067077246513429012050656694, 12025944304201831968979068261, 9847849734011595224211342946, -17164182987196920070734585102, 4708369673869593399298388725], [1388936202821373120587429132340, 10249376099670556767257529022452, 32837008372822860642451186628655, 76466749156375766006366069908869, 125219720239435617695674715237832, 180980199474610626691359313713272, 177631404759534521529603543342870, 152144565289546840158050650678248, 78339814604725227095079991738407, 8414545224642313382116233441615, -10064240372137094633009527982847, -2011829387324251896125644106908, 936881207714222394173120362473, 504061500146124543735749877963, 36871758662282430426489184806, 8960516219329144702745684094, -44896678927199690199190010514, 14157720536121118884053792015], [2976411464728962890751342479970, 20211643620277816813286237788500, 58649800977992398636342483692897, 139909011227748225994330579946706, 218215822550642285736880260380340, 317615938056742590676112901126572, 304099319275526362418945412995493, 252768523143786780400681337681589, 129867328650235822830051858940539, 14965728076743555008150337642471, -16692064037065800505751984971101, -3418708473022950048432022891090, 1543046061815684023931851468491, 861605260065477276330788235882, 47518852501807108475746686825, 25086343727955317484603153960, -78386602493529797622915003228, 24134694293349454004581350575], [905773594869594128801841784416, 11644672741905695103419399116596, 43052658537355820960239774390296, 111932751489917940513860559874797, 193488702640354012761879469309968, 296519055677159951871871990509557, 300265915606461054162352583119062, 269927392598757564410741552777385, 144503309491594095634931938734327, 16969289860509123716517635337288, -18404071041302567983840702404270, -3876742602959483715937737331129, 1660655075482500692302941175845, 923960581126324213455753542118, 71825690407947829042486662309, 20431227048910590841762778157, -84481791508377431496118754067, 26099366397779599622736751847], [563494878914400256576560209550, 10197669730123241255886683777694, 45280179515483597549774722183266, 120014057156825867965486127084514, 214249576908828666528936256163964, 338972512317037280317401221676311, 348550452534475010824086333386610, 320321956946740792108459260348429, 174412906237928043126516660511224, 21151432373020563003787330708629, -22129995736440852539517588800775, -4760429269233785637413739414214, 1974910701055852065950680124835, 1108771430587697606659248392793, 90128213406817992257977784730, 25857715361821391928459669906, -102554629880830771029735688842, 31456413298341720160375144571], [8227219587007826619, 93168542955813728376, 357493410372750206202, 866390852186202675640, 1522532243175778742855, 2263418772682677750223, 2288898744474733487658, 2035535615077829228139, 1067637651139693922490, 114976300556160673087, -136589037878556006223, -27619339164715290638, 12600912052012107630, 6731043895121464254, 576215338636562922, 89982817832438707, -600065581912132306, 189987438568418044], [-1980070461003814924427007343659, -32863260029673004729491231994482, -122345133605207142999154480162032, -325398253173498984455527720324788, -561308015758463249213577972615246, -878308700007851697281432277434101, -895360592880579434138336386034775, -817156588370805399614519825215218, -444418014929759976563162613059253, -54576341753744721356352025652700, 56402896243569861607931076400485, 12171478211277403323055932235784, -5017846030687465904709934153830, -2849075754042316911861432159000, -218076138028049051639858845488, -73427545097228993276337226650, 264117948234902985757056530625, -80630175602154817518359481205], [6425272946973976591535625553272, 63050469609168302079740373881163, 222913619760447244997467117590867, 526267581000308760834583628307498, 913764294252665316427285108666593, 1303742089520979617712468607412464, 1318007320667633481354959995501425, 1128649389830737329608374078668663, 560171429626759246241523693312414, 49144802098094464272591283364502, -72609249362629318412633570647449, -13351076616056099151555081409463, 6979110664921566068828115634815, 3519367475587308301094228173509, 306092528716769569399603915284, -182970566122048167634003701, -294838584364082053076958198396, 97840735245757496952441748198], [6521006495666350439000470393398, 59808537765923187156305464395603, 232398341906193359626124929418850, 557047160714328843359937077750859, 988468767332924450417299021621032, 1462823034972996670835002102997819, 1489037204604029789694857919456141, 1321321628951129536458685493429655, 686135470459053135811244625151257, 70620033263800197889765411078722, -87987542134716366628403891634327, -17440571908579674653224044024403, 8187478749883765804969541869569, 4304029744822788899245792812699, 380894308509631369046156015151, 39718996396657289945372076846, -378227016597730483612935398547, 121178432938992740065612370510], [-2421304566653719784443358422527, -26695315854869903246030107012287, -102636871859771567128804017534321, -260024167903081543413774359717745, -449499336262842668834143983463585, -689440353013060506895522947455952, -695836164695687258747899685673585, -625863257684411583571716684788523, -336308406802845254051004895789524, -39934222918559384687818942547154, 42792806003222162513695015142045, 9067838064355178520284742138651, -3857469405821145774070148093334, -2147941192052956377218016522642, -168104863256813191644791236626, -49194581531733157875959643138, 197403744180344768155502710427, -60831464903533644776576914128]];
    Rf_basisdens := [1, 1, 120643294798248855786063810651, 120643294798248855786063810651, 361929884394746567358191431953, 120643294798248855786063810651, 1682094761273482869, 120643294798248855786063810651, 120643294798248855786063810651, 361929884394746567358191431953, 361929884394746567358191431953, 361929884394746567358191431953, 361929884394746567358191431953, 1682094761273482869, 361929884394746567358191431953, 361929884394746567358191431953, 361929884394746567358191431953, 120643294798248855786063810651];
    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_380_u();"
function MakeCharacter_380_u()
    N := 380;
    order := 9;
    char_gens := [191, 77, 21];
    v := [9, 9, 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_380_u_Hecke();"
function MakeCharacter_380_u_Hecke(Kf)
    N := 380;
    order := 9;
    char_gens := [191, 77, 21];
    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, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 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 := 2;
    raw_aps := [[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, 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, 1, 0, 0, 0, 0, 0, -1, -2, -1, -1, 0, 1, 0, -1], [-2, 2, 0, 2, -1, 0, -1, -1, 0, 1, -1, 0, 1, -2, 1, 0, 0, -1], [0, 0, 0, 0, 0, 0, 2, 0, 1, 1, -1, 0, 0, -1, 0, 1, 0, 0], [1, -1, 0, 0, 1, 1, 0, -2, -1, 1, 1, 0, 1, 1, 0, 0, 1, 0], [0, 0, -1, -1, 0, 0, -1, 0, 1, 0, -1, -1, -3, 0, -1, -1, 0, 0], [-1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0], [-1, -1, -1, -2, -1, -1, 1, 1, 1, -1, 0, 0, -3, 1, -2, -1, 1, 1], [0, 0, 1, 0, 0, -1, 0, 0, 1, -1, -1, -3, -2, 1, 0, 1, -1, -1], [4, -1, 0, 1, 1, 1, 0, 0, -2, 2, 1, -1, 2, 0, 1, 1, 0, 1], [0, 0, -2, -3, 0, 0, 2, 3, 2, 2, 0, 1, -1, 1, -2, 0, 0, 2], [-2, 1, 1, -1, 4, 1, 1, 0, -1, 3, 0, 1, 5, -4, 0, 0, 1, 1], [1, -2, -2, 0, 0, 2, 2, 2, -1, 2, 0, 1, 3, 0, 1, 1, 0, -1], [2, 0, -1, 1, 1, -1, 0, -2, -1, 0, 0, -1, 0, 1, -1, -1, 1, 0], [2, 1, 0, 0, -2, -1, 0, 0, 0, -2, 0, 2, 2, 2, 0, -3, -1, 1], [1, 0, 1, -1, 2, 1, 0, 2, 0, 0, 2, 1, -1, 4, 0, 0, 0, 2], [-4, 1, 2, 1, -1, -1, -1, -2, -2, -1, 0, -2, 2, -4, 3, 2, -1, -1], [1, -3, -3, 1, 5, 1, 1, 0, -2, 1, -1, 1, 0, 1, 0, 0, 1, 1], [2, -1, -1, -2, -1, -1, 2, 2, 3, -1, 1, 5, -3, 2, -1, 0, -1, 3], [-1, 3, -2, 1, -2, 3, -1, -1, 1, -1, 2, 1, 1, 1, 2, 0, -2, 1], [0, 1, -4, -2, 0, 4, -2, 1, 1, -1, 1, -1, -2, 7, 0, -1, -1, 1], [0, 0, 0, 0, 0, -2, 2, 2, 1, -2, -2, 2, -2, -3, -2, -1, -2, 0], [3, 0, 1, 0, -2, -1, 1, 3, 0, 1, 0, 2, 3, -2, 0, 3, 0, 0], [-1, 0, 3, -3, 1, -2, -1, 2, -2, -4, 4, 0, 0, 1, 0, -2, 0, 0], [-1, -3, 1, -3, -1, 0, 0, 3, 0, 1, 2, 2, -1, 1, -4, -2, 0, 4], [0, -5, -3, -2, 7, 3, -2, -5, -3, 4, 2, 2, 0, 8, 0, -2, 3, 2], [0, 2, 2, -1, 4, 0, 0, 0, 0, 3, 4, 4, 3, 1, 0, 0, 4, 4], [-7, 2, 0, 2, -2, 1, -4, -4, 3, 3, 0, -5, -2, 0, 0, -2, 0, -2], [-1, 0, 0, 0, 1, 2, -5, -2, 0, 4, 2, -2, 0, 1, 0, 0, 0, 0], [4, 0, 1, 0, -5, -1, 1, 3, 2, 1, -2, 3, 4, 1, 0, -1, -1, -1], [4, 3, 2, 1, 3, -1, 0, 1, -1, 0, -2, -5, -1, 1, -1, 3, -3, -2], [-5, 0, 2, -2, 5, -4, 2, 4, 5, 5, -6, -4, -1, -6, -1, 4, -1, 0], [7, -3, 0, 4, 1, -3, 3, -4, -1, -8, -1, 3, -6, 0, 1, 0, 1, -1], [5, -2, 0, 5, 0, 4, -3, -3, 1, 7, 0, -7, 0, 0, 0, 0, 0, 0], [2, -5, -5, -2, 5, 3, 3, 0, 2, 1, 2, 0, -1, 1, 2, 2, 0, 0], [1, 2, 2, 2, 1, 0, -5, 3, 0, -6, 0, -7, 1, 0, 1, 1, -5, -1], [-6, 1, 3, 5, -7, -5, 0, -2, 0, 0, -2, 4, 5, -9, 0, -1, 1, -2], [3, -1, -4, 0, 7, 5, -4, -6, 0, 8, 0, -7, 3, 4, 0, 1, 3, -3], [-6, 4, 2, 4, -3, 0, -1, -3, 0, 4, 1, 2, 2, -10, 3, 4, 1, -3], [-1, -5, 0, 1, 4, 1, 5, 0, -1, -9, 0, -3, -9, -4, 0, 1, 1, 1], [-4, 1, 0, -1, -7, 0, 0, 0, 3, -2, -4, 1, -11, 0, -4, -1, 0, -1], [-5, 1, 0, 4, 4, 1, -1, -4, -1, 6, -4, -5, 0, -6, -1, 0, 4, -1], [-2, -4, -3, 1, 1, 3, 1, -4, -3, 1, 0, 5, 5, 1, 2, 0, 3, 2], [-1, 2, 2, 3, 0, 1, -2, -2, -2, 8, 0, 0, 10, -2, 2, 2, 0, -1], [0, 1, 3, 0, -5, -4, 3, -5, 2, 1, -2, 3, 0, -8, 0, 6, 1, -3], [9, 2, 2, 1, 3, -3, -3, 0, 1, 2, -1, -2, -7, 5, 1, 1, -2, -2], [-1, 1, 0, -1, -2, -6, 0, 0, 5, 6, 0, -5, -2, 0, 0, 1, 0, 1], [2, -2, 0, 1, -3, 2, 1, 1, -1, -4, 4, 6, 1, 0, 4, 2, 0, 2], [0, 1, 1, 5, 1, 2, 2, 0, 3, 3, -4, -7, 3, -10, 5, 5, -7, -7], [-8, 1, 0, 1, -5, 0, 1, -2, 0, 8, -1, 2, 6, -7, 0, -1, 3, 0], [-9, 0, 0, 0, 9, 3, 0, -3, 1, 8, -2, -4, -2, -6, -2, -1, -2, 0], [6, -6, 2, 0, 10, 0, 0, 2, -4, 0, 0, -2, -8, 10, -4, -3, 3, 0], [0, 2, -3, -4, -1, -1, -2, 3, 4, -4, 0, 1, -6, 5, -2, -4, -2, 4], [6, -3, 3, -2, -1, -3, 0, 2, 2, -3, 1, 6, -9, -1, -3, 0, -1, 2], [2, -4, 3, -3, -3, -4, 1, 3, -3, -3, 3, -2, -7, -8, 1, 0, -3, -3], [1, 5, 5, -1, 2, -2, -2, 0, 4, -5, 0, -4, -6, 2, 3, 3, -4, -4], [-5, -1, -1, -1, 6, 0, 5, -4, 0, -6, -4, -5, -1, -4, 3, -1, 0, -3], [-5, 0, 5, 0, 4, 0, 0, 5, 0, 0, 1, 6, 11, 5, 0, 1, -1, 1], [2, -4, 0, 0, 3, 4, 0, -2, -5, 1, 5, 2, 2, 10, 0, -4, 0, 5], [-6, 5, 5, 5, -8, 0, 1, -6, 0, 5, -1, -6, 11, -8, 3, 2, -3, -3], [-4, -3, 1, 0, 0, -3, 2, 0, 4, 5, 0, 0, 1, 1, -1, 0, 0, 4], [-2, 4, 4, -1, 1, -4, -1, 4, 0, -4, 0, -3, -3, 2, 2, 0, 0, 2], [-2, 7, 2, 4, -11, 2, -7, -2, -2, -4, 0, 10, 0, 8, 4, 2, -2, -1], [-14, 0, 0, 0, 14, -2, 7, 2, -2, -2, -1, 2, 2, -14, 2, 0, 2, 0], [-5, 0, 0, 0, -10, 0, -1, 1, 0, 11, 1, 8, 3, -4, -2, -1, 1, 2], [-2, 3, 3, 7, 3, -3, -3, 0, 0, 2, 2, 2, 4, -2, -4, -4, 2, 2], [-6, 3, 3, 6, 4, 0, 0, 0, -1, -2, 0, 1, 4, -3, -4, -4, 1, 1], [2, -1, -1, 0, -3, 1, 0, -1, -5, -7, 1, 0, -1, 0, -2, -1, 5, -1], [-9, 0, -4, 0, 7, 0, 4, -4, 0, -7, -1, -11, 4, -11, 3, 2, 0, -3], [7, -4, 0, 0, 5, 4, 0, 2, -5, 5, 5, 0, 7, 5, 0, 3, 2, 3], [-7, 0, 1, -1, 7, 5, -5, -5, -1, -5, 5, -1, 0, -5, 0, -1, 0, 0], [0, -2, -4, -2, 13, 4, -2, -2, -1, 9, 2, -1, -3, 2, 0, -2, 1, 2], [6, -2, 0, 2, -4, -4, 0, 0, -7, 0, 1, 0, -3, 0, 1, 0, 0, 0], [12, 3, -3, -3, -4, 3, 0, 3, 2, -11, 4, 4, -7, 7, -1, 0, -4, 2], [3, -4, -6, -4, -5, 2, 4, 6, 0, 6, 0, 11, 1, 11, -5, 0, 5, 3], [0, 3, -7, 0, 6, 4, -7, 0, -2, -2, 2, -4, 0, 6, 0, -4, -2, 4], [-2, 3, -1, 0, -17, -2, -1, 1, -1, -11, 1, 18, -2, -3, 0, -4, -3, 4], [-9, 4, 3, 4, -6, 1, -4, -3, -1, -13, 0, -7, -6, -8, 7, 1, -6, -5], [-5, 3, 0, 0, -1, -1, -3, -3, -1, -2, 4, 3, 3, 0, 4, 1, 0, 1], [-6, -4, 1, 4, -3, -4, 3, -4, 3, 5, 3, -15, 5, 2, 1, 0, -3, 3], [0, 0, 4, -4, 0, 1, 0, -1, 0, 0, -1, 2, 1, -2, 1, 1, 1, 0], [8, -2, 6, 3, 5, -3, 0, 3, -2, 0, -6, -12, 5, -1, -2, 1, -1, -6], [9, 0, -1, 0, -9, 1, -1, 3, -2, 1, 2, 11, 9, 3, 0, -1, 1, 1], [-3, 0, 2, -2, 3, 9, -5, -9, -6, -14, 8, -2, 1, 5, 1, -5, 1, 0], [-3, -2, -4, -1, 13, 4, -1, -2, -3, 17, -5, 5, 10, 3, 3, 5, 3, -2], [-4, 3, 0, -9, -4, -8, 6, 6, 11, 1, -2, -1, -6, 0, -2, 0, 0, 0], [0, -1, -1, 10, 6, -1, -1, 0, -7, 2, 0, 7, 2, 5, -3, -3, 7, 7], [1, -3, -2, 3, 6, 2, 3, -3, -7, 10, 2, 12, 10, 9, -1, -2, 7, 1], [4, -5, 4, -5, -3, 0, 4, 1, 0, 4, 2, -10, 14, 6, -4, -2, 1, 4], [10, 0, -9, -9, 8, 9, 0, 0, 2, 0, 3, -9, -1, 11, 2, 1, -1, 3], [-6, 4, 2, 5, -4, -2, 5, 4, 7, 0, -10, -7, 3, 1, 6, 10, -7, -4], [8, -2, -2, -10, 4, -2, 4, 10, 4, 2, -4, -7, -2, 10, -10, 0, 4, 4], [3, 5, 5, 10, -5, -2, -2, 0, 1, 6, -3, -4, 3, -7, 2, 2, -4, -4], [-10, 8, 3, 6, -6, 3, -8, -3, -3, 5, 0, -8, 9, -11, 4, 3, -1, -7], [-7, 2, 6, 5, -2, -5, 0, 1, 3, 0, -4, 0, -1, -6, 3, 2, -2, -4], [10, -9, 2, -9, -7, 0, 1, 8, 0, -3, 2, 1, -4, 7, 1, 3, -10, -1], [-12, -3, 0, 0, -9, 0, 3, 0, -3, 16, 0, 1, 19, -2, 3, 3, 0, 1], [7, 2, 3, -4, 5, -7, -2, -3, -2, -15, 0, -5, -16, -7, -1, 2, 3, -9], [-1, -1, -2, 5, -4, -5, 0, -7, 0, 0, -9, -8, 5, -13, 0, 1, -1, -9], [5, 0, 3, -3, -5, -3, 1, 3, 0, 8, -6, -2, -1, 7, -1, -1, -1, 0], [2, 0, -3, -2, 2, 3, -2, 0, 7, -10, -1, -22, -21, -10, -2, 1, -7, -3], [-3, 7, 0, 0, 1, -3, -7, -7, 2, -1, 5, 0, 6, 0, 5, -1, 0, -1], [-12, 4, 0, 7, 0, 13, -11, -11, -7, 4, 4, -6, 4, 0, 4, -2, 0, -2], [2, -2, 5, 5, -10, -5, 5, -2, 3, -7, 3, 1, -2, 3, -2, -3, -3, 1], [11, 1, 6, 0, -7, -7, 6, 10, 1, -3, -1, 6, 11, -8, 0, 3, 1, -2], [10, -6, -1, 2, -7, -2, 0, -3, 1, 0, -2, -13, 5, -9, 1, 5, -5, -2], [0, -4, -4, 3, 5, 7, 4, 4, -1, 11, 0, 3, 7, 2, -4, 1, 5, 7], [1, -3, -9, -3, 4, 9, -3, -3, -3, -4, 3, -3, -6, 22, -1, -3, 3, 2], [3, 11, 0, 5, -11, 4, -16, -16, -6, -1, 3, -9, -8, 0, 3, -10, 0, -10], [3, -6, -6, 7, -2, 4, 4, 0, 0, 15, 6, 6, 12, -6, -5, -5, 6, 6], [7, 0, 2, 2, 14, 0, 0, -2, -2, 9, 0, -1, 5, -3, -4, 2, 6, 4], [8, -6, -6, -6, 14, 0, 8, -2, 0, -14, 1, -8, -6, 6, 1, 2, 0, -1], [1, -1, 5, 5, 12, -5, 0, 0, 0, 0, -8, -9, -3, 4, 0, 4, -4, -8], [-8, 7, 7, 6, -6, -5, -5, 0, -3, 7, -7, -4, 15, -19, 0, 0, -4, -4], [-13, 1, -3, 1, 2, 1, 2, -1, -1, 11, -2, 20, 9, -5, 2, 0, 2, -1], [-2, -4, 0, 3, 2, 8, 1, 1, -11, -6, 4, 6, 6, 0, 4, 0, 0, 0], [6, 2, 8, -2, -8, -8, -2, 2, 5, 0, -2, -5, -3, -1, -6, 2, -5, -8], [0, 0, 0, 0, 0, -6, -3, 6, 2, -3, -5, 2, 1, -4, 1, 3, 1, 0], [5, -4, -6, -7, 6, 7, 0, 1, -5, 0, -2, -2, 6, 4, -5, -6, 6, -2], [-16, -2, -8, -2, 11, 0, 9, -7, 0, -3, -3, -5, 2, -11, -2, -5, 8, 2], [-2, 8, -3, -6, -2, 3, -6, 8, 4, 7, -5, 2, 7, -12, 2, 5, -4, -3], [-15, -2, 0, 8, 0, 2, -6, -6, -5, 4, 1, -2, 1, 0, 1, 2, 0, 2], [1, -8, 4, 1, 0, -4, 1, -8, -5, -19, 6, -9, -15, 17, -1, -6, 5, 5], [9, 2, -2, 0, -5, 0, -2, 1, -2, 2, 2, 7, 9, 3, 0, 4, -3, 5], [3, 0, 6, -6, -3, -8, -2, 8, 1, -2, 5, -1, -1, 3, -1, 0, -1, 0], [-8, 11, 3, 0, -7, 11, -14, 0, 1, 4, 7, -15, 9, 2, 4, 0, -7, 1], [5, -13, -13, -6, 21, 8, 8, 0, -6, 0, 0, 6, -5, 11, -3, -3, 6, 6], [7, -7, -1, -7, 18, 0, 7, 0, 0, -19, 0, 0, -19, 12, -5, -5, -1, 5], [-1, -1, -3, 0, -5, 4, -3, -10, -2, 3, 2, 7, -1, 10, 0, -10, 5, -3], [6, 1, 2, 0, 16, -3, 2, 3, 1, -3, -1, -17, 6, 0, 0, -4, 0, -1], [-4, 0, 0, -7, -2, -7, 0, 0, 8, -14, 0, -13, -16, -5, -2, -8, -6, -3], [-1, -3, 10, 0, -3, -3, -7, 0, -4, -1, 3, -7, 12, 7, 2, 0, -3, -4], [-5, -3, 0, 0, 9, 3, 3, 3, 6, 16, 0, -12, 9, 0, 0, 4, 0, 4], [5, -8, -9, -6, -3, 3, 8, 9, 3, -12, 0, 8, -10, 11, 2, -3, -5, 3], [9, 0, 7, -7, -9, 9, -7, -9, -7, -4, 17, 10, 3, 6, 3, -4, 3, 0], [17, 0, 7, 0, -7, 0, 2, -2, 0, -4, 4, -7, 3, 10, 3, 7, -11, -3], [-13, -5, 0, -3, 3, -1, 8, 8, 4, 1, -6, 3, -3, 0, -6, 4, 0, 4], [-2, -2, -4, -2, -6, 0, 2, 0, 0, 1, -3, 6, -5, -1, 2, -1, -5, -2], [-3, 0, -5, 5, 3, -4, 1, 4, 1, 1, -11, -4, -1, 0, -1, 0, -1, 0], [-5, -4, -4, -7, 6, 7, 0, 3, -3, 0, 11, 19, 1, 17, -3, -8, 8, 11], [-5, 0, -4, 4, 5, -8, -1, 8, 3, -5, -10, -7, -5, -1, -5, -2, -5, 0], [2, -6, -9, -9, -5, 0, 6, 9, -2, 12, 0, 12, 10, 10, -2, 2, 4, 3], [4, 4, -4, -11, -6, 4, -11, 4, 4, -13, 10, -5, -15, 20, -4, -10, -4, 6], [3, -5, 3, -1, 5, -5, 2, 1, 1, 5, -5, -4, -2, 2, -8, 0, 5, 1], [-18, 6, -3, 0, 3, -3, -3, -3, 2, -3, -2, -5, -18, 4, 0, -5, -4, 2], [-7, -7, 5, 0, 5, 2, 5, 0, -6, -7, 6, 1, -7, -9, 0, 5, 3, 3], [-13, 7, -7, -7, -6, 7, 0, 0, -4, 0, 2, 19, 4, -4, -4, -4, 4, 2], [-3, 3, 5, 3, 15, 0, 1, -4, 0, -15, -4, -15, 0, -9, 10, 6, 0, -10], [10, -8, 5, 6, -2, -8, 3, -6, -8, -13, 2, -17, 7, 9, 3, 0, -2, -8], [-1, -2, 12, 3, -2, -12, 3, -2, -6, -3, 1, 7, 6, -18, 1, -1, 6, 2], [10, -1, 1, 7, 12, 6, 1, -1, 1, 2, 0, -5, 0, -4, -2, -1, 1, -2], [8, 0, 1, -1, -8, -3, -5, 3, -5, -14, -2, 2, -3, 11, -3, -8, -3, 0], [-17, 7, 7, 8, 13, 0, 0, 0, -5, 7, -5, 0, 24, -24, 8, 8, 0, 0], [16, -11, 0, 11, 5, 1, 0, 0, -3, -1, -7, 1, -2, 0, -7, 0, 0, 0], [-1, -3, -9, -3, 6, 9, -3, -3, -3, 1, 6, 5, -1, 11, 1, -6, 3, 7], [-1, -8, -9, 0, 7, 17, -9, 1, -9, -12, 9, 2, -1, 9, 0, -15, 3, 6], [4, 0, -2, 2, -4, 6, -7, -6, -2, 32, 0, 7, 4, -1, 4, 2, 4, 0], [19, 0, -1, 0, 25, 1, 0, 1, 0, 2, 0, -5, -2, -5, -4, 0, 4, 1], [-8, 1, -1, 3, -2, 1, 0, -3, -1, -4, 2, 13, 7, -2, 12, 0, -2, -1], [9, 3, -8, 0, 4, 3, 5, 0, -3, -13, -4, 14, -13, -7, 4, 0, 4, -3], [14, -10, 8, 0, -11, 2, 8, 10, 0, 20, 0, 11, 14, 17, 0, 6, -3, 3], [-12, 0, 4, 0, 7, -4, 4, -7, 3, -6, -3, -10, -12, -7, 0, 3, -5, 2], [17, -2, 2, -2, 9, 0, -4, 6, 0, 0, 9, 2, -2, 13, -5, 4, 9, 5], [3, 6, 6, 6, -6, 0, 0, 0, 3, -6, 6, 3, -9, 12, 3, 3, 3, 3], [2, 11, -3, 7, -2, 11, -8, -7, -8, -6, 2, -6, 12, 6, 4, 0, -2, -8], [-7, 13, -2, 12, -5, 14, -13, 2, 0, -11, 0, -9, 4, -9, 15, 0, -15, -7]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_380_u_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_380_2_u_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_380_2_u_a(:prec:=18)
    chi := MakeCharacter_380_u();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 2));
    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_380_2_u_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_380_2_u_a( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_380_u();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<3,R![9, -81, 333, -321, 864, -696, -2681, 2961, 2952, -4587, 3537, -2082, 1135, -297, 54, -24, 9, -3, 1]>],Snew);
    return Vf;
end function;