
// Make newform 225.4.k.c in Magma, downloaded from the LMFDB on 23 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_225_k();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_225_k_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_225_4_k_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_225_4_k_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 := [81, 0, 585, 0, 886, 0, -719, 0, 198, 0, -23, 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, 0], [33786, 0, -1388, 0, -2275, 0, 1311, 0, -260, 0, 17, 0], [-24327, 0, 5566, 0, 9800, 0, -3627, 0, 445, 0, -19, 0], [-5994, 0, -18398, 0, 13350, 0, -3594, 0, 415, 0, -18, 0], [-133794, 0, -411623, 0, 295225, 0, -77019, 0, 8665, 0, -368, 0], [0, 132273, 0, 124141, 0, -115325, 0, 33723, 0, -4055, 0, 181], [29448, 0, 111416, 0, -80150, 0, 21423, 0, -2455, 0, 106, 0], [0, -70929, 0, -67168, 0, 60725, 0, -17154, 0, 2015, 0, -88], [0, -277353, 0, -264751, 0, 233450, 0, -64053, 0, 7355, 0, -316], [0, -514449, 0, -1604758, 0, 1163225, 0, -309924, 0, 35465, 0, -1528], [0, 800019, 0, 3102073, 0, -2181725, 0, 575244, 0, -65540, 0, 2818], [0, -275688, 0, -860821, 0, 620450, 0, -164763, 0, 18830, 0, -811]];
    Rf_basisdens := [1, 7875, 7875, 1125, 7875, 23625, 1575, 6750, 23625, 23625, 23625, 6750];
    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_225_k();"
function MakeCharacter_225_k()
    N := 225;
    order := 6;
    char_gens := [101, 127];
    v := [2, 3];
    // 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_225_k_Hecke();"
