
// Make newform 1600.4.a.cg in Magma, downloaded from the LMFDB on 23 February 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_1600_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_1600_4_a_cg();".
// 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_1600_4_a_cg();".
// 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
        poly := [-1, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0], [-2, 4]];
    Rf_basisdens := [1, 1];
    Rf_basisnums := ChangeUniverse([[z : z in elt] : elt in Rf_num], Kf);
    Rfbasis := [Rf_basisnums[i]/Rf_basisdens[i] : i in [1..Degree(Kf)]];
    inp_vec := Vector(Rfbasis)*ChangeRing(Transpose(Matrix([[elt : elt in row] : row in input])),Kf);
    return Eltseq(inp_vec);
end function;


// To make the character of type GrpDrchElt, type "MakeCharacter_1600_a();"
function MakeCharacter_1600_a()
    N := 1600;
    order := 1;
    char_gens := [1151, 901, 577];
    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_1600_a_Hecke( : Kf := Kf)
    return MakeCharacter_1600_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, 0], [0, -1], [0, 0], [0, -7], [0, -2], [-62, 0], [46, 0], [0, 24], [0, 43], [90, 0], [0, 34], [-214, 0], [-10, 0], [0, 15], [0, 89], [-678, 0], [0, -92], [-250, 0], [0, -11], [0, 82], [-522, 0], [0, -196], [0, -85], [970, 0], [934, 0], [602, 0], [0, -409], [0, 341], [-2154, 0], [2182, 0], [0, 293], [0, -46], [2094, 0], [0, -308], [334, 0], [0, -702], [834, 0], [0, 691], [0, 1], [-1838, 0], [0, 412], [-1862, 0], [0, 462], [-3378, 0], [66, 0], [0, 272], [0, -1182], [0, 663], [0, 977], [3250, 0], [-3298, 0], [0, 124], [5150, 0], [0, 310], [4166, 0], [0, 215], [1494, 0], [0, -1122], [-1006, 0], [-3210, 0], [0, -813], [-3622, 0], [0, -467], [0, 1990], [-8778, 0], [-5046, 0], [0, -70], [2574, 0], [0, -591], [10170, 0], [318, 0], [0, -2768], [0, -687], [-3278, 0], [0, 1144], [0, -257], [-834, 0], [-8734, 0], [242, 0], [-6514, 0], [0, 3596], [-7250, 0], [0, -1114], [-11482, 0], [0, -848], [0, 167], [-1306, 0], [9526, 0], [-1518, 0], [0, 3867], [0, 3797], [0, -852], [0, 293], [0, 662], [0, -4320], [0, 687], [-18550, 0], [-2102, 0], [0, -3957], [9922, 0], [0, -831], [-15094, 0], [0, -1265], [-5906, 0], [0, -1094], [13286, 0], [0, -2019], [-11442, 0], [0, 3164], [3110, 0], [0, -2503], [-5342, 0], [-19714, 0], [0, -2944], [0, -2742], [-2690, 0], [0, -2737], [0, -4019], [-3478, 0], [0, -2364], [110, 0], [14278, 0], [18386, 0], [0, -3425], [0, 2126], [15830, 0], [20050, 0], [0, -4724], [0, -2535], [-17198, 0], [0, 1028], [0, -541], [0, -1662], [11474, 0], [31802, 0], [-5310, 0], [37938, 0], [0, -8415], [-17526, 0], [8970, 0], [0, -794], [15550, 0], [0, -5973], [0, 193], [-19066, 0], [0, 10676], [-14462, 0], [-29346, 0], [0, 5100], [0, 5535], [-32126, 0], [-33570, 0], [0, 1439], [0, -10471], [0, -2679], [0, 5410], [0, 8388], [-21994, 0], [16286, 0], [-24302, 0], [0, -4443], [22422, 0], [0, 9789], [0, -5750], [-28986, 0], [0, 7183], [0, 2682], [-406, 0], [5810, 0], [-28302, 0], [0, -12424], [-26382, 0], [0, 1390], [-3322, 0], [0, -8816], [-45990, 0], [0, -6006], [68858, 0], [0, 5211], [-15626, 0], [0, 3417], [0, 3914], [46042, 0], [-59946, 0], [0, -11073], [33810, 0], [32506, 0], [0, -5697], [-55346, 0], [0, 10274], [-68378, 0], [0, 8951], [0, 4054], [-38970, 0], [0, -7687], [-60018, 0], [49310, 0], [-43478, 0], [7454, 0], [0, 2031], [23770, 0], [0, -8226], [25754, 0], [11410, 0], [0, 15844], [-23646, 0], [0, 6840], [0, 8791], [-25110, 0], [0, -4030], [90366, 0], [16830, 0], [0, -2513], [0, -14107], [0, 14588], [-15930, 0], [0, -13419], [-40062, 0], [0, -12775], [-18622, 0], [2270, 0], [0, -6796], [-91630, 0], [0, 23331], [0, 18761], [27886, 0], [57798, 0], [0, -5704], [0, -1827], [0, -17814], [-107582, 0], [0, 13432], [0, 7910], [-16890, 0], [0, -5749], [0, 8861], [1414, 0], [-92358, 0], [0, -16896], [0, 806], [0, 20451], [0, -13722], [0, -13205], [25690, 0], [7758, 0], [0, 8296], [0, -6323], [0, -4394], [0, -13548], [0, -13397], [2866, 0], [29202, 0], [0, 725], [-6194, 0], [29282, 0], [0, 24704], [-85638, 0], [0, -14439], [-36606, 0], [32726, 0], [0, 24335], [0, -20103], [-58030, 0], [13418, 0], [-42034, 0], [0, 8976], [-110230, 0], [-95862, 0], [0, -7113], [12858, 0], [60898, 0], [0, 8581], [88702, 0], [0, -2288], [-27514, 0], [0, -2037], [0, 19377], [100010, 0], [64630, 0], [0, 4394], [0, 15047], [0, -22402], [0, 23029], [82858, 0], [0, 16949], [0, 20162], [-87218, 0], [2946, 0], [0, 13428], [-34874, 0], [116870, 0], [0, 19929], [26518, 0], [0, 12686], [-123678, 0], [-314, 0], [0, -19438], [99658, 0], [0, -1440], [0, -11787], [-82322, 0], [-128766, 0], [0, 13204], [0, 39671], [0, 15462], [-150826, 0], [0, -25343], [133290, 0], [0, 14968], [164298, 0], [0, 1695], [12130, 0], [106482, 0], [0, -1481], [0, -10327], [-32230, 0], [0, 4392], [0, 29066], [-4698, 0], [-97274, 0], [0, -18690], [73054, 0], [-140730, 0], [0, -25221], [42958, 0], [149870, 0], [0, 9648], [0, 11519], [0, -32263], [202842, 0], [14470, 0], [50514, 0], [0, -10812], [0, -17189], [0, 27694], [0, 34173], [-93594, 0], [-144778, 0], [-99290, 0], [0, -31155], [51418, 0], [48646, 0], [39294, 0], [0, -7030], [70938, 0], [0, 2112], [92990, 0], [0, 30849], [0, -45934], [-153054, 0], [0, 43746], [-109354, 0], [115350, 0], [0, -34925], [98370, 0], [48198, 0], [0, -7180], [0, -48654], [54214, 0], [0, 15251], [143354, 0], [-72982, 0], [0, 28897], [0, -2236], [0, -42199], [-101058, 0], [242226, 0], [0, -12961], [151910, 0], [0, -14622], [0, -4512], [0, -6197], [-144626, 0], [0, 10530], [139026, 0], [0, -15696], [0, -35246], [-156402, 0], [14214, 0], [-106866, 0], [-129582, 0], [-48002, 0], [0, 24261], [133614, 0], [0, 30696], [0, -50765], [0, -36370], [97946, 0], [0, 21543], [0, 8985], [79014, 0], [79042, 0], [0, 35628], [0, 35213], [0, -56670], [-230002, 0], [0, -34788], [77130, 0], [0, -16386], [-205170, 0], [227686, 0], [-31138, 0], [0, 5105], [33294, 0], [-130914, 0], [0, 8178], [105754, 0], [-241822, 0], [0, -64629], [0, 40196], [92798, 0], [-103974, 0], [0, 55811], [0, 1234], [18534, 0], [157842, 0], [0, 22360], [0, -1991], [-64186, 0], [0, -34005], [-137626, 0], [-71454, 0], [0, -35863], [0, 27660], [77542, 0], [-293806, 0], [0, -60729], [-135234, 0], [0, -134], [0, -57800]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_1600_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_1600_4_a_cg();".
// 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_1600_4_a_cg(:prec:=2)
    chi := MakeCharacter_1600_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_1600_4_a_cg();".
// 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_1600_4_a_cg( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_1600_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<3,R![-20, 0, 1]>,<7,R![-980, 0, 1]>,<11,R![-80, 0, 1]>,<13,R![62, 1]>],Snew);
    return Vf;
end function;