
// Make newform 2450.4.a.z in Magma, downloaded from the LMFDB on 28 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_z();".
// 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_z();".
// 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], [-4], [0], [0], [30], [4], [-9], [-88], [-33], [126], [155], [-116], [-423], [340], [-339], [312], [-462], [326], [-704], [621], [250], [-1105], [198], [-873], [-905], [600], [-293], [1686], [1640], [1185], [-1976], [-1530], [1587], [-2242], [-1470], [-664], [1966], [3016], [-1608], [-2514], [-1614], [-2770], [-4635], [475], [-4896], [-2797], [2612], [-3629], [414], [-1570], [-5262], [4305], [-982], [4080], [-846], [3273], [-7140], [5681], [-2102], [-6297], [-8906], [4782], [9412], [-7569], [8719], [-3216], [-4306], [-3179], [-4818], [-9376], [-10083], [-276], [6244], [-416], [12302], [6393], [4068], [14686], [-3702], [-8443], [-13140], [-9604], [327], [5983], [-14563], [-15564], [4017], [14974], [8076], [-14045], [7662], [-6033], [-7337], [13032], [-7786], [-12720], [5190], [-18303], [8962], [10340], [-4196], [-11178], [15048], [-7107], [-4060], [16558], [9546], [-11259], [-14181], [-3562], [18955], [3454], [20745], [17930], [-5689], [23205], [18190], [-11388], [-23364], [7890], [2774], [10075], [-6414], [13890], [-15730], [-12336], [-22486], [7815], [20737], [10102], [14612], [21981], [22184], [12148], [29205], [5906], [26136], [2212], [24654], [-36870], [5096], [12768], [4300], [-1374], [-32134], [-10227], [-9560], [-3558], [1550], [15777], [-20258], [43347], [-1658], [14928], [6370], [30273], [45389], [35298], [-52382], [28944], [-25776], [-31062], [-44951], [46950], [24867], [-3720], [44939], [-20132], [-19987], [29868], [5142], [39356], [1560], [-9179], [63365], [52431], [-9358], [-30858], [58156], [-11590], [-18956], [-17562], [-63470], [-11190], [-13647], [68850], [-26510], [11878], [72389], [-17496], [19474], [-10572], [21590], [-20154], [22062], [-67194], [-37642], [-18686], [-29406], [-11856], [-33972], [-68047], [-45578], [-75229], [59706], [-87108], [-18751], [4338], [45411], [56366], [-81449], [11424], [9031], [33528], [65001], [-39775], [-50639], [-89934], [-45240], [-24], [-7954], [-34651], [-62295], [-52985], [11262], [28676], [-42759], [60543], [-32879], [21480], [83728], [34886], [45803], [75867], [61048], [80859], [67154], [10338], [24168], [17463], [-27228], [-78838], [83560], [-33070], [-65067], [64239], [-63803], [-56022], [-15640], [106725], [81028], [-36402], [-65343], [8246], [54276], [-516], [-106972], [84964], [-56034], [31579], [-11792], [-35958], [15926], [-12512], [25191], [34358], [-54150], [3510], [7414], [32598], [-17794], [-67934], [-18239], [-21031], [-80894], [-109703], [68178], [121934], [68675], [-10710], [-117723], [-71023], [104571], [6230], [-13064], [-73629], [-44069], [90726], [-120640], [-1185], [2520], [134016], [-102615], [-116544], [57880], [-13194], [-149992], [-145716], [122592], [-13304], [75427], [-73338], [-120955], [-65982], [112688], [-6905], [92562], [-137560], [81672], [-107186], [95979], [175986], [70770], [-6674], [5175], [-188746], [-9714], [176457], [-48083], [150735], [-58030], [-50834], [-107970], [3208], [-109761], [165806], [-158452], [71380], [19383], [17814], [135632], [-178542], [54947], [-88788], [-160918], [159102], [157502], [-165423], [-153106], [-105263], [66598], [-51933], [15864], [136088], [-164610], [-74700], [-57862], [164722], [176520], [-59688], [-133930], [-69329], [-88638], [-148139], [29738], [-37851], [44337], [-185808], [146679], [-89040], [-184802], [144966], [46083], [68916], [26944], [20026], [-175758], [66031], [195194], [-62406], [-2860], [123543], [-85200], [-163399], [179134], [-78024], [127512], [69865], [-32979], [-138749], [146496], [168990], [-133472], [245646], [200720], [52299], [-130303], [-220502], [-64274], [145803], [108023], [-208812], [-145416], [-139238], [-98763], [-44633], [1340], [-159006], [64784], [192720], [-152890], [-22398], [142063], [264570], [111384], [163757], [-87494], [-154959], [148696], [-5688], [-3458], [-220362], [211668], [-297094], [12589], [-35706], [-1704], [-8849], [-309], [78024], [56490], [-133796], [186684], [315288], [207295], [-296790], [183180], [222654], [-78976], [-6621]];
    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_z();".
// 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_z(: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_z();".
// 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_z( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_2450_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<3,R![4, 1]>,<11,R![-30, 1]>,<19,R![88, 1]>,<23,R![33, 1]>],Snew);
    return Vf;
end function;