
// Make newform 1050.4.a.o in Magma, downloaded from the LMFDB on 30 September 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_1050_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_1050_4_a_o();".
// 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_1050_4_a_o();".
// 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_1050_a();"
function MakeCharacter_1050_a()
    N := 1050;
    order := 1;
    char_gens := [701, 127, 451];
    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_1050_a_Hecke( : Kf := Kf)
    return MakeCharacter_1050_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], [-3], [0], [7], [3], [-4], [-54], [-148], [-15], [-69], [146], [-19], [-24], [29], [228], [174], [-732], [-220], [11], [-429], [-910], [-889], [78], [-960], [-550], [-330], [-1300], [1356], [341], [-1467], [719], [-1170], [-18], [-838], [513], [293], [2660], [1220], [-1176], [4272], [12], [-1258], [-2196], [-4705], [2373], [2456], [-748], [-178], [3624], [-1906], [3603], [-4848], [-760], [-5310], [-1590], [6183], [-5334], [5312], [3674], [867], [-4498], [192], [3926], [6342], [-2500], [381], [11315], [7274], [303], [812], [-2670], [8811], [3836], [-2497], [-11917], [5460], [6279], [-12526], [4503], [-10720], [-5142], [9635], [15624], [-13552], [-7516], [8268], [165], [-13261], [3648], [-3436], [-5058], [11172], [-6883], [7863], [16988], [3342], [12588], [-4746], [-376], [-637], [-3625], [-9843], [16806], [-11853], [13331], [1856], [-18882], [15684], [12741], [3788], [-18472], [-1879], [15519], [5528], [6107], [18135], [-11500], [28482], [-10782], [-324], [13400], [-7054], [-14790], [26679], [-16924], [10410], [-13042], [34680], [-10678], [-18100], [17765], [30648], [-33016], [20597], [-29844], [6392], [-7986], [15782], [-7830], [1929], [-35026], [13554], [2843], [46083], [974], [19986], [-38500], [4140], [22106], [-18081], [-49066], [-40326], [-11389], [16092], [28712], [5481], [-47221], [45678], [-25612], [16974], [-57636], [-19419], [47912], [-10656], [-23481], [6906], [-49165], [21404], [-62593], [-35178], [-45927], [-21268], [-31515], [-6478], [31442], [17898], [13907], [64302], [-23860], [56666], [-26971], [-39732], [-763], [-45546], [-67587], [32874], [40115], [64010], [-17539], [-56430], [-44338], [42345], [-36187], [-15966], [-41061], [-24468], [-33055], [19685], [-63396], [67578], [-85866], [-25162], [-23254], [46172], [16056], [1068], [72134], [-20364], [-57315], [61808], [-5923], [82890], [48593], [46716], [-77166], [83246], [47273], [56700], [-94239], [68487], [-46699], [63914], [-87495], [77699], [-49116], [7406], [-47862], [33309], [-31354], [-51093], [76817], [11954], [21152], [-20751], [101348], [-36798], [-35044], [25257], [-39609], [-24468], [36825], [-103948], [69722], [93575], [82824], [29766], [34166], [109062], [44696], [86904], [-62422], [2208], [106488], [27434], [-96528], [-56652], [-67687], [-75754], [-48660], [-62116], [-23584], [27591], [-10606], [19334], [57750], [-50896], [14649], [56058], [-37051], [-80073], [-11644], [57044], [99368], [67079], [-82510], [-13558], [-23865], [-33370], [38207], [-121410], [18006], [-91720], [-82836], [25634], [110270], [-92997], [-110569], [100473], [89204], [-61530], [-39795], [101814], [14391], [42426], [-120649], [58278], [128396], [-82044], [-23364], [53246], [-21886], [123126], [-21145], [85263], [49103], [87002], [-71379], [-120160], [-95787], [32330], [50322], [124938], [11667], [-67420], [-171111], [-43738], [714], [-167508], [30476], [6135], [126134], [-158902], [-73116], [23735], [-91155], [-14338], [-154933], [-45886], [57441], [-17469], [71282], [178515], [-153394], [-143418], [-51208], [95568], [-109363], [110688], [-147940], [-75598], [-55294], [-38337], [47424], [-68605], [-212457], [-76809], [103802], [-140107], [-155736], [42054], [82586], [75719], [-182826], [-155332], [-168433], [-18744], [-52710], [-85110], [171186], [82752], [-121609], [-178650], [-134436], [37527], [-96532], [208838], [8442], [-16387], [-190189], [-15129], [-59470], [1317], [219198], [48566], [-51829], [11940], [15339], [126350], [168972], [6902], [-214770], [-72603], [-223981], [-161271], [-151234], [-142824], [24305], [-214054], [53957], [-83664], [101765], [20658], [52695], [198854], [-144045], [11309], [243824], [259488], [-9892], [245487], [193088], [121605], [-87001], [220260], [30588], [194756], [-264241], [-32670], [80624], [-173790], [44552], [-208905], [-26376], [251147], [70085], [128868], [-274128], [-285574], [-192684], [138486], [112842], [-140254], [-183504], [-152472], [-72718], [167190], [166299], [37038], [310958], [167886]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_1050_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_1050_4_a_o();".
// 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_1050_4_a_o(:prec:=1)
    chi := MakeCharacter_1050_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_1050_4_a_o();".
// 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_1050_4_a_o( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_1050_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<11,R![-3, 1]>,<13,R![4, 1]>],Snew);
    return Vf;
end function;