
// Make newform 18.40.a.a in Magma, downloaded from the LMFDB on 23 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_18_a();"
// To make the coeffs of the qexp of the newform in the Hecke field type "qexpCoeffs();"
// To make the newform (type ModFrm), type "MakeNewformModFrm_18_40_a_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_18_40_a_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
        Kf := Rationals();
    end if;
    return [Kf!elt[1] : elt in input];
end function;


// To make the character of type GrpDrchElt, type "MakeCharacter_18_a();"
function MakeCharacter_18_a()
    N := 18;
    order := 1;
    char_gens := [11];
    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;

function MakeCharacter_18_a_Hecke(Kf)
    return MakeCharacter_18_a();
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 := 40;
    raw_aps := [[-524288], [0], [16226178983250], [16050065775887864], [167429747630019631548], [-1323691058888421756442], [496480799590583480551566], [-11499782498758130928946180], [666241934758249389046846872], [-44018303948798095210174459350], [15831006217138043611820986592], [-2586566128509039416001203660146], [-51237316431927477788465354103642], [78798404752245159214502811925028], [-242751106429257069824806165133904], [-695517143534500492850281534063998], [20181524948439110783048183071512300], [-128433361186908960737422356033926218], [456917726301331948233545546175061964], [99458563668407119053976138500473928], [812887758504563318241014461088181818], [-8572745601192170985075907678235922640], [-7125890269767880907477351827779977148], [130969521476936175444631870523462811990], [761042994574827986180495148895603139234], [714964484776919873992457167802680413618], [655258604515964711163616001555235887768], [5914562962061465232645242003479680071196], [-4185041836769264128696670873351302842490], [-3824689324548054249832479260871681062418], [81415008658441407433844313742269341258624], [-255072419580034173647590002807016383239052], [157559580637672516670157103702005918028806], [-588829467631347805153391042196053251832380], [-1207468095436203795680955433606725593022750], [5685078770571915055615639967009085337150952], [-9750642781149204731232375715227619087510186], [4570338059050573545178912138325683670770028], [-21618029318358468376113504832264309622399064], [36190839482135957552309576436878267199691962], [-87301009530057872451477094138693019315131740], [-151508334867606442604455452025314037108595458], [-432591245287308117249594444031985125761682752], [-704390237977568367554048507553799466811044542], [181044287048822846377122871662040687638425106], [-978459617827575790886017454956637968363550920], [187843601994419420600745425982917679926949692], [-7178385275881593113777518333106096329802371552], [7821838076856411148703061623034581485361273556], [-4607137508686822261642116460980747270393413170], [-18088843067261541183791113706541451305751921818], [8375055536858292882008787300303750979828441200], [1671672116451548637969748949239043320355625362], [7605449976998310054535220299034714094819090348], [-96464222883623141531590426470346263940073596674], [238043372720282238750611637847854357513816335112], [343729860079334304535696247162817381177988013850], [234239150235147149214788633417285307934069580912], [497473387755029471456765235887476539272024703134], [228342911781247920635360107332927279731780243478], [609891262976240824063492560779186473936260806708], [2185356495841585652506807567592929962997908899442], [-1847111296233690584688935273612443145967570277156], [-3226736011058023558452591459065994724794682506312], [-6993899741243929354505015481752565171559661064502], [-5379162700312569970657677341642313321405568441014], [-14001778697581696163234810895774420022204589718268], [-3355765358344739444607277252625806654292965810126], [26083896061620233085866720108501611692232370417676], [20363490378656526592934422947125690876745674178710], [-80831896134418748984940627645496356493826524129698], [-73536253707944887224546629542048821948395975258520], [-99943657977765360104375128706189478135735513496816], [-106368229529124179592853920566569399555221357517762], [309568250305884774558169099255046969955977191788500], [-131361625111559507895749442905790351856900412439168], [-127217312718467926020580411048785871861276350343470], [-410443350641037538325406100458263502807332215932826], [-75878734117426408606137933894609929491288732852722], [210087362436531530053236194224371870541558162488170], [-177773473827741539750131211142423558784524753580140], [-765652991396037541942717225836209700185912814450418], [906011793089441014685668998778580367341728677108528], [-2959579207459820569655051314996195610525052614881582], [-1932854913534546092993517344305099984876321574856760], [-5234731593016856798415509299521035298214143256835988], [-2644976242053728521957798137658467694363323199386690], [33721834303491529514963917094176421120541529284794], [793486576663612133720177695840916353080789139229658], [-7375746877925635671633548451388642422062629236557392], [8022860466343274064091910506105488528502643266116036], [-21087115475443494964919542435819904694820266828076320], [21733050203091570257635449675146622610667381982567704], [46457961683038238851229086999284050311671940426528668], [71883419052078109397393785585749786421901500122775580], [12324832666291081225353142339025974398241706994657912], [-21873765175844674946793072234598660769614246982448630], [75092519574640538844109423181052576122461363893731718], [-156095374963145867510050113066066223165214071683701692], [26170976648279629065936622682354541220649107316870102], [-407794903266657474628355384907026758475839241868732436], [67294848386426680459064538676524037412034484535326266], [455904361394604086202101433912098393239207115130479652], [-598038718613465240293433352719866482310163168933266890], [35405592018459996745673377518628365587708140583200532], [271624333762528789330971657383370941012816797576800194], [917024742756850238269006385390301034629555428199070716], [1826613903740050812311108719029895578063238431057811662], [-2029963157263298697792610362490764170777298237547374120], [-1351729903309332901535091349221513601036019708829815638], [2316497338581441083269711306283591962802857225795569824], [-204560753032764024660146398299127635144913489734799282], [594190419529836180746241380674212387644802039783049446], [1600534796345891731013070759197938115098609188064708580], [3927564185599801490430142382615767634836678734868656392], [-3850057676376216793995051816455739953962436319093784962], [-3532583761695489825246598939684672417863773397036371572], [-6407787720383212160647617089407687792240149503864995704], [-1992102564948075485744018066932898259733095584346007398], [11724848659436324789412557092883354289775790344111339140], [-13140630981905141489545634915756477483930205277875290338], [9019812926270510633168353634723981391449084235495651938], [-24739870667136070423104965855108429834985879710980188174], [-3208671571901919778805722162907717606771000861334271908], [-21639319744074297414754792464435241561682611836462746788], [19253343008550534340909427516004542929021829079693364938], [-50042810191893758198307413892401634925367558539707953170], [-29483718357477969737333468276967981978390878850031304880], [90655101137604719509348374498057277522146551888980418984], [121736886522046124943175825425499073705786831194961180438], [-74260503869016129479838804085692698569134554288377822420], [-98655829156433218448524765379032534777009572588329923608], [197248570802987251773057207023106407124612339379131231632], [198250827928398804518012136384510115095971311449495683774], [-183094723797207298712691889246878689952836798174172776202], [-206386507653119631540286271579143366957845705634331634430], [130612594791932859234000088417932730696272416656220948562], [104230822675320730904038778694713810971547623526382190844], [-194067403874474292791615017170725909012862484268769958614], [-223938195122000714141685297485226526417138641954282455130], [-547814091342870234934536973480448646217826401967823587548], [498979602251898829596500342247945039806093755842672704898], [403098414458610167056382032912121030071063346862546315848], [-5983932037348227565385127149671379131506030186710992404], [-622264926756803198616753330563469246990647799584180324170], [-1719249356031371501410099332532077449042812119219216367800], [-1474982396646661144917244662644814574839293479469525889442], [2259224265989947039806569229617834403271544713351920655446], [1626023075498902462539724164460558626230520158528200658420], [493930572553240276682015061834139632447498488399194361952], [3262531681918429613512273432589434365544647946472903623814], [-1491441497805828310306253775308422528281341138343083330322], [-1825757585776992661101681816333848250151518206551248337252], [3771834696265705730914541534882680518577776792681022429176], [3059049925375584252942328785691161552592792065820835742404], [3490117995038090393578937302112675443213644880425824225808], [1500667632727578019964527651225002113009926555170598947560], [-10722947589201674915619359228902511937386402763819697545570], [-2190366736391909360089806302908009421737562650830243980326], [10810142233665870029577679274887287171123399567641650597818], [-10136396236443351242893809233253262207602435220379775918684], [33170170273237510892544149941821777969600913615499073462], [21973009079673969374344193735122800191696571319079033883704], [-17683547218806398585120493704878451605626798280837593408132], [5669634124224890666698450985125543799805503384925737061966], [32254455515735164584376270208657195296294785147578989209432], [27397425754471157223875246797229329244976920229318164570912], [-27126042832057549191002872233822723561207399243794295071026], [31850141011603509782222647850622452766786794758887714369170], [21125237872092937604929165248039117768724676570952641281602], [9288818117306151162511864220264022350351889515508362183340], [72163780496670037561446761460398655795462746003159398044662], [19315535419166276305700624266377338774878471370422289374728], [11308682625353672274345343145429837180085951314156039310458], [-98459022008724733087060028771070892133715630984605312943760], [-57621356140464987508710857692545673997292949324869385368810], [114390737625282307832912802554587104147817034615236673148212], [-136527205543413790334593890748109218505330827128041824786062], [72653248010808170414483896424313564424804089104271523254488], [-26126469694012995149862295989459244755697619942941405550650], [-77156758142385140688108783589470401302602446649587126856256], [-121086619601594851653707949011312060653507073873560143944652], [9882332647936740299709287020918601625464886400593776598638], [-197274382680465305942146873935069037544106056867960487021114], [-287830960303630979477218406150129218595472119117448695581488], [361802584316935440787476082002439525455257816475258293334690], [92184132520527672437387924837614382047394946315433080614294], [-520888375892824021590627914989063407242013826684467322521172], [-412468915610953422049876707503206478747399445592444708682470], [-267682111737026991213009892719527797379054447462496588001152], [-488642920264818085770087240212437154390483316237657308041342], [361858748326608388748348268092511536436556093819630507310652], [-782135805998108788122195479602107576275600655858718144977028], [166210691521636352968577686247237679251793940479792148868778], [458985208142745903329699317878127688604962995573776578667156], [1024698034923763174480089239218392382822770547545240098762022], [984813364517343612964610164409008774733293054196037616862162], [-1280347653906075745685309839402519703992001372583530047795402], [1926646883480267793735295508720239152409631579481711016572606], [2751430103983506387857523926076637089636249177623778789072072], [-1879820432741601043320758560075990266538135684680802735374630], [785170026070221922831944939403337033129093991186788941057712], [-2754153551358312143492775658638599594633847133872875759530786], [1821433754391470485130751962513218377850831014659623472697890], [-3454729091971075678426033708527055751007128212245513134409060], [2160186628773401350206502515828934438177720921447367971118346], [-313728249830786377314400290991372928724015387386389261139200], [2446306879959231359725013051431793582175653854059559733455092], [5210849129277718258440017822348695586439334571928799309905030], [1657186675412209566000120998575754318545037440186438886678852], [3520518020309235124522888009448554854811946677429128671582834], [3496965302147604645283117778201172650869618675881494830908258], [2312912194156508721908192950392457505625339513290851657776488], [-9539433447696283909414845597636660923568327452576432972444724], [11066705881651484803252875800633210728693236777021872408238120], [6665573190276583208088836798148690406286927236410967309594202], [-7682458699096211178049531100295218232469524656135103814361776], [351844630635084793255609398900374328095865625159554638209998], [-3291321062522215633654072296952492767508481135138240731499304], [3604707269241432917098053381047375679709204885717803004756842], [12644172469396651783309039326138245209164485793737997653921102], [-8338872259304670667308419399848241822438002059995082288572920], [-4277971421516729865452272215539974278032275768650423907612290], [21737222461512963995105016945605842202495120118365900958925808], [20813637050611520390835526563790751305728966208022565920074116], [-59186922604244520990270896446061400510054167828533601997521890], [14186337146121636537901634569313217778875967048566681203607702], [19321757937615974406439467065685040224716076308608923682519200], [-8406436601165322762463431052242720071521985402542664123051176], [-15978504062038597433915384008036653774878203162480861447779492], [35255972619685776798136205848607202615153432153249771984997958], [37356480609949874154882564609377987595417574275683903131435100], [-9120551790200665379013696182560212026995094546181338463383488], [93817411810872199517854626410641826651801589027857872201442118], [-100737615676685306533595883265031563792219591269466457683124092], [-57244121441490130673100295627225623954321190283473774813074864], [91203860819952653000892144587449535446108432046439955186024370], [12620919050860015414367277120990189859918616337189388409320482], [101107220617623525426254764837973058281563127708084034433623180], [3038121766096516331158214996748739880800985368838826002188008], [31615440859257158235369482622897345262990297657469535211586532], [-163078551079805249648415791385042571257080177216426677952726188], [121430492105964562700925305384402643092196220015237198830309368], [80775882314594126203862426378847535120828236149813516142201830], [216710129235671560523099284568951670530614339762763452239756942], [-327901619471033093016854585488382514918091124887013257389700200], [127632837785555472441709294445093427494463091299090075747187424], [293273356587490786869575015639911296776694567003998851345428], [-168401963665733694426169651953906168065761558340725383962561500], [-313070874518656592609111108562303561772775672208904250868917328], [-453202082707250711154726996308484420155549107472450300808223306], [-22005747239176425245980258316820953317474873756635241836299202], [-368427412389315024503908498836366784724364455540835270015223224], [-78591021739108940413180193549070256835818244802763382575597510], [163111536990378015248434460865128034950776249505342993129306202], [-569591459682239747897607172928618911873944868764947182059657660], [53737549936364033265579236053931107410247358197311381062011742], [42291387476300730384541360295174082026306660826368038337620724], [-770116634825243495340013835159310658244600752854120618865929294], [280760669180222045730862966893069912316854213246849166527240074], [121383372800273591087330169138685882309724105491916282166263168], [696052196470370581506953456296294744194458122157144469308592756], [-613422894211712046332486650355623788368322800858700771017440210], [1485831000319133405838465324711386699972565305584968040831233878], [1098330462612852851816751180039238958044204209141450337552116126], [-432439731820710899657042213470032297754495141472268720747267220], [-15627412273956298680628214484102013379173616938776964741971270], [-37623376887481729356810078584130224311841380329081788401831242], [1659746687186736080696846476784600555146721165625794582399849108], [1517136968819057027959226905023231465420798893447428785575506962], [484593434570669385844523052648644461474329236388965871319490342], [2377143711943821800683541836309033902334804058498121676285432124], [-2710251460003925097756509204959218717675462084264925996898765782], [-3564497381916264088730850571931872334834898790623842805621614560], [-1267153598944368534530720979767570547263416687082313552831650926], [-4115635790255238599455626880211507476301491480618258921338165112], [1176766182289059700136479362043069475625530294063919924933649836], [3243302117939344475135471880662129856306299204121138485441183990], [3020903558243041302654449736209885363009828088988521050557559162], [-1597052276015713540881025545867166126641943859265891789762493692], [6430050315192351444687703952800316595248372030305317695734259232], [-2992530465965863329382515370655858664150676800770350134699452968], [2395009602820218569757168912534696830061749895962773329072142776], [7363480161021504735485238328975512065876169806542661316604853102], [3773490041121164694811410470824716660865623359007034566463471364], [-5941635671452166448330577344211113263488942039144502395430314032], [636462069749988523208885807427262026960993861824271260107319858], [2346855596079275724466178270466038955030642167363131749119096226], [5994107514956602297217584189650738128344686205524318678686644520], [-12341302163206624822287708301187546951339773169663345260539188130], [-386355372751996487167847891703189693279061296515046015380881542], [2344841032037522671317841970075174652858670526634341781127183716], [10941937489957354737233551081799886847763879456575199074022207862], [4833500577896228247234035601013661351806175356932201968072917308], [-12520374831686125237743126334825537052619529249096776009301732762], [6678636693734422982702489338239676696712271322176582274145993130], [-15250611478693431608921524152436197523078750688552247265143679648], [1480227745966698495993249114887645950178762600178157509595701762], [-19887991266847186009052622602329917330454192600248900817813467540], [-10862926647643931231149145711200928553982437615004079814697398196], [-327383884337132425739414792176108694637598478987438546522510662], [-32330878436986709982656062943764016262520136756766901269131808294], [-3907752833284292291962426895903304757018133122524197996327705680], [21999892859613498841088054690158424820933956542929922207047892932], [-38535820346953603714300966231000494290960107435494508648680416908], [-24764259499244946336478596979437070790714550379441838495106095326], [55969997740360316720457658766885791062647620160824947211939872156], [14633210623670091359587300073231416306559378530535567995236399110], [60391003308654891908888384209682535270484816609548922859738112120], [34078076121049147363434101614776031546791420905114889971868783278], [-4732942908739420091888976875159632712568931367276233752623519088], [29694235967059769100441829624635208378317222759068851473929078370], [36456511293453087245593775963837583158835092823377914214942592798], [89437144545817700231391108081464228003130603033053276243030307308], [71565512458561419909168827889335735592257561898607096837802529576], [11419425086315175086625771968782919555850751843567761000991896410], [14400172413875520073526006236314981020070678644802928852346571300], [52076002030805735853529957521585479031592594978424618952810090048], [66213791001782043175316995690114780599623862815885873540832924098], [15120817786938927813341095260386699926602044898502786368230977230], [113745007973622941467069716866990189152375445774431647189072148412], [-124226840264958738937375831769371989948171694646005039580818991446], [39837936201766276186979935158350464661466756781463546789023258218], [-105334588285726758964827228621538646886278198915135147404620795232], [-146361306761662357627719666807052749336662067507099575820041281818], [-69075692783343702755412488256289465500511800333732101442963943918], [163773946379111040627891443003052514692082751816387334615099820940], [-210776388231433980131433108746526795665987524845718307989792448332], [191777044549339703733484938989473426409995222621757626241715274656], [14542151829881573202383358152542164425522260226878408707331022322], [24560066055999117965604060256284471572424574810438759550101510982], [-368827717396367230212347227437033577016297824097252619641736334134], [75666998383292884228906197548325589850456000231505620210754340160], [-13672535428480543096248965416451774962297185545061403690333790028], [314895284406905564885376653345274990344844423535413647342965218692], [-144705684599222915829412810734655308329403514404450428194262038644], [181516322927743409140318825164881838406441499200996048698612928790], [11304131635058839226869785150660475742997245875134282067795595742], [-152723516374343347846134641689148176664314281046871648714947822438], [-171933353127408474689847515130880022781596252511642489494730614896], [-125887759113763993831487555172699212508646857166264866404401759042], [661119272751214348463833425942734117294744391512630079178481856246], [-482689659216897892657344825298198967255940908092908307073715876270], [599395486011134181583717538299892630802824356116171290768142849272], [378556788120868592579522939045559091297588650532783925546632170282], [469191660763937325113479428319074263797816016854850814125874691860], [-344715880704604826563629512546281904047206091752571325961953119858], [-450759220171716483459288564626353672256215228550659923772894219996], [-780617009772005333658055246766832680670786933238552440167614396752], [874185487425295474999986888650673234180188514508725023808684721026], [-51763904058452219963038823443127266049328171003559592395884615988], [629049859898919320557367612933940598522282418047702432190827330874], [-680174853548518637523896931086088388340380144563242216735209542822], [-390731843659451165892101477973908860267254143413554156985851957712], [-205617308940489771231985528783801479309153516119974219718637369250], [-199252704086645751821406354228905311125782765395513907812791586218], [-1185672701307418673925946349653073836912356551158117268650244921760], [1441355762223733614894859190283007645318244209364968652407450484508], [-692182726285549721782750872307800720747123584973497551748574663954], [-821047571627262390524449816145218368657262996607480818152257958408], [-621272878686713951386601795620071976810847143178185631109784116946], [-638319098273506889263895109517536877050748813957593525096089303802], [-136745051489658677160353354792642679276563927986526293766742876144], [1174586122013473370154180226929267843397212777959991976687997763660], [73124259506459975993613310785160292671620905928193357704904779884], [-889702053770514915890077783157981394158470839166967732228291500582], [-1498100427211893949283487220183991259831917689455392278138105055814], [96033992508412890695975299379677498941972965435752990256206075448], [-365070245192442682048294475228733396023147723988376160769000236758], [-3246313963593583336551800645373849699190889744166541559961415134252], [-1182690644253953164226610924336976639567253041721295991764561428380], [-4007665169017623191014591766158788912418782035935353586578030534288], [-524075339570705563587645157162811526156161540377328231156232108990], [2590340565728630597942943626950802742508936831781041687440254193032], [2879667407361828388327632834161278339863360956170749822573789064694], [-4169315008419576587342673128060658644855720499965309190741923613180], [2327367845806317646460274874066058749272449396602522897018668902688], [4111622939265166517602215531581997211717473978758625479324965084898], [-6166328684190217299118554149804757643748999979317435101100272798290], [-2469798979690476253540722858099697839661891892261525798898621809206], [2650552961475260790599838974974552795430870160412687732471900839498], [8532761510092870423479911933167115459313919827596368365699570518982], [-7049039876200662407305192297975693710207223634677302958790451585496], [5266678333063708833187465427299138203023606382407678261717081929566], [6525991798176194861737328731827085805814687704201859311368098304940], [-8623416085646506083814921217074624277185099649779840839287354146968], [-3521629583310462864855848266522072206418519042763846590364266970608], [-2407300788972839665916009346567463541988134533012371367324996969666], [2921689972398485040270604447956801742570391134994472397586157037268], [13412554048965304741147654083610952377550225002903810103803391846016], [5019846001110658683534645778169698021679257980917845226560434100610], [6927481238089742149763379030841395457135744853034381235792769794002], [12869541293622896895364732145692051406986185505556518007643696645180], [13969171365945578011752290943405293961796072721887686364036844765564], [3490574892164986221367072337552221760951608729411275006011828450328], [-13920567786930431917255224097550674784634852217189630459236011898262], [14365255854343115703075048176702777062136120240229880465611043818080], [15964718447819082717772054532335163422659919320509853705528368841510], [-8367208082299028144209833581728846927021859947483484076675760296028], [14100296639271620549148469516158594958054174270482556753027133875458], [10729376581680958508412893431430064127715558794020567158800405473590], [-19492155080975790316843298663873565660454765700993512925185811534658], [7126881741820378955817864424973542827517360833764441409127202715824], [6399323460983010652840472101082107689546480306295822589402430148566], [14054467065657260793035930074714322716525050528629284969590258534450], [6553816663333739253905453999167164401245772287417431661395850308632], [-15180881150918871498606485740705197812045231674520581973733766396666], [9987315773313031831414361988805247506932247242262841872272312475758], [-15134619567623698345046961897098402162320522260505207667646731720932], [10643139145524289291921331435186513236044032176492681645686658797300], [36406141786550314021245346811857126666189330413519783199111219979378], [6695199545708259313674591461665363580907195174239490421065807317346], [-12588003812658165972052058099428347064401027483731071671179628801588], [-27856106785940912712661237801722224274334874210504102266509095575828], [4636861951762815033754624007986841479454881275721432796748548839514], [-50373588525494905731773322827233620341858685416150142703910838595782], [-48779458483898213878348055047356220479579825841294362030334699120320], [-4034349364427395391687542560395363509542925743549987345891393505096], [-38083450692685340830452412885154581661868310708904647694747864057394], [2090231742977159359814258029227743177394018261411249765253369883352], [-12105406102356451495212641821096704618355637152541414531836524172950], [-20979925862702643125505446409228299757237045398290818633166930065586], [-27184989057056344931083199067208117967212590625885504743297296238864], [81947620317788432023055349370175067771424415730294904015357151197740], [-24857336695576514069223333742796446085708448684189541397666670343942], [30908346392477999758389570390509226652827204781568119579026573439386], [53566141698477159661328296533133385649206204191323309481649808265092], [-22940226657660441803890292835581386355536412874638389565852507865450], [68193078330738335166828550532472445497109211190616795142738437897652], [99579400824603516464054109153041476153177531549810010499607480205880]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_18_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_18_40_a_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_18_40_a_a(:prec:=1)
    chi := MakeCharacter_18_a();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 40));
    S := BaseChange(S, Kf);
    maxprec := NextPrime(2999) - 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_18_40_a_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_18_40_a_a( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_18_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,40,sign)));
    Vf := Kernel([<5,R![-16226178983250, 1]>],Snew);
    return Vf;
end function;