
// Make newform 1600.4.a.cw in Magma, downloaded from the LMFDB on 15 May 2024.
// 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_cw();".
// 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_cw();".
// 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 := [-6, 25, -24, -2, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0], [-1, 2, 0, 0], [-50, -4, 4, 0], [101, -198, -12, 8]];
    Rf_basisdens := [1, 1, 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)
    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+1)]];
    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, 0], [0, 1, 0, 0], [0, 0, 0, 0], [0, -1, 0, 1], [0, -4, 0, -3], [-18, 0, -1, 0], [-15, 0, -1, 0], [0, 5, 0, 2], [0, -16, 0, 6], [18, 0, 3, 0], [0, 16, 0, -10], [-232, 0, -3, 0], [181, 0, -4, 0], [0, -13, 0, 11], [0, -31, 0, -11], [222, 0, 0, 0], [0, -53, 0, -25], [-444, 0, 1, 0], [0, 46, 0, -25], [0, 1, 0, 29], [-265, 0, 17, 0], [0, -107, 0, -9], [0, -114, 0, -37], [225, 0, 5, 0], [-126, 0, -10, 0], [-508, 0, 15, 0], [0, -5, 0, 63], [0, -70, 0, 73], [-676, 0, 23, 0], [-1471, 0, -8, 0], [0, 214, 0, 96], [0, -111, 0, -31], [31, 0, 22, 0], [0, 32, 0, -63], [-1378, 0, 13, 0], [0, 277, 0, -5], [-2170, 0, 26, 0], [0, 60, 0, 133], [0, 115, 0, -97], [-1616, 0, -48, 0], [0, 307, 0, -28], [342, 0, -16, 0], [0, 218, 0, -100], [-7, 0, 11, 0], [-1958, 0, 46, 0], [0, -56, 0, -12], [0, -362, 0, 133], [0, 558, 0, 258], [0, -117, 0, -85], [-2848, 0, 22, 0], [-974, 0, 44, 0], [0, -63, 0, -287], [1043, 0, -27, 0], [0, 421, 0, -232], [-1586, 0, 98, 0], [0, -248, 0, -234], [2068, 0, 34, 0], [0, 238, 0, 268], [2842, 0, 83, 0], [-2030, 0, 70, 0], [0, -593, 0, 52], [524, 0, 81, 0], [0, -699, 0, 412], [0, 655, 0, -295], [682, 0, -50, 0], [-2148, 0, -12, 0], [0, 524, 0, 337], [-4435, 0, 116, 0], [0, -338, 0, 133], [-4412, 0, -137, 0], [2054, 0, -94, 0], [0, 221, 0, -321], [0, 888, 0, -492], [-5922, 0, -154, 0], [0, -849, 0, 190], [0, 737, 0, 15], [4266, 0, 60, 0], [1132, 0, -124, 0], [-5733, 0, -65, 0], [3497, 0, -114, 0], [0, -67, 0, -698], [2856, 0, -94, 0], [0, 889, 0, 315], [13053, 0, -35, 0], [0, 201, 0, -671], [0, -1479, 0, 194], [-7821, 0, -95, 0], [-3149, 0, 30, 0], [-4652, 0, -44, 0], [0, -1202, 0, -230], [0, 725, 0, -59], [0, -1244, 0, 502], [0, 1546, 0, -348], [0, -577, 0, 295], [0, 1445, 0, 845], [0, 578, 0, 590], [4502, 0, -348, 0], [-8851, 0, -44, 0], [0, -1808, 0, 595], [-14464, 0, 124, 0], [0, 1805, 0, 452], [-2846, 0, 173, 0], [0, -617, 0, -421], [11665, 0, 36, 0], [0, 225, 0, -287], [309, 0, -272, 0], [0, 1959, 0, 840], [-9819, 0, -222, 0], [0, 1303, 0, 441], [2361, 0, -89, 0], [0, 1384, 0, 528], [12838, 0, -180, 0], [18658, 0, 152, 0], [0, 2827, 0, -21], [0, 2972, 0, 890], [-2850, 0, -370, 0], [0, -631, 0, -359], [0, -210, 0, 178], [-8940, 0, -227, 0], [0, -2566, 0, 245], [-7486, 0, 279, 0], [9422, 0, -356, 0], [-1100, 0, -466, 0], [0, 1930, 0, -1195], [0, 1695, 0, 1088], [-28594, 0, -9, 0], [-26088, 0, -118, 0], [0, 1727, 0, -771], [0, -2819, 0, -1307], [-12458, 0, 195, 0], [0, -357, 0, -157], [0, -820, 0, 562], [0, 37, 0, -875], [11472, 0, 28, 0], [-2771, 0, 512, 0], [24431, 0, 341, 0], [21950, 0, -223, 0], [0, 1627, 0, 691], [-17278, 0, 68, 0], [4774, 0, -386, 0], [0, 2401, 0, -799], [5330, 0, 130, 0], [0, 406, 0, -446], [0, -1781, 0, -4], [-19514, 0, -193, 0], [0, -2002, 0, 1222], [7766, 0, 178, 0], [7283, 0, -196, 0], [0, -1964, 0, -1547], [0, -4175, 0, -455], [26044, 0, -360, 0], [-4734, 0, 246, 0], [0, 4101, 0, 980], [0, -996, 0, -856], [0, 2739, 0, -285], [0, -2064, 0, -212], [0, -586, 0, 296], [-9050, 0, 164, 0], [-34637, 0, -193, 0], [1110, 0, 647, 0], [0, 3415, 0, -29], [-27033, 0, 60, 0], [0, -2720, 0, 232], [0, -2020, 0, 885], [825, 0, 801, 0], [0, -1791, 0, 31], [0, 5567, 0, 617], [35272, 0, -382, 0], [14859, 0, 739, 0], [-14742, 0, -45, 0], [0, 679, 0, 2310], [-380, 0, -623, 0], [0, -1235, 0, 455], [27127, 0, -211, 0], [0, 2681, 0, 345], [8037, 0, 567, 0], [0, 3981, 0, 2280], [13060, 0, -733, 0], [0, -4930, 0, -202], [-34646, 0, -450, 0], [0, 3838, 0, -1070], [0, -3411, 0, -106], [6208, 0, -609, 0], [-19989, 0, -123, 0], [0, -7155, 0, -1839], [-440, 0, 190, 0], [7760, 0, -11, 0], [0, -1709, 0, 742], [20629, 0, -270, 0], [0, -6055, 0, 1417], [68161, 0, -96, 0], [0, 3501, 0, 1826], [0, -1706, 0, -451], [3410, 0, -220, 0], [0, 4065, 0, 404], [-61346, 0, -68, 0], [12979, 0, -256, 0], [-55186, 0, -218, 0], [-7175, 0, 1046, 0], [0, -2821, 0, 3185], [53610, 0, -370, 0], [0, 336, 0, -2700], [10864, 0, 140, 0], [-19637, 0, -1272, 0], [0, -7505, 0, 2207], [-28530, 0, -474, 0], [0, -1120, 0, -1690], [0, -3345, 0, -3977], [-17762, 0, 88, 0], [0, 8391, 0, -877], [-10202, 0, 292, 0], [41976, 0, -69, 0], [0, 2939, 0, 3243], [0, 1622, 0, 2665], [0, 348, 0, -1342], [42725, 0, 290, 0], [0, 3226, 0, -644], [36879, 0, 261, 0], [0, -6793, 0, -1379], [-19732, 0, 75, 0], [-16782, 0, -92, 0], [0, 6003, 0, -3649], [6043, 0, 473, 0], [0, 2545, 0, 1063], [0, -8405, 0, -4662], [-66692, 0, -93, 0], [-16297, 0, 995, 0], [0, -1651, 0, 1885], [0, -1805, 0, -1721], [0, -4779, 0, 1116], [15572, 0, 1279, 0], [0, -4372, 0, 375], [0, -6609, 0, 1253], [-46391, 0, -1211, 0], [0, -359, 0, 2781], [0, -5895, 0, 983], [9647, 0, 613, 0], [-10498, 0, -535, 0], [0, 3115, 0, -4658], [0, 4334, 0, 850], [0, -2885, 0, 3058], [0, -6071, 0, -104], [0, -2794, 0, -4872], [-21040, 0, 1390, 0], [-72499, 0, -652, 0], [0, 9338, 0, 1962], [0, -2613, 0, -2423], [0, -6969, 0, 5431], [0, 8679, 0, 2838], [0, 4161, 0, 937], [-59332, 0, 1222, 0], [-13781, 0, -1928, 0], [0, -2389, 0, -1967], [24681, 0, 815, 0], [-13898, 0, 425, 0], [0, 4274, 0, -611], [30770, 0, 503, 0], [0, -863, 0, 1474], [-18084, 0, -453, 0], [29351, 0, -990, 0], [0, -6977, 0, -651], [0, 4764, 0, 4773], [-79590, 0, -965, 0], [64886, 0, -417, 0], [-41771, 0, -1867, 0], [0, -3425, 0, 928], [44766, 0, -674, 0], [20922, 0, -6, 0], [0, 2570, 0, -6139], [-62392, 0, 65, 0], [-202, 0, 2455, 0], [0, -7486, 0, -2145], [82435, 0, 333, 0], [0, -9587, 0, 4805], [-31034, 0, -580, 0], [0, 14798, 0, 578], [0, -8680, 0, -469], [-71368, 0, -1188, 0], [83438, 0, 1288, 0], [0, -8581, 0, -2876], [0, -8422, 0, 1150], [0, -9288, 0, -70], [0, 5272, 0, 1448], [-33724, 0, 148, 0], [0, -1387, 0, -374], [0, -13982, 0, 930], [4794, 0, 2012, 0], [19030, 0, 1789, 0], [0, 7046, 0, 6062], [17098, 0, 252, 0], [-63248, 0, 707, 0], [0, 8947, 0, -3917], [-19705, 0, -1883, 0], [0, 9145, 0, 2388], [-6524, 0, -1496, 0], [27046, 0, 1110, 0], [0, 873, 0, -3865], [-66126, 0, -109, 0], [0, 5853, 0, -3771], [0, -7212, 0, -7527], [5819, 0, -494, 0], [-11752, 0, -2641, 0], [0, -9208, 0, -4512], [0, 4973, 0, 1672], [0, -17483, 0, 5752], [57761, 0, 177, 0], [0, -17025, 0, 3031], [78292, 0, -353, 0], [0, -7112, 0, -4522], [23112, 0, 1299, 0], [0, 8309, 0, -6013], [20606, 0, -464, 0], [-82885, 0, -187, 0], [0, 2367, 0, -2597], [0, 5236, 0, -2808], [-30318, 0, -398, 0], [0, -1343, 0, 982], [0, -2032, 0, -2768], [-3611, 0, 142, 0], [72847, 0, 1026, 0], [0, -7691, 0, -5603], [1111, 0, 102, 0], [28878, 0, 2763, 0], [0, -11616, 0, 594], [-22902, 0, -2530, 0], [-70090, 0, -570, 0], [0, 2728, 0, 583], [0, -143, 0, 4713], [0, 13109, 0, 6463], [-72990, 0, -387, 0], [53178, 0, -2347, 0], [91004, 0, -925, 0], [0, -17099, 0, 2767], [0, 1949, 0, -2880], [0, 7706, 0, 855], [0, -67, 0, 3953], [-44102, 0, -2453, 0], [-20330, 0, 788, 0], [-111207, 0, 113, 0], [0, 5963, 0, -5251], [58348, 0, -270, 0], [87059, 0, -1802, 0], [210402, 0, -12, 0], [0, 9143, 0, -2861], [-40482, 0, 3120, 0], [0, -17905, 0, 6191], [-63090, 0, 2215, 0], [0, -10633, 0, -1852], [0, -1645, 0, 1483], [-144240, 0, 519, 0], [0, 708, 0, 4887], [45842, 0, 1446, 0], [-49436, 0, -1961, 0], [0, -13117, 0, 2199], [-23538, 0, 852, 0], [-81897, 0, -855, 0], [0, 3115, 0, 7815], [0, -19242, 0, 5187], [-174598, 0, -1052, 0], [0, 1426, 0, -8754], [104832, 0, -1427, 0], [-38643, 0, 1909, 0], [0, -6075, 0, -5069], [0, 20575, 0, -2313], [0, -6706, 0, -605], [16755, 0, -897, 0], [151134, 0, -1587, 0], [0, 20528, 0, -5024], [-12375, 0, -2030, 0], [0, 5853, 0, -147], [0, 18880, 0, 649], [0, 13380, 0, 4624], [-14420, 0, -1464, 0], [0, 6462, 0, 1326], [-56620, 0, 2069, 0], [0, -7425, 0, -6708], [0, -19267, 0, 2571], [-89567, 0, -290, 0], [138971, 0, 377, 0], [958, 0, -2096, 0], [-124390, 0, -1558, 0], [158843, 0, -1550, 0], [0, 6625, 0, -4127], [-607, 0, -2896, 0], [0, 705, 0, -9507], [0, -16685, 0, 6365], [0, 17964, 0, 11012], [-33864, 0, -380, 0], [0, 13749, 0, 8721], [0, 11016, 0, -9342], [-90729, 0, 2022, 0], [-15760, 0, -1982, 0], [0, -16219, 0, 7832], [0, -2310, 0, -4681], [0, -22936, 0, -6178], [-15565, 0, 552, 0], [0, 13568, 0, -6700], [161189, 0, -766, 0], [0, 6992, 0, 5873], [-59942, 0, -2282, 0], [16726, 0, 2265, 0], [-63875, 0, 893, 0], [0, 11905, 0, 9165], [-46961, 0, 2320, 0], [-119464, 0, 1040, 0], [0, -14921, 0, -12809], [-196614, 0, -388, 0], [65950, 0, -178, 0], [0, 7983, 0, 207], [0, 2806, 0, 501], [-93107, 0, -3910, 0], [-215752, 0, 92, 0], [0, 19343, 0, -3968], [0, -18183, 0, -12767], [218031, 0, 747, 0], [-82652, 0, 511, 0], [0, -19622, 0, -2836], [0, 15656, 0, 4770], [-4151, 0, 1685, 0], [0, -23101, 0, -9583], [-42534, 0, 1327, 0], [54892, 0, -239, 0], [0, 11260, 0, 11166], [0, -1779, 0, -2412], [-25173, 0, 1160, 0], [85606, 0, 917, 0], [0, 13947, 0, 6999], [-59463, 0, 2151, 0], [0, 3330, 0, -5177], [0, 8506, 0, 3548]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_1600_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_1600_4_a_cw();".
// 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_cw(:prec:=4)
    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_cw();".
// 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_cw( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_1600_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<3,R![5, 0, -102, 0, 1]>,<7,R![58320, 0, -632, 0, 1]>,<11,R![6762845, 0, -5982, 0, 1]>,<13,R![-2272, 36, 1]>],Snew);
    return Vf;
end function;