
// Make newform 2450.4.a.cd in Magma, downloaded from the LMFDB on 26 September 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_2450_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_2450_4_a_cd();".
// 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_2450_4_a_cd();".
// 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 := [-189, -67, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0], [0, 1, 0], [-45, -4, 1]];
    Rf_basisdens := [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_2450_a();"
function MakeCharacter_2450_a()
    N := 2450;
    order := 1;
    char_gens := [1177, 101];
    v := [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_2450_a_Hecke( : Kf := Kf)
    return MakeCharacter_2450_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 := [[-2, 0, 0], [1, -1, 0], [0, 0, 0], [0, 0, 0], [-8, -3, 2], [-28, 1, -4], [-11, 3, -3], [7, -13, 3], [16, -10, -5], [-135, -9, -1], [206, 5, 3], [-146, -17, -12], [34, 6, 1], [78, -44, -15], [-127, -34, 21], [-123, -56, 21], [41, 21, 32], [218, 27, 7], [-228, 6, 24], [173, 84, -14], [-256, 80, 4], [480, -32, 19], [189, -101, 47], [49, -158, -47], [335, -25, -22], [6, -129, 9], [-227, -131, -38], [-500, 122, 5], [16, -217, 42], [1126, -167, -3], [-24, -152, -69], [-1878, -83, -59], [676, 170, -125], [904, -101, -76], [-651, -231, -35], [-7, -183, -53], [-275, -149, 198], [1833, -100, -1], [1444, -31, -24], [274, -261, 67], [916, -4, -170], [-959, -53, 93], [-217, -188, 200], [-2354, 46, -131], [1695, -331, 118], [4189, -90, -23], [-358, -205, -183], [609, 491, -102], [54, 79, -315], [1943, -45, -116], [1789, -274, -18], [-1549, 89, -225], [1794, 284, -157], [-508, 331, 1], [-1718, 114, -94], [1197, 11, 296], [3219, -126, -24], [969, -36, -71], [-1831, 253, 186], [2026, -392, -210], [-299, -249, 470], [-6627, -166, 103], [304, -314, -247], [-512, -52, 114], [-6436, -265, 120], [-3541, 740, 20], [-4679, -450, -428], [-580, 623, -189], [537, 661, 348], [4417, 370, -367], [-3678, -699, -293], [-6164, 391, 171], [10196, -357, -9], [4124, 1251, -519], [-770, 1397, -89], [4182, 165, 238], [-4788, 20, 87], [2909, -966, 47], [-3681, -539, -140], [8375, 100, -202], [5517, 51, 401], [2815, -1091, -52], [5772, 447, -606], [6603, 619, -489], [706, -1016, 421], [3116, -1339, 489], [12007, -592, -240], [3487, 702, 393], [4840, -353, 455], [-3952, -1680, 434], [2492, 911, -165], [-2778, -1395, -388], [5865, 635, -393], [-7608, -690, 96], [6073, 314, 542], [9587, 439, 167], [-380, 22, 522], [486, 472, 242], [2983, -332, -314], [4901, 952, -7], [-7553, 11, 632], [-2036, -600, -545], [-8913, 2488, -32], [-981, -2211, -479], [5713, 1625, -38], [-176, -407, 505], [-7071, -1628, -589], [13920, 414, -426], [-2440, -1202, 652], [-3014, -1654, -165], [3783, 509, -319], [-9601, 853, 199], [-1988, -395, -425], [10115, 218, 878], [-474, 1337, 497], [-1410, 1565, 345], [7109, -3408, -314], [6329, 702, -1195], [9323, -90, 459], [3541, 75, 160], [-3416, 1438, -754], [11765, -805, 462], [10389, -1509, 943], [-10525, -450, -1219], [-7156, -999, 1022], [297, 901, 209], [13849, -975, -78], [-16902, -447, -835], [3324, 195, 1604], [2154, 485, 497], [-10527, 754, -624], [1863, -3435, -1140], [3553, 2467, 614], [-61, -1423, 1175], [-11981, -352, -2034], [8588, 81, -369], [-14530, -1292, 491], [-7106, 238, -283], [-20739, -1239, -1968], [10555, 2639, -147], [-10362, -1400, 1695], [-16178, -505, 1165], [-6956, -2145, 919], [10458, 2273, 69], [3037, 1254, 889], [-30294, 742, 34], [30782, -493, -14], [-16268, -1180, 1297], [13960, 2087, -432], [-7137, 2200, 225], [17942, -1854, -150], [-1263, -2771, 862], [35302, -1279, 372], [-12124, -1294, 605], [22839, 3092, 342], [-12255, 2076, -2147], [5314, -245, -1897], [26567, -3039, -396], [-12987, -2081, 93], [-14112, 5917, -316], [2028, 2726, 1230], [-24270, 2040, 481], [8209, 3249, 249], [6483, 2910, -1130], [-21672, -375, 432], [6655, -1497, 970], [-27143, -318, 1164], [-26567, 2268, 239], [-16699, -1654, -2605], [639, 6515, -455], [-41936, -2747, 611], [18817, -2685, 68], [-6394, -359, 531], [-25798, 1003, -1035], [7891, -765, -1995], [-3958, 3498, 881], [4889, -2560, 1835], [27657, 1605, -132], [25411, -3717, 346], [15192, 626, 1884], [-28949, 5617, -30], [-10867, 1258, -344], [748, 3148, -1660], [-20336, 3849, -1420], [-26327, 479, -1927], [-16325, -1291, 1052], [-15968, 1398, 1427], [9886, 936, -1715], [-5611, -6229, 2608], [20755, -1618, -31], [24652, 35, 1261], [-8536, 4727, -881], [-2852, -3036, -2141], [470, 968, -411], [-10980, 6714, -892], [-423, -2004, -2661], [-14782, -1339, -743], [-31862, 5214, 1004], [-1551, -4149, 1408], [-10869, 1138, -1858], [6180, 4669, -1834], [25167, 2107, -2787], [-19001, -2914, 3562], [-25869, -3255, 394], [-23888, 3200, 278], [-1276, 8393, 1436], [29823, -3077, -1368], [-12411, -114, -4236], [-45803, -3196, 1636], [36429, -389, -422], [-24626, -487, -1017], [-2391, -3192, 954], [49357, 4236, 207], [15210, 199, 1665], [-38775, -5955, 2282], [-6700, -5794, -2867], [-9019, 500, -2074], [-64580, -193, 113], [16631, 7406, 1351], [-4622, -1867, 1835], [69107, 3246, -1947], [6846, 3922, 1574], [2460, -4587, 4038], [-21272, -7771, 577], [-3185, 474, -3597], [48424, 1975, 2433], [1375, 211, 3015], [13044, 5288, -716], [13985, 3192, -1116], [-49932, -1699, -2134], [23995, -210, 735], [-6050, 893, -1485], [294, 1783, 1273], [10326, -1260, 1652], [-10013, 5161, 837], [-14582, 1922, 1003], [22883, -9687, 395], [2015, -4944, -1975], [-19877, -197, -2356], [3115, 7480, -100], [16317, -6305, 2570], [34610, 7211, 730], [48768, 4482, -795], [-30598, -5305, -4721], [-45380, -109, 698], [-24403, 3850, 1537], [50890, -4371, -359], [49836, -7131, 1471], [-41753, 12604, -404], [-36492, -1216, -3121], [-25790, 6945, -1977], [10401, 7494, 1241], [-9426, -534, -2192], [23821, -952, 287], [-84018, 66, 1831], [-10545, -3575, -1070], [-29131, 2787, -2201], [14844, -487, 98], [-5790, -3204, -3826], [-21848, -6751, -5192], [40681, -1519, -3185], [-18170, -3819, -1262], [46157, 5766, -4979], [4223, -5389, 3236], [-13981, -704, -788], [14205, 52, 1716], [37470, -6513, 2291], [22764, 3529, 6674], [-11227, -8986, -2246], [-9021, -7797, -66], [43094, 133, -1030], [49303, -1033, 1972], [-37125, 6817, 1168], [-31707, -2241, -1355], [-26037, 7465, -1200], [83104, 4776, -232], [24775, 5782, -49], [2462, -2229, 2151], [-30365, -676, 1762], [-2176, -8274, -5373], [-42684, 7496, 3335], [-50758, -3885, 1617], [51502, 3734, 5135], [44948, -8036, -2405], [-18377, -8229, 2250], [-85899, 7281, -178], [-32500, 3035, 4111], [-85978, -4247, 4173], [-10780, 4652, 2882], [-27864, 3609, 2744], [46186, -15526, -1421], [65555, 9221, -5972], [41255, 2585, 36], [-7761, -3239, -4776], [24477, 3642, 456], [15506, -8402, -4763], [-32357, -4796, 72], [-127575, 4829, -745], [43859, -3320, 1595], [-15946, -10585, 2930], [-42479, -6394, 948], [-42539, 274, -7255], [-24856, -1390, -4797], [-81334, -1352, 2705], [-19183, -7635, 6329], [61544, -3818, 4503], [106350, 1610, 5194], [39306, 6306, -3171], [-54261, -10521, 2289], [80744, 8271, -2224], [-38943, -1053, 615], [-74080, -9518, -4143], [36219, 8926, -2950], [-57093, -235, -646], [27048, -3729, -944], [36972, -18869, 1438], [-2028, -7998, -2211], [-26522, 770, 3311], [42077, 6223, -6594], [-20283, 19697, -1544], [70424, 5544, 4401], [-40977, -9638, 3007], [-42861, -9677, -3278], [-70157, 8630, 1809], [31958, 4153, 1520], [91775, -8212, 369], [15784, 12487, 5162], [32340, 12840, -701], [-121374, -7988, 5519], [-51075, -1383, -2494], [43692, 5591, -4110], [-146262, -3630, -3859], [39892, -617, -2953], [13427, -4193, 9313], [-2893, -10584, 4473], [-35067, -1290, 2243], [-17351, 12810, -4662], [-68979, 2088, 3510], [150163, -1676, 1549], [-103255, -1849, 1844], [-60986, -11664, -6119], [-15368, 7347, -7740], [26713, -4120, -744], [64918, 349, -3448], [-73151, -10555, 3350], [12127, 18528, -5751], [-64284, 18354, -3579], [-70043, 1320, -1601], [49588, -17215, 1436], [-24544, -9497, -5838], [95258, -7282, -1365], [83185, -17959, -1556], [19544, -14822, 1969], [41927, -15613, -1180], [-125565, 14139, 1662], [-48566, -14347, 8745], [78333, -1335, -6327], [80143, 5530, 9072], [88872, 9192, -6219], [-90173, 29, -7416], [31416, 5780, 8000], [41380, -26676, -1409], [59436, 4985, 3700], [23231, 5009, -4506], [-12831, -9427, 1518], [119728, 6222, 2782], [37255, 19183, -1108], [51858, -1517, -2589], [65140, 7440, -2993], [32443, 5270, -11344], [-84261, -8056, -3727], [80558, 3173, 1569], [15434, 541, 12748], [-68954, -4890, -3923], [53690, 3665, 12686], [-53047, 11414, -2658], [-116498, -8005, 1328], [64093, 4980, 11065], [-44938, 15544, 1355], [-134868, -13164, 4247], [-61729, 1218, -4874], [48036, 4450, 5676], [-40885, -12524, 10664], [102107, 6412, -6202], [-18596, -2713, -8298], [14452, -22207, -3343], [-129985, -725, -10460], [-124906, 1634, -1070], [10867, -10280, 6088], [-50622, -2086, 1196], [28282, 13072, 8741], [68341, 12988, 1500], [-99700, -7960, -2685], [-130222, 4030, -5196], [-109430, -11283, -8613], [-115808, 8112, -1810], [-48948, 19034, 3071], [-10109, -9098, -3021], [213608, -920, -810], [-49938, -822, -4254], [-50716, 21958, 5475], [-91585, -695, -14288], [-83954, -3078, -1336], [-2955, 6324, -694], [-50355, -9982, -5185], [71285, -13998, -3202], [-21891, -6919, 8703], [-13706, 1232, 12859], [-61365, -20310, 8459], [-93154, -10709, -621], [-12018, -20447, 9117], [114754, -9232, 8096], [154803, 4662, 7959], [66310, 2400, 4238], [-92427, 5135, -8034], [-180034, -7506, 285], [-39384, 204, -12421], [-61795, 22216, 3056], [62766, 12528, 8014], [23999, -4231, 2310], [112309, -20145, -1648], [-100914, -16082, 3919], [20628, -9723, -11823], [-162207, -191, 6390], [30310, -1336, 2208], [157881, 10058, 3723], [5876, -23184, 6244], [-135075, -8793, -606], [25022, -30495, -795], [-161757, 7159, -1682]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_2450_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_2450_4_a_cd();".
// 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_2450_4_a_cd(:prec:=3)
    chi := MakeCharacter_2450_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_2450_4_a_cd();".
// 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_2450_4_a_cd( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_2450_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<3,R![255, -64, -3, 1]>,<11,R![-36407, -1393, 26, 1]>,<19,R![-95205, -12709, -18, 1]>,<23,R![94749, -14822, -53, 1]>],Snew);
    return Vf;
end function;