
// Make newform 18.19.b.a in Magma, downloaded from the LMFDB on 20 February 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_18_b();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_18_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_18_19_b_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_19_b_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
        poly := [2, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rfbasis := [Kf.1^i : i in [0..Degree(Kf)-1]];
    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_18_b();"
function MakeCharacter_18_b()
    N := 18;
    order := 2;
    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;

// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_18_b_Hecke();"
function MakeCharacter_18_b_Hecke( : Kf := false)
    N := 18;
    order := 2;
    char_gens := [11];
    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 := 19;
    raw_aps := [[0, -256], [0, 0], [0, 459525], [-352276, 0], [0, 664810332], [4851691832, 0], [0, -71905951161], [-45462084496, 0], [0, -1267190169468], [0, -5234179810197], [-18943596568996, 0], [-166886471089186, 0], [0, -97437534227727], [-730556755353160, 0], [0, -1207792948328940], [0, -3230047264409757], [0, 618457705029624], [-6927847017559630, 0], [12289128589408232, 0], [0, 14560345710981324], [95119031558434736, 0], [225037391450064644, 0], [0, -103430236456454844], [0, -221499813239756631], [-425589333450778096, 0], [0, -912103850608497939], [-756523397531165452, 0], [0, -2280269817726704640], [525367677254150216, 0], [0, -637318815418070799], [2741347726906360268, 0], [0, 10172226577000616040], [0, 12704676452336374719], [3932221215856294712, 0], [0, -14517075325193644965], [-38928937838730862948, 0], [-89002614895009835218, 0], [-41543066664029931496, 0], [0, 27505334817717667896], [0, 46917811913826018093], [0, 33036439572839744496], [261236295817484728808, 0], [0, -45320829284910579384], [312396293296030724174, 0], [0, -87528736171213068627], [876078179856595360100, 0], [-873071399481089356024, 0], [-1822668486739765392004, 0], [0, -979292950783394373732], [-207119635797738800392, 0], [0, -1180088457686601488361], [0, 1335907761926132189856], [-1363503895398055299328, 0], [0, 3271162165581721895316], [0, 3474165105723975574719], [0, 5038158098847965401896], [0, 5210148419875862047557], [282061915618016076140, 0], [461619917481669562568, 0], [0, -9934402547347008523959], [-11595486244151586629392, 0], [0, -14892253807757709042861], [-34467551654999489509480, 0], [0, 12388515396427050136536], [10178120962019040856994, 0], [0, -29984761325141107220667], [22018939259452283548856, 0], [98735982646005259516208, 0], [0, 82700244669287609530716], [108929329642476280843922, 0], [0, -108866811387217853117631], [0, 73655910185943095700804], [-131406742823332141161844, 0], [-75107345401383324265150, 0], [-234997066714781732189920, 0], [0, 172996962979261390678272], [0, -251940523093983028093125], [132144681195010143543314, 0], [0, -10857779733441031884969], [176700969002431942039568, 0], [0, 398230754876660445022596], [304287685494863087625320, 0], [0, 588283546773827159024292], [921225355580371875492638, 0], [-362669735766975326461204, 0], [0, -517637005784357708824428], [0, -200245493999174134565367], [-372416169373891600150960, 0], [0, -1173596634705772682919453], [346260225014466174948404, 0], [0, 244725293157442834681548], [0, -1444944454940855212217148], [-1414720661569585356723676, 0], [0, 1882033158964551041227008], [-997073071008110883864736, 0], [0, 317648540347684855956468], [0, 2545823386010604128682459], [0, 2340171737258475219530751], [4061170641019282772783456, 0], [-4529127988014860248257688, 0], [159805395760243396275704, 0], [0, 2395077226418204016769827], [0, -5837171339231733859068372], [0, 2997458721545109720818271], [-2798923973946541612128592, 0], [-10534331251163343411928078, 0], [0, -1406938073717653647460824], [0, -4885148214310372688238993], [0, -8909868794521032774884796], [-3006418941256518569878882, 0], [21120126201478587885349628, 0], [-1391761843572328757657278, 0], [0, 1959572126432504725744089], [16639043101068202625835776, 0], [377677251258387289143140, 0], [0, 24464712822539971796867463], [10275879802729855906469432, 0], [0, -3056053271730925255242516], [0, -12078109285488562782799203], [0, 10661642473770001583533176], [-18089649847127206662097858, 0], [-13015736913633989940883870, 0], [0, 22976688795262860164263125], [0, -35003464065654809376709404], [-43058686556564694888892360, 0], [0, -1460412788771784383602965], [-15984217335204041073593992, 0], [0, 22856399918798122832345388], [10859863729213350326544788, 0], [92093539810643336908516664, 0], [35924364797846367327514256, 0], [0, 7837894356405399997827960], [51364936152615510371702828, 0], [47924873357483319531694040, 0], [0, -106731326659292888826020991], [88148178845123201610544370, 0], [0, -50878430309468264015401389], [78588511206834479134286000, 0], [0, -5223021721484297456266755], [0, -51499262549303282012672223], [-274784847315452468247424480, 0], [0, -144354966060176844488645331], [-55979018464444704223373572, 0], [0, 123352867936142709389846568], [-103625523667886500397181688, 0], [0, 19609273517141634161380116], [201318205789772433813539774, 0], [0, -100548736627999054447163487], [221955006120077203123934648, 0], [0, 154432402558077203909203608], [464987151410442489510095090, 0], [0, 2282300289084446578226223], [-486526978742372335223858104, 0], [0, 218917688109832676566204104], [52706473399716779868311288, 0], [0, -549040964870452734487805448], [178751360244909988293289580, 0], [0, -626481595507498326042728889], [-53291198148687467329751602, 0], [0, -766452980191483660256105469], [0, -473493910000697098328143272], [0, 264216816825571613879398863], [884045401170011881577782580, 0], [0, -462849332834785330613145996], [0, 786871437111302918495820393], [0, -483406687866420103166681736], [58013814539890559785733228, 0], [864922274413902582471762626, 0]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_18_b_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_18_19_b_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_19_b_a(:prec:=2)
    chi := MakeCharacter_18_b();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 19));
    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_18_19_b_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_19_b_a( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_18_b();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,19,sign)));
    Vf := Kernel([<5,R![422326451250, 0, 1]>],Snew);
    return Vf;
end function;