
// Make newform 225.4.f.c in Magma, downloaded from the LMFDB on 25 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_225_f();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_225_f_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_f_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_f_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 := [506944, 0, 126224, 0, 3889, 0, -512, 0, -14, 0, -16, 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], [418024, 0, 83197, 0, 3248, 0, 634, 0, -56, 0, -3, 0], [-1578712, 0, -1896111, 0, -356014, 0, -4502, 0, 2538, 0, -71, 0], [78379688, 0, 22729229, 0, -2560724, 0, 158738, 0, -22972, 0, 1029, 0], [559571096, 0, 44277523, 0, -2434608, 0, 167406, 0, -110024, 0, 5723, 0], [-51726904, 0, -16244903, 0, -1362480, 0, -23478, 0, -2936, 0, 1265, 0], [0, 93476563288, 0, 12758183579, 0, 253832976, 0, 76074438, 0, -12179272, 0, -113621], [0, 554840616, 0, 79774373, 0, -5223568, 0, 577306, 0, -146104, 0, 6773], [0, 28260515592, 0, 6018524881, 0, 1380835984, 0, -15466318, 0, 7804552, 0, -1093919], [0, -11971272, 0, 8928141, 0, 745404, 0, 18534, 0, 7908, 0, -1095], [0, 7004722280, 0, 659420461, 0, -118083000, 0, 15340242, 0, -1867040, 0, 72101], [0, 713598880, 0, -70039446, 0, -13483505, 0, -670717, 0, -59505, 0, 12569]];
    Rf_basisdens := [1, 182400, 3620640, 9051600, 18103200, 2896512, 25778956800, 226131200, 25778956800, 21482464, 1288947840, 161118480];
    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_f();"
