
// Make newform 2400.4.a.x in Magma, downloaded from the LMFDB on 09 January 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_2400_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_2400_4_a_x();".
// 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_2400_4_a_x();".
// 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 := [-10, -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_2400_a();"
function MakeCharacter_2400_a()
    N := 2400;
    order := 1;
    char_gens := [1951, 901, 1601, 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_2400_a_Hecke( : Kf := Kf)
    return MakeCharacter_2400_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], [-3, 0], [0, 0], [-6, -1], [-12, -4], [-40, 3], [-20, -9], [-18, 9], [-54, 1], [-54, -12], [258, -5], [-224, -9], [-106, -30], [-228, 12], [-378, -13], [-126, -42], [396, -4], [82, -6], [108, 44], [528, -8], [18, 6], [1014, -19], [-180, -32], [-794, 30], [-770, 72], [-638, 12], [-990, -49], [552, -122], [-1074, 84], [76, 51], [-222, -13], [-600, -170], [480, -51], [-438, -1], [-598, -36], [-390, -69], [1020, 33], [-84, -184], [2874, 61], [1478, 120], [-2016, 26], [-202, -180], [24, 252], [-1470, -78], [690, -66], [1122, -253], [114, 39], [1038, 9], [3132, 136], [674, -6], [4880, 33], [4980, -110], [5258, -36], [-504, 230], [2588, 123], [3630, -241], [1146, -12], [-1806, -273], [3580, -207], [-6066, -102], [-3588, -72], [-2438, -150], [456, 26], [828, 10], [-270, 78], [-1662, 66], [426, -329], [-342, 414], [5376, -498], [-5286, -450], [6480, -411], [2760, -140], [1782, 201], [5276, -387], [438, -127], [-474, -209], [4050, 168], [4648, -33], [-5230, -36], [-2086, 384], [10152, 274], [-2350, 906], [576, -76], [-2950, 318], [10266, 559], [-10956, 352], [2210, -924], [3718, -792], [90, 600], [-246, -537], [-5496, 94], [16296, -288], [17406, -247], [-180, -1508], [3834, -981], [8742, 135], [3826, -672], [6970, 1068], [-1104, -1386], [12110, -276], [-1668, -1032], [-17618, 612], [-7920, -1366], [6610, -576], [-4974, 227], [-5770, 276], [5808, 714], [-12, -1113], [1368, 1148], [16154, 240], [1230, 1697], [-6016, -1329], [-15424, -159], [-19926, 415], [-9666, 1077], [-9794, -918], [-8652, 1732], [8202, -887], [-21170, 900], [-24348, 396], [9154, -1290], [-11198, 618], [2902, 468], [13992, 50], [-9150, 115], [10186, -612], [-8230, -1770], [11940, -1514], [-6954, 957], [16796, 165], [-27678, -209], [16026, 821], [-6846, -1269], [5716, -2475], [-22390, 84], [-13998, 912], [19290, -414], [12696, -1746], [-25890, -780], [-1962, -1254], [-12222, -1489], [7226, 840], [11538, -693], [-7452, -1084], [-24866, -732], [15888, 608], [-5704, 987], [-21276, 999], [-29970, -579], [21138, -387], [24092, -639], [6, -2574], [8388, -884], [-20430, 737], [-20112, 390], [3924, 1666], [-2646, -3189], [-6886, 2280], [31910, 1488], [-34990, 420], [-1416, 1362], [-2112, -3075], [-25266, 669], [1008, 3386], [-6804, 1503], [-5286, -3131], [-6714, 717], [-17588, 2061], [30362, -372], [3270, -1452], [-1548, 2776], [20598, 2796], [18624, 508], [19394, -1434], [-8994, -2999], [-738, 3330], [-9642, -939], [-41966, -408], [-11418, 105], [-25066, 1908], [-20118, -1413], [59292, 604], [-2164, 1401], [-17196, 723], [11358, 3027], [36042, 276], [-7144, 3915], [-3744, -1266], [-43910, 528], [-28224, -2176], [-29822, -3366], [21120, 3034], [-3870, 1727], [-45246, -1812], [-27828, -2996], [29364, 2787], [-9934, -216], [-6616, -4413], [-25564, -1425], [20490, 1197], [14978, 2460], [-44826, -1599], [-10664, -2457], [-10622, -840], [6576, 362], [49962, -1146], [-48990, -2505], [-16008, -5194], [-10218, -4530], [5814, 697], [-43014, 6], [-41766, 252], [42258, 2383], [-43908, -2360], [-12684, -2230], [-5430, -5112], [-4386, 3957], [-43686, 3192], [46398, -1969], [-35594, -1272], [40546, -942], [-25974, 1463], [-18826, -1266], [74586, -417], [12024, -2930], [28070, 3792], [22452, -2013], [-40620, -658], [35082, 3147], [-12144, -3162], [20192, -2769], [-63990, 1247], [-27774, 527], [7734, -6906], [1584, 5926], [31818, 2837], [-7526, -5700], [-21714, 576], [83856, -366], [68640, 1424], [39144, 1734], [-29046, 2751], [-49110, -3257], [38162, -390], [-5856, -1011], [11052, 766], [-20898, -1067], [40500, 668], [54774, 741], [-60246, -1319], [76076, -987], [-44166, 276], [-3858, -4621], [-43886, 4380], [-68678, -4290], [-69108, 208], [56766, -4512], [-63936, 570], [44922, 18], [-25222, 3258], [-66930, 3617], [100848, 1974], [-81758, 1026], [-15560, -2169], [-40864, 6585], [52554, -4461], [4498, 2508], [26730, -936], [15696, -762], [-8418, -4704], [-32770, -4416], [86184, -1534], [-27590, 138], [63942, -1715], [72722, -2598], [-100230, 1971], [-4584, 8418], [-49934, -4230], [-59150, -156], [-38064, 3418], [-23562, 4427], [97062, 1733], [-10902, 9385], [54326, -2328], [-7152, -2546], [10320, 3704], [-55226, -3348], [3030, -1620], [3222, -5775], [21994, -5316], [105562, -3216], [121452, -2556], [-46160, 3177], [-98856, 5266], [68688, 6891], [86258, 4956], [-39570, 5909], [-26710, 5754], [50520, -3690], [33708, -5064], [107122, -714], [19950, -7500], [62970, 7135], [104400, 814], [-59802, -399], [-56290, 1968], [-5412, -6196], [-121998, 390], [27516, 2566], [19740, -5019], [-76062, -243], [103154, -4452], [-141654, -1608], [-62688, 4370], [19638, 1499], [25082, -2736], [38160, 570], [22980, -2962], [-12798, -4926], [-78878, 192], [-22314, -6159], [36370, 6462], [-45510, -5748], [43830, 9921], [59524, -5553], [39506, -8472], [42522, 6159], [28860, -3596], [92154, -7903], [93438, -1296], [-146758, -2094], [115446, 1224], [31770, -357], [-10200, 2906], [-106002, 2921], [-27852, -2328], [-32058, 10884], [52904, -9567], [-96398, 4740], [-97206, 1743], [-6772, -6915], [46468, 11607], [70698, 3264], [-26682, -7843], [-52974, -2454], [12948, 1032], [-12638, 1674], [41772, 2832], [-40668, -3898], [82530, 10302], [-44274, -8007], [-10138, -5544], [147546, 2268], [-101898, 5677], [-71574, -438], [-600, 14685], [-2568, -10972], [-150192, 3318], [-96968, 3429], [49638, -11365], [-47180, 585], [-48910, -1452], [5322, -1391], [103776, -1190], [-13956, 2140], [57126, 6792], [110634, -6330], [62502, -6283], [5474, 12108], [161616, 6246], [52878, 7509], [-3282, 8491], [92594, -1380], [49314, 4527], [-76476, 6585], [-9804, 2112], [-143508, -3938], [-92730, 12132], [-53334, 11976], [-81114, -11064], [19866, -11664], [82432, -915], [114330, -9945], [184512, -2427], [211554, 1395], [-18522, 13531], [31314, 14483], [31468, 2649], [72432, 9018], [-243750, -2523], [97098, -2556], [98054, -132], [208308, -1944], [49464, 3526], [-75528, 1872], [-62890, 3816], [-10938, 11265], [-162930, -3618], [-117738, -5559], [-31950, -15696], [123254, 4788], [27992, -3435], [-21630, -10885], [24504, -759], [-82830, 5652], [145758, -3147], [-29452, -14367], [-45742, -9684], [23820, 3864], [-55128, 2026], [-69202, -10728], [32070, 3012], [-62760, -14438], [178362, 1127], [18930, 14934], [-99294, 14088], [22896, 17752], [57594, 4855], [-15832, -8523], [-77382, 273], [141682, 11916], [-206412, 1017], [-274878, -2971], [3660, -7512], [-39782, 4698], [-12446, 19314], [104652, 9384], [-46974, 13236], [56142, -11779], [-26568, -1868]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_2400_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_2400_4_a_x();".
// 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_2400_4_a_x(:prec:=2)
    chi := MakeCharacter_2400_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_2400_4_a_x();".
// 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_2400_4_a_x( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_2400_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<7,R![-128, 12, 1]>,<11,R![-2480, 24, 1]>],Snew);
    return Vf;
end function;