
// Make newform 50.26.b.b in Magma, downloaded from the LMFDB on 10 January 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_50_b();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_50_b_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_50_26_b_b();".
// 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_26_b_b();".
// 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 := [1, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0], [0, 2]];
    Rf_basisdens := [1, 1];
    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_50_b();"
function MakeCharacter_50_b()
    N := 50;
    order := 2;
    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;

// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_50_b_Hecke();"
function MakeCharacter_50_b_Hecke( : Kf := false)
    N := 50;
    order := 2;
    char_gens := [27];
    char_values := [[-1, 0]];
    assert UnitGenerators(DirichletGroup(N)) eq char_gens;
    values := ConvertToHeckeField(char_values : pass_field := ISA(Type(Kf), Fld), 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]];
    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 := 26;
    raw_aps := [[0, -2048], [0, 81432], [0, 0], [0, 8800446746], [-11240373835548, 0], [0, 2121104467567], [0, 568927974345951], [-2989845386727620, 0], [0, -61152727672159398], [2120475579683207970, 0], [4225863091688971352, 0], [0, -12083938476384042739], [-161564320765298755398, 0], [0, -155806138858089358028], [0, 612928649464510593366], [0, -239457739823663667693], [-12143384628398397940860, 0], [-20332807034763696982498, 0], [0, -30782626448566676972524], [134076626495447231398752, 0], [0, 111889318209560137151677], [-382349749262069041023680, 0], [0, -385909145913451703600688], [840580682623068403216710, 0], [0, 3095820598857832579281191], [6643420588943093532004902, 0], [0, 6837050115785953043025082], [0, -986959280519455668724104], [-48625188947799686339985710, 0], [0, 22920490441321267245225417], [0, 65860659403039438418898206], [-73628115685032041370334548, 0], [0, 479159889068993816045890011], [490566336521811291652319860, 0], [-909615407353130383774459350, 0], [824559604577859310957683152, 0], [0, -486453435652848368481758479], [0, -1274865927102024281151483008], [0, -4045332681181104141235092174], [0, 2257774802365040600123360727], [19469413699531969917214931820, 0], [-12195246571345682295158539498, 0], [61111937219352318900938554152, 0], [0, 32446727537502991061940190297], [0, 15876249100387000671211507941], [73923571857175361273316302200, 0], [11801616502328111578524442652, 0], [0, 7799610771795470786736283702], [0, 178874151905509730930054680356], [616468348267679983449116536570, 0], [0, 284171838194002023022736072637], [596387613839094073859523495360, 0], [-497937947908098842955987695998, 0], [1756101068845023964322211063252, 0], [0, -610325821307963776591045244529], [0, 1139135417685920328727256149842], [3128149536606215517063035963730, 0], [1318181228899839801779795191352, 0], [0, -1059309693026940341538470323819], [-6371407450269828711284907769398, 0], [0, 1503625634266844932107319586812], [0, -3596671829714893867513186412253], [0, 3043187612122948540737843943196], [3601684520048091818111909516352, 0], [0, 1535829079963945433619660887917], [0, 14033011062174578001621653557401], [-17989260152201072149911270883948, 0], [0, 16883975624734023391806032667911], [0, 1535348823087589442424305097216], [-47355280895409688406085762765950, 0], [0, -56867495004602789107546957313343], [-75831650308149281893812554016360, 0], [0, -33294422085616371196869471547474], [0, 20194582895236887769628561711227], [-300035571487255848027992315963180, 0], [0, -29175744777105184926137162811738], [465525578401662557162514975395610, 0], [0, 178544249436025850524061205546641], [-585409584468299022828275642322798, 0], [585777768503114354768533626507190, 0], [215945168078849026113017496009180, 0], [-257301268296616496909533042623898, 0], [-487419771663466996067299010823048, 0], [0, 670632913197254001753892543813537], [-320032687776815059124705625758840, 0], [0, 754494330074110284837741958825572], [732432134043317377911538634832750, 0], [0, 904237670353189507698797921116571], [-2023477255867418751207687692002098, 0], [0, 2004481544063300025975797221378942], [0, 559753140884427943950298771380276], [5669684469960946793076346492476720, 0], [0, -880464929428264146133023211958014], [-5583537514302454174156124170845948, 0], [4373683408382125278773854738155100, 0], [0, -2161896736213408086948440168888718], [-1817363963641454565163301005250910, 0], [-7481313189089904057839538023257398, 0], [0, 6720259138375028525454423619876852], [-9166204759454074810215097079067298, 0], [0, 12370162080593254086699937582668116], [0, 10154168883276151073861976074150121], [0, -16314843505207713492072676744427808], [-34144277054160629986056427420028970, 0], [1364498469846601979630951587990052, 0], [0, -19649370815520701243414639713051969], [0, -18635891135191839725825563677539664], [0, 38758425902150664047419042385959497], [-61882042447460318892103531568812200, 0], [-29585223248975435313223374052562998, 0], [0, 50308327421511299631000818551918046], [0, -22372322751039550174631904237400133], [0, -12939965937335201495612471702895549], [137687466609877319894874322427942980, 0], [-28348353869903846460987138160472848, 0], [-13636775703148329155621820302351598, 0], [0, 423969558823367165968505481491872], [0, -125239221671756112613205505301093134], [0, -77887289833137077515699466466773793], [185484979021281434607545246428576140, 0], [292622526062374975984056139771394102, 0], [0, 106914378014648687238328740126340777], [0, -79604045386938326328402351114749019], [0, 211501725886535488547933569321371012], [302758809116182232246909685593536652, 0], [266144742798309664687310069843679102, 0], [-28174474940189336110792075206202310, 0], [-287440508832739867532203083804633120, 0], [0, 249023154403778569203386900475971906], [0, -423669718944681567077173795049079713], [-712136135206926054013729798625026340, 0], [0, -309433668092136180617060475607199478], [1340816210907553907682600882392113352, 0], [0, -440522718466653706178678066066977579], [-908045207776058822480125352555078598, 0], [-1574266827076497109254290758639620770, 0], [0, -986535640163294170410340261636125573], [0, -476276653207966896498529846744226764], [0, -185431251991597556081513699813445159], [2081519042905223883738341082244755990, 0], [-92004630270080280896220413643109948, 0], [964905181563334821326496153190726902, 0], [0, 216988481617969366087311988187135002], [0, -711115671979639290956304916306117344], [-4072340367121399763354716667180825630, 0], [-1542590226449401535748062786073215640, 0], [0, 3973260651209076846123850873429470307], [0, 368605948298313909841282005959935971], [6085369943280485208001051676668302340, 0], [0, 1651624200168349551214047752306747742], [0, 126982061804760654910525017689976281], [701270141559522825383304280468453602, 0], [0, 3837688709873412261767640677475376912], [0, 5954378817366290471727228978134231586], [0, -3493843717804594664752210547802915904], [-8237189107234403571972681565341213048, 0], [8311770929311871043753254356242353080, 0], [14867216384876357487702654416625667470, 0], [0, -11277948290003949627133031400669598189], [24058029735232134921933335455178466702, 0], [0, 102934224353927049722505699580786716], [0, 3980547123950398854529320871246716957], [0, -2419282433583040676684126232571882774], [12405984284122657372169608576015270452, 0], [0, -2762417888077887290412718318937823969], [0, -18116349231129286230722219580495828438], [-15599935358071269457658459599861259848, 0], [0, 29470219198850171804083197695850462341]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_50_b_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


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