function MakeCharacter_225_f()
    N := 225;
    order := 4;
    char_gens := [101, 127];
    v := [2, 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_225_f_Hecke();"
function MakeCharacter_225_f_Hecke(Kf)
    N := 225;
    order := 4;
    char_gens := [101, 127];
    char_values := [[-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 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, -1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [-2, -2, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -7, 0, -7, 3, 0, 1], [9, -9, 2, -3, 0, -2, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -8, -12, 0, 12, 1, 1], [0, -20, 0, 5, 5, 4, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, -2, 8, -2, 6, -6], [0, 0, 0, 0, 0, 0, -25, -4, 25, 0, 5, 0], [-104, 0, -4, 5, -5, 0, 0, 0, 0, 0, 0, 0], [-69, -69, -8, 0, 7, -8, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 38, 0, 38, 29, 0, 16], [8, -8, -16, 14, 0, 16, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -58, -23, 0, 23, 9, 9], [0, 0, 0, 0, 0, 0, 0, 5, 34, 5, -10, 10], [0, 0, 0, 0, 0, 0, -41, 31, 41, 0, -17, 0], [8, 0, -48, 15, -15, 0, 0, 0, 0, 0, 0, 0], [-136, -136, 44, 0, -2, 44, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -16, 0, -16, 4, 0, -32], [-331, 331, 18, 12, 0, -18, 0, 0, 0, 0, 0, 0], [0, 672, 0, 25, 25, 28, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 153, 78, 153, 1, -1], [0, 0, 0, 0, 0, 0, 36, 163, -36, 0, 42, 0], [-231, -231, 50, 0, 78, 50, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 83, 0, 83, 50, 0, -29], [-70, 70, -32, -5, 0, 32, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 118, 91, 0, -91, 7, 7], [0, 0, 0, 15, 15, 96, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 93, -220, 93, -39, 39], [450, 450, -56, 0, -95, -56, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 59, 0, 59, -79, 0, -17], [0, 0, 0, 0, 0, 0, -4, -197, 0, 197, -9, -9], [0, 408, 0, -10, -10, -148, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -35, 164, 35, 0, 85, 0], [-1652, 0, -4, 50, -50, 0, 0, 0, 0, 0, 0, 0], [-335, -335, -56, 0, 15, -56, 0, 0, 0, 0, 0, 0], [-372, 372, 76, -46, 0, -76, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 84, -168, 0, 168, -16, -16], [0, 0, 0, 0, 0, 0, 0, -49, 384, -49, 67, -67], [0, 0, 0, 0, 0, 0, 459, 375, -459, 0, 63, 0], [-656, 0, 32, 35, -35, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -280, 0, -280, -168, 0, 160], [999, -999, 200, -138, 0, -200, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 136, -459, 0, 459, 37, 37], [0, 20, 0, -20, -20, -100, 0, 0, 0, 0, 0, 0], [896, 0, -12, -180, 180, 0, 0, 0, 0, 0, 0, 0], [-1530, 1530, -60, -95, 0, 60, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -52, 270, 0, -270, 150, 150], [0, -234, 0, 20, 20, -196, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, -154, -308, -154, 17, -17], [0, 0, 0, 0, 0, 0, -320, 36, 320, 0, 220, 0], [-1550, 0, 68, -160, 160, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 317, 0, 317, 275, 0, -191], [0, 0, 0, 0, 0, 0, -540, -111, 0, 111, -67, -67], [0, 0, 0, 0, 0, 0, 0, 306, -288, 306, 22, -22], [0, 0, 0, 0, 0, 0, 237, -586, -237, 0, 69, 0], [3324, 0, 196, 70, -70, 0, 0, 0, 0, 0, 0, 0], [-2611, -2611, -110, 0, -247, -110, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 404, 0, 404, -355, 0, -302], [-812, 812, 132, 284, 0, -132, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, -309, -856, -309, 27, -27], [3172, 3172, 452, 0, 314, 452, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -202, 0, -202, -1074, 0, 346], [701, -701, -280, -142, 0, 280, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1418, 203, 0, -203, 186, 186], [4148, 0, -396, 165, -165, 0, 0, 0, 0, 0, 0, 0], [255, 255, 150, 0, -280, 150, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -1296, 840, 0, -840, -220, -220], [0, -824, 0, 345, 345, 608, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, -498, 1740, -498, -11, 11], [0, 0, 0, 0, 0, 0, -570, 530, 570, 0, -90, 0], [3098, 3098, -428, 0, 131, -428, 0, 0, 0, 0, 0, 0], [4997, -4997, -104, -59, 0, 104, 0, 0, 0, 0, 0, 0], [0, 2936, 0, -110, -110, 188, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, -523, -1126, -523, 309, -309], [0, 0, 0, 0, 0, 0, -301, -1700, 301, 0, 83, 0], [1169, 1169, 432, 0, 693, 432, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -1342, 0, -1342, 1823, 0, 346], [0, -3976, 0, 330, 330, 448, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -2045, -933, 2045, 0, 295, 0], [-4390, 0, 228, -300, 300, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1760, 0, 1760, -1852, 0, -80], [4417, -4417, -64, 46, 0, 64, 0, 0, 0, 0, 0, 0], [0, -6444, 0, 310, 310, 292, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 518, -1596, 518, 166, -166], [0, 0, 0, 0, 0, 0, -966, -2079, 966, 0, -102, 0], [-5355, -5355, -70, 0, 210, -70, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -397, 0, -397, 2776, 0, 91], [5630, -5630, 220, -425, 0, -220, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -1046, 1169, 0, -1169, 493, 493], [0, 0, 0, 0, 0, 0, 1436, 1480, -1436, 0, -268, 0], [6850, 6850, -424, 0, -175, -424, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -1963, 0, -1963, -837, 0, -731], [0, 4564, 0, -515, -515, -780, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, -789, 3526, -789, -13, 13], [0, 0, 0, 0, 0, 0, 925, -416, -925, 0, 535, 0], [0, 0, 0, 0, 0, 0, 1514, 0, 1514, 137, 0, 538], [-4512, 4512, 232, 524, 0, -232, 0, 0, 0, 0, 0, 0], [5184, 0, -272, 145, -145, 0, 0, 0, 0, 0, 0, 0], [-3900, -3900, 680, 0, 120, 680, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -50, -2043, 0, 2043, -596, -596], [0, 0, 0, 0, 0, 0, 0, 2460, 320, 2460, -120, 120], [0, 0, 0, 0, 0, 0, 398, -5, -398, 0, 1286, 0], [3092, 0, -228, -135, 135, 0, 0, 0, 0, 0, 0, 0], [-487, -487, -552, 0, -564, -552, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 2606, 1187, 0, -1187, -201, -201], [0, 0, 0, 0, 0, 0, 0, -431, -212, -431, 413, -413], [0, 0, 0, 0, 0, 0, -428, 488, 428, 0, -956, 0], [-10792, 0, -288, 120, -120, 0, 0, 0, 0, 0, 0, 0], [11022, 11022, -264, 0, -751, -264, 0, 0, 0, 0, 0, 0], [-7261, 7261, 192, -543, 0, -192, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 2268, 74, 0, -74, -307, -307], [0, 6672, 0, 100, 100, -1460, 0, 0, 0, 0, 0, 0], [8880, 0, 2668, -785, 785, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 2726, 0, 2726, 497, 0, -608], [-3528, 3528, -412, -444, 0, 412, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -314, 1913, 0, -1913, 301, 301], [0, 0, 0, 0, 0, 0, 0, 949, -5254, 949, -432, 432], [0, 0, 0, 0, 0, 0, 785, 3753, -785, 0, -295, 0], [-11320, 0, 384, -15, 15, 0, 0, 0, 0, 0, 0, 0], [5839, -5839, 448, -798, 0, -448, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -358, -101, 0, 101, -852, -852], [0, 0, 0, 0, 0, 0, 0, 3785, -1586, 3785, -415, 415], [3748, 0, 1892, -685, 685, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -1261, 0, -1261, 3336, 0, 1033], [0, -1286, 0, -840, -840, -1132, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 876, -2564, -876, 0, 1152, 0], [3438, 3438, 1376, 0, 951, 1376, 0, 0, 0, 0, 0, 0], [-5151, 5151, 1274, -633, 0, -1274, 0, 0, 0, 0, 0, 0], [0, 7580, 0, 475, 475, 692, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 413, -838, 413, 921, -921], [-12424, 0, -1380, -45, 45, 0, 0, 0, 0, 0, 0, 0], [1419, 1419, -482, 0, -917, -482, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -3658, 0, -3658, 3357, 0, -266], [0, 5464, 0, 970, 970, -384, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1727, 2350, 1727, 794, -794], [-12236, -12236, -992, 0, -702, -992, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -4248, -2685, 0, 2685, 455, 455], [0, 0, 0, 0, 0, 0, 3102, 4195, -3102, 0, 624, 0], [-6800, 0, -2356, 620, -620, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1121, 0, 1121, 2544, 0, -293], [-6730, 6730, -476, 865, 0, 476, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -1076, 146, 0, -146, 982, 982], [0, 19120, 0, 185, 185, 2032, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -5434, -5062, 5434, 0, 1022, 0], [18957, -18957, -960, 1591, 0, 960, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -4144, -1224, 0, 1224, 777, 777], [0, 448, 0, -680, -680, 804, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, -1540, 3604, -1540, -1480, 1480], [-16937, -16937, 856, 0, 1161, 856, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 728, 0, 728, -1243, 0, -554], [-18372, 18372, 892, -886, 0, -892, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -1620, 1580, 0, -1580, -100, -100], [-8480, -8480, -612, 0, 910, -612, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 2210, 0, 2210, 1682, 0, 1270], [0, 2096, 0, -1235, -1235, -412, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -298, 141, 298, 0, -586, 0], [14307, 14307, 736, 0, 484, 736, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 2861, 0, 2861, -1824, 0, -83], [0, 0, 0, 0, 0, 0, -1636, -2962, 0, 2962, -1134, -1134], [0, 0, 0, 0, 0, 0, 0, 1719, -1796, 1719, 1523, -1523], [2242, 2242, 676, 0, 549, 676, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 3653, 0, 3653, 619, 0, -2159], [0, 0, 0, 0, 0, 0, -10056, -1252, 0, 1252, 641, 641], [0, 0, 0, 0, 0, 0, 0, -1289, -6594, -1289, 247, -247], [34324, 0, -1588, 650, -650, 0, 0, 0, 0, 0, 0, 0], [3915, 3915, 1616, 0, -1395, 1616, 0, 0, 0, 0, 0, 0]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_225_f_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_225_4_f_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_f_c(:prec:=12)
    chi := MakeCharacter_225_f();
    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_f_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_f_c( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_225_f();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<2,R![4096, 0, 0, 0, 149073, 0, 0, 0, 978, 0, 0, 0, 1]>,<7,R![700928, 369408, 97344, -2560, 72, 12, 1]>],Snew);
    return Vf;
end function;