
// Make newform 19.5.d.a in Magma, downloaded from the LMFDB on 25 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_19_d();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_19_d_Hecke();"
// To make the coeffs of the qexp of the newform in the Hecke field type "qexpCoeffs();"
// To make the newform (type ModFrm), type "MakeNewformModFrm_19_5_d_a();".
// 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_19_5_d_a();".
// 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 := [108300, 0, 300520, 0, 61507, 0, 4107, 0, 109, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [570, 300, 649, 0, 56, 0, 1, 0, 0, 0], [-570, 300, -649, 0, -56, 0, -1, 0, 0, 0], [57000, 177210, 0, 50867, 0, 3917, 0, 109, 0, 1], [22, 0, 1, 0, 0, 0, 0, 0, 0, 0], [-1786950, -1713360, -552615, -263572, -24510, -12087, -285, -204, 0, -1], [1786950, -1713360, 552615, -263572, 24510, -12087, 285, -204, 0, -1], [1259700, 5198730, 1498340, 857771, 202065, 65961, 7980, 2127, 95, 23], [-1259700, 5198730, -1498340, 857771, -202065, 65961, -7980, 2127, -95, 23], [-627000, 1895160, -28500, 497882, 0, 37767, 0, 1104, 0, 11]];
    Rf_basisdens := [1, 600, 600, 114000, 1, 171000, 171000, 171000, 171000, 57000];
    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_19_d();"
