
// Make newform 650.4.a.w in Magma, downloaded from the LMFDB on 22 October 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_650_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_650_4_a_w();".
// 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_650_4_a_w();".
// 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 := [1600, -48, -113, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0], [0, 1, 0, 0], [-256, -85, 4, 1], [-416, 73, 8, -1]];
    Rf_basisdens := [1, 1, 24, 24];
    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_650_a();"
function MakeCharacter_650_a()
    N := 650;
    order := 1;
    char_gens := [27, 301];
    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_650_a_Hecke( : Kf := Kf)
    return MakeCharacter_650_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, 0], [0, 1, 0, 0], [0, 0, 0, 0], [-14, 0, 0, -1], [-12, -3, -1, -2], [-13, 0, 0, 0], [-5, -2, -7, 3], [14, 1, -5, -1], [0, 0, 9, 3], [-39, -1, -5, -9], [8, -16, 6, -3], [-2, -22, -8, 8], [132, -5, 19, -1], [-152, -36, -1, 13], [64, -26, -2, 7], [-245, -5, 19, -7], [-58, 32, 2, -17], [355, -19, -27, 15], [-154, -27, 37, -36], [166, 2, 16, -4], [-338, 3, 31, 7], [-12, 108, -7, 27], [-686, 21, 11, -6], [-308, -19, -1, 39], [-326, -44, 54, -50], [409, 111, -29, 21], [-688, 106, -57, 7], [80, -7, -70, 20], [-468, 176, -30, 10], [86, 21, -8, 64], [-848, -50, -9, 17], [-1020, -140, -21, 55], [-176, -109, 71, 67], [-356, -31, 70, 92], [-242, -174, 32, 4], [-110, 118, 68, 47], [-703, 135, -156, -20], [-710, -137, 9, -59], [-174, 280, 54, -42], [1301, -175, -14, 12], [-480, 169, -54, -90], [-749, -151, -48, 4], [1140, -298, 141, 19], [-1684, -81, 35, -85], [1928, 36, -60, -16], [0, 170, -37, 153], [-456, -345, -97, 97], [254, -12, -20, 200], [596, -222, -314, 43], [-526, -34, 166, -210], [814, 244, -141, -105], [1164, 710, -146, 37], [-1700, 31, 105, -23], [-64, -101, -133, -21], [1721, 129, 141, -211], [320, -228, -216, -60], [1841, 83, -29, -149], [-3098, -136, -202, 117], [-146, -232, -173, 55], [138, 824, -68, 248], [-904, -529, 167, -231], [2610, -452, 200, -108], [-598, -59, 125, 57], [4116, -108, 477, 87], [-1631, -131, 349, 415], [1466, 436, 164, 264], [-6018, 353, 101, -91], [1139, -108, 44, -274], [-2392, 169, 128, 30], [1330, -156, -424, -20], [912, 58, 326, -378], [-4644, -650, -6, 71], [1016, 156, -181, 259], [-3235, 651, -649, -9], [-1766, 121, -639, 120], [5518, 216, 146, -18], [2594, 618, -93, 663], [-5670, 348, -592, 108], [5406, 117, 337, 157], [-376, 123, 157, 113], [-2668, 113, -214, 58], [664, -88, 782, 78], [6582, -306, -602, 322], [1882, -369, -74, -290], [3592, -374, 946, -84], [-2920, -141, -645, 193], [-876, -193, 479, -561], [6548, -433, -541, -141], [-1698, 36, -332, -536], [-4624, -880, 38, -881], [-44, 788, -613, 279], [-6870, 206, 454, 705], [-3092, 158, 706, 277], [5408, 1036, -83, -145], [-4708, 138, -176, -719], [2124, 368, 1063, -197], [-2716, -312, 324, -400], [8374, -1413, -222, -6], [-4600, 841, 1057, 167], [-7294, 856, -366, -102], [-8908, 401, 453, 725], [-28, 1150, -188, 648], [4716, -308, -1023, -325], [7629, -1328, -1172, -192], [-512, 420, 96, -822], [-11678, -1433, 243, 111], [11444, -885, 33, -502], [2622, 819, 395, 607], [-600, -978, -247, -235], [2129, -1086, -558, -680], [-12164, -34, 186, 216], [-5698, 1268, 794, 330], [-6490, 596, -1390, 38], [1070, -1130, 112, 72], [-13998, -502, -224, -256], [291, -2017, 219, -575], [8122, 666, -630, -46], [-3912, -1254, 882, -1014], [-4019, 2009, -182, 618], [-3624, 1039, 422, 728], [3464, 850, -308, 1316], [-16349, 2043, 326, 280], [3394, 1902, -865, 267], [-3692, -2531, 1017, -724], [2352, -63, -911, 426], [8379, -199, -1179, -1219], [20792, 290, -618, -254], [-17680, -1034, 499, 395], [2708, 814, -267, -195], [-3184, 1066, -418, 274], [-12178, 484, 160, 773], [11330, 372, 168, -811], [5232, -942, 175, 233], [8047, 3433, -380, -506], [-14090, -1487, 615, -1381], [19972, 411, -699, -1059], [1922, 1756, -784, -980], [6554, 580, 762, -33], [4191, 281, 61, 321], [2174, 1988, 192, -512], [-18404, 418, 1136, 817], [5610, -1002, -1178, -754], [23812, -940, -69, -201], [-22480, -861, -549, -418], [31297, -759, 801, -229], [-12614, -1216, -978, -342], [-11084, 716, -732, -860], [11806, -2249, -122, -762], [20952, -1935, -319, -25], [-2566, -210, 142, -1221], [-26360, -992, -194, -354], [-16547, -1723, 785, -731], [-5360, -3419, -68, -1468], [1148, -1580, -952, -1474], [-3484, -2172, -1477, -465], [6184, -1494, 47, 857], [4624, 984, 2516, -1402], [-4958, -996, -1138, 990], [8355, -752, 1044, -136], [-22322, 1808, -944, 76], [-1612, -3462, 882, 853], [27497, -996, -911, -1059], [-22112, -1350, -982, 1421], [-592, 321, -1375, 2303], [7688, -3381, 1497, -1171], [27158, 3700, -518, 297], [-2820, 822, 67, -1595], [-3209, -1879, 185, 615], [-7824, 2335, -1339, 1293], [2205, -2065, -121, 1653], [-14314, 623, 793, -787], [-8604, 226, 934, 2098], [-22992, -690, 345, 1757], [4842, 2243, 1819, -1685], [6208, -2272, -1037, 337], [-25161, 728, 2068, -1616], [-28070, 641, -889, -432], [5346, 2536, 420, 2564], [-42984, 674, -907, -197], [22961, -4247, -634, -674], [-10014, -2682, -166, 1246], [-14364, 3861, 837, 1811], [350, -3114, 250, 810], [8732, 633, 1493, -403], [34020, 1444, 978, 1231], [-18202, -1846, 1155, 1455], [-3113, 2635, -1273, -897], [-31020, -103, -585, -1564], [-4238, 1481, 3699, -1541], [-10286, -5410, 1598, -1723], [-44254, -2663, -347, 1], [1086, -3443, -151, 212], [3540, 3811, 1043, -2415], [-2, 4624, 154, 570], [4796, 217, 173, 2339], [11885, 3977, -706, 3150], [15374, 4363, -1651, -699], [-897, 597, 3173, -715], [-3718, 627, -2887, 1481], [-27468, 900, 1436, -1406], [-25454, -1884, 1178, -3034], [-4760, -2964, -2684, -352], [-9402, -358, -1414, -1554], [41817, 186, 2994, 64], [-35316, 4182, 3370, -995], [13778, 1160, -259, 449], [-25114, -2154, 962, -1665], [-41108, 956, 745, -231], [33924, 586, -2232, 852], [-20336, -348, 1816, -828], [-7063, 4729, 1110, -1270], [37218, 4404, -68, 1588], [-17972, 172, 800, 1772], [21190, 3175, -1455, -1058], [-22910, -5066, 2818, -1893], [1696, -2361, -2163, -1651], [-22908, 114, -2373, -1863], [5975, 2930, 4221, -1983], [12604, -796, -2846, 3873], [-6564, 470, 2490, 2766], [-15670, -564, 425, -2163], [-34094, 2000, 2930, 3502], [-7072, -329, -2225, 1907], [-6070, -2350, -4772, 2517], [8744, 3449, -1796, -902], [32737, -7207, -199, -1577], [-31930, -3451, 318, 526], [1596, 4952, -388, 3406], [-49256, -606, 154, 958], [6894, -1619, 1769, 1074], [-59050, -2672, 1393, -2915], [21436, 5643, -58, -2278], [26084, 2942, -180, 751], [25382, 2977, -1211, 3201], [-10272, -3776, 1536, 2690], [18158, -6828, -782, -562], [-11794, 1581, -2973, 3015], [28454, 4138, 840, -4460], [-62200, 4227, -3721, 351], [-26840, 2574, -6051, -31], [-17842, -123, -221, 1951], [11644, -1681, 1756, -326], [59956, 352, 2479, 1887], [-19838, -5192, 534, -4394], [16414, -5921, -2745, -889], [-23796, 2722, 3055, -2745], [25602, -626, 1170, 430], [-27450, 4538, 114, -2042], [766, 3525, -4045, 562], [29080, 3950, -2381, -777], [-45104, 956, 3226, 1706], [-11378, -4205, 1479, 3039], [-34406, -2622, 3778, -3034], [7159, 3152, -3280, -2930], [24458, 704, -341, -1937], [-20614, 1333, -833, -3688], [20714, 1992, -4105, -1829], [-6890, -2327, -805, -3910], [-27785, 1373, 3101, 1301], [85822, 697, 2151, 2319], [6640, -1228, -2819, 1607], [-17356, -525, 824, -3226], [-20088, -2968, 4694, -1310], [-22642, -1114, 751, 107], [-26956, -3157, -5417, 471], [6972, 7613, -1959, 2523], [14188, 9054, -1652, 2468], [-23942, 2392, -2690, -1466], [90340, 1817, -1417, 2434], [73481, -1213, -2781, -1883], [-10138, -2942, -2331, -1663], [32864, 2795, -555, -1210], [1486, -2113, -5957, -3309], [42048, 4288, 1591, 575], [-33575, 6029, -2023, -17], [10496, -2650, 4660, -4109], [-33850, -4251, -955, -959], [-46182, 6670, 5440, -424], [-2164, -1162, -4814, 2282], [-60804, -9131, 168, 3970], [-32704, -8244, 4129, -69], [29602, 2998, -4754, 474], [20024, 848, 5252, -3520], [-57328, 9780, 3860, 1860], [35668, -7269, 4597, -3204], [-70584, -4840, -607, -5109], [-11381, -2757, -2605, -5845], [23672, 10700, -856, 2360], [54372, -11274, -492, -2807], [8181, -5779, 6789, -2843], [52103, 4879, 1834, -160], [-21552, -36, -5568, -1296], [-14726, 3923, -2615, -15], [-37012, 2935, 727, 2694], [-4235, -2725, -1121, -6237], [-50649, -13893, 2818, -2558], [41048, -4658, -314, -2470], [55206, -6486, 4054, -1106], [9824, 2044, -2416, -2314], [57604, 9295, -3305, -1390], [71997, 1220, -3476, 2912], [-68460, 3140, 5046, 4758], [-15300, -11022, -137, -6829], [45552, 4869, 1850, 6402], [6952, -985, -1936, 6004], [6678, 3069, 7251, 1603], [1760, 13412, 436, 2600], [28850, 3190, -6073, 6667], [-21830, -650, -1420, 640], [-36157, 6445, -5823, 3917], [-42732, 1226, -6247, 1099], [54112, -8414, -134, -2714], [-4927, 13384, -1996, 610], [56140, 6744, -3373, 8165], [-8946, 1748, -2296, 1787], [-42250, 5708, 3215, -877], [-31618, 3563, -2863, -416], [-4386, -1374, 4534, -4146], [95600, -3091, -1373, 1515], [13323, -7472, 1260, 1774], [21348, 2316, -2153, 355], [-13412, 11195, -3375, 3213], [-18550, -7548, 3316, -2196], [-17714, -1082, -610, -2191], [-7414, 6724, 10470, -6430], [-30269, 8243, -697, 959], [-56320, -11997, 3113, 936], [-51756, -10286, 3222, -5717], [-41740, -10478, 867, 5551], [18377, 14843, 247, -2037], [30606, 8700, 5760, -2672], [-56818, 3078, -7010, -346], [27988, 9440, -1681, 3255], [-15110, -4145, -1721, 388], [-32654, 4651, -4503, 596], [7478, -5036, -3906, -8579], [9206, 10428, -3106, -186], [-10468, 2354, 5612, 1724], [-71228, -1975, 1073, 1593], [-13904, 8848, -1800, -1358], [26500, 2182, -1778, 4018], [-57242, 8123, 2459, 3415], [5608, -606, 7364, 6984], [77860, 844, 3923, 5353], [21434, -7006, -5946, 7170], [-28116, 7500, -7709, 3839], [9245, -8501, -5397, -1137], [27424, -4781, 1159, -7282], [63602, -3414, -382, -331], [-64165, -15935, 2521, -4867], [7674, -12075, 2059, -1222], [40708, 9114, -4440, -1428], [43920, 7558, 240, -1516], [-61008, 484, -5668, -6266], [-141986, -5718, 1225, 1285], [-2511, -10806, -7098, 1568], [24284, -5888, 5586, 4151], [-37346, -6457, -7141, 5566], [-137491, 10673, 49, 1857], [28564, -3176, -1242, 1729], [55736, 4398, 5302, 3594], [31118, -7159, -2211, 3737], [-69636, -9210, -347, 1073], [45810, 4322, 4490, 1002], [59864, -3305, -1394, 256], [-87658, 6349, 2932, 4084], [-31408, -194, 10848, -3680], [4846, -10922, 3420, -3761], [125331, 1934, 3442, -2976], [-46280, -10452, 3063, -9233], [-43584, 11545, 1208, -1600], [-115446, 156, -2998, -810], [-74297, 5849, 2997, 3007], [109212, 9170, -4474, -4724], [-6253, -9403, 3772, 1610], [110196, -1699, 7959, 3672], [-90320, -14490, 2686, -1928], [-30148, 1653, 143, -7421], [-54897, 1710, -10295, 5521], [116446, -9816, -8003, 3625], [133116, -10740, -978, -730], [-55720, 12887, 343, -2741], [4176, -8696, -12886, -2113], [-66140, 9873, -1505, 1995], [-27138, -16754, 1386, -3214], [76106, -6836, 1890, 3790], [46912, -5412, -5616, -10173], [76545, 1621, 3085, -1277], [-39270, 14090, 7902, 5686], [19816, -2106, 9945, 5923], [50288, -5459, 5559, -5029], [-5032, 6446, -2398, -6802], [23310, -19175, 7533, -2222], [193236, -5533, 7656, -1098], [-40168, 12470, -2526, 4539], [66223, 5434, -10878, 7286], [-65112, 11898, -11772, 1127], [-38601, -18618, 7769, -5701], [14244, -2427, 8228, -2550], [82696, 2874, -1798, 6874], [-59586, 7666, 4786, -4430], [71503, -5734, -218, -5032], [85964, 11916, 3518, 939], [-26114, -1163, -5097, -601], [16882, -9712, -3326, 3366], [23196, -5558, 5549, -3301], [58302, -3146, 6756, -1524], [77292, -10518, -10254, -9382], [-106028, 9698, 4950, 4581], [28954, -989, 749, -3527], [73137, 22050, -5761, 10167], [-44281, -5139, 4413, 7399], [-143588, 8323, 3930, -594], [-12108, -5756, -12712, 2882], [-1754, 11029, -2019, -4391], [-20217, 10095, -306, 3016], [160710, -11600, -2948, -1188], [-52516, -4458, 7105, -7423], [-16296, 6511, -10041, 1915], [30228, -17134, 2365, 4551], [-69795, 12435, 4056, -3934], [-23418, 5040, -3572, -4696], [10148, -442, -13650, -5339], [34296, 3255, -3098, 8354], [41190, 7961, 9183, -1357], [2290, -22326, 4874, -4570], [29648, 12516, 3852, 3388], [220508, 8553, -1515, -3091], [57740, 20061, -1395, 7572], [-139620, -6536, 7033, -5623]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_650_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_650_4_a_w();".
// 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_650_4_a_w(:prec:=4)
    chi := MakeCharacter_650_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_650_4_a_w();".
// 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_650_4_a_w( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_650_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<3,R![1600, -48, -113, 0, 1]>,<7,R![-44600, -1270, 755, 56, 1]>],Snew);
    return Vf;
end function;