
// Make newform 74.4.c.b in Magma, downloaded from the LMFDB on 25 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_74_c();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_74_c_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_74_4_c_b();".
// 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_74_4_c_b();".
// 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 := [443556, 497502, 511389, 164178, 67648, -5214, 6309, -140, 84, 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], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0], [-620934447646350, 72259964551152, 73510030975680, -76851150344224, 8941322845902, -1041192911556, 97444452524, -11318780244, 1291648158, -2923369], [-56884796531432298, -58415892817295295, -11320651802402374, -7669494646415948, 617180442626994, -660777027324751, 15340563156556, -8797366014792, 216329306, -103592667275], [-151653093189987762, -43682233694673672, -44437917620472480, 10255188571799297, -5405163931650297, 629416750566366, -79298402920351, 6842372630934, -780820708113, 82964449469], [260020960627171716, 188237480420177496, 191493908174780640, -72853561118616281, 23292179764972371, -2712311464862538, 318765756856633, -29485465261362, 3364748327259, -276538800347], [6268457212298551206, 6453480882011100669, 3385101636576729159, 863941772170989457, -61976010456722316, 90630484257083826, -1882111164964658, 1201327539595005, -622808271963, 14502998162881], [-798612045641956998, -237960216695881008, -242076826482678720, 80760297682695928, -29444785022728758, 3428765740407924, -409020400061429, 37274020494276, -4253543126982, 378746420581], [-802609209663182532, -1851170184076462500, -2110652418918317709, -1502883505705851906, 310299148572658375, -137232325886487043, 5662916693503905, -1770475510640473, 33668105489074, -21187262572329], [33836539355339861034, 34919597698843104711, 19957398724377803151, 4760688828058942478, -303331120279030014, 572203665882183294, -11150616860155192, 7683965959724250, 20662805213298, 94253847831539]];
    Rf_basisdens := [1, 1, 703951748722773, 52092429405485202, 21118552461683190, 21118552461683190, 781386441082278030, 10559276230841595, 260462147027426010, 390693220541139015];
    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_74_c();"
function MakeCharacter_74_c()
    N := 74;
    order := 3;
    char_gens := [39];
    v := [2];
    // 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_74_c_Hecke();"
