
// Make newform 1575.4.a.bk in Magma, downloaded from the LMFDB on 29 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_1575_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_1575_4_a_bk();".
// 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_1575_4_a_bk();".
// 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 := [46, -3, -24, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0], [0, 1, 0, 0], [-12, 0, 1, 0], [-2, -20, 0, 1]];
    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_1575_a();"
function MakeCharacter_1575_a()
    N := 1575;
    order := 1;
    char_gens := [1226, 127, 451];
    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_1575_a_Hecke(Kf)
    return MakeCharacter_1575_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, -1, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [7, 0, 0, 0], [-5, -5, 3, -1], [2, 3, 1, -3], [-24, 7, -3, -3], [18, 6, 4, 0], [-25, -10, -6, -2], [59, -30, 0, 4], [90, -9, 3, -9], [99, -69, -9, 3], [-96, 7, 15, 3], [115, -6, -28, 0], [-14, 30, 36, -4], [-222, -17, 3, 15], [218, -3, 27, -17], [168, 87, 3, 15], [-119, -105, 17, -27], [167, 45, 21, 13], [304, 162, -68, 12], [87, -153, 37, -3], [-370, 51, -33, -29], [46, 140, -78, 14], [-102, -168, 28, 36], [108, 268, 78, -30], [874, 21, 35, 3], [-892, 66, -6, 46], [37, -357, 15, 15], [47, 111, 93, -23], [1021, -111, 103, 51], [504, 232, -126, -6], [-6, -398, 30, -78], [676, 24, 46, -6], [-703, -244, -138, 46], [-867, -63, -37, -105], [-108, -138, -82, -90], [936, -441, -61, 39], [130, 224, 66, 74], [886, -758, -48, -52], [1436, 150, -66, -38], [1164, -42, -52, 12], [2368, 475, -177, 47], [221, 777, 93, -27], [-1793, 518, 120, 56], [1112, -288, -176, 0], [-1428, -141, -69, 123], [-1596, 447, 101, -27], [-2026, -99, -309, -65], [2874, 72, 124, 12], [1209, 899, -243, -27], [1828, -920, 60, 128], [250, 720, 26, -78], [916, 223, 249, -163], [-2578, 793, -147, 73], [-1407, 140, -96, 96], [-2246, 552, -300, -4], [-2926, 1014, 24, 132], [-506, 264, 544, -12], [879, 841, -321, 63], [-638, 1434, 174, 30], [3238, 1518, -84, -88], [4644, -258, 156, 24], [3348, -754, 540, 156], [-1866, 900, -266, -162], [-3221, 554, -120, -76], [-465, -930, 300, -12], [1866, 2475, -329, -81], [3133, 41, 525, 185], [2178, 1107, -511, 21], [514, 512, -480, -112], [3419, 324, 24, -56], [2644, 2037, -459, -111], [-2075, -1125, -93, 51], [-81, 192, 670, 186], [-8846, 1006, 228, 44], [3539, 919, 225, 13], [678, 633, 257, -267], [5063, 401, 531, -425], [6590, -96, 110, 174], [2962, 131, 411, -313], [6683, -117, -489, 63], [7472, -769, -897, -53], [-372, 2022, -526, -126], [-4638, -609, -1035, 93], [-4200, 1092, 576, -252], [-1135, -1717, -579, 217], [2521, 636, 392, -156], [-470, -730, 360, 92], [6088, 264, 652, 228], [3410, 251, -1125, 127], [-5666, -1078, -972, 68], [-1369, 1503, 593, -255], [-8545, -25, 183, 79], [-2428, -2547, 917, 153], [-9834, 1144, 228, 84], [1610, -2326, -504, -92], [298, 243, 243, 95], [4800, 1260, -68, 396], [-1721, 2637, -275, 669], [6633, 2010, 16, -204], [6935, -1685, -435, -359], [-1658, 2367, -189, 95], [-2297, -2369, 453, -19], [-3765, 3600, 386, 402], [-3926, -2280, -846, 594], [-1604, -739, 135, 803], [-5528, -514, 1266, 314], [-5843, -2734, 894, 194], [4376, 4980, -1072, -24], [-7910, -1218, -984, 300], [1907, 51, -669, 795], [5405, -1859, -129, 451], [-446, -60, -858, -318], [5523, -1533, 745, -627], [12107, 3987, -1311, 37], [-2740, 1662, 1670, -210], [6158, -1336, -72, -80], [10854, 196, -792, 24], [2732, -1382, 1242, 538], [5930, -1980, 310, -162], [-21930, 903, -329, -105], [10798, 4174, -6, 74], [-13155, -3099, 129, -111], [4984, -1866, 322, -726], [2906, -217, 1179, 187], [-786, -7986, -154, 402], [2548, 862, -54, -526], [6108, -6453, -779, -27], [-11300, -2157, 651, 255], [-7307, 1134, -428, 1140], [-4652, -1057, 987, -709], [-2820, 2892, 464, 336], [1239, 4791, 1575, -21], [9464, 734, 642, -1382], [2692, -744, 1012, 756], [19166, -2366, -606, 178], [3748, 1374, 1004, -888], [7676, 2658, 180, -200], [-7635, 2959, 441, -747], [-1510, 2052, 916, -636], [22310, -3756, 108, 388], [13529, 1269, 539, -1113], [3641, -2859, -1167, -935], [228, 3237, 1075, -825], [12992, 7420, -1254, 346], [-20248, 2127, 1467, -225], [28064, -1358, 54, 598], [5970, -1026, 538, -1134], [3993, -8141, -705, 219], [-166, -2070, -1118, -714], [12162, -931, 177, 1341], [817, 2922, 44, 588], [17616, 4166, 1122, -54], [9332, -4437, -321, 195], [-11243, 7532, 972, -496], [-30921, -4935, 427, 207], [11580, 2283, -1323, 1101], [-24720, -186, -470, 1218], [4322, 5446, -1146, 1606], [3188, 5556, 2580, -20], [-18197, -5975, -717, 767], [6496, 9984, -2344, -252], [-27534, -5838, 1140, 420], [15621, 7589, -2385, 711], [-5662, -2130, -390, -350], [31835, -2319, -25, 819], [1522, -2220, 1386, 810], [5371, 6060, -1760, -984], [-9380, 2340, 2130, -298], [2309, -235, -1911, 1405], [17318, 651, 85, 537], [8025, -1406, -3006, -558], [-8658, 5391, 1455, -1029], [-7260, 7164, 794, 1230], [10112, 1383, -207, -743], [27563, -3831, -61, 291], [11494, -2187, -951, -655], [838, 3657, -2229, -453], [21458, -3771, -635, 1017], [35679, 3051, 1149, -675], [-20112, 499, 975, -1101], [-5953, -3033, 359, -417], [-2802, 3635, 2979, -225], [-5937, 3245, -1707, -1383], [1998, -3324, 468, -2364], [-27499, 4107, -2481, -1917], [14702, 6672, 1004, -372], [-16743, 108, -504, -156], [-9780, -1752, -3078, 378], [-758, -12630, 90, 330], [-33545, -3619, 2205, 173], [4905, -10833, -439, -2031], [7330, 3352, 276, 1988], [-19711, -9917, 567, 31], [3672, 10473, 1557, -615], [17253, -1740, 624, -2028], [-14669, -9441, 2387, 891], [-5766, 1476, -6438, 654], [-36766, -2638, 2670, -482], [8950, -2504, -636, -1948], [7394, 8205, -1595, -423], [5678, 2589, 1453, 873], [45308, -3294, 986, -942], [29780, 9559, -405, 79], [41168, -5472, 3444, 1708], [-8758, -2973, -2229, 1623], [12884, 11450, -2118, 1414], [13629, -903, -5601, -633], [9076, -10182, 2670, -738], [-7653, -3405, 67, -561], [45308, -3366, -552, -1604], [-1601, -12717, 377, 1173], [-13584, -5935, 2445, -303], [3780, 8318, -1344, 2352], [35628, 3780, 698, 2058], [18083, 5409, 419, 2067], [37050, -10820, -4182, -1146], [-3761, 5048, 36, 812], [1345, 6052, -882, -2794], [-44079, -621, -1733, -249], [-18832, 81, -8013, 627], [16545, 2941, 771, 3315], [16853, -8685, 693, 3093], [-29330, 11630, 2448, -472], [19566, 14352, 1400, -1452], [-4280, -12678, 1320, -316], [-55039, 187, -429, 487], [-10172, -5172, 1002, -762], [24499, -3857, -1209, 383], [-32869, 1461, -5251, 1941], [47198, 2094, 2414, -522], [9932, 5280, -1204, -516], [32889, 541, 2763, -2421], [-19518, -12666, 1260, 384], [15378, -12286, 2526, 342], [87224, -6582, -1402, 54], [83047, 5935, -147, -79], [-4981, -15297, 1011, -2729], [52480, -7514, -1710, 698], [6131, -3839, -6459, -707], [-17078, 14652, 2634, -882], [34026, 1455, 1687, 507], [-14973, 12987, -365, 2679], [-13362, 10181, -5205, -549], [-8384, -9204, 846, -2194], [-20386, -3147, 869, 1857], [10886, -12546, 726, -674], [7868, 6864, -5108, -1260], [6072, -10128, -2040, 2736], [-1382, -2190, 4366, 2706], [-22488, -16453, 2715, -849], [-34880, 10943, -1353, 2567], [51164, 7722, 3444, -108], [14542, -7430, 1440, -436], [14228, -3318, -1518, 2638], [11865, 13461, -7103, 1317], [29940, 474, -4512, 1140], [-66894, -1956, 3498, 678], [-15206, -14784, 5390, -2826], [-4688, -10212, 5596, -2448], [-29815, -10137, -2025, -1301], [-12270, -5673, -4713, 2715], [-2722, -6540, -6848, 1704], [28632, -14837, -1947, -2187], [39984, -9678, -990, -774], [18913, 14496, -6, -550], [31756, 11639, -411, 2093], [-20405, -1674, -6272, 756], [60473, -17204, -6762, -662], [-22988, 3561, -3919, -4275], [44452, -321, -2809, 219], [37936, 3828, 2756, 2076], [-60921, 11445, -1341, -645], [44300, -2568, -530, -834], [19836, 9684, 1606, -318], [-24359, -8433, 2007, 1127], [21322, -972, -1744, -2076], [15699, -16140, 6384, 1728], [-63332, -2329, -2235, -2599], [-34036, 13036, 2454, 3598], [3968, 5652, 956, 1032], [40030, -10434, 2472, -4360], [-5868, -9813, 3109, 2193], [-37472, -6156, -4354, -1830], [-58717, 15192, -132, 1684], [52821, -9804, -2320, -1740], [-19173, 9227, -2979, -1791], [-53884, -9885, 4515, 471], [-2166, -2780, 852, 1812], [-2895, 3913, 3447, -2277], [-54462, 1938, -8694, 1506], [76253, 5311, 393, -2927], [35840, 112, 1950, 574], [-49871, -3999, 149, 1269], [-8580, 20616, -2670, 5286], [36892, -13053, -10285, -1113], [40090, 4708, 4362, 2918], [-14936, 599, -9381, -961], [51370, 10020, 2984, 960], [10012, 15912, 70, 3942], [742, -1125, -7509, -193], [13011, -11085, -3, 2349], [-25839, -5861, 6579, 1743], [-60253, -5895, -8465, 5655], [14070, -7143, 8889, 237], [-53097, 83, -8385, 387], [-66022, -21069, 477, -63], [-13111, 22732, 2388, 28], [32678, 28392, 784, -3276], [-57664, -21438, 1524, 1036], [262, -7085, 2691, -1729], [-7445, 5911, -1143, 1481], [-13148, -828, 3724, 3348], [11687, 13834, 5358, -2006], [9824, -8346, 2816, -2928], [-69746, -9290, -1878, -838], [-3652, -7721, -2193, 4387], [-41204, 20508, 876, 4596], [36775, 4645, 447, -2617], [21144, -15222, 5976, 1644], [43630, -5664, -1088, 2868], [5014, -864, 1218, -346], [1589, 9795, 10009, -1167], [37879, -929, 1653, 5189], [-24502, -20934, 8398, -786], [-101621, 4044, 894, -906], [-19726, 26232, 1056, 1848], [591, -3183, -1443, 717], [34141, -1308, 5814, -5194], [32806, -15168, 2620, -6264], [3901, 15440, 3234, -1642], [-85046, -531, -1971, -1431], [-95104, 2727, -4539, -3551], [-119604, -7893, 2199, -573], [-22586, 22366, 2124, -4228], [-30807, 12399, 1359, 123], [-63490, 17769, -1137, -1097], [25986, 11076, 7266, 3354], [-111336, -13005, 4977, 681], [-9546, -24720, -4896, 948], [32125, 1145, 7803, 3503], [13844, -4092, 8088, 2944], [29643, 4461, -3365, 2907], [39029, -16246, -4080, 2140], [-36985, -28095, 5649, 1201], [39464, -23670, 64, -192], [100371, 15276, -5074, -270], [4934, -5550, -1800, -5984], [-76352, -7362, -4536, -3292], [-53960, -13428, 9558, 762], [-99915, 22812, 952, 804], [18958, -2447, 1173, -5935], [-46086, 22731, 2849, 2289], [-50245, -21825, 1583, 1947], [30466, -10017, 3057, 3689], [7778, -9384, 4200, 5824], [-52488, 28377, 7359, 1587], [-32458, 13900, 1536, -2768], [53948, 18801, -4323, 3469], [23913, -12141, -3945, 1911], [-14366, 39320, 5688, -3352], [144448, -6644, 6552, 908], [-59369, 11637, 3285, 173], [-6050, -37572, 6190, 1002], [-39570, 18393, -2315, 3861], [-70446, -11868, -6444, 7596], [-52733, 6129, -7433, -3573], [-10853, 37818, 4066, -738], [16855, 1481, -8343, 4841], [5062, 1002, -10670, -726], [57323, -7150, -3546, 3706], [-11922, 15965, -855, 3753], [20366, -25077, -1145, -5973], [-1891, 2271, 16099, -3165], [-87024, 23531, -5145, -333], [-130137, 5913, -2991, 1449], [48700, 9420, 2390, 3918], [-50794, -13389, -3195, -2483], [40660, 22632, 7466, 2850], [-122624, -33890, 1044, 2504], [41775, -511, -609, 6615], [-57519, 23307, -1079, 5001], [-7913, -967, -8445, 131], [-58204, 8724, -10018, 2898], [34476, 37068, -5736, 4272], [70085, 11661, 4427, 2427], [-120090, 8940, -5276, 180], [16519, 23877, 8475, -1701], [23336, -10102, -8094, 3874], [19553, -3390, -5810, 1578], [16498, -16606, 14634, 2810], [-131773, 2951, -6453, 1471], [33862, 19020, 3628, 3468], [-3793, -27588, 8508, -5492], [136571, -4677, 7531, 7491], [53556, -42561, -3021, 5391], [54354, 4055, 2817, -6183], [10384, 42396, -4480, 4728], [-38865, 7723, -13623, -1767], [89146, -4131, 7055, 675], [57983, -6045, 5169, -299], [3045, -27753, -8939, 1905], [-15058, -44417, -1863, 3769], [3374, -39146, 720, -1532], [-29262, 20841, 13415, 4167], [-120871, -8979, -1327, -3279], [30754, 10624, -7692, 6512], [-14704, -9438, 14994, -318], [32226, -29322, -42, 3366], [19982, -11310, -2240, -7800], [-31655, -43115, 279, 4727], [-15516, 40788, 24, -4500], [-95545, 4584, -9850, -4218], [8171, -34158, -12630, 2802], [-67178, -17974, 2412, 1808], [75512, -14613, 5235, -3701], [-28220, -16635, 1687, -4473], [-161284, -6213, -5733, -4673], [64574, 160, 2172, -2996], [138526, -15427, -2187, 3161], [-57556, -5523, -12197, 327], [125472, 9879, 8127, -4725], [-75448, 19933, -5739, 7129], [13426, -9258, -26574, -510], [-131428, 26176, 9126, 1138], [73341, 3977, 3057, -1947], [161142, 6996, 3624, 5784], [-75380, 16896, -9990, -66], [25350, -51916, -5700, 2004]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_1575_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_1575_4_a_bk();".
// 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_1575_4_a_bk(:prec:=4)
    chi := MakeCharacter_1575_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_1575_4_a_bk();".
// 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_1575_4_a_bk( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_1575_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<2,R![46, 3, -24, 0, 1]>,<11,R![-304010, -61617, -2643, 21, 1]>,<13,R![545368, 102608, -6940, -5, 1]>],Snew);
    return Vf;
end function;