
// Make newform 50.12.a.c in Magma, downloaded from the LMFDB on 15 April 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_50_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_50_12_a_c();".
// 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_50_12_a_c();".
// 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_50_a();"
function MakeCharacter_50_a()
    N := 50;
    order := 1;
    char_gens := [27];
    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_50_a_Hecke( : Kf := Kf)
    return MakeCharacter_50_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]];
    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 := 12;
    raw_aps := [[32], [-738], [0], [-25574], [769152], [918982], [-10312794], [-5521660], [39973422], [-15269010], [-241583788], [25751446], [-1217700138], [683436262], [-1537395294], [-3572891298], [-1069039020], [-2091535078], [1462369186], [9660178332], [5603447662], [5026936280], [38405955462], [35558583210], [-10572232514], [-88436538978], [-17319727178], [-226284410934], [-96624135430], [-226933436058], [-97298812694], [304354493952], [-691218366114], [-576365470300], [-1686364600350], [-96379210948], [-1469464949474], [-735408841898], [2765507262186], [519253166382], [-1348222432500], [2237380287662], [-6304211202948], [4208972568742], [-1263379608954], [4570995543320], [1842634573712], [-5985993208658], [-4697495897574], [10287855778310], [-3587998793418], [11293674672120], [-5854203444658], [13686649834752], [14789665337286], [-33364289829738], [-344100275190], [-15797778724708], [-17670689893634], [10655440379382], [-54200061478178], [7082323039542], [58302633360706], [44781125657892], [97166417907622], [53890835462286], [30829068028472], [13855049532766], [61486974412626], [-93137260186210], [-104174656265298], [88314164604360], [-128309117597294], [-108176571623618], [249029220202940], [299433257691582], [30529763875650], [-346957376943674], [273372955127682], [-159143110672690], [-101758749438180], [-140103694963678], [-31745377058868], [229492952234782], [556662126381080], [-123574238670378], [-565612877707290], [-24278664983594], [572909392323462], [172525749693382], [-375877269979614], [-80477876620680], [-707883340489454], [439300612966272], [-986712825593980], [620084630815542], [1240953413938350], [1518422046336522], [-559189331349698], [-1491066114504298], [-1605496860340934], [1111991825886246], [-280668968021778], [-2236740013089330], [1373031244358072], [-705140081100074], [888811759121226], [1097240815657422], [2285334665738880], [-1905684807650458], [-11040721852814], [-3094263287105258], [1899707887932726], [271829171816780], [779292400407212], [989427544995342], [1166379348119662], [-970992532227294], [-3950213617204098], [2993084596390620], [-5384318702018158], [5898449419283182], [2004063352228806], [-1220632018344378], [6484362173103992], [5883022698114042], [-5423923192715050], [-2515335097894920], [-9615728233705334], [6794016851519902], [-3111942447717460], [-2879475159049458], [-4180932104475628], [96961292615086], [6022372970680602], [-11840557958406910], [3879125975089782], [-9917058307229414], [-12426740562521634], [14469148994431050], [4812616984913552], [-19974154963605198], [11090151247411342], [-9094627157260014], [-10071973489929190], [-16867479761425680], [-8506616965799738], [22517222945778366], [-15315819442192540], [5265104413145022], [26272814214463246], [-5986611336456018], [-13465501692957938], [26408690942041866], [26809991219461666], [-9345479967520188], [12954202555768400], [38682998996414070], [2804693358554566], [30386575568273622], [-11201855490944814], [-5772738317572458], [707033261707426], [-36843757161951528], [16613235337394766], [-14615328648387018], [-16420543421732908], [16819256322076126], [-32317588570772590], [-64204366344943578], [53938468804914300], [42792744326653142], [37718736287090532], [7245786165514222], [-63253384616534320], [-27323355274895910], [14014286831732792], [69167771373324942], [43591341805208062], [29729572178800010], [-48475635014880014], [-71979717002217648], [-36614467866692978], [49770080028545166], [-25710836728885458], [12970988717486070], [45841388888838166], [12992920163256622], [-86717480569125490], [-98145866165786748], [68078328687071062], [-126099809948057178], [107341620736590632], [7626065566212282], [81471330489252186], [56355599117255862], [7002056547236942], [41925080404445422], [-27391236382990434], [-42685910180453178], [-126217730124485490], [-103445618544257908], [7191609912365806], [-191131652527316590], [-1592357891898780], [183925974902467086], [112029425880652640], [-29401404841221378], [153059341278909450], [-189412179356797048], [103908294174666886], [207492191252890962], [117996391598195542], [-19244594593760214], [152823301913802480], [-45297495449187898], [-212185455874393094], [9215382392858802], [-125493894856134774], [-51873426888224298], [28215874628512802], [225582924029181920], [69572681393033490], [154565503617262102], [-50499470401428534], [215051816777309330], [363827624495009262], [-12667169782327680], [303302394926976226], [-6004363128837288], [-296048076969689738], [18073299688515380], [-24300423341525908], [393775161008279622], [187650993225634222], [131486179422190506], [212382190045593350], [434940411561577902], [421629545248290780], [-179939290845538188], [149808935708639862], [-274655983581020608], [167780999916539902], [282533806302791870], [-428731277981691138], [-253363392557428920], [373454080367995546], [-112953782471686968], [252663890390434340], [282679228294383942], [-40936858577897354], [99460101894643602], [-768951057850984014], [258681464210754590], [-19178323077596178], [-63148110088985100], [-60908152187572738], [342025145544931906], [-573181077547920114], [127409816196300886], [60876660701590942], [-100382947741922934], [208189338244624070], [334105221672827062], [475576089028080726], [-763268458644873580], [-276926842176816690], [-1067018806404644838], [-765324678441717098], [-677547171802252698], [677143094139873062], [230755174099433026], [1186981902305373622], [-1281749547389523760], [-1056079685841731594], [-256544770546455698], [-1439833944240020094], [-1030605267152132770], [-121963544971165258], [408149286586251312], [-530023647694866738], [1018963736123173172], [753916909767735426], [-540556612671833698], [261804517264300186], [-1918758646943831628], [634660283841469702], [393062174413544406], [266455994172750320], [-883068461752284810], [-286999008158045238], [-191422544153810454], [-638410474962881538], [-1339450180348631088], [-654090377600878898], [-1467870233830163670], [2078937956737978052], [1534911398492386182], [-220233963108651300], [2499743458071346], [-1790681348077094978], [1640018492128718046], [2660106770496705080], [-1766670202123964178], [1928013121341641312], [972036050020486846], [1006703115296515026], [-2377110863501600770], [287204001913690440], [-2420765467564568618], [1589010412367251662], [-3023289960336460170], [-890545613638335198], [-186539180729118578], [-151708799431216134], [-158309830074057190], [-3184041981442062300], [3137055244194683652], [-1093936874121845978], [3039278943821166870], [-1538603962869113608], [-1858565515725583154], [3467548193947758522], [3376599684845501302], [-2769816607626531378], [-3853513654596846178], [-513206832078220300], [-2148463341465123578], [291358244173351506], [939115901866043502], [2426406837394028522], [-2632287261154955874], [696045305994533960], [-1993134408953284938], [3525737835216032912], [1921133264571609066], [642127847584634570], [2100710081786817702], [-4224811578433245658], [-1280449032938854454], [592894183205553142], [-3857566605232730394], [97719551487465810], [-1809573409729995268], [-1069012727858991018], [-3444767378832787020], [189956716566327362], [-1858805741863907294], [2153403621470307252], [3418668400065854886], [-882442818496310608], [5793204052679024806], [218687415449322282], [5571609836694086902], [-629006998665453130], [-1239241358163923298], [2497310251931932440], [2340775535322997512], [2205199704315068526], [2042843735034291102], [-6522943729252588754], [-5936354173588236198], [7120651153683652146], [4867374636540878340], [4092291074481130906], [-2901525568837821338], [8786881888437860646], [-4814662148632493498], [2962014265122335462], [-1129411168512556848], [5571172675526505500], [3180651300319742022], [7566986744798411010], [-84506963058621028], [-4066700693687881994], [-45658423728851340], [1906830039672082692], [-6703677086464956818], [-2315335291749119610], [-9095461249416744434], [-7493169292130977098], [-1309185954011137218], [5663580671625463906], [1701279924523894446], [-3667027948099196860], [-10237263358752923058], [-7369776860104671988], [-6426998693543027834], [-1726625885212523018], [2312458600717399026], [-14322690725847250090], [-3923247423512762418], [4357806947203712580], [-8422692051669644174], [11080780529928973932], [3570799057584968062], [2120858116420744280], [-10586807570540052150], [4596273848752075232], [5157968480064906162], [-8853581148313030390], [-2963036224919389338], [-8451243444281867054], [16688852342671967166], [-10997277350207251230], [8125904637973435772], [-2583488765076509714], [-4300673081111041038], [-8457113882906122778], [2972800051959336060], [3611902997806252942], [-2324827446911235354], [12866530260864511422], [11040585185224324832], [12024854787170044126], [-10998060285065220378], [4471490238755692320], [8356841177068368346], [-14673458725897437954], [-5434202689035578898], [5083052877492860730], [-16412396187710708714], [-12221988118582665054], [-13023406743110760540], [15162281119912653862], [10936539633975272526], [16110435930747503982], [-9997527369443239890], [-6478836615987100648], [20688262900219517880]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_50_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


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