
// Make newform 60.5.b.a in Magma, downloaded from the LMFDB on 19 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_60_b();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_60_b_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_60_5_b_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_60_5_b_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 := [25600, 0, 17000, 0, 2705, 0, 110, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0, 0, 0, 0, 0], [148000, 536200, 148200, 113385, 8200, 5190, 80, 49], [1511200, -120200, 379240, 45535, 15280, 3010, 136, 31], [-444000, 1608600, -444600, 340155, -24600, 15570, -240, 147], [7693120, 1455400, 2318440, 338005, 113680, 14470, 1096, 133], [18668000, 698200, 4518200, -739265, 178700, -45410, 1580, -461], [0, 476200, 0, 187485, 0, 9290, 0, 89], [4602160, -3458200, 1348840, -913315, 64480, -40690, 616, -379]];
    Rf_basisdens := [1, 53600, 32160, 53600, 32160, 80400, 13400, 16080];
    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_60_b();"
function MakeCharacter_60_b()
    N := 60;
    order := 2;
    char_gens := [31, 41, 37];
    v := [2, 1, 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_60_b_Hecke();"
function MakeCharacter_60_b_Hecke(Kf)
    N := 60;
    order := 2;
    char_gens := [31, 41, 37];
    char_values := [[1, 0, 0, 0, 0, 0, 0, 0], [-1, 0, 0, 0, 0, 0, 0, 0], [-1, 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 := 5;
    raw_aps := [[0, 0, 0, 0, 0, 0, 0, 0], [0, -1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 0], [0, 0, -1, 0, -1, 0, 0, 1], [0, -3, 0, -1, 0, 0, 3, 0], [0, -11, 5, 4, 0, 1, 0, 0], [48, 1, 2, 0, -5, 1, 0, -1], [0, 11, 10, -3, 0, 2, 0, 0], [0, 6, -27, 0, 3, 6, 0, -3], [-188, -1, -2, 0, 5, -1, 0, 1], [0, 147, 0, 49, 0, 0, -23, 0], [0, 11, -48, 0, 7, 11, 0, -7], [0, -63, 0, -21, 0, 0, 8, 0], [0, -241, 40, 83, 0, 8, 0, 0], [0, 165, 45, -52, 0, 9, 0, 0], [0, -8, 19, 0, -21, -8, 0, 21], [-1372, 7, 14, 0, -35, 7, 0, -7], [0, 399, 0, 133, 0, 0, 104, 0], [0, -20, 86, 0, -14, -20, 0, 14], [0, -294, 0, -98, 0, 0, -46, 0], [1884, 3, 6, 0, -15, 3, 0, -3], [0, 11, -110, -11, 0, -22, 0, 0], [0, -4, 62, 0, 42, -4, 0, -42], [0, 528, 0, 176, 0, 0, -148, 0], [0, 10, -57, 0, -7, 10, 0, 7], [0, 324, 0, 108, 0, 0, -125, 0], [0, 75, -390, -51, 0, -78, 0, 0], [3476, 15, 30, 0, -75, 15, 0, -15], [0, 429, -135, -152, 0, -27, 0, 0], [0, -882, 0, -294, 0, 0, -71, 0], [0, -104, 569, 0, 49, -104, 0, -49], [0, 669, 465, -192, 0, 93, 0, 0], [9680, 1, 2, 0, -5, 1, 0, -1], [0, -21, -91, 0, -196, -21, 0, 196], [-24404, 11, 22, 0, -55, 11, 0, -11], [0, -1911, 0, -637, 0, 0, 419, 0], [0, 2247, 0, 749, 0, 0, 88, 0], [0, 2847, -240, -965, 0, -48, 0, 0], [0, 781, 1265, -176, 0, 253, 0, 0], [0, -36, 341, 0, 161, -36, 0, -161], [-30802, 2, 4, 0, -10, 2, 0, -2], [0, 268, -1384, 0, -44, 268, 0, 44], [0, -840, 0, -280, 0, 0, -1036, 0], [0, 1829, 565, -572, 0, 113, 0, 0], [15180, -53, -106, 0, 265, -53, 0, 53], [-44520, 13, 26, 0, -65, 13, 0, -13], [0, 2874, 0, 958, 0, 0, 47, 0], [0, 1423, 1040, -405, 0, 208, 0, 0], [12154, 124, 248, 0, -620, 124, 0, -124], [0, 3637, -235, -1228, 0, -47, 0, 0], [0, -224, 900, 0, -220, -224, 0, 220], [-43220, -117, -234, 0, 585, -117, 0, 117], [0, -368, 1763, 0, -77, -368, 0, 77], [0, -4371, -1575, 1352, 0, -315, 0, 0], [0, -3301, 1810, 1221, 0, 362, 0, 0], [0, -291, 1455, 0, 0, -291, 0, 0], [-30260, 139, 278, 0, -695, 139, 0, -139], [0, 4767, 0, 1589, 0, 0, 85, 0], [0, 237, -1104, 0, 81, 237, 0, -81], [0, 2001, 0, 667, 0, 0, 526, 0], [0, 4893, -2895, -1824, 0, -579, 0, 0], [0, 4407, 0, 1469, 0, 0, -2190, 0], [0, -184, 1186, 0, 266, -184, 0, -266], [0, -5682, 0, -1894, 0, 0, -910, 0], [0, -5339, 845, 1836, 0, 169, 0, 0], [-22616, 21, 42, 0, -105, 21, 0, -21], [0, 11844, 0, 3948, 0, 0, 1204, 0], [0, -4065, -2760, 1171, 0, -552, 0, 0], [-35026, -142, -284, 0, 710, -142, 0, 142], [0, 8653, 2105, -2744, 0, 421, 0, 0], [0, 92, -866, 0, -406, 92, 0, 406], [0, 1926, 0, 642, 0, 0, -1277, 0], [0, -5817, 0, -1939, 0, 0, 2085, 0], [10600, 437, 874, 0, -2185, 437, 0, -437], [0, -2273, 1520, 859, 0, 304, 0, 0], [0, 537, -3251, 0, -566, 537, 0, 566], [0, -6291, 0, -2097, 0, 0, 1339, 0], [0, -736, 2660, 0, -1020, -736, 0, 1020], [-64436, 379, 758, 0, -1895, 379, 0, -379], [0, 248, -127, 0, 1113, 248, 0, -1113], [136228, 343, 686, 0, -1715, 343, 0, -343], [0, 756, -2932, 0, 848, 756, 0, -848], [0, -588, 0, -196, 0, 0, -1432, 0], [70932, -57, -114, 0, 285, -57, 0, 57], [0, -3105, 5520, 1403, 0, 1104, 0, 0], [0, 1, -862, 0, -857, 1, 0, 857], [0, -8526, 0, -2842, 0, 0, 1246, 0], [0, 1054, -3583, 0, 1687, 1054, 0, -1687], [0, 7182, 0, 2394, 0, 0, -2109, 0], [0, 14763, -2550, -5091, 0, -510, 0, 0], [0, 2140, -10224, 0, 476, 2140, 0, -476], [0, -7644, 0, -2548, 0, 0, -837, 0], [0, -824, 3815, 0, -305, -824, 0, 305], [93744, -31, -62, 0, 155, -31, 0, 31], [0, 6975, 960, -2261, 0, 192, 0, 0], [0, -898, 5533, 0, 1043, -898, 0, -1043], [0, -68, -150, 0, -490, -68, 0, 490], [0, -6615, 0, -2205, 0, 0, 4264, 0], [305338, -148, -296, 0, 740, -148, 0, 148], [0, -10773, 0, -3591, 0, 0, 5542, 0], [0, 35853, -4815, -12272, 0, -963, 0, 0], [0, -5813, -5830, 1549, 0, -1166, 0, 0], [0, -1563, 6520, 0, -1295, -1563, 0, 1295], [122752, 809, 1618, 0, -4045, 809, 0, -809], [0, 12144, 0, 4048, 0, 0, 4984, 0], [0, -15633, -4920, 4883, 0, -984, 0, 0], [0, -16947, -135, 5640, 0, -27, 0, 0], [0, -536, 1706, 0, -974, -536, 0, 974], [164012, -821, -1642, 0, 4105, -821, 0, 821], [0, -1962, 0, -654, 0, 0, -1591, 0], [0, 34923, 0, 11641, 0, 0, -3187, 0], [0, -18203, -1075, 5996, 0, -215, 0, 0], [321016, -115, -230, 0, 575, -115, 0, 115], [196100, 783, 1566, 0, -3915, 783, 0, -783], [0, -1297, 8718, 0, 2233, -1297, 0, -2233], [0, -9069, 0, -3023, 0, 0, -9786, 0], [0, -18213, -510, 6037, 0, -102, 0, 0], [0, 3269, -875, -1148, 0, -175, 0, 0], [0, -668, 5101, 0, 1761, -668, 0, -1761], [34100, -1361, -2722, 0, 6805, -1361, 0, 1361], [0, -11424, 0, -3808, 0, 0, -3156, 0], [0, -1451, -3115, 276, 0, -623, 0, 0], [0, 28031, -11000, -10077, 0, -2200, 0, 0], [-233216, -199, -398, 0, 995, -199, 0, 199], [0, 1973, -12837, 0, -2972, 1973, 0, 2972], [43566, 930, 1860, 0, -4650, 930, 0, -930], [0, 68, 836, 0, 1176, 68, 0, -1176], [0, 52920, 0, 17640, 0, 0, 1671, 0], [0, 19017, 0, 6339, 0, 0, 11371, 0], [-137680, -1279, -2558, 0, 6395, -1279, 0, 1279], [0, 12591, 17880, -3005, 0, 3576, 0, 0], [-187396, -509, -1018, 0, 2545, -509, 0, 509], [0, -45465, 0, -15155, 0, 0, 10981, 0], [0, 1004, -7274, 0, -2254, 1004, 0, 2254], [-54282, -1354, -2708, 0, 6770, -1354, 0, 1354], [0, -14235, 22965, 6276, 0, 4593, 0, 0], [0, 43023, 0, 14341, 0, 0, -14198, 0], [0, 39397, 15725, -12084, 0, 3145, 0, 0], [0, 1980, -8718, 0, 1182, 1980, 0, -1182], [-390248, 509, 1018, 0, -2545, 509, 0, -509], [0, -2159, 9561, 0, -1234, -2159, 0, 1234], [0, -21504, 0, -7168, 0, 0, 7191, 0], [0, -34421, -7390, 10981, 0, -1478, 0, 0], [-806460, 151, 302, 0, -755, 151, 0, -151], [0, 52, 2134, 0, 2394, 52, 0, -2394], [0, -441, 0, -147, 0, 0, -16463, 0], [0, 18285, -21255, -7512, 0, -4251, 0, 0], [799456, -231, -462, 0, 1155, -231, 0, 231], [0, -7089, -7800, 1843, 0, -1560, 0, 0], [0, -42147, 0, -14049, 0, 0, 7727, 0], [0, 5775, -24150, 0, 4725, 5775, 0, -4725], [0, 5523, 0, 1841, 0, 0, -660, 0], [0, -4005, 9090, 1941, 0, 1818, 0, 0], [0, -76923, 0, -25641, 0, 0, -5478, 0], [0, -3380, 16004, 0, -896, -3380, 0, 896], [-186444, 2375, 4750, 0, -11875, 2375, 0, -2375], [0, -4897, 26998, 0, 2513, -4897, 0, -2513], [0, 61842, 0, 20614, 0, 0, -9310, 0], [0, -314, 121, 0, -1449, -314, 0, 1449], [0, 38271, -22920, -14285, 0, -4584, 0, 0], [0, 61693, 9665, -19920, 0, 1933, 0, 0], [0, -82992, 0, -27664, 0, 0, 12329, 0], [0, -6564, 28935, 0, -3885, -6564, 0, 3885], [0, -44427, -12315, 13988, 0, -2463, 0, 0], [0, -59153, -40, 19715, 0, -8, 0, 0], [-83708, -561, -1122, 0, 2805, -561, 0, 561], [0, -114213, 0, -38071, 0, 0, 14037, 0]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_60_b_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_60_5_b_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_60_5_b_a(:prec:=8)
    chi := MakeCharacter_60_b();
    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_60_5_b_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_60_5_b_a( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_60_b();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,5,sign)));
    Vf := Kernel([],Snew);
    return Vf;
end function;