
// Make newform 1456.4.a.b in Magma, downloaded from the LMFDB on 04 March 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_1456_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_1456_4_a_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_1456_4_a_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
        Kf := Rationals();
    end if;
    return [Kf!elt[1] : elt in input];
end function;


// To make the character of type GrpDrchElt, type "MakeCharacter_1456_a();"
function MakeCharacter_1456_a()
    N := 1456;
    order := 1;
    char_gens := [911, 1093, 1249, 561];
    v := [1, 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_1456_a_Hecke( : Kf := Kf)
    return MakeCharacter_1456_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 := [[0], [-7], [0], [-7], [-39], [13], [24], [-38], [-39], [-96], [-227], [425], [-105], [-344], [-99], [-540], [-114], [-565], [385], [156], [-673], [-749], [1044], [-690], [317], [-663], [646], [744], [218], [-1623], [-659], [216], [1842], [628], [321], [1600], [1127], [1204], [600], [-2154], [2850], [4205], [4152], [-3148], [1173], [-3512], [3418], [-4241], [-888], [4700], [6363], [3078], [3674], [345], [6888], [1248], [-2253], [-1397], [-2302], [8532], [3769], [-6150], [-4592], [-6498], [5762], [2565], [745], [8345], [1776], [-8602], [-6477], [-7920], [-3404], [10604], [11680], [-8133], [2556], [12620], [2064], [-5974], [-12459], [-2221], [15162], [-10978], [3274], [-3888], [-11262], [-9718], [-13656], [-12008], [-2268], [10536], [-12566], [12444], [6091], [-9204], [21522], [-12474], [-16607], [-19690], [19960], [19137], [-6711], [-5595], [21274], [-15694], [-21054], [-17910], [-3213], [15158], [26206], [-6145], [9474], [14326], [15478], [17439], [-30296], [17124], [27120], [138], [29720], [-32929], [33021], [-18519], [-15248], [-7740], [29747], [-10266], [8026], [13268], [8080], [27096], [-25067], [-6442], [26511], [-17665], [36258], [-21296], [-28947], [-20418], [14524], [-7710], [-2531], [-24516], [-15586], [24915], [-20500], [26694], [-20801], [37404], [-20581], [-34314], [12058], [-20406], [2914], [1044], [-20693], [-52653], [34868], [25542], [672], [52278], [-758], [-27285], [18786], [-37152], [17143], [-14137], [560], [14778], [23220], [12062], [58773], [-7540], [22642], [43332], [-32321], [-5310], [-34940], [19433], [-5654], [45387], [36326], [-29007], [38940], [-1650], [25904], [880], [8012], [-69063], [-29284], [11397], [-34886], [60798], [-38094], [-5658], [-58768], [-79846], [44334], [63360], [-14493], [-48368], [40376], [7202], [70782], [-34170], [23092], [-5694], [-9222], [-44111], [2117], [38367], [27835], [1344], [37155], [16967], [-28307], [12084], [71574], [61263], [36074], [-8039], [29340], [-75242], [23271], [-54340], [-14928], [63939], [-25328], [-53397], [11108], [105316], [-89192], [112131], [-22457], [-351], [63281], [-3219], [-99168], [95316], [16251], [-58637], [58264], [112070], [915], [94446], [-40331], [-100254], [-66359], [3003], [-120121], [-31146], [-111222], [-21814], [17829], [44256], [38990], [-63758], [-83889], [98453], [96208], [-106302], [99506], [-63493], [-5169], [137968], [-74829], [-65277], [-50321], [-13908], [-33685], [16243], [-135745], [-99344], [6482], [-120296], [-33972], [-116287], [34004], [-29652], [90006], [77218], [57942], [-7810], [-46316], [-48663], [72425], [-52650], [-80921], [59820], [10866], [124149], [-65958], [120018], [-84202], [87822], [130012], [-104847], [19995], [-144074], [-54934], [60489], [-83144], [-18828], [-8012], [-35656], [55854], [-14398], [26754], [50168], [-7314], [45102], [-100539], [-69698], [163722], [-160504], [-66948], [-86274], [3458], [109641], [-148925], [-34252], [40263], [95038], [135918], [-121678], [-131987], [-159572], [143376], [56622], [-19285], [46800], [87262], [-146940], [71719], [-55314], [-174706], [189777], [-13678], [-64694], [-93022], [198717], [129150], [140299], [139479], [-78228], [-151846], [10204], [-73641], [-117525], [-60338], [12620], [28299], [227482], [-107422], [-79308], [-73653], [61914], [143307], [-134244], [183386], [-177594], [88557], [175029], [-202079], [140591], [-133572], [-6518], [55433], [12702], [-119945], [-224874], [224280], [146968], [-30364], [-64584], [234687], [-189349], [69432], [176420], [-78804], [62988], [119932], [7344], [13084], [20328], [42982], [13709], [116692], [-210336], [-216574], [-130902], [76311], [165364], [534], [-159901], [-162929], [-92232], [108034], [-135150], [172712], [-279474], [-100244], [-39807], [79980], [-81740], [61445], [193308], [154168], [-28056], [-5434], [-275604], [29406], [127276], [260651], [257958], [150762], [-58232], [116463], [82290], [198066], [-10510], [-288876], [-232524], [202538], [215952], [-160578], [138024], [-245810], [240150]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_1456_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_1456_4_a_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_1456_4_a_b(:prec:=1)
    chi := MakeCharacter_1456_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_1456_4_a_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_1456_4_a_b( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_1456_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<3,R![7, 1]>,<5,R![0, 1]>],Snew);
    return Vf;
end function;