
// Make newform 1200.4.a.bi in Magma, downloaded from the LMFDB on 15 March 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_1200_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_1200_4_a_bi();".
// 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_1200_4_a_bi();".
// 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_1200_a();"
function MakeCharacter_1200_a()
    N := 1200;
    order := 1;
    char_gens := [751, 901, 401, 577];
    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_1200_a_Hecke( : Kf := Kf)
    return MakeCharacter_1200_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], [3], [0], [13], [-6], [5], [-78], [-65], [-138], [66], [-299], [-214], [360], [-203], [-78], [636], [-786], [467], [217], [360], [-286], [-272], [-498], [0], [-511], [-1812], [1708], [-1236], [-1543], [1884], [-2072], [2508], [1566], [196], [-1278], [-1385], [-481], [2815], [-1956], [2382], [-4386], [-2275], [-714], [1547], [438], [-437], [-1625], [-875], [4680], [1469], [3960], [-2652], [5753], [-3588], [-564], [-1248], [-7266], [-3224], [-151], [7566], [-1469], [-306], [-4661], [-2514], [6707], [4632], [988], [-9079], [5994], [-286], [-11466], [624], [-8477], [-11257], [1213], [11076], [-8016], [6851], [12636], [10829], [6252], [-15730], [10062], [707], [12493], [5928], [-2028], [17030], [-1044], [-9704], [4194], [12174], [1651], [6456], [559], [14208], [-8082], [20502], [-2069], [1553], [-12584], [20754], [-14370], [15774], [3055], [-25021], [18828], [19968], [-9684], [23243], [22984], [13754], [9468], [28099], [-14807], [20844], [-3692], [20004], [-17862], [-18552], [-12382], [-1690], [5682], [-31512], [-20648], [-11874], [-10699], [5598], [-22859], [-31642], [12220], [-17892], [16648], [31733], [-10068], [24323], [-2184], [37531], [28644], [-17316], [-425], [-25194], [33961], [1956], [-47302], [-30726], [-34489], [8484], [520], [6864], [-38857], [-10080], [34549], [18798], [-50276], [20502], [-37817], [-11778], [-18409], [-9330], [-49146], [-5928], [9520], [-12558], [-46206], [32676], [8137], [18578], [-15931], [37578], [2778], [-31753], [-52242], [56381], [-8861], [-7008], [-48809], [390], [-17555], [-31369], [-8183], [-25896], [32669], [-56598], [39930], [-51810], [13733], [871], [71597], [-40254], [7553], [-45552], [-43511], [2574], [42354], [28158], [-55978], [31790], [-20598], [77790], [624], [-28964], [-70126], [-64726], [19116], [-52638], [66859], [71202], [50076], [73177], [63011], [13650], [-12023], [-21132], [64866], [-11050], [69421], [-40614], [-65784], [-87282], [17057], [-76121], [-30], [17728], [-78840], [-32089], [-50454], [91962], [-99749], [4290], [-75847], [6460], [86935], [-95082], [17836], [80232], [-19870], [-39852], [6282], [-25572], [-41622], [19297], [6499], [95147], [-90138], [94518], [25135], [9354], [76345], [11406], [-44674], [-35598], [-30804], [25397], [49674], [-114348], [57617], [71188], [-15540], [29198], [-113303], [-48114], [43598], [15575], [13962], [38248], [47298], [77688], [48652], [119826], [58271], [95992], [-44278], [-104759], [-26935], [1369], [17862], [-118105], [54983], [108048], [-60672], [-63992], [-79638], [118547], [139627], [-30558], [51377], [-55488], [-40664], [157776], [39546], [-75036], [-3540], [39624], [-53821], [624], [40885], [88920], [28314], [-59852], [-15946], [-65676], [59233], [-21438], [-48476], [126581], [-47268], [97865], [-176436], [-93634], [23178], [-167700], [-161940], [161305], [24102], [-63103], [-52854], [95052], [-160855], [100014], [-12800], [176891], [50724], [13813], [-37134], [-48166], [7039], [-172241], [-32430], [-97176], [65969], [127062], [-31511], [-64890], [111007], [-139932], [12707], [-49212], [-106483], [74464], [-6253], [-14040], [-160758], [22963], [-42978], [-198138], [-61543], [-130793], [-202020], [-112884], [-38705], [58682], [-39234], [-166049], [-3385], [-137994], [140952], [132522], [-65190], [208494], [-169009], [61974], [208170], [-85488], [50380], [-7645], [-47736], [-122564], [-178105], [34620], [135481], [172218], [-59892], [-87752], [7085], [-121056], [-201318], [135599], [-141180], [-224515], [108654], [70278], [-123032], [-120696], [-164756], [213954], [114877], [-8962], [-11756], [-64206], [78221], [-66768], [158100], [-13079], [-64350], [-102439], [152845], [-197964], [-235247], [221052], [-34558], [-134220], [-73541], [-99060], [65676], [-83864], [-160459], [-164472], [-222209], [-146484], [119639], [255228], [67458], [127855], [66245], [-280020], [-96486], [30211], [152184], [39684], [-77496], [-148837], [23742], [-139998], [103502], [-50544], [239616], [-137748], [185185], [-20190]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_1200_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


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