
// Make newform 2450.4.a.bp in Magma, downloaded from the LMFDB on 22 September 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_2450_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_2450_4_a_bp();".
// 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_2450_4_a_bp();".
// 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_2450_a();"
function MakeCharacter_2450_a()
    N := 2450;
    order := 1;
    char_gens := [1177, 101];
    v := [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_2450_a_Hecke( : Kf := Kf)
    return MakeCharacter_2450_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 := [[2], [10], [0], [0], [9], [-52], [96], [10], [-75], [189], [232], [-305], [438], [-353], [-486], [354], [672], [-206], [-599], [-471], [614], [743], [996], [-180], [-184], [726], [-1798], [-876], [-691], [1521], [-1031], [1116], [1398], [-674], [-1281], [953], [650], [-932], [-180], [-834], [-648], [2914], [-876], [601], [2013], [-326], [-5956], [-3118], [-6], [586], [-1293], [-5376], [670], [-1380], [-3576], [5919], [1764], [340], [-4706], [6681], [-226], [4320], [-6604], [-6036], [9146], [4449], [-10081], [-7778], [-1017], [-10370], [-9432], [7557], [-11662], [2377], [4427], [4608], [-699], [-7630], [5601], [-4670], [-36], [5495], [2700], [15104], [-14948], [-4980], [12375], [-10835], [-5700], [-6128], [-9810], [204], [-15401], [3897], [8132], [-10998], [-5940], [-17022], [-15748], [-3373], [14389], [4929], [15678], [-14499], [-9457], [10370], [-12126], [1068], [3375], [27448], [3884], [3643], [-30369], [10888], [28499], [5817], [22376], [3018], [29682], [2052], [-14222], [-20942], [13074], [31383], [622], [7782], [7502], [20814], [14360], [-1588], [2957], [12384], [-20236], [-37601], [13392], [-22430], [34704], [37646], [-8988], [-28029], [-8078], [-35574], [-6599], [663], [22564], [294], [-28852], [-7422], [-8138], [32199], [11158], [-16272], [-9071], [-30138], [-25844], [40815], [-5389], [-43662], [-11950], [8448], [-25692], [-47547], [-51608], [11754], [-12765], [-32112], [-42505], [59654], [14411], [31212], [-213], [5014], [13383], [-42338], [35890], [-39948], [41735], [-24810], [-24640], [27484], [33775], [66144], [52891], [20730], [-44643], [3498], [-31571], [6446], [44417], [-22326], [-33922], [22545], [15437], [24954], [67611], [-7974], [49949], [-63857], [12426], [58032], [-11670], [-63770], [-3508], [19978], [11826], [-26418], [-24134], [18912], [-70089], [2578], [-72629], [-20916], [-14993], [-20064], [5466], [-2864], [-26993], [-18282], [66753], [-42045], [-84499], [-59900], [24435], [59533], [-30360], [69878], [75786], [-22449], [-35224], [34185], [-76565], [80764], [44732], [-67269], [-70552], [-44196], [112150], [66093], [-6471], [-18720], [86529], [-70508], [-35356], [-63541], [-33168], [-42840], [24446], [12270], [-100480], [-98088], [31678], [-69078], [111288], [-46508], [122190], [16116], [58277], [64076], [101382], [-14614], [110764], [-14769], [-6068], [44048], [-41106], [41008], [11643], [99354], [12391], [103767], [-32564], [129004], [-89212], [-5953], [9140], [29492], [21831], [66746], [-57241], [-47544], [39042], [149792], [-56436], [-122612], [28502], [-17727], [-63263], [89025], [63124], [-95202], [28707], [-33900], [84999], [134070], [121153], [-69768], [71026], [113508], [24942], [4406], [-84166], [-102486], [-34477], [-29505], [-114553], [-48926], [15513], [-17132], [-15789], [-18818], [70254], [-38802], [167181], [-119948], [-131619], [71080], [96042], [-13152], [47474], [191685], [34720], [141190], [99510], [-50615], [61893], [161452], [111251], [38606], [-107331], [47487], [-179158], [42315], [-35066], [-175476], [-138364], [-8394], [-162307], [-47928], [85300], [-98494], [-211106], [31731], [169290], [121115], [188631], [69717], [209650], [-66341], [-34530], [184542], [-98426], [87793], [41058], [21590], [73355], [-20274], [24156], [164178], [-96270], [216972], [127237], [52272], [-47976], [-50343], [107150], [113182], [220302], [-48713], [170435], [-223875], [97576], [37065], [-187890], [19252], [-176375], [-11496], [32865], [-30760], [92454], [1706], [-143430], [213237], [118969], [-186723], [-168698], [74412], [-73687], [-34036], [-38717], [-169386], [227681], [259656], [-87351], [125054], [57645], [143695], [-81932], [-204408], [-33748], [10965], [-116588], [-154551], [-176675], [241092], [-169974], [191764], [-1751], [133350], [1850], [201792], [67172], [-238905], [13428], [-155701], [102427], [-31170], [-247656], [54998], [-46740], [-89304], [249774], [210422], [-169056], [-211140], [7508], [-188682], [-54141], [128070], [169300], [254346]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_2450_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_2450_4_a_bp();".
// 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_2450_4_a_bp(:prec:=1)
    chi := MakeCharacter_2450_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_2450_4_a_bp();".
// 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_2450_4_a_bp( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_2450_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<3,R![-10, 1]>,<11,R![-9, 1]>,<19,R![-10, 1]>,<23,R![75, 1]>],Snew);
    return Vf;
end function;