function MakeCharacter_225_k_Hecke(Kf)
    N := 225;
    order := 6;
    char_gens := [101, 127];
    char_values := [[0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0], [-1, 0, 0, 0, 0, 0, 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, 0, 0, 0, 0, -1, 0, 0, 0, 1], [0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, -5, 0, -1, 0, -5, 6, 1], [-3, 0, 2, -3, -2, 0, -7, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, -3, 10, 3, 14], [0, 0, 0, 0, 0, 27, 0, -2, -3, 0, 0, 0], [55, 5, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, -36, 42, 36, 9], [-117, 0, 23, -117, -23, 0, -7, 0, 0, 0, 0, 0], [0, 31, 0, -127, 2, 0, 31, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, -46, 0, -24, 51, 0, 0, 0], [0, 20, 0, 72, 49, 0, 20, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 128, 0, 8, 0, 128, 87, -8], [0, 0, 0, 0, 0, 96, 0, 59, 0, 96, -15, -59], [0, 0, 0, 0, 0, -102, 0, -70, 24, 0, 0, 0], [0, 41, 0, 36, -149, 0, 41, 0, 0, 0, 0, 0], [448, 0, 85, 448, -85, 0, 10, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 21, 308, -21, 41], [81, -38, -211, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 10, 0, -44, 192, 0, 0, 0], [-154, 0, 136, -154, -136, 0, -56, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 3, 0, 105, 0, 3, -354, -105], [-549, -84, -156, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, -80, 0, 78, 0, -80, -60, -78], [30, 0, 105, 30, -105, 0, -9, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, -57, -392, 57, 132], [0, 0, 0, 0, 0, 15, 0, 15, 492, 0, 0, 0], [388, -123, 246, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, -252, 309, 252, 262], [0, 0, 0, 0, 0, 524, 0, -31, 45, 0, 0, 0], [0, -174, 0, -642, -546, 0, -174, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, -51, 0, -438, 0, -51, 210, 438], [0, 216, 0, 160, -192, 0, 216, 0, 0, 0, 0, 0], [0, -5, 0, -1740, -454, 0, -5, 0, 0, 0, 0, 0], [667, 0, -368, 667, 368, 0, -167, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, -66, -814, 66, -426], [0, 0, 0, 0, 0, 148, 0, -276, 255, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, -111, 1515, 111, 273], [0, 0, 0, 0, 0, 120, 0, -192, 0, 120, 318, 192], [-1185, -20, -259, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1217, -153, 459, 0, 0, 0, 0, 0, 0, 0, 0, 0], [-225, 0, -419, -225, 419, 0, 118, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, -1089, 82, 1089, -6], [0, 0, 0, 0, 0, 549, 0, -1110, 108, 0, 0, 0], [139, -133, -38, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, -327, 0, 35, 312, 0, -327, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, -283, 0, -663, 0, -283, -99, 663], [0, 0, 0, 0, 0, -1143, 0, 562, 0, -1143, -399, -562], [0, -451, 0, -449, 571, 0, -451, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 612, 0, 12, 1041, 0, 0, 0], [0, 71, 0, -2430, 937, 0, 71, 0, 0, 0, 0, 0], [3148, 0, -698, 3148, 698, 0, 19, 0, 0, 0, 0, 0], [-399, 576, -231, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, -456, 1401, 456, 264], [0, 0, 0, 0, 0, 912, 0, 296, 0, 912, 303, -296], [-2196, 85, 482, 0, 0, 0, 0, 0, 0, 0, 0, 0], [-2509, -203, -16, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, -731, 0, 314, 0, -731, 657, -314], [1506, 0, 1344, 1506, -1344, 0, 219, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1596, -1292, -1596, -353], [0, 0, 0, 0, 0, 0, 0, 0, 1029, -957, -1029, -1566], [0, 0, 0, 0, 0, 1820, 0, -235, 648, 0, 0, 0], [0, -510, 0, 2193, -1659, 0, -510, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, -2017, 0, -1416, 0, -2017, -225, 1416], [0, 0, 0, 0, 0, -1179, 0, 52, 0, -1179, -453, -52], [790, 0, 785, 790, -785, 0, 827, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 2670, -931, -2670, -1586], [0, 0, 0, 0, 0, 0, 0, 0, -1569, -714, 1569, -364], [95, 0, -2404, 95, 2404, 0, 164, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, -2838, 0, 504, 0, -2838, -804, -504], [1071, 534, 1245, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, -1988, 0, 3008, 0, -1988, -1785, -3008], [0, 0, 0, 0, 0, 0, 0, 0, -372, -1136, 372, -1066], [4468, -820, -1178, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, -351, -3192, 351, 300], [1392, 0, 1701, 1392, -1701, 0, 174, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 389, 0, 1916, -2652, 0, 0, 0], [0, 975, 0, 4050, 531, 0, 975, 0, 0, 0, 0, 0], [0, -432, 0, 1816, 1602, 0, -432, 0, 0, 0, 0, 0], [0, -833, 0, -2055, 860, 0, -833, 0, 0, 0, 0, 0], [-1784, 0, 2254, -1784, -2254, 0, 1276, 0, 0, 0, 0, 0], [-4452, -228, -1014, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, -1619, 0, 2326, -453, 0, 0, 0], [8594, 0, -1141, 8594, 1141, 0, -253, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1251, 0, -1497, 0, 1251, -1473, 1497], [-3048, -443, -2089, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 400, 0, 448, 0, 400, 1383, -448], [-3183, 0, -651, -3183, 651, 0, 129, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, -861, 193, 861, -698], [0, 0, 0, 0, 0, -1836, 0, -784, 3987, 0, 0, 0], [4116, 0, 762, 4116, -762, 0, 1152, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 3017, 0, -4350, 2829, 0, 0, 0], [0, 2195, 0, 492, -1661, 0, 2195, 0, 0, 0, 0, 0], [0, 1003, 0, 5062, -3199, 0, 1003, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1089, 0, -1457, -1659, 0, 0, 0], [0, 1664, 0, 2193, -1076, 0, 1664, 0, 0, 0, 0, 0], [-1449, 493, -2947, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 6862, 0, -3641, 1761, 0, 0, 0], [11651, -682, 3328, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 466, 0, 3523, 0, 466, 1368, -3523], [0, 0, 0, 0, 0, -1581, 0, 2892, -4212, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, -417, 1575, 417, 3579], [7590, 0, -1692, 7590, 1692, 0, -2196, 0, 0, 0, 0, 0], [0, -636, 0, -7948, -3396, 0, -636, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, -4882, 0, 846, -2352, 0, 0, 0], [0, 0, 0, 0, 0, 5292, 0, -5781, 0, 5292, 1824, 5781], [0, 0, 0, 0, 0, -2478, 0, -4532, -3609, 0, 0, 0], [0, -416, 0, 6012, -4222, 0, -416, 0, 0, 0, 0, 0], [2932, 0, -1290, 2932, 1290, 0, -1788, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 8541, -1084, -8541, -5009], [0, 0, 0, 0, 0, 6289, 0, -686, 2439, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 384, -2991, -384, 2166], [-769, 0, 1038, -769, -1038, 0, -2367, 0, 0, 0, 0, 0], [-10498, 1669, 707, 0, 0, 0, 0, 0, 0, 0, 0, 0], [10080, 0, 1614, 10080, -1614, 0, -1545, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 45, 2461, -45, -4757], [0, 0, 0, 0, 0, 6423, 0, -3953, -129, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1683, -10518, -1683, -2320], [-10422, 0, -3137, -10422, 3137, 0, -1493, 0, 0, 0, 0, 0], [0, 914, 0, 13154, 850, 0, 914, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 449, 0, -6284, 0, 449, 2013, 6284], [0, 0, 0, 0, 0, 8631, 0, -2460, 0, 8631, 3627, 2460], [0, 0, 0, 0, 0, 1206, 0, 4992, -3741, 0, 0, 0], [-5096, 0, 4138, -5096, -4138, 0, -1328, 0, 0, 0, 0, 0], [7026, 898, 1577, 0, 0, 0, 0, 0, 0, 0, 0, 0], [7151, 0, -3709, 7151, 3709, 0, 2909, 0, 0, 0, 0, 0], [-14196, -1431, 483, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 4774, 0, 423, 0, 4774, -1293, -423], [0, 0, 0, 0, 0, 0, 0, 0, 984, 9169, -984, 2064], [22018, -859, 2101, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 5562, -4107, -5562, -5417], [0, 2474, 0, -5725, -4031, 0, 2474, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, -4180, 0, -3142, 8679, 0, 0, 0], [0, 1755, 0, 5313, -3459, 0, 1755, 0, 0, 0, 0, 0], [0, -351, 0, -19271, -5193, 0, -351, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, -7170, 0, 8796, -4620, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, -4149, 6266, 4149, 1192], [0, 0, 0, 0, 0, 0, 0, 0, 7905, -8007, -7905, -7964], [18066, 1769, 2929, 0, 0, 0, 0, 0, 0, 0, 0, 0], [-23614, -2296, 628, 0, 0, 0, 0, 0, 0, 0, 0, 0], [-17490, 0, 2841, -17490, -2841, 0, 3804, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, -81, 2278, 81, -3237], [0, 0, 0, 0, 0, -12399, 0, -539, -957, 0, 0, 0], [-13250, -2426, -487, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1929, 0, -10594, 1929, 10594, 0, -1609, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, -8881, 0, 8872, 0, -8881, -5871, -8872], [0, 0, 0, 0, 0, 2682, 0, 1610, 0, 2682, 4623, -1610], [0, 1066, 0, 13597, 2771, 0, 1066, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, -39, 0, -8345, 4407, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, -4971, 1490, 4971, -2578], [21252, 1670, -959, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, -9617, 0, -3039, -3135, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, -2067, -4290, 2067, 1812], [0, 0, 0, 0, 0, -7499, 0, -5653, 0, -7499, -3465, 5653], [20238, 0, -5215, 20238, 5215, 0, 3059, 0, 0, 0, 0, 0], [-34568, -286, -2660, 0, 0, 0, 0, 0, 0, 0, 0, 0], [8784, 0, 2180, 8784, -2180, 0, 3494, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 3683, 0, -2954, -72, 0, 0, 0], [0, -703, 0, 8865, 13381, 0, -703, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 4866, 0, -2907, 0, 4866, 7629, 2907], [0, 0, 0, 0, 0, -7875, 0, -3712, 11799, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, -1980, -4816, 1980, -1395], [-10833, -2247, 4272, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 7341, -5481, -7341, 4460], [0, 0, 0, 0, 0, 6540, 0, 1905, 0, 6540, -10902, -1905], [398, 4071, -5133, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, -2384, 0, -874, 0, -2384, -5448, 874]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_225_k_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_225_4_k_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_225_4_k_c(:prec:=12)
    chi := MakeCharacter_225_k();
    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_225_4_k_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_225_4_k_c( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_225_k();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<2,R![81, 0, -2655, 0, 86710, 0, -10307, 0, 930, 0, -35, 0, 1]>],Snew);
    return Vf;
end function;