
// Make newform 64.10.a.a in Magma, downloaded from the LMFDB on 01 May 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_64_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_64_10_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_64_10_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_64_a();"
function MakeCharacter_64_a()
    N := 64;
    order := 1;
    char_gens := [63, 5];
    v := [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_64_a_Hecke(Kf)
    return MakeCharacter_64_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 := 10;
    raw_aps := [[0], [-228], [666], [-6328], [30420], [32338], [590994], [-34676], [1048536], [-4409406], [-7401184], [-10234502], [18352746], [252340], [-49517136], [66396906], [61523748], [-35638622], [-181742372], [90904968], [-262978678], [-116502832], [9563724], [611826714], [-259312798], [-1565549766], [377094824], [2177171316], [-1508114702], [-1453545486], [2436793472], [1433578140], [930903498], [-4843158956], [-8532694134], [-7145151400], [3382387522], [901514620], [4056052968], [1027601586], [-14847209748], [-25326997910], [-16165599552], [-1801886014], [18697917402], [28988997128], [19798972876], [-67876825120], [-54560580804], [-46395169094], [-391388886], [90653840496], [-67766317966], [-54716262300], [-34089989886], [-71736053688], [-2316102318], [80466212240], [165643908874], [25717723866], [-43312567484], [48347327610], [-137970582932], [-204451356168], [-174184416262], [84246776226], [288776811412], [135029772242], [39190343940], [45881779330], [529589509218], [-45489271896], [245166676208], [160289709994], [355772343268], [-497007817344], [594268284186], [118575136978], [-527597710830], [-89687206054], [-926538081156], [-1226924410886], [-956151121104], [74284069682], [-166517995912], [-641581356636], [-277232914494], [755228037386], [-915740166510], [-635894424496], [-617286487860], [277942362336], [-499400167384], [-2062408293900], [1219121486764], [1804298344632], [203239213794], [-693093244086], [1979559486676], [2958993335746], [-3275255805956], [3764047394610], [-2349868527252], [2667012654330], [1723424732452], [1558564754498], [2166226815636], [3562436548818], [1544068310040], [-1052773495270], [-4474705746592], [6018616101178], [2161908043434], [4169235770740], [4100365614392], [1871876798082], [1341661665436], [-4943672484408], [-2671390140462], [-5500888739316], [-1069367027318], [-4965673777246], [2757390044922], [5055280567092], [2554141162732], [8115520572450], [2043939389914], [12423132718416], [-5374335694696], [-128617519358], [-13672589407940], [13158138050856], [-2086817962384], [-5546599185878], [-1134509892678], [-2616018781438], [53315438490], [3307830934924], [3868732816578], [7395256886634], [-8928026222924], [10553356281834], [-9160303545352], [24409596202020], [-9120505612382], [6075746579592], [-16791715149110], [-27770698320102], [-1854051098876], [8721418022496], [-27622167739406], [-10018626813198], [-9437017481684], [-3756353305032], [-23679500941484], [19002986679312], [5569915092824], [35429330866338], [-24559193495062], [-20051649283662], [15129512809452], [21875058913914], [-33223929603832], [-37143028994796], [14687195711058], [21874564829592], [42008880149216], [-2697043219526], [-53508859189390], [-12336243336918], [47241896516964], [9216998062306], [-43897125991608], [70220984702282], [-29668300779376], [22495427079642], [-63350075723708], [34002303234426], [-31062051769240], [2304096363826], [21032695965248], [36255615660252], [-51257903356838], [55062340691850], [-4191178493232], [95656967299530], [82975480555906], [-44880013341764], [41075852378282], [49771551238272], [-108725144409982], [-99785292538284], [-9332130824180], [-96812696453310], [20823559070076], [-84104736099606], [-26246205805006], [16684196805154], [54746238839490], [-48124119408120], [58107461417874], [-7881598257328], [17145158167882], [107141609667554], [-33063898437900], [-87695916232734], [116343260916992], [163250399785500], [-81917651509686], [-124365016438316], [-2734756089454], [-91338333121782], [-44247988605736], [-198126477899964], [-96989231121048], [-149277527541910], [13455643974320], [44430651495378], [-171366300877032], [-117963454332798], [-31651989533126], [223750212212792], [86747506758018], [289695251914256], [-239747622889716], [183125350588042], [-91915777025190], [-285785484213600], [-83991597587992], [184860751665204], [-109270565820494], [-200024674057748], [-173577670315072], [-343372867054326], [109869779426068], [23247987097680], [-78469878425518], [234849755382858], [273685989070980], [-266820695403480], [142858134681516], [12930517764964], [22509060201800], [210386863392850], [267814669064850], [259850407949784], [-132172790675680], [-86949992274948], [135369793233844], [388353756013488], [259542814686370], [302595645438018], [123884353081224], [272441778043274], [100263943945746], [83596106135628], [-41094325956662], [-12149427821564], [295736508458298], [-289807917540550], [167713700559488], [-190618360531812], [11186444195866], [-217052304478910], [-114980090123358], [-341170404749444], [50938073693874], [167289042300282], [-374963364668252], [310332567051738], [537253176764818], [-557958094658612], [-74288225397094], [-408998835843616], [-503943544823182], [-450626000697928], [434245644657252], [-490958637171230], [746166682497098], [271071081879948], [212528170356768], [586326417706856], [712351227484152], [-126640840562342], [-303659876450924], [-592588887618096], [-307640699509294], [84394513131210], [853723946291480], [617685351846498], [-852212113383438], [850062536948268], [-626336726563782], [1173930653246292], [-26231612273966], [-443188914944958], [-154660495403872], [712571232472938], [-405283480603740], [-1296096150658724], [402671711553290], [-348004353032046], [351494046700112], [394507540314828], [251870212834948], [895446706157282], [340092962466804], [823991077440370], [1193430706327224], [-1109963096556902], [731590486963344], [592128197089290], [885795910973730], [1329600401609212], [-960232740399000], [-32545260948886], [-849542947644564], [543248100182592], [-756020878865854], [1858071237693138], [1443610681714252], [578024756683802], [-1497939878951550], [-894776173323424], [506922399769770], [903404508712946], [-137246939815268], [-418247956244540], [-753032041701984], [1737390368774394], [551824195464370], [1808272837236258], [-2255364402852160], [-2245735274792868], [861530970546196], [1746969771466116], [-689762025770750], [-1663520456417310], [-1329157441083094], [1939549275888752], [1866555034111018], [-599829417717318], [386516042420634], [1034651811903560], [-905467221473598], [-360889542088452], [-1399124220255110], [1208768977217716], [-14197291008336], [-127394058292758], [-154985043958820], [-320108869847926], [-2380089586187502], [393767233986512], [2704002965394634], [642587741998362], [-3004088725330848], [-1168552385851788], [1601883600394482], [-1216114396562376], [163201245420826], [-595810292209974], [667547271856656], [-943619702755644], [1408191414998140], [3445145015033834], [-3061062586924110], [-2750863381754104], [-1753609244651110], [3554726201928252], [-290844123915788], [333426724480368], [-746089912442070], [2804386097275064], [1074885838815970], [655935704555148], [-1389942596998368], [-4045829841163486], [-1641430530195534], [1088432255061242], [-114942190823262], [-4053357441958518], [2122634548997144], [3028957423955298], [3563864301000124], [1765242684300456], [869168848071152], [1009483383549610], [4503715711742692], [264821962038912], [2426568117706370], [3860361667228698], [-542409425246124], [-2358915770496500], [4900727222271576], [-242373418817446], [5008262726119328], [668627946178794], [3426412361976628], [-996108713700246], [-3136546445589470], [-2451516548071230], [-3612583827739312], [-361313614521702], [-2119489897214790], [-5279490750529240], [-1718855127854990], [-3544956301318542], [5821087142914732], [5644782772370460], [4567752665319314], [-2296109805937398], [-1680121483554492], [-6889800015931652], [5423968741789034], [5824175048214066], [313446466610496], [-5773585899275128], [-2879579675538990], [2056069532497176], [-1444815748134270], [5484591434864698], [-1600046351125776], [4993421624478180], [-4469779621111606], [-4967308907862318], [-5943073128570612], [2482266201755994], [-4250092456239932], [-2600804445855624]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_64_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_64_10_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_64_10_a_a(:prec:=1)
    chi := MakeCharacter_64_a();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 10));
    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_64_10_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_64_10_a_a( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_64_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,10,sign)));
    Vf := Kernel([<3,R![228, 1]>],Snew);
    return Vf;
end function;