
// Make newform 1344.4.c.c in Magma, downloaded from the LMFDB on 24 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_1344_c();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_1344_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_1344_4_c_c();".
// 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_1344_4_c_c();".
// 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 := [13042, 2466, 299, -164, -17, -2, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0, 0, 0], [-47393, -157, -453, 553, -54, 4], [6037, -31287, 2952, -427, 236, -11], [-1699, -4726, -529, 54, 28, -3], [-88273, 123, 4692, 1183, -194, -31], [-17197, -1678, 563, 162, 34, -9]];
    Rf_basisdens := [1, 39375, 13125, 1875, 13125, 1875];
    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_1344_c();"
function MakeCharacter_1344_c()
    N := 1344;
    order := 2;
    char_gens := [127, 1093, 449, 577];
    v := [2, 1, 2, 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_1344_c_Hecke();"
function MakeCharacter_1344_c_Hecke(Kf)
    N := 1344;
    order := 2;
    char_gens := [127, 1093, 449, 577];
    char_values := [[1, 0, 0, 0, 0, 0], [-1, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0], [1, 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, 0, 0, 0], [0, 3, 0, 0, 0, 0], [0, 1, -1, 0, 0, 0], [7, 0, 0, 0, 0, 0], [0, -23, 2, 0, 3, 0], [0, 18, -5, 0, -1, 0], [-9, 0, 0, 1, 0, 10], [0, -14, 7, 0, -7, 0], [-35, 0, 0, -1, 0, -8], [0, -30, 13, 0, -17, 0], [20, 0, 0, -19, 0, -11], [0, -212, 9, 0, 21, 0], [-39, 0, 0, -1, 0, -10], [0, 6, 22, 0, 26, 0], [-72, 0, 0, 40, 0, 28], [0, -390, -15, 0, 15, 0], [0, 32, -6, 0, -58, 0], [0, -400, -35, 0, -1, 0], [0, 20, -78, 0, -12, 0], [-177, 0, 0, -29, 0, 22], [-12, 0, 0, -54, 0, 48], [246, 0, 0, 14, 0, 76], [0, -34, 74, 0, 76, 0], [399, 0, 0, -7, 0, -70], [-412, 0, 0, 72, 0, 6], [0, -831, -47, 0, -38, 0], [488, 0, 0, -93, 0, -21], [0, -725, -50, 0, 65, 0], [0, 32, 30, 0, -78, 0], [-468, 0, 0, -8, 0, -122], [982, 0, 0, 108, 0, -6], [0, 110, 104, 0, -110, 0], [676, 0, 0, -16, 0, -62], [0, 460, -168, 0, -84, 0], [0, -2270, 45, 0, 43, 0], [1084, 0, 0, 118, 0, 98], [0, -8, -265, 0, 133, 0], [0, -2000, 50, 0, 124, 0], [622, 0, 0, 44, 0, 178], [0, -1433, 199, 0, 26, 0], [0, -683, 114, 0, -53, 0], [0, -1486, 71, 0, -113, 0], [1987, 0, 0, 31, 0, -66], [-1040, 0, 0, -39, 0, 135], [0, -1824, -111, 0, -87, 0], [2932, 0, 0, -62, 0, 2], [0, 694, 428, 0, -44, 0], [4288, 0, 0, -82, 0, -86], [0, 1174, 70, 0, 56, 0], [0, -790, -401, 0, -1, 0], [-1622, 0, 0, -112, 0, 112], [1727, 0, 0, -97, 0, 402], [-2856, 0, 0, 224, 0, 154], [0, 102, 84, 0, 126, 0], [2369, 0, 0, 271, 0, 302], [-793, 0, 0, -111, 0, -116], [0, -1053, -723, 0, -180, 0], [1676, 0, 0, 339, 0, -105], [0, -1028, 99, 0, 219, 0], [-1030, 0, 0, -106, 0, 270], [0, -1158, 143, 0, 85, 0], [0, -3873, 175, 0, 82, 0], [0, 2630, -299, 0, -445, 0], [-5552, 0, 0, 108, 0, 32], [4334, 0, 0, 4, 0, 152], [0, -1790, -703, 0, -57, 0], [0, -898, 266, 0, -266, 0], [1094, 0, 0, -434, 0, -322], [0, -3447, -6, 0, 75, 0], [0, -1344, 929, 0, 439, 0], [-2765, 0, 0, -115, 0, -2], [-8167, 0, 0, 49, 0, -394], [1356, 0, 0, 174, 0, -594], [0, -1328, 94, 0, -226, 0], [0, 2126, 544, 0, 788, 0], [1926, 0, 0, -948, 0, -858], [0, -4638, 363, 0, -411, 0], [0, 5920, 57, 0, -57, 0], [2296, 0, 0, -500, 0, 222], [-3128, 0, 0, -98, 0, 308], [0, -5252, -124, 0, 276, 0], [0, 3436, -443, 0, 389, 0], [-4745, 0, 0, 709, 0, -216], [4602, 0, 0, 746, 0, 334], [-2520, 0, 0, -348, 0, 828], [0, 209, -406, 0, -1001, 0], [-2316, 0, 0, 824, 0, -454], [1074, 0, 0, -980, 0, 224], [0, -3207, -259, 0, -778, 0], [5398, 0, 0, -198, 0, -360], [0, 446, 1012, 0, 342, 0], [-4028, 0, 0, 166, 0, 246], [-11944, 0, 0, 56, 0, -320], [0, 5823, 1146, 0, 753, 0], [0, -10058, -720, 0, 264, 0], [-8626, 0, 0, -1010, 0, -112], [0, -4527, 171, 0, 12, 0], [-5415, 0, 0, 39, 0, 1062], [0, 3128, 1228, 0, 8, 0], [0, 7552, 1227, 0, 519, 0], [0, 13448, -768, 0, -606, 0], [0, -2454, 851, 0, 1505, 0], [0, 10612, -1010, 0, -346, 0], [-1678, 0, 0, 1920, 0, 412], [0, -1172, 430, 0, -244, 0], [-11866, 0, 0, 278, 0, -62], [0, -12462, 14, 0, -532, 0], [8489, 0, 0, -385, 0, 630], [-11785, 0, 0, -965, 0, -1066], [5558, 0, 0, 236, 0, 1660], [9080, 0, 0, 778, 0, 1358], [0, 16420, -376, 0, -224, 0], [-13980, 0, 0, -1192, 0, 302], [0, 5012, -540, 0, -12, 0], [-12162, 0, 0, 76, 0, 1010], [-6648, 0, 0, -854, 0, 196], [0, -5926, 1851, 0, 1401, 0], [-18742, 0, 0, -836, 0, 14], [0, -11324, -1055, 0, 809, 0], [0, 11913, 782, 0, -409, 0], [0, 7872, 705, 0, 807, 0], [-8372, 0, 0, -409, 0, -443], [0, 17045, -103, 0, -782, 0], [0, -903, 658, 0, 343, 0], [0, -4860, -1964, 0, 176, 0], [0, -9828, -483, 0, -1659, 0], [0, 9704, 2754, 0, 222, 0], [-4938, 0, 0, 1148, 0, 1214], [1388, 0, 0, -565, 0, -1337], [0, 7954, 869, 0, 997, 0], [0, 3812, -1602, 0, -2004, 0], [-15607, 0, 0, -955, 0, -342], [9956, 0, 0, -2492, 0, -2032], [0, 4796, -914, 0, -850, 0], [24399, 0, 0, 237, 0, -654], [5806, 0, 0, -1614, 0, -222], [0, 2021, 2453, 0, -902, 0], [0, 9028, -1000, 0, -548, 0], [0, -9569, 2295, 0, 370, 0], [2044, 0, 0, -1030, 0, -584], [0, -19744, -1888, 0, 220, 0], [0, -3858, 741, 0, 663, 0], [6682, 0, 0, 2232, 0, -222], [0, 22101, 1134, 0, -441, 0], [0, -9206, -161, 0, 2687, 0], [-19530, 0, 0, 510, 0, -1716], [0, -11448, 2367, 0, 33, 0], [583, 0, 0, -1707, 0, 626], [0, -20790, 1009, 0, -1717, 0], [-7835, 0, 0, 2969, 0, 2362], [0, 6816, -548, 0, -2440, 0], [5389, 0, 0, 923, 0, -794], [0, 34898, -316, 0, 1192, 0], [-9826, 0, 0, -620, 0, 890], [0, 3750, 1282, 0, 2882, 0], [3159, 0, 0, -1171, 0, -1264], [2084, 0, 0, -1332, 0, -1344], [19755, 0, 0, -2731, 0, -430], [12718, 0, 0, 720, 0, 2664], [0, -37703, 1359, 0, -812, 0], [0, -16469, 1026, 0, 97, 0], [-31578, 0, 0, -810, 0, -582], [1682, 0, 0, 44, 0, -2282], [0, -18344, 886, 0, -1030, 0], [-7766, 0, 0, 3446, 0, 1126], [6748, 0, 0, 550, 0, 2034], [-572, 0, 0, 966, 0, 474], [0, 17980, -2595, 0, -1905, 0], [-28796, 0, 0, -2601, 0, 513], [0, -14613, -3213, 0, 486, 0], [0, 4995, -3646, 0, 5, 0], [0, 2356, -659, 0, -2713, 0], [-7065, 0, 0, -2337, 0, -2790], [832, 0, 0, -2219, 0, 791], [25756, 0, 0, 684, 0, 3096], [21811, 0, 0, -91, 0, 2674], [0, 41792, 966, 0, -756, 0], [0, 7932, 223, 0, 2863, 0], [-17996, 0, 0, 2167, 0, 1151], [0, -7860, 827, 0, -3407, 0], [38098, 0, 0, 2546, 0, -356], [0, 1692, -2928, 0, -1032, 0], [0, -17564, -1989, 0, -2697, 0], [-7089, 0, 0, 3241, 0, -686], [35367, 0, 0, 615, 0, -2622], [0, -9153, 4143, 0, 1206, 0], [0, 4240, 672, 0, -1248, 0], [0, 2576, 5900, 0, 436, 0], [31764, 0, 0, 547, 0, 17], [22298, 0, 0, -1614, 0, -56], [14296, 0, 0, 3424, 0, -1306], [0, 40281, -790, 0, 551, 0], [0, 978, -2552, 0, -4276, 0], [0, -5855, 1581, 0, -74, 0], [0, 5263, 1850, 0, 1641, 0], [-13853, 0, 0, 4073, 0, 3238], [14540, 0, 0, -311, 0, 803], [0, -8188, 4701, 0, 4185, 0], [-10469, 0, 0, -1027, 0, 4990], [28360, 0, 0, 224, 0, 1348], [0, 3496, 337, 0, -4567, 0], [3724, 0, 0, 2308, 0, 2840], [0, -7594, -5787, 0, 1389, 0], [-46612, 0, 0, 2966, 0, 2080], [0, -50432, -2104, 0, -1812, 0], [0, 6921, -679, 0, 2630, 0], [17408, 0, 0, -1300, 0, -284], [0, 16575, -3666, 0, -711, 0], [-50234, 0, 0, -3694, 0, 2218], [0, 1194, 2545, 0, 3947, 0], [7654, 0, 0, -500, 0, -3628], [0, 21451, -299, 0, -5140, 0], [9316, 0, 0, -2462, 0, 4574], [0, -42696, -236, 0, 808, 0], [-14444, 0, 0, 2954, 0, -1166], [3974, 0, 0, -4368, 0, -5292], [15404, 0, 0, 286, 0, -1174], [29453, 0, 0, 3219, 0, -3398], [53595, 0, 0, 1069, 0, -1916], [0, 5798, 5413, 0, 2979, 0], [0, 14076, 278, 0, -3650, 0], [34304, 0, 0, -4227, 0, -3279], [40472, 0, 0, 1132, 0, -286], [-11956, 0, 0, 2328, 0, -3300], [0, -24810, -686, 0, 196, 0], [0, -29704, 1681, 0, 3953, 0], [9573, 0, 0, 4047, 0, 1494], [26837, 0, 0, -2853, 0, 1180], [14788, 0, 0, -1477, 0, -6605], [0, 22277, 7266, 0, 4319, 0], [0, 9364, -3746, 0, 4358, 0], [0, 12146, -4195, 0, 4267, 0], [12512, 0, 0, -4668, 0, -6036], [-40656, 0, 0, -3562, 0, -2188], [0, -70342, 2799, 0, 429, 0], [56640, 0, 0, -1512, 0, -3888], [-8348, 0, 0, 326, 0, 3820], [0, -1844, 3881, 0, -315, 0], [0, 36161, -1666, 0, -2765, 0], [-14078, 0, 0, -4898, 0, 780], [0, 23079, 3946, 0, -2747, 0], [0, -31704, -1020, 0, 2544, 0], [25092, 0, 0, 1296, 0, -1956], [0, -19648, -2447, 0, -2467, 0], [-6751, 0, 0, -1005, 0, -6326], [6670, 0, 0, -2546, 0, 6492], [-30576, 0, 0, -2513, 0, 623], [0, 56194, 2254, 0, -28, 0], [0, 39968, 7358, 0, -128, 0], [-16429, 0, 0, 5613, 0, 2428], [0, 29192, 4536, 0, 1584, 0], [41365, 0, 0, 4235, 0, 7126], [32241, 0, 0, 2943, 0, 2748], [29660, 0, 0, 6102, 0, 540], [0, -6113, 2047, 0, 3326, 0], [0, -10599, -1926, 0, 3327, 0], [0, -66676, -3773, 0, -2689, 0], [0, 14882, -1487, 0, -7477, 0], [0, 97155, -2253, 0, 2082, 0], [-6190, 0, 0, 3456, 0, 4320], [-49978, 0, 0, 3928, 0, 1574], [0, -2627, -934, 0, 1119, 0], [0, -8678, 3125, 0, 8041, 0], [0, 6512, 6055, 0, -5815, 0], [8289, 0, 0, -5913, 0, 90], [0, -50264, 524, 0, -3680, 0], [0, 29908, -4409, 0, -3061, 0], [50305, 0, 0, -2277, 0, 1982], [0, 57260, -4972, 0, 3910, 0], [0, 48588, 11979, 0, 2859, 0], [0, 63176, 3257, 0, 2047, 0], [0, 39558, -1562, 0, -1006, 0], [-4040, 0, 0, -4436, 0, -274], [-42364, 0, 0, -5998, 0, 1366], [-15232, 0, 0, 5404, 0, 7826], [-28120, 0, 0, 6705, 0, -1323], [0, 2163, 5534, 0, -5083, 0], [0, 59944, 977, 0, -1043, 0], [17304, 0, 0, -803, 0, 3611], [0, -12210, -4614, 0, -5556, 0], [-27536, 0, 0, -2138, 0, 366], [-59834, 0, 0, -1994, 0, -988], [13752, 0, 0, 4474, 0, 2818], [0, 14008, -2445, 0, -15, 0], [0, -44764, -4532, 0, -2164, 0], [-19093, 0, 0, 2893, 0, -7876], [43734, 0, 0, 2798, 0, -6782], [0, 93168, -4861, 0, -5941, 0], [-16628, 0, 0, -3303, 0, 5877], [-38811, 0, 0, 3687, 0, 2850], [0, 26612, 541, 0, -567, 0], [0, 90234, -496, 0, 3806, 0], [-8728, 0, 0, 8936, 0, 8370], [0, -100544, -7034, 0, -2158, 0], [0, 2528, -4542, 0, -9798, 0], [0, 25399, -6293, 0, -7858, 0], [-39252, 0, 0, -4274, 0, -3634], [0, 3825, 2211, 0, 5112, 0], [0, 66786, 3862, 0, -3524, 0], [0, 47652, -572, 0, -4372, 0], [54350, 0, 0, 1626, 0, -6378], [0, 44174, -4141, 0, -1799, 0], [-64810, 0, 0, 88, 0, 806]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_1344_c_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_1344_4_c_c();".
// 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_1344_4_c_c(:prec:=6)
    chi := MakeCharacter_1344_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(1999) - 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_1344_4_c_c();".
// 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_1344_4_c_c( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_1344_c();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<5,R![80656, 0, 11652, 0, 252, 0, 1]>,<23,R![-455616, -4266, 98, 1]>],Snew);
    return Vf;
end function;