
// Make newform 192.14.a.j in Magma, downloaded from the LMFDB on 21 May 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_192_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_192_14_a_j();".
// 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_192_14_a_j();".
// 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_192_a();"
function MakeCharacter_192_a()
    N := 192;
    order := 1;
    char_gens := [127, 133, 65];
    v := [1, 1, 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_192_a_Hecke(Kf)
    return MakeCharacter_192_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 := 14;
    raw_aps := [[0], [729], [30210], [235088], [11182908], [-8049614], [-117494622], [214061380], [830555544], [1252400250], [6159350552], [5498191402], [-4678687878], [-7115013764], [-29528776992], [204125042466], [29909821020], [134392006738], [-348518801948], [1314335409192], [-1178875922326], [-1072420659640], [-1124025139644], [2235610909530], [-14215257165502], [-17019415289742], [10990429870784], [19640332937772], [9820991409010], [-17026697549166], [-44934655354072], [1201824485988], [17156152133178], [-105644089827860], [85353252521010], [-61641427803328], [118020796127122], [-154710153734924], [376012022331288], [-373562385120294], [-42334856171820], [310446880718218], [-862273101479808], [-937836643014526], [671714610973362], [-43645139278720], [1621621640538868], [1473330009613544], [3748889415542772], [14799292425850], [3630529144975914], [-4339000266991440], [3023722695906962], [1751455209412908], [4876036408101378], [4678821543034104], [1802619594866250], [6100162734217592], [10702338294035242], [-2454600608693958], [-4011554116057604], [-2081866149710094], [13235219589981652], [-8093014030966488], [-14818112378698726], [24317052393895482], [-11623168076685812], [46265248280338898], [-4794041266797108], [-37689996015206990], [48017883307283394], [40661600992602120], [29673300626881928], [90134578399742266], [15484136763879340], [9370880885351424], [-29580560950821630], [-18061747254883838], [-120412338372532158], [-17752187046553510], [-175670394916722060], [-184473355563153062], [80553231525379392], [-197091993816489166], [98900719348059440], [125103588906174636], [-180094876495581870], [-94359735356483062], [-80050008235378182], [214173898288828664], [180680568239247012], [-266712175160724720], [-263551809580416592], [-411733255212655572], [-399657893624094380], [-283580918412321096], [-640326900632610630], [-401347517619457638], [505985210228308156], [169124296693931458], [432104161768514452], [-1368041672491465158], [952405281999985956], [153631850757108810], [1279564588105932028], [356769908131216898], [-1289684669126598708], [-1886401262114136846], [-1446677070600326280], [-44435774160833158], [29805045055555208], [884082193304375626], [1436836808847628938], [-1688623164304257140], [-353490178580679328], [1618021270187842002], [1960652047007687476], [-596113924824003672], [2583179311300172826], [-2641366001552122860], [-4124511248489144582], [2797256078346568994], [4255534250446409922], [-1608930463689743364], [3063314825700705028], [-2991437193856022982], [5316937814777947930], [-4031529113805099840], [-4776426414945960832], [-1716681243640173854], [869722540682337700], [2402718896241612984], [9371752053600359912], [-3091198274554751318], [-7977871652476589718], [7373436784822403330], [1673351637239220786], [3753588992895967972], [-3388531507318303158], [-3131192643290467110], [-10473099865314978692], [6851622106721884098], [306934487430456704], [-7753651513750186308], [-2343362495933519390], [-16329737288829562680], [-19379431935392705414], [12053714055262658538], [10061197000379391820], [8014071791272343904], [-887791325937727838], [3787737592660941042], [27542811574029009796], [-28416466180617255672], [-7510233078116348228], [-23402776617717897648], [22088090744681728160], [-10563249724354118190], [-17283283288395126262], [-21403762991627970342], [591308436260262612], [-23939617111356889206], [1990454979252485408], [-41238481315770147492], [-12537361145705977662], [-18396640167476237976], [-34306388283336427528], [57245767419897960202], [9367560197027780690], [45523036426616575026], [-2481141303536652420], [-28523225828478642062], [-7634467799982901608], [-13461043841193865366], [72066521085801094760], [-25978749856631665350], [27426727181422141948], [-10855803466050364062], [11175726337857326144], [-48755220330617284670], [-12969416500500953512], [40191944781440912628], [-86024165338564738214], [2194222626365823018], [-94945883066747460816], [-17036461391056654830], [-19612116253523129438], [-51948875862650258684], [64869952478778649130], [82217474640186769152], [-87998877639474545086], [3528845390024208876], [68044836414203228788], [14168677014352601418], [-31428163265983480188], [74754803482742057034], [72028579069116421682], [118579641880473485506], [-129821926516405337982], [-112719811165346610216], [167332320924595980090], [196960305327093272312], [159023731481080054762], [-20775136492719983710], [48472565957695937340], [-168056130582088606278], [172604749495668487400], [104211648458648768436], [-180679419959611959030], [-116429276342919550532], [-255922809432856014382], [-201593473660296197742], [-81580941611831307376], [-176129916200302870788], [-147449352746562368280], [180254973308672612042], [283016855589142964648], [-271721038589336227998], [387988532876972395368], [-279620452483873062294], [-385598159932047239462], [-276791127251908709200], [-172265579638046047950], [367483190287448835704], [215977659431823987972], [19806332897832557050], [321491680470999222234], [372945962730524458320], [167502868611901216928], [468638362930215377388], [-42590431134598317134], [-611153023485300795740], [-506205128658560143288], [-112110052975622045718], [78670332622873137916], [193119461538250505568], [-430121744895485053390], [86209126390735560306], [-759915651759404268180], [286188716255173407432], [-265314135345474402204], [-796289401172048314052], [-249841284216676620016], [35827533198116009890], [-808285285919579509806], [-694850046279247429320], [114516236378188618328], [109996627113370036068], [273092171640886832620], [940855532097170950704], [-1136240479343070878], [673347814830590164002], [662250746426215493928], [-1259905158601557347350], [1053871211380094230026], [475270238719443806100], [-128169631493007884822], [1033433896567225400092], [78550749938187330642], [-889426788319143037222], [-747562706161215224536], [-632912879077380749148], [-1441484254409574532550], [676361489840507975506], [936803956801550177298], [-996970169085298263260], [-962008594600221715590], [1961031306882529976442], [685845728241187875916], [-697054707254358430014], [1022792097471220652098], [-1360639335139548242348], [713731829563025265914], [-200895014107241503240], [1750661217809139725618], [1664297842983793470704], [-456350377644704365428], [303755434684764573970], [872063916343021526762], [2032295800889079777108], [-2952849519724612539696], [-1171773647190119339968], [1764493646677513815768], [-3058123508782088918102], [-1813447909223286631268], [-1915677132949126890288], [-3552771797436756567886], [1642928994118894700562], [-358804038065627886400], [1512961604058147540930], [895797690500820417978], [1359554356372765832532], [1193055566409573226554], [628745729297134035948], [-2201119534861321368734], [-221030324415223411350], [1125909517099114738952], [-628107705508668490014], [1427275836783307592460], [-424200832937801553068], [-2041757619793092811606], [-863495306275862631078], [1481535118782228276200], [-4289720203358079247884], [4190673270817474168108], [-101445644275070727742], [-23216951905874526948], [-4223067356267369469230], [2692363244869982340120], [5654397293552676830506], [-2952940196898858171216], [1353208817348566125570], [-5875818434281971893838], [-2751374444363177424044], [-899375429210247538632], [-1072089575979213279670], [-3987976325050941293580], [-6326780618721480121968], [-2001430457827643728126], [-1914876632002655947470], [2243015786170871461108], [3894031936647462520058], [3011549636159499113658], [4482402209449095992024], [-4565288441881185541446], [-4510211344238157991918], [-5186444943643620982220], [5844244119991680179116], [-5408172217059743668512], [6477906881060061073506], [2094717016963953687538], [-3554399013842751688758], [-442400771103523699960], [-9078639993476379575484], [5060913422983687456108], [-8210933718726141049428], [-1865565448956096439790], [8820483378238669220994], [5084678685037705632842], [-7887470263576917887752], [-3180743976748857536294], [-8961154800205218253302], [9064735414236314668050], [6050181091226748149312], [-4860534826680922126374], [1315535340787168223700], [-617867591225984545862], [-8974507061048350967828], [1632391424239100800992], [11847715784230482793602], [1958585545474843533268], [-4930170152397160447222], [4148519631182442651498], [-4953169392463855369576], [16736824286259616349050], [-2690005606047387105606], [7825825547631645951360], [-6190353641163587978772], [6969419915077536596418], [-7111292850544074718296], [14613814529600794831882], [4125313399231838501322], [298549623954743088048], [-7408159894943821131540], [933808202816906620132], [5948031352904125097354], [-17739113236745301393558], [-832868636463994654096], [-424508115822785045638], [3111129653126449790388], [-12385185131647713076580], [9414822086002852173264], [-6401027281410921092190], [5054251001344111310432], [20912894888836831090882], [-3350442699298233251580], [18335537200333195939872], [10221656853365525303714], [-4530738524549835359070], [2776301797044096546938], [25027573961436827054538], [4864672644503256691194], [-17988462523327543015552], [10534959425304020757858], [-1800593580555511190060], [-25023332984553998810856], [6260621437770763755752], [-20743386507124941530678], [-32068870119744878885924], [-19320797563855913206032], [18141227010667003795010], [25174616889241811374626], [-22873016175100857352980], [1008172379375948588932], [22058516395912488976392], [-34960216321501618190566], [-10643350671494680515640], [-31394619536032539153030], [-3305923938468103479332], [-10078652841321299445102], [18472773963198578968210], [-35392096458523570165326], [43680598545662761108568], [-42998944541205057728982], [11403184696516040944050], [19848641679871628011472], [-26828397768597803808398], [-15691338485310265507038], [33043377455466777685156], [31228048378841231965620], [18763849176029854257554], [51091575304913244940242], [-37694300130676173144564], [-27418608397900425755852], [2536854262575928475018], [-16353871775879318703702], [52308874130047060924800], [-14956821663722049372112], [37315903088908598128578], [-38177993470055834218056], [-52477453573440338998230], [-623013008630071659158], [-19975816013545449962832], [24170654247656699489100], [-3607795234746859165846], [-33655490725596226575798], [28191693621137053200996], [-40410720451472165458470], [-13074320821397900903732], [-46610528661667172757000]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_192_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_192_14_a_j();".
// 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_192_14_a_j(:prec:=1)
    chi := MakeCharacter_192_a();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 14));
    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_192_14_a_j();".
// 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_192_14_a_j( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_192_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,14,sign)));
    Vf := Kernel([<5,R![-30210, 1]>,<7,R![-235088, 1]>],Snew);
    return Vf;
end function;