function MakeCharacter_19_d()
    N := 19;
    order := 6;
    char_gens := [2];
    v := [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;

// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_19_d_Hecke();"
function MakeCharacter_19_d_Hecke(Kf)
    N := 19;
    order := 6;
    char_gens := [2];
    char_values := [[0, 0, 0, 1, 0, 0, 0, 0, 0, 0]];
    assert UnitGenerators(DirichletGroup(N)) eq char_gens;
    values := ConvertToHeckeField(char_values : pass_field := true, Kf := Kf); // the value of chi on the gens as elements in the Hecke field
    F := Universe(values);// the Hecke field
    chi := DirichletCharacterFromValuesOnUnitGenerators(DirichletGroup(N,F),values);
    return chi;
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 := 5;
    raw_aps := [[0, -1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 1, 0, 0, 0, 0], [2, 1, 1, -3, 0, -1, -1, 0, -1, 0], [-4, 1, -1, 0, 1, 1, -1, 0, 0, 0], [8, -1, 1, 0, -4, -5, 5, 4, -4, 0], [-80, -2, 8, 45, 5, 2, 6, -2, 4, -5], [-61, 4, 5, 63, 0, 2, 7, 0, -3, -17], [-30, -44, -22, 140, -10, 27, 19, -7, 8, -4], [-37, -21, -10, 69, 7, 75, 37, -1, 0, 7], [315, 3, -113, -129, -6, -3, 63, 3, -6, 6], [-198, 207, 207, 396, 11, -67, -67, -4, -4, 22], [88, 156, 156, -176, -11, 30, 30, 21, 21, -22], [-81, -170, 5, -63, 104, 28, -5, -10, 5, 52], [1209, 217, 401, -1253, 0, -44, -55, 0, -33, -8], [5, 63, 40, -489, -87, 7, -5, -17, 0, -87], [-36, 32, -430, 3, 19, -32, 34, 32, -64, -19], [1290, -156, 53, 885, 100, -299, -53, -106, 53, 50], [11, 95, -5, 127, -36, -127, -11, 105, 0, -36], [1777, -43, -194, -1075, 98, 43, -459, -43, 86, -98], [-1683, 31, 7, -1875, -256, -178, -7, -14, 7, -128], [325, 178, 167, -171, 0, 154, 497, 0, -189, 62], [1547, -455, -19, 1897, -160, 312, 19, 38, -19, -80], [752, -538, 538, 0, 356, 124, -124, 1, -1, 0], [-3372, 27, -738, 1503, -13, -27, -312, 27, -54, 13], [3269, 104, -32, 2919, 60, -414, 32, 64, -32, 30], [383, 1951, 957, -3915, 444, -803, -383, 37, 0, 444], [-852, -114, -114, 1704, 142, -74, -74, -158, -158, 284], [-1344, -1370, -1370, 2688, 226, -634, -634, 28, 28, 452], [-3921, -26, 80, -3853, 186, 228, -80, -160, 80, 93], [642, -2106, -2106, -1284, -187, -28, -28, 130, 130, -374], [-1706, -81, 405, 1063, 14, 81, 258, -81, 162, -14], [3890, -552, -1006, -3933, 0, -43, -184, 0, 98, 180], [-802, 2196, 1160, -1569, -284, 1728, 802, -124, 0, -284], [297, 2667, 1152, -2399, -894, -957, -297, 363, 0, -894], [158, 701, 1431, 447, 0, 605, 1181, 0, 29, 630], [4444, -1089, -1089, -8888, 221, 517, 517, 82, 82, 442], [-12445, 2526, 5442, 12235, 0, -210, -810, 0, 390, 55], [12604, 187, -187, 0, 1106, 115, -115, -222, 222, 0], [-1314, 227, -5519, 849, 234, -227, 838, 227, -454, -234], [-1005, -3454, -416, 297, -318, 470, 416, 832, -416, -159], [-10278, 1608, 1608, 20556, -554, 1840, 1840, -463, -463, -1108], [-25627, 117, -2241, 11909, -402, -117, -1575, 117, -234, 402], [19478, -456, 456, 0, 1728, -90, 90, 854, -854, 0], [2661, -6176, 599, 2843, -1986, 1380, -599, -1198, 599, -993], [-5296, 2664, -2664, 0, 451, -2146, 2146, -345, 345, 0], [1588, -6353, -3373, 16167, 688, -3569, -1588, 393, 0, 688], [-957, 4043, -128, -2135, -1928, -1434, 128, 256, -128, -964], [2178, 6194, 295, 1195, 1150, -393, -295, -590, 295, 575], [1842, 750, 750, -3684, 494, 1934, 1934, 223, 223, 988], [25880, -540, 540, 0, 798, 1602, -1602, -2148, 2148, 0], [-14269, 1872, 2097, 10263, 0, -4006, -6365, 0, -1647, 832], [42152, -530, 530, 0, 320, 340, -340, -1208, 1208, 0], [9630, 497, 8416, -3137, 532, -497, 4350, 497, -994, -532], [-1831, 6212, 2680, -13509, -1912, 2810, 1831, 852, 0, -1912], [-47466, -287, -1362, 25053, 422, 287, 2066, -287, 574, -422], [11852, 4144, 8353, -14607, 0, -2755, -5575, 0, 65, 2067], [-15543, 3884, 884, -23181, 2106, -5870, -884, -1768, 884, 1053], [-7182, -1878, -4569, 7869, 0, 687, 2187, 0, -813, 1703], [28144, 6750, -6750, 0, -827, -2808, 2808, 3057, -3057, 0], [-17658, 195, 14114, 9381, 856, -195, 1494, 195, -390, -856], [46532, -462, -966, -48125, 0, -1593, -3144, 0, -42, 3976], [-17172, -1958, -1958, 34344, 465, -3380, -3380, 1943, 1943, 930], [2728, -1542, 327, 565, 4812, -1509, -327, -654, 327, 2406], [62858, -731, 731, 0, -1789, 3925, -3925, 646, -646, 0], [-2538, -10287, -4476, 17929, 396, 6411, 2538, -1335, 0, 396], [-53532, 628, -15648, 28425, -1405, -628, 4574, 628, -1256, 1405], [-36986, -1896, -1896, 73972, -360, 4292, 4292, -631, -631, -720], [-34325, -2098, -2012, -22645, -3892, 7656, 2012, 4024, -2012, -1946], [46226, -6960, -11903, -42201, 0, 4025, 6033, 0, 2017, -6004], [-3760, -6852, 6852, 0, -1278, -9198, 9198, 2004, -2004, 0], [-53104, -4252, 4252, 0, 1419, 1842, -1842, -1720, 1720, 0], [50588, 6060, 11079, -58743, 0, -8155, -15269, 0, -1041, -4823], [-5303, 12523, 4004, -30629, 2505, 6091, 5303, 4515, 0, 2505], [-59480, 14106, 14106, 118960, 2424, 4850, 4850, 512, 512, 4848], [74142, 10539, 10539, -148284, 588, -3723, -3723, -2139, -2139, 1176], [40368, 11974, -627, 48129, -13894, 6507, 627, 1254, -627, -6947], [4322, 29238, 15002, -44463, -1871, -7878, -4322, -766, 0, -1871], [22676, 6335, 17263, -15315, 0, 7361, 10129, 0, 4593, -8002], [82191, -9810, 1504, 80151, -1148, 968, -1504, -3008, 1504, -574], [16580, -499, 14044, -19743, 390, 499, -23904, -499, 998, -390], [74990, -16486, 16486, 0, -1944, 3552, -3552, 434, -434, 0], [-12164, 8531, 2641, -10381, 9608, 7065, -2641, -5282, 2641, 4804], [-203178, 441, 17373, 98331, -316, -441, -5634, 441, -882, 316], [51080, 1161, -8892, -21331, -4053, -1161, 10740, 1161, -2322, 4053], [16808, 33554, -2843, 7317, -1830, -15177, 2843, 5686, -2843, -915], [2579, -31454, -13770, 68307, -2640, -1244, -2579, -3914, 0, -2640], [11136, 2679, 2679, -22272, -4771, 6083, 6083, 2431, 2431, -9542], [-7972, -13115, 13115, 0, 343, 3259, -3259, 2847, -2847, 0], [-12061, -7446, -9850, 3237, 0, -8824, -22690, 0, 5042, -8403], [-55980, 608, -608, 0, 3622, 12698, -12698, 4764, -4764, 0], [72284, 3243, -3243, 0, 2964, -405, 405, -514, 514, 0], [-2470, -13657, -2571, -86589, -1382, 13455, 2470, -8515, 0, -1382], [-23540, 14433, 14433, 47080, 3163, -8049, -8049, -294, -294, 6326], [-85567, 6555, 14195, 84945, 0, -622, -2329, 0, 1085, -13848], [-6312, -10708, -18416, 19433, 0, 13121, 23242, 0, 3000, 5142], [-10279, 17733, 8148, 51861, -3487, 19121, 10279, 1437, 0, -3487], [-29034, -1106, -1306, 1233, -2429, 1106, -28780, -1106, 2212, 2429], [42816, 34026, 34026, -85632, 2075, -25222, -25222, -590, -590, 4150], [-193906, 795, 17421, 104285, 3912, -795, 16254, 795, -1590, -3912], [-3810, -27072, -12876, 118431, -1679, 8940, 3810, -1320, 0, -1679], [38796, -1441, 6331, -18977, -1568, 1441, -2040, -1441, 2882, 1568], [3098, 56660, 25254, -45351, -1121, -12348, -3098, 6152, 0, -1121], [188742, -24972, -24972, -377484, -4454, -4988, -4988, -1081, -1081, -8908], [-124152, -22835, -22835, 248304, 506, -21915, -21915, 3609, 3609, 1012], [-87202, 20844, -20844, 0, 1722, -11214, 11214, -10491, 10491, 0], [-128488, -31630, 31630, 0, 4565, 2324, -2324, -1332, 1332, 0], [-229153, 15921, 31831, 229485, 0, 332, 675, 0, -11, -7786], [19004, 15905, 7786, -382203, 5462, -38341, -19004, 333, 0, 5462], [102873, -3571, 8490, -63165, -5209, 3571, -30599, -3571, 7142, 5209], [75956, -16209, -16209, -151912, 1447, -10537, -10537, -4579, -4579, 2894], [23280, -20775, -20775, -46560, 6065, 30791, 30791, 3188, 3188, 12130], [-260001, -13374, -23814, 244605, 0, -15396, -33726, 0, 2934, 2219], [-16192, -1922, -4770, -131085, 4872, 24766, 16192, 7618, 0, 4872], [113774, -5586, 5586, 0, 1152, 12528, -12528, -78, 78, 0], [12963, 71787, 35610, 182223, 8119, -26493, -12963, 567, 0, 8119], [126759, 62814, -725, 126003, 21916, -2206, 725, 1450, -725, 10958], [159508, 23544, 38874, -161827, 0, -2319, 3576, 0, -8214, 8166], [102158, 12604, -12604, 0, 8656, -9298, 9298, -4224, 4224, 0], [40340, -11608, 11608, 0, 15488, -18698, 18698, -1484, 1484, 0], [-232626, 8321, -4175, 103725, -14544, -8321, -8534, 8321, -16642, 14544], [-269693, 247, 21851, 119667, 14654, -247, -29865, 247, -494, -14654], [172360, -37155, -37155, -344720, 5438, -10751, -10751, 877, 877, 10876], [79398, 12038, 12038, -158796, -9402, 31388, 31388, 3142, 3142, -18804], [-227634, 14408, 14408, 455268, -4582, 25084, 25084, -5080, -5080, -9164], [-19598, -9580, 9580, 0, -22698, 1058, -1058, -8178, 8178, 0], [3116, -63617, -136849, -7365, 0, -4249, 1117, 0, -9615, 3676], [-26451, -56331, -27255, 145751, -6988, 54723, 26451, -1821, 0, -6988], [-85315, -12477, -32541, 70053, 0, -15262, -22937, 0, -7587, -11672], [259003, 36249, 63051, -283279, 0, -24276, -39105, 0, -9447, 66], [-281584, -21626, 21626, 0, -12713, -13472, 13472, 11727, -11727, 0], [-8240, 19134, 48447, 22271, 0, 14031, 17883, 0, 10179, 12648], [-157320, -20132, 9797, -151893, 16430, 25021, -9797, -19594, 9797, 8215], [228584, 10387, -88981, -100529, -6330, -10387, 48300, 10387, -20774, 6330], [-156971, 16048, 39374, 146823, 0, -10148, -27574, 0, 7278, -30025], [-77392, 13632, -13632, 0, 21473, -23654, 23654, 2074, -2074, 0], [-2118, 89559, 42222, -105205, 23081, -879, 2118, 5115, 0, 23081], [-190275, -9001, -10577, 113757, -6954, 9001, 19237, -9001, 18002, 6954], [134838, -30366, -30366, -269676, 5488, -30962, -30962, 3739, 3739, 10976], [-368340, 30464, 30464, 736680, 9381, 22106, 22106, -1373, -1373, 18762], [-630586, 41713, -41713, 0, -14485, 18313, -18313, -2333, 2333, 0], [-274162, 1599, 62817, 147005, 14268, -1599, 23046, 1599, -3198, -14268], [-13258, 135572, 71472, -243309, -15509, 33888, 13258, -7372, 0, -15509], [24488, -88135, -41981, 395195, 3452, -44803, -24488, -4173, 0, 3452], [474519, 4768, -29978, -237051, 5178, -4768, 9953, 4768, -9536, -5178], [-16088, 20544, 20544, 32176, 24706, 34104, 34104, -7248, -7248, 49412], [23760, -26992, 8181, -43833, -3402, -51231, -8181, -16362, 8181, -1701], [186423, 15058, 39230, -182549, 0, 3874, -1366, 0, 9114, -32729], [293361, 86944, -9804, 282417, -35596, -30552, 9804, 19608, -9804, -17798], [-19665, -2916, -5706, 384149, 23468, 30834, 19665, 8496, 0, 23468], [-207834, -5345, -5345, 415668, -11765, -35299, -35299, 1336, 1336, -23530], [215822, -21031, -1385, 219825, -21036, 1233, 1385, 2770, -1385, -10518], [57230, -32503, 32503, 0, 24217, -4471, 4471, 483, -483, 0], [-21649, 134408, 57646, 48147, -12110, 24182, 21649, 19116, 0, -12110], [-607086, -6969, -62615, 329121, -16980, 6969, 37218, -6969, 13938, 16980], [-183488, -99646, 13405, -178075, 31544, 32223, -13405, -26810, 13405, 15772], [-72636, -161773, -161773, 145272, 2503, 4905, 4905, 4698, 4698, 5006], [-214370, -40724, 40724, 0, 7448, -63854, 63854, 13872, -13872, 0], [207515, 28638, 67634, -249381, 0, -41866, -94090, 0, 10358, -29208], [-8222, 92617, 55670, -113229, -19496, 35167, 8222, -18723, 0, -19496], [735522, -5304, 134584, -363153, 4419, 5304, -1392, -5304, 10608, -4419], [598385, -48331, -103305, -565377, 0, 33008, 72659, 0, -6643, 27240], [-371961, -70786, 6575, -364977, 37020, 20134, -6575, -13150, 6575, 18510], [-443825, 96515, 189391, 442843, 0, -982, 1675, 0, -3639, 17884], [-318372, -14990, -5249, -271323, 37484, 36551, 5249, 10498, -5249, 18742], [317814, -61344, -61344, -635628, -17033, 14278, 14278, -4336, -4336, -34066], [-129657, -87863, -2377, -57783, 21644, 67120, 2377, 4754, -2377, 10822], [76323, 157497, -1041, 103305, 40592, 24900, 1041, 2082, -1041, 20296], [66449, 48215, 31909, -477409, -37546, -117295, -66449, -15603, 0, -37546]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_19_d_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_19_5_d_a();".
// 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_19_5_d_a(:prec:=10)
    chi := MakeCharacter_19_d();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 5));
    S := BaseChange(S, Kf);
    maxprec := NextPrime(997) - 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_19_5_d_a();".
// 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_19_5_d_a( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_19_d();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,5,sign)));
    Vf := Kernel([],Snew);
    return Vf;
end function;