function MakeCharacter_74_c_Hecke(Kf)
    N := 74;
    order := 3;
    char_gens := [39];
    char_values := [[-1, 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 := 4;
    raw_aps := [[0, 0, 0, 2, 0, 0, 0, 0, 0, 0], [-1, 1, 0, -1, 0, 0, 0, 0, 0, 0], [0, -1, 0, 0, -1, 0, -1, 0, 0, 0], [0, 0, 0, 0, -1, 0, -1, 1, 0, 1], [-8, 0, 2, 0, 0, -3, 0, -1, 0, 0], [14, -4, 0, 14, 3, 0, 3, 3, 1, 3], [0, -4, 4, -13, 0, 0, -4, 0, 0, 4], [8, -2, 0, 8, -7, 0, -7, -4, 0, -4], [-52, 0, 2, 0, -2, -4, 0, 3, 0, 0], [29, 0, 14, 0, 3, 2, 0, 9, 0, 0], [-76, 0, 10, 0, -12, 7, 0, 1, 0, 0], [-5, 17, -1, -12, 16, -6, 18, -8, -5, -11], [72, 3, 0, 72, -15, 0, -15, -4, -7, -4], [-49, 0, 43, 0, -1, 8, 0, -4, 0, 0], [-2, 0, -4, 0, -6, -9, 0, -13, 0, 0], [0, -43, 43, 11, 0, -14, -36, 0, 14, 27], [0, -8, 8, 24, 0, 3, -15, 0, -3, 3], [39, 58, 0, 39, 24, 0, 24, -2, -21, -2], [150, -60, 0, 150, 23, 0, 23, -28, -8, -28], [108, 12, 0, 108, 15, 0, 15, 7, 16, 7], [31, 0, -39, 0, 19, -15, 0, -20, 0, 0], [-156, -6, 0, -156, 53, 0, 53, -6, 20, -6], [0, -107, 107, -441, 0, 0, -24, 0, 0, -24], [0, 109, -109, -180, 0, -11, -1, 0, 11, -16], [-480, 0, 69, 0, 102, 34, 0, 3, 0, 0], [-2, 0, 159, 0, -26, -45, 0, -61, 0, 0], [476, 0, -20, 0, -82, 35, 0, -4, 0, 0], [-391, -179, 0, -391, 2, 0, 2, 7, -27, 7], [0, -50, 50, -99, 0, 61, 32, 0, -61, -14], [0, -29, 29, 153, 0, -44, -94, 0, 44, -19], [0, -18, 18, -656, 0, -7, 15, 0, 7, -64], [0, 41, -41, 319, 0, -32, 44, 0, 32, 16], [-97, 0, -268, 0, -53, 1, 0, -49, 0, 0], [0, -49, 49, 541, 0, -10, -26, 0, 10, -40], [-1329, 0, -84, 0, 65, -10, 0, -7, 0, 0], [-34, 164, 0, -34, -107, 0, -107, -114, -47, -114], [0, -324, 324, -869, 0, -29, -66, 0, 29, 66], [0, 247, -247, -841, 0, 3, -152, 0, -3, 63], [984, 220, 0, 984, 41, 0, 41, -51, -51, -51], [0, 50, -50, -2295, 0, -49, -64, 0, 49, -2], [-282, 0, 222, 0, 130, -40, 0, -148, 0, 0], [-262, -83, 0, -262, 121, 0, 121, -36, -2, -36], [208, 0, -78, 0, 22, 124, 0, 45, 0, 0], [-3115, 0, -18, 0, -95, -27, 0, 63, 0, 0], [0, -236, 236, 847, 0, 79, 218, 0, -79, -26], [1346, 0, 190, 0, -148, -45, 0, 0, 0, 0], [-1769, 0, -161, 0, 27, 2, 0, 36, 0, 0], [-2610, 0, -596, 0, -220, 148, 0, 57, 0, 0], [544, -38, 0, 544, 141, 0, 141, -68, -136, -68], [387, 82, 0, 387, -156, 0, -156, -46, -11, -46], [141, 0, -206, 0, 13, -93, 0, 15, 0, 0], [0, -368, 368, 452, 0, -118, 11, 0, 118, 113], [1845, -181, 0, 1845, 144, 0, 144, 91, 78, 91], [-971, 0, 149, 0, 313, -158, 0, -198, 0, 0], [0, 175, -175, 986, 0, 97, 29, 0, -97, -12], [-2614, -46, 0, -2614, -37, 0, -37, 183, 83, 183], [-302, 0, 512, 0, 496, -280, 0, -248, 0, 0], [0, -400, 400, 1262, 0, -70, -429, 0, 70, -44], [3422, -19, 0, 3422, -79, 0, -79, 8, -126, 8], [0, 434, -434, -1963, 0, 140, 302, 0, -140, 116], [1995, 259, 0, 1995, -188, 0, -188, 381, 77, 381], [-623, -316, 0, -623, 58, 0, 58, -2, 71, -2], [1817, 0, 837, 0, 225, 24, 0, -138, 0, 0], [0, 248, -248, -1876, 0, -226, 307, 0, 226, -55], [0, -523, 523, -1896, 0, -123, -309, 0, 123, -112], [0, 455, -455, 5850, 0, 126, 39, 0, -126, 36], [0, 242, -242, -282, 0, -109, -165, 0, 109, -9], [-3892, -637, 0, -3892, -83, 0, -83, 204, 391, 204], [5961, 0, 63, 0, 117, 247, 0, -41, 0, 0], [0, 117, -117, -2648, 0, 114, 321, 0, -114, 52], [0, -633, 633, 3246, 0, -73, 61, 0, 73, -248], [-272, 0, 984, 0, 460, 56, 0, 172, 0, 0], [-1558, 70, 0, -1558, 171, 0, 171, -343, -189, -343], [1718, -71, 0, 1718, 73, 0, 73, 388, 464, 388], [0, 171, -171, 3571, 0, -87, 448, 0, 87, 379], [3862, 558, 0, 3862, -59, 0, -59, 163, 422, 163], [-3610, -419, 0, -3610, -163, 0, -163, -364, -308, -364], [3844, 0, -571, 0, 868, -199, 0, -21, 0, 0], [3681, 0, 603, 0, -719, -333, 0, 0, 0, 0], [0, -1237, 1237, -394, 0, -309, -439, 0, 309, 408], [0, 51, -51, 1067, 0, 119, 784, 0, -119, 209], [2542, 0, 1439, 0, 258, -331, 0, 99, 0, 0], [-484, 1074, 0, -484, 101, 0, 101, 16, 246, 16], [1422, 0, 1527, 0, 376, 0, 0, -313, 0, 0], [1618, 914, 0, 1618, 103, 0, 103, -245, -245, -245], [-936, 0, 336, 0, -372, -278, 0, 274, 0, 0], [2903, 421, 0, 2903, 90, 0, 90, 219, -208, 219], [-543, 144, 0, -543, -120, 0, -120, -24, -292, -24], [0, -72, 72, 3038, 0, 169, 225, 0, -169, -351], [364, 296, 0, 364, -753, 0, -753, -111, -102, -111], [-2014, 0, -58, 0, 814, -42, 0, -302, 0, 0], [0, 846, -846, -6466, 0, -133, 47, 0, 133, 173], [-9182, 0, -444, 0, 340, 78, 0, 1, 0, 0], [1106, 0, -664, 0, -1350, 249, 0, 289, 0, 0], [9276, 750, 0, 9276, -119, 0, -119, -222, -346, -222], [0, 68, -68, 4882, 0, 124, 1027, 0, -124, -374], [0, -451, 451, -3448, 0, -240, -151, 0, 240, -272], [1355, 1457, 0, 1355, 66, 0, 66, -501, 164, -501], [1271, -931, 0, 1271, 568, 0, 568, -350, -88, -350], [-8495, 0, 478, 0, -437, -218, 0, -427, 0, 0], [-11494, 0, -436, 0, 870, 305, 0, 359, 0, 0], [0, -205, 205, 634, 0, 40, 703, 0, -40, 160], [-187, 0, -2309, 0, -211, 627, 0, 847, 0, 0], [2936, 0, 585, 0, -1438, -196, 0, -381, 0, 0], [0, 287, -287, 4865, 0, 112, 570, 0, -112, -874], [0, 66, -66, -704, 0, 561, -1261, 0, -561, 361], [1281, 1695, 0, 1281, 170, 0, 170, -82, 422, -82], [-440, 0, -939, 0, 842, 12, 0, -133, 0, 0], [9096, -1814, 0, 9096, -795, 0, -795, 880, 268, 880], [0, -50, 50, 7565, 0, 568, -542, 0, -568, -472], [0, 314, -314, -2364, 0, 278, -59, 0, -278, 78], [0, 23, -23, 8542, 0, -128, 467, 0, 128, -456], [0, 1019, -1019, -5363, 0, -106, -1830, 0, 106, -711], [6131, 0, 547, 0, 99, -4, 0, -688, 0, 0], [0, 1120, -1120, -9310, 0, 615, -519, 0, -615, -246], [0, 2295, -2295, -2090, 0, -383, -311, 0, 383, 172], [-1786, 0, 1068, 0, 1730, -783, 0, -213, 0, 0], [-5670, -722, 0, -5670, 89, 0, 89, -165, -474, -165], [-2328, 2115, 0, -2328, 1571, 0, 1571, 168, -60, 168], [-4106, -3286, 0, -4106, -657, 0, -657, 77, 327, 77], [-2352, -1533, 0, -2352, -601, 0, -601, 304, 210, 304], [5681, -441, 0, 5681, 800, 0, 800, -17, -154, -17], [-473, 0, -2932, 0, 1, -190, 0, 373, 0, 0], [0, 91, -91, -2825, 0, 315, -1080, 0, -315, 605], [0, 252, -252, -9790, 0, 64, -21, 0, -64, 2], [0, -3002, 3002, 140, 0, -71, -629, 0, 71, 273], [-6974, 0, 880, 0, -340, -304, 0, 408, 0, 0], [0, -1216, 1216, 18602, 0, -473, 285, 0, 473, 1020], [10356, -856, 0, 10356, -811, 0, -811, -509, -795, -509], [1392, -754, 0, 1392, 17, 0, 17, -1029, 47, -1029], [8017, 0, 879, 0, 457, 89, 0, 63, 0, 0], [5620, -1058, 0, 5620, -2527, 0, -2527, 50, 96, 50], [8350, 0, -1438, 0, 800, 589, 0, 1208, 0, 0], [0, -2338, 2338, -5163, 0, -341, 272, 0, 341, 310], [0, 1736, -1736, 451, 0, -330, 748, 0, 330, -436], [-7927, 0, 267, 0, -1359, 891, 0, 996, 0, 0], [5945, 868, 0, 5945, 1862, 0, 1862, -1014, -847, -1014], [-10214, 0, 2766, 0, 1118, -278, 0, 560, 0, 0], [0, -296, 296, -8370, 0, 839, 1105, 0, -839, 553], [-10847, 2047, 0, -10847, 2148, 0, 2148, -801, -800, -801], [-462, -438, 0, -462, -897, 0, -897, 225, 443, 225], [5046, 1568, 0, 5046, -141, 0, -141, 939, 1467, 939], [0, -640, 640, 11450, 0, -735, -1871, 0, 735, 762], [-11286, 1106, 0, -11286, 2195, 0, 2195, 979, -887, 979], [0, -532, 532, 14962, 0, -951, 889, 0, 951, -635], [0, -2228, 2228, 254, 0, -587, -539, 0, 587, 1278], [0, -152, 152, 11499, 0, -327, -2114, 0, 327, -202], [-2238, 0, 3299, 0, -120, 974, 0, 107, 0, 0], [11493, 0, -703, 0, 1965, 56, 0, 748, 0, 0], [0, 606, -606, 1374, 0, -549, -1045, 0, 549, 1053], [2980, 0, 4665, 0, -428, -367, 0, 87, 0, 0], [-10413, 30, 0, -10413, -318, 0, -318, -804, -1926, -804], [-6701, -3199, 0, -6701, 88, 0, 88, 1518, 1080, 1518], [7890, 0, 2192, 0, 12, -378, 0, -579, 0, 0], [11508, -298, 0, 11508, -1275, 0, -1275, 652, 78, 652], [5362, 0, -592, 0, 1316, -378, 0, 977, 0, 0], [-6792, 0, 878, 0, -42, 646, 0, 693, 0, 0], [9144, -3589, 0, 9144, -411, 0, -411, 916, -185, 916], [0, 1459, -1459, 1926, 0, -389, -27, 0, 389, -32], [0, -144, 144, 11115, 0, 447, 1190, 0, -447, -1242], [0, -2302, 2302, -2470, 0, -1003, -777, 0, 1003, -241], [0, -1507, 1507, -6357, 0, 1528, 284, 0, -1528, 425], [16160, -2036, 0, 16160, 405, 0, 405, -197, -151, -197], [0, 1349, -1349, 1439, 0, -504, 716, 0, 504, 532], [0, 65, -65, 9191, 0, 1042, 1508, 0, -1042, -795], [0, -1748, 1748, -7010, 0, 1650, 275, 0, -1650, -1126], [9810, 0, 986, 0, -764, 893, 0, -1202, 0, 0], [0, 616, -616, 13822, 0, -1247, 597, 0, 1247, 1677]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_74_c_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_74_4_c_b();".
// 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_74_4_c_b(:prec:=10)
    chi := MakeCharacter_74_c();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 4));
    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_74_4_c_b();".
// 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_74_4_c_b( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_74_c();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<3,R![1960000, 896000, 650400, 97120, 69944, 7728, 5696, -26, 99, 5, 1]>],Snew);
    return Vf;
end function;