
// Make newform 1911.4.a.e in Magma, downloaded from the LMFDB on 18 September 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_1911_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_1911_4_a_e();".
// 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_1911_4_a_e();".
// 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_1911_a();"
function MakeCharacter_1911_a()
    N := 1911;
    order := 1;
    char_gens := [638, 1522, 1471];
    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_1911_a_Hecke( : Kf := Kf)
    return MakeCharacter_1911_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 := 4;
    raw_aps := [[-1], [-3], [5], [0], [-1], [-13], [-19], [117], [-141], [-131], [128], [55], [0], [-201], [96], [510], [156], [845], [-470], [324], [373], [-526], [-266], [250], [-322], [-852], [201], [1686], [-827], [-138], [1514], [-359], [2757], [168], [-1464], [895], [2193], [146], [-1715], [2994], [-1660], [-4130], [-4397], [552], [1668], [3523], [-4163], [-2926], [-6578], [-1850], [-4012], [-4968], [86], [525], [782], [-2388], [-1622], [-1962], [3338], [4762], [-2616], [-5670], [2128], [-558], [6648], [-11180], [-1450], [-8685], [-876], [-3598], [-12038], [-7680], [-8944], [8644], [5700], [9917], [-14554], [-9410], [6194], [-8881], [-4109], [-5206], [6978], [-7252], [-1451], [12718], [233], [14132], [-8729], [-12017], [9357], [13911], [7776], [6666], [-7596], [13846], [-10817], [-14481], [16588], [10485], [-6620], [-24648], [2529], [21650], [-5944], [25174], [-10514], [-20750], [-21827], [-6748], [24421], [-21155], [4559], [-24939], [8507], [-25166], [22099], [3964], [10275], [-1258], [13890], [-929], [-26546], [-8331], [-26028], [1570], [-12398], [7194], [33061], [-1248], [-16570], [-8706], [20852], [4258], [-27736], [-1785], [-34193], [11069], [9352], [-24858], [4249], [14440], [10716], [16151], [-9539], [14700], [7980], [-30574], [4604], [-38074], [314], [-37331], [20407], [1524], [-41364], [17341], [13278], [43188], [10822], [-20522], [3723], [-31092], [-47227], [35880], [-26349], [28303], [-4838], [50822], [-20130], [15552], [-21645], [51338], [-5048], [18990], [34827], [2478], [40266], [-24900], [58520], [-46293], [-18691], [19152], [-4534], [-17418], [-65360], [56100], [15784], [-58595], [19802], [-14943], [-21856], [-58777], [79876], [72497], [-34266], [-12087], [-10928], [35314], [43526], [20760], [-44388], [-17423], [3134], [-9182], [10332], [-39730], [-76288], [24884], [28303], [13064], [19697], [-69972], [-57790], [26374], [-11135], [-90617], [-28078], [-72259], [16176], [-43692], [-47356], [5936], [74045], [55852], [-23709], [-22370], [-36927], [39136], [-23263], [-97343], [-76602], [-47234], [-78643], [-23724], [-82642], [48729], [110059], [-105064], [-112082], [14476], [72764], [44588], [-12731], [-39390], [-40950], [18156], [3374], [-51504], [63734], [-106923], [99479], [-32524], [31632], [31934], [-55284], [10289], [-2500], [30172], [-5586], [48137], [67332], [53972], [101194], [-121807], [83904], [-43822], [77086], [-12138], [-96304], [-4558], [27130], [98622], [-32695], [26564], [115248], [55424], [6257], [-99737], [-24116], [-58452], [-17904], [14657], [11452], [125440], [113209], [52268], [66415], [-113370], [-101876], [102095], [11451], [-16581], [-32523], [98868], [40798], [-92132], [34032], [-167258], [-123265], [-53669], [-20876], [57644], [-82286], [129628], [-21463], [114564], [150436], [-127057], [-145734], [79218], [127076], [118152], [55376], [66583], [-127622], [22864], [252], [77804], [25907], [-165114], [166210], [64168], [151872], [126807], [-44367], [99678], [128792], [41753], [-130621], [-32373], [-182785], [173655], [73472], [163130], [-91484], [-143234], [80719], [46268], [137998], [159521], [-172362], [66992], [-116095], [26966], [-137726], [-67002], [153911], [51526], [183344], [-51410], [-181008], [-58500], [78444], [110812], [220478], [184793], [38267], [25734], [-39978], [-220036], [189681], [-210471], [-186117], [142596], [76946], [-242474], [163947], [-66767], [-94827], [162798], [-203100], [-24256], [211185], [-110577], [-47664], [-27144], [-115827], [-38281], [-168107], [-65310], [127374], [209043], [229133], [106854], [-114436], [64633], [-171627], [97701], [197588], [260834], [-125914], [-150838], [249304], [195844], [184876], [-73886], [5266], [-136143], [-67709], [74010], [7348], [42426], [265999], [-179748], [-282070], [220645], [167110], [242293], [18153], [-16956], [185974], [160621], [129264], [-15191], [46041], [-154128], [51778], [-1517], [-60018], [-69400], [263171], [-120990], [-76424], [50036], [-102263], [-194822], [-32082], [-221646], [-51035], [-108960]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_1911_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


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