
// Make newform 825.4.c.k in Magma, downloaded from the LMFDB on 25 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_k();".
// 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_k();".
// 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 := [484, 0, 632, 0, 53, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0], [-22, 0, 27, 0, 1, 0], [0, 1226, 0, 75, 0, 1], [386, 0, 51, 0, 1, 0], [0, -6082, 0, -623, 0, -13]];
    Rf_basisdens := [1, 1, 48, 1056, 24, 352];
    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, 1, 0, 1, 0, 0], [0, 0, 0, 3, 0, 0], [0, 0, 0, 0, 0, 0], [0, -2, 0, -4, 0, -2], [11, 0, 0, 0, 0, 0], [0, 0, 0, 38, 0, -2], [0, -2, 0, 34, 0, 2], [24, 0, -14, 0, -8, 0], [0, 24, 0, 48, 0, 4], [62, 0, 34, 0, 0, 0], [96, 0, -40, 0, 8, 0], [0, -20, 0, -286, 0, 0], [30, 0, 66, 0, 0, 0], [0, 22, 0, 48, 0, -14], [0, 0, 0, -168, 0, 4], [0, 96, 0, 126, 0, 16], [-172, 0, -32, 0, 8, 0], [134, 0, 12, 0, -68, 0], [0, 100, 0, 176, 0, 16], [-324, 0, 60, 0, 28, 0], [0, -36, 0, 194, 0, -38], [212, 0, -94, 0, 8, 0], [0, 180, 0, 60, 0, 54], [-254, 0, -28, 0, 120, 0], [0, 100, 0, -658, 0, 44], [-718, 0, -122, 0, -28, 0], [0, 56, 0, 244, 0, -60], [0, 20, 0, 668, 0, 82], [-1054, 0, -64, 0, -24, 0], [0, 100, 0, 322, 0, -100], [0, 238, 0, -316, 0, -78], [1188, 0, -240, 0, -28, 0], [0, 480, 0, -342, 0, 192], [88, 0, 66, 0, -180, 0], [1782, 0, 126, 0, 68, 0], [-1116, 0, 542, 0, -88, 0], [0, 568, 0, 218, 0, 124], [0, -24, 0, 1688, 0, 252], [0, 372, 0, -1992, 0, 30], [0, -262, 0, 2, 0, 262], [-800, 0, 44, 0, -84, 0], [1006, 0, 88, 0, -60, 0], [-940, 0, 52, 0, 404, 0], [0, -192, 0, -1702, 0, -110], [0, -482, 0, 430, 0, -150], [188, 0, 572, 0, 84, 0], [2432, 0, -18, 0, -72, 0], [0, -76, 0, 1768, 0, -116], [0, 500, 0, 1220, 0, -282], [-122, 0, 120, 0, -164, 0], [0, 382, 0, -722, 0, -414], [3696, 0, 228, 0, -116, 0], [-1182, 0, -52, 0, -76, 0], [4776, 0, 180, 0, 228, 0], [0, -1084, 0, 1658, 0, -284], [0, 12, 0, -1752, 0, -114], [4242, 0, 120, 0, -136, 0], [-1228, 0, -582, 0, -208, 0], [0, 88, 0, 3266, 0, 18], [-2130, 0, 306, 0, 400, 0], [0, 182, 0, 2152, 0, 58], [0, 582, 0, -4158, 0, -142], [0, 798, 0, -584, 0, 718], [-2200, 0, -848, 0, -336, 0], [0, -508, 0, 6490, 0, -248], [0, 1900, 0, 5290, 0, -252], [-284, 0, 1012, 0, 656, 0], [0, 1364, 0, 4326, 0, 182], [0, 420, 0, 348, 0, 282], [4418, 0, 1508, 0, 428, 0], [0, -1504, 0, -4030, 0, 328], [2784, 0, -360, 0, 148, 0], [0, 380, 0, -1752, 0, -748], [0, 2612, 0, 6286, 0, -390], [1880, 0, -1840, 0, -380, 0], [0, -1744, 0, 1256, 0, -144], [1834, 0, 908, 0, 120, 0], [0, -2220, 0, 4882, 0, -836], [-5658, 0, 2160, 0, -280, 0], [4086, 0, -1052, 0, -416, 0], [-4184, 0, -988, 0, 220, 0], [1854, 0, 1688, 0, -484, 0], [3456, 0, -2364, 0, 632, 0], [0, 788, 0, 1066, 0, 204], [1924, 0, 2694, 0, 684, 0], [0, -24, 0, 5940, 0, 808], [9666, 0, 924, 0, -152, 0], [0, 268, 0, 326, 0, -542], [-9614, 0, -1342, 0, -500, 0], [0, 156, 0, 7400, 0, 28], [0, 1296, 0, -4332, 0, -1084], [5568, 0, -2052, 0, 468, 0], [0, 108, 0, -6572, 0, -456], [-444, 0, 2028, 0, 40, 0], [6200, 0, 1124, 0, 556, 0], [0, 588, 0, 6360, 0, 586], [-374, 0, -1888, 0, -720, 0], [7750, 0, -184, 0, 960, 0], [0, -586, 0, -14432, 0, -66], [-858, 0, -400, 0, 1040, 0], [0, -3462, 0, -8960, 0, 570], [0, 114, 0, 11766, 0, -878], [0, -1128, 0, -1404, 0, 1250], [-12550, 0, -1142, 0, 572, 0], [-1272, 0, -2638, 0, -580, 0], [0, -2280, 0, 5494, 0, -1020], [0, -2976, 0, -13116, 0, -164], [0, -138, 0, -2466, 0, 534], [-6792, 0, -3504, 0, -1360, 0], [3698, 0, 1680, 0, 852, 0], [0, -2402, 0, -11476, 0, -198], [0, 1084, 0, 9510, 0, -110], [0, 1860, 0, -810, 0, 868], [812, 0, -2764, 0, -512, 0], [-276, 0, -4324, 0, -52, 0], [10974, 0, -1884, 0, 48, 0], [0, -2936, 0, 3336, 0, -932], [0, -3880, 0, -9568, 0, 544], [0, -948, 0, -16206, 0, -1076], [1764, 0, 1464, 0, -1056, 0], [-722, 0, 3016, 0, -904, 0], [0, 1800, 0, -2830, 0, 1674], [0, -1330, 0, -1570, 0, 1518], [0, -3624, 0, 5148, 0, -668], [-7000, 0, 1656, 0, -500, 0], [-2854, 0, -1478, 0, 536, 0], [14110, 0, 744, 0, 1016, 0], [-3228, 0, 2316, 0, -1252, 0], [0, 984, 0, 1936, 0, 192], [0, 3840, 0, 13310, 0, 114], [8032, 0, -2562, 0, 1476, 0], [0, 832, 0, -1328, 0, -522], [-17380, 0, 3228, 0, -132, 0], [0, -120, 0, -8534, 0, 716], [-5346, 0, -1002, 0, -1284, 0], [6590, 0, 2576, 0, -916, 0], [0, -844, 0, 7586, 0, -1244], [0, 786, 0, -7688, 0, -1002], [0, 2956, 0, 1330, 0, -1668], [-4758, 0, -1806, 0, 960, 0], [10544, 0, 2766, 0, 2268, 0], [3642, 0, -978, 0, 848, 0], [0, -3280, 0, -17108, 0, -220], [0, 1188, 0, -8004, 0, -1142], [12534, 0, -7808, 0, 856, 0], [-9376, 0, -3848, 0, -1344, 0], [0, -2180, 0, 10014, 0, -14], [0, -2586, 0, 12330, 0, 1594], [8164, 0, 420, 0, -1832, 0], [0, 5640, 0, -7536, 0, 1136], [0, -3124, 0, -19494, 0, 230], [16698, 0, -1452, 0, -256, 0], [0, 1472, 0, -92, 0, 16], [0, -2648, 0, 16, 0, -346], [0, 2660, 0, -2028, 0, 3044], [-17268, 0, -1692, 0, 732, 0], [9668, 0, 7286, 0, 1820, 0], [7470, 0, 2556, 0, 2384, 0], [0, 1112, 0, 27054, 0, 2378], [23394, 0, -546, 0, -860, 0], [0, 6728, 0, 5468, 0, -356], [0, 2026, 0, -8234, 0, 746], [0, -8106, 0, 16948, 0, -1782], [-17620, 0, -5552, 0, -2152, 0], [0, 4832, 0, -13150, 0, -984], [0, -7296, 0, 7584, 0, -2888], [-12576, 0, 1832, 0, 512, 0], [0, 1188, 0, -11270, 0, -930]];
    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_k();".
// 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_k(: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_k();".
// 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_k( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_825_c();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<2,R![2304, 0, 817, 0, 54, 0, 1]>,<7,R![11888704, 0, 433776, 0, 1308, 0, 1]>],Snew);
    return Vf;
end function;