
// Make newform 825.4.c.n in Magma, downloaded from the LMFDB on 24 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_825_c();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_825_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_825_4_c_n();".
// 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_825_4_c_n();".
// 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 := [2, -14, 49, 12, 2, -2, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0, 0, 0], [-103, 6, -18, -27, 8, -3], [737, 10, -30, -45, 29, -5], [93, -673, -237, -3, 27, -16], [131, -949, -255, -30, 35, -19], [693, -5021, -1152, -177, 183, -98]];
    Rf_basisdens := [1, 141, 141, 141, 141, 141];
    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_825_c();"
function MakeCharacter_825_c()
    N := 825;
    order := 2;
    char_gens := [551, 727, 376];
    v := [2, 1, 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_825_c_Hecke();"
function MakeCharacter_825_c_Hecke(Kf)
    N := 825;
    order := 2;
    char_gens := [551, 727, 376];
    char_values := [[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, -1, 0, 0], [0, 0, 0, 0, -3, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 4, -7, 1], [11, 0, 0, 0, 0, 0], [0, 0, 0, 5, 13, 1], [0, 0, 0, 4, 19, -3], [56, 7, 8, 0, 0, 0], [0, 0, 0, 12, 49, -4], [97, -21, -35, 0, 0, 0], [-85, -35, 47, 0, 0, 0], [0, 0, 0, 55, -14, -73], [7, 32, 55, 0, 0, 0], [0, 0, 0, -17, -23, -23], [0, 0, 0, 65, -132, 61], [0, 0, 0, 54, -56, -34], [176, -119, 37, 0, 0, 0], [-388, -158, -32, 0, 0, 0], [0, 0, 0, 56, -138, 44], [-467, -60, -118, 0, 0, 0], [0, 0, 0, 2, -428, 112], [129, 2, 121, 0, 0, 0], [0, 0, 0, 101, -151, 5], [93, -163, 165, 0, 0, 0], [0, 0, 0, 56, -419, -62], [440, 301, -206, 0, 0, 0], [0, 0, 0, 99, -549, 245], [0, 0, 0, 65, -37, -309], [-77, -61, 183, 0, 0, 0], [0, 0, 0, 340, -518, -180], [0, 0, 0, -56, 169, 191], [-513, 53, -193, 0, 0, 0], [0, 0, 0, 99, -231, 39], [-49, -157, 67, 0, 0, 0], [509, 432, -167, 0, 0, 0], [-2036, -118, 490, 0, 0, 0], [0, 0, 0, -702, -140, 6], [0, 0, 0, 194, 678, -544], [0, 0, 0, -418, -220, -304], [0, 0, 0, 299, 1622, -348], [144, -625, -207, 0, 0, 0], [-558, -231, 313, 0, 0, 0], [-2215, 652, 22, 0, 0, 0], [0, 0, 0, 538, -1014, -114], [0, 0, 0, -131, -1564, 44], [1639, 377, -105, 0, 0, 0], [912, 62, -338, 0, 0, 0], [0, 0, 0, -754, 2526, -480], [0, 0, 0, 929, 1339, -251], [3136, 547, -371, 0, 0, 0], [0, 0, 0, 966, -233, 991], [-508, 194, 510, 0, 0, 0], [2840, -152, -1234, 0, 0, 0], [-3132, -60, 936, 0, 0, 0], [0, 0, 0, -31, -3325, 915], [0, 0, 0, 306, -2064, 1194], [-2334, -742, -412, 0, 0, 0], [691, -1896, 877, 0, 0, 0], [0, 0, 0, -686, 2944, 1160], [501, -908, -1025, 0, 0, 0], [0, 0, 0, 460, -463, -649], [0, 0, 0, -34, 8377, -237], [0, 0, 0, 1490, 2624, 1102], [-815, -129, -857, 0, 0, 0], [0, 0, 0, -985, 450, -321], [0, 0, 0, -474, 3778, -1964], [568, -1346, -680, 0, 0, 0], [0, 0, 0, 1596, 7158, 654], [0, 0, 0, 1246, -1682, 2572], [-4353, -1549, -1679, 0, 0, 0], [0, 0, 0, 1103, 5243, 555], [-1724, -2268, -730, 0, 0, 0], [0, 0, 0, -397, 2789, 329], [0, 0, 0, -584, -2858, -180], [546, -974, -96, 0, 0, 0], [0, 0, 0, 129, 461, -997], [-958, 1914, -802, 0, 0, 0], [0, 0, 0, -1874, 4936, 546], [-5315, -1193, 2325, 0, 0, 0], [-4968, -1602, 1212, 0, 0, 0], [1378, 1907, -223, 0, 0, 0], [-1218, 1311, 1179, 0, 0, 0], [-3360, -148, 110, 0, 0, 0], [0, 0, 0, 2313, -1353, -1141], [3819, -1142, 317, 0, 0, 0], [0, 0, 0, 613, 3170, 603], [3557, 3953, 831, 0, 0, 0], [0, 0, 0, 1596, 3874, -222], [-204, -2736, -2078, 0, 0, 0], [0, 0, 0, -273, -3967, 4121], [0, 0, 0, 844, 8424, -1228], [3582, 90, -2724, 0, 0, 0], [0, 0, 0, 1549, 27, -623], [3019, -2109, 17, 0, 0, 0], [-806, 1104, -170, 0, 0, 0], [0, 0, 0, 1582, 920, -3930], [6514, 2248, 232, 0, 0, 0], [3185, -231, -1177, 0, 0, 0], [0, 0, 0, -1171, -9034, 1588], [1213, 4403, -761, 0, 0, 0], [0, 0, 0, -2089, 8554, 2108], [0, 0, 0, 2791, 2831, 2535], [0, 0, 0, 1600, -1644, 3512], [1311, 3726, -4351, 0, 0, 0], [-14709, 2235, 603, 0, 0, 0], [0, 0, 0, 3675, 3548, -1323], [0, 0, 0, -1525, -666, -2915], [0, 0, 0, -2942, 490, -872], [4758, 3509, 3977, 0, 0, 0], [8666, 1170, -2700, 0, 0, 0], [0, 0, 0, -3584, -806, 1532], [0, 0, 0, 256, 526, 5224], [0, 0, 0, -4461, -8117, 779], [6338, 2558, 4982, 0, 0, 0], [-8128, 4492, -1012, 0, 0, 0], [7199, 4927, 113, 0, 0, 0], [0, 0, 0, -6034, -4450, -2842], [0, 0, 0, -6975, -2394, -497], [0, 0, 0, -2036, 15716, 3450], [17235, 2781, -609, 0, 0, 0], [1698, 4265, 2721, 0, 0, 0], [0, 0, 0, -1450, 660, -2218], [0, 0, 0, -1087, 6769, -3191], [0, 0, 0, -947, -6322, -1359], [866, 4900, -3014, 0, 0, 0], [2880, -327, -5344, 0, 0, 0], [2830, -1447, -4801, 0, 0, 0], [-504, 8540, -2392, 0, 0, 0], [0, 0, 0, -5015, 6561, -5801], [0, 0, 0, -6557, 7085, -221], [7185, 2944, -5869, 0, 0, 0], [0, 0, 0, 1126, -6322, -5140], [-31089, 353, -143, 0, 0, 0], [0, 0, 0, -2166, -5624, 1126], [-8938, -182, 7220, 0, 0, 0], [3516, -5146, 4594, 0, 0, 0], [0, 0, 0, -1874, 3904, -8488], [0, 0, 0, -1370, -13959, 1585], [0, 0, 0, 10586, -1254, 1602], [9663, -1818, -2955, 0, 0, 0], [-2135, -1448, -157, 0, 0, 0], [-3729, -8275, 1655, 0, 0, 0], [0, 0, 0, -2842, -13592, -2602], [0, 0, 0, 2369, 12393, -2861], [-7382, 5516, -908, 0, 0, 0], [33860, 3512, 1568, 0, 0, 0], [0, 0, 0, -2722, 15536, -1564], [0, 0, 0, 6314, -14847, -6701], [-10116, -4192, -5394, 0, 0, 0], [0, 0, 0, 1733, -27275, 9663], [0, 0, 0, 6469, -16835, 745], [-13995, -5437, 1247, 0, 0, 0], [0, 0, 0, -1540, -33276, -204], [0, 0, 0, 8828, -3628, 5686], [0, 0, 0, 1594, -23660, 8188], [29188, 2789, -3701, 0, 0, 0], [-22919, 2044, -553, 0, 0, 0], [-3125, -5753, 8673, 0, 0, 0], [0, 0, 0, 1542, 11118, -1014], [5081, 7754, -4437, 0, 0, 0], [0, 0, 0, -1291, 3602, 861], [0, 0, 0, -3224, 19099, 2055], [0, 0, 0, 4482, -18076, -7746], [-3626, -73, -9837, 0, 0, 0], [0, 0, 0, -2674, 7762, 7378], [0, 0, 0, -2990, 12221, 3426], [-36152, -7774, -1946, 0, 0, 0], [0, 0, 0, 3660, 3758, 2244]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_825_c_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_825_4_c_n();".
// 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_825_4_c_n(:prec:=6)
    chi := MakeCharacter_825_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_825_4_c_n();".
// 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_825_4_c_n( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_825_c();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<2,R![121, 0, 247, 0, 31, 0, 1]>,<7,R![30276, 0, 24361, 0, 602, 0, 1]>],Snew);
    return Vf;
end function;