
// Make newform 1200.4.a.v in Magma, downloaded from the LMFDB on 14 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_v();".
// 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_v();".
// 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], [-23], [30], [29], [78], [-149], [-150], [-234], [217], [146], [-156], [433], [-30], [-552], [270], [275], [-803], [-660], [-646], [-992], [846], [-1488], [-319], [-792], [-812], [1416], [-55], [1404], [-1280], [-480], [-282], [-1604], [-774], [-293], [-1729], [1123], [-1200], [-1734], [-2586], [-3931], [-1566], [2291], [2142], [4903], [-605], [145], [-2964], [-5635], [4164], [1944], [857], [3924], [-2844], [6060], [3906], [-2144], [2321], [-6822], [-4049], [2238], [-1385], [5670], [-421], [9984], [4228], [5393], [7914], [1010], [4722], [-6204], [-1361], [-913], [8881], [-5460], [-13884], [-3781], [9024], [14789], [-9840], [5510], [-11070], [-12133], [1873], [576], [-4884], [-15802], [-15360], [-1712], [16278], [14766], [3319], [-11064], [14131], [-11988], [10806], [22578], [-12065], [-12055], [-6176], [8274], [-966], [19002], [-8645], [10931], [-8904], [8820], [-9804], [-23437], [-2648], [794], [18720], [8959], [12373], [24900], [14668], [10788], [-14214], [588], [-3166], [9182], [11742], [6024], [-9344], [21234], [-1723], [-18510], [1009], [-21994], [13948], [26508], [1600], [30101], [35628], [-12517], [14124], [-40433], [-27300], [-2856], [12619], [-29082], [-10235], [-26976], [37802], [16974], [-24937], [15756], [-38144], [-5448], [21191], [18216], [-12767], [-11010], [-22772], [-29802], [-48941], [31026], [11183], [-2562], [-7638], [51432], [-39728], [47946], [-22326], [48468], [25141], [-35422], [-24907], [-9438], [-7962], [13679], [-4554], [-2155], [9511], [12552], [-24533], [-30078], [44881], [-15769], [37861], [-9768], [-39835], [-14262], [-25110], [-38274], [9821], [6379], [-55291], [-54186], [-32359], [-55644], [27013], [-21510], [-53682], [3582], [15950], [34238], [-36270], [71418], [27852], [67732], [15554], [-34414], [1500], [32550], [20695], [-37386], [31620], [133], [-80701], [-13998], [-67403], [1860], [4962], [-22354], [-51695], [22974], [-53172], [20802], [18905], [-39725], [3090], [-103736], [-20316], [-33217], [66582], [95490], [55015], [-9858], [-66271], [-37100], [18811], [112998], [36196], [43992], [94250], [-17808], [32778], [30408], [10398], [-109595], [-57281], [-22453], [-47658], [9702], [54571], [12246], [73477], [-48162], [116174], [-83394], [58644], [-29491], [-90258], [89652], [-10399], [-7076], [-68064], [20846], [-51755], [25506], [93278], [-18913], [30426], [-130736], [104970], [-85248], [-99668], [-130662], [-2569], [-65360], [-81142], [51325], [80873], [111469], [-11082], [106847], [-21457], [-87480], [109836], [89080], [-60714], [15635], [26647], [-54414], [116273], [22956], [-115472], [42684], [95010], [-19380], [-48012], [-48960], [40787], [25212], [112009], [129684], [102630], [-6716], [-144250], [-15804], [-15155], [-133014], [18052], [37997], [9636], [-57559], [149808], [41438], [80886], [-113916], [61596], [60061], [-21774], [-35191], [-117402], [-142164], [38825], [-91710], [-167384], [25931], [55056], [104833], [-83862], [-124558], [-58445], [-162773], [119406], [-29052], [127217], [-131322], [99637], [-55110], [-60893], [-10428], [15179], [51816], [-86131], [-102800], [7043], [-167796], [89598], [-2345], [86226], [-163266], [125153], [-44693], [140952], [129636], [-124925], [9290], [-54918], [-210869], [-67849], [33198], [169332], [71118], [158382], [6546], [-189985], [-30018], [152190], [229080], [61684], [-199669], [-129960], [210724], [-233089], [50604], [-8411], [132366], [-145452], [-65000], [115349], [2844], [88842], [-22777], [-5532], [-103747], [-183882], [99162], [-31736], [194964], [92428], [6666], [-94463], [18398], [225916], [126102], [-226387], [-10692], [-102888], [-127739], [-55374], [-104719], [-132383], [-252672], [87805], [133716], [167546], [91080], [260119], [167592], [-217440], [-169544], [109517], [-280236], [239443], [-246828], [-91441], [150828], [-291150], [-108389], [-249619], [104844], [243834], [182119], [41484], [-39552], [219168], [23723], [187134], [149898], [298334], [-114564], [-204612], [169896], [-226115], [89646]];
    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_v();".
// 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_v(: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_v();".
// 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_v( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_1200_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<7,R![23, 1]>,<11,R![-30, 1]>],Snew);
    return Vf;
end function;