
// Make newform 825.4.c.r in Magma, downloaded from the LMFDB on 19 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_r();".
// 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_r();".
// 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 := [40000, 0, 87636, 0, 24517, 0, 2275, 0, 83, 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, 1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 4293124, 0, 688783, 0, 28325, 0, 297, 0, -1], [2000, 0, 219038, 0, 35665, 0, 1530, 0, 19, 0], [2293360, 0, -75578, 0, -35665, 0, -1530, 0, -19, 0], [205736, 0, 131621, 0, 19117, 0, 921, 0, 13, 0], [4265120, 0, 1036247, 0, -110900, 0, -12375, 0, -224, 0], [0, 17899796, 0, 3850322, 0, 291625, 0, 8838, 0, 91], [0, -8764897, 0, -2982214, 0, -263300, 0, -8541, 0, -92], [0, -21976888, 0, -10327741, 0, -1297475, 0, -57339, 0, -773]];
    Rf_basisdens := [1, 1, 2869200, 143460, 143460, 9564, 143460, 717300, 358650, 478200];
    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, 0, 0, 0, 0], [-1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 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, 1, -1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 7, 0, 0, 0, 0, 0, 0, -1], [11, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, -3, 10, 0, 0, 0, 0, 2, 5, 0], [0, 5, -31, 0, 0, 0, 0, 2, -1, -2], [65, 0, 0, -12, -2, 4, -2, 0, 0, 0], [0, -6, -37, 0, 0, 0, 0, 6, 1, -1], [34, 0, 0, 11, 0, 8, -3, 0, 0, 0], [52, 0, 0, 5, -4, 11, 0, 0, 0, 0], [0, -31, 77, 0, 0, 0, 0, 4, 9, -2], [-29, 0, 0, -45, -6, -17, 0, 0, 0, 0], [0, 23, 34, 0, 0, 0, 0, 14, 13, 2], [0, 11, -93, 0, 0, 0, 0, 22, 7, -4], [0, -18, 116, 0, 0, 0, 0, 2, -36, 0], [-71, 0, 0, 71, -12, -31, -4, 0, 0, 0], [-218, 0, 0, -38, 44, 9, 5, 0, 0, 0], [0, 38, -226, 0, 0, 0, 0, 12, 47, 7], [229, 0, 0, -114, 6, -65, 1, 0, 0, 0], [0, 32, 4, 0, 0, 0, 0, 38, 20, 10], [-433, 0, 0, 105, 2, 25, 8, 0, 0, 0], [0, 35, -210, 0, 0, 0, 0, -46, 2, 17], [-80, 0, 0, 57, -50, 20, 5, 0, 0, 0], [0, 144, 443, 0, 0, 0, 0, 0, -10, 2], [-61, 0, 0, 74, 24, 63, 11, 0, 0, 0], [0, -181, 506, 0, 0, 0, 0, 30, 12, 3], [0, -139, -74, 0, 0, 0, 0, 12, 0, -13], [-134, 0, 0, 181, 16, -71, -14, 0, 0, 0], [0, 128, -44, 0, 0, 0, 0, -30, -68, 18], [0, -237, -5, 0, 0, 0, 0, 30, -93, 4], [-922, 0, 0, -65, 98, -54, -39, 0, 0, 0], [0, -239, 574, 0, 0, 0, 0, 44, 154, 9], [620, 0, 0, -227, -16, -40, -17, 0, 0, 0], [-521, 0, 0, -251, -112, 89, 6, 0, 0, 0], [1022, 0, 0, 230, -90, -1, -23, 0, 0, 0], [0, -88, 932, 0, 0, 0, 0, 106, -3, -27], [0, 310, 18, 0, 0, 0, 0, 62, -3, -45], [0, -292, -716, 0, 0, 0, 0, -2, -210, 24], [0, -108, 733, 0, 0, 0, 0, 132, -33, 25], [-823, 0, 0, 93, -72, 211, 28, 0, 0, 0], [-203, 0, 0, -203, -122, 50, 71, 0, 0, 0], [1517, 0, 0, 266, 46, -37, 21, 0, 0, 0], [0, 140, -298, 0, 0, 0, 0, -134, 15, -37], [0, -182, -2217, 0, 0, 0, 0, -44, 57, -19], [-418, 0, 0, 169, -10, 7, -130, 0, 0, 0], [1338, 0, 0, -390, -14, 123, 13, 0, 0, 0], [0, 418, 366, 0, 0, 0, 0, 70, 255, -43], [0, 31, -2498, 0, 0, 0, 0, -96, -90, 91], [-425, 0, 0, -241, 150, -78, 101, 0, 0, 0], [0, 225, 785, 0, 0, 0, 0, 14, 101, 104], [-2372, 0, 0, -250, 194, -76, -44, 0, 0, 0], [920, 0, 0, 52, 248, 9, -41, 0, 0, 0], [-292, 0, 0, 204, -232, 258, -58, 0, 0, 0], [0, -779, 1382, 0, 0, 0, 0, -220, -314, -83], [0, -86, 846, 0, 0, 0, 0, -300, -216, -46], [1430, 0, 0, -776, -94, 258, 96, 0, 0, 0], [1901, 0, 0, 103, 150, 87, 64, 0, 0, 0], [0, 86, 414, 0, 0, 0, 0, -72, -359, -43], [1947, 0, 0, -787, -106, 385, 88, 0, 0, 0], [0, 917, -3289, 0, 0, 0, 0, -250, 98, -9], [0, 39, -181, 0, 0, 0, 0, -272, -373, -54], [0, 38, 4762, 0, 0, 0, 0, -214, 165, 67], [-292, 0, 0, -1089, 20, -410, -53, 0, 0, 0], [0, -301, -3687, 0, 0, 0, 0, -364, -128, -3], [0, -56, -4096, 0, 0, 0, 0, -64, -34, 46], [-224, 0, 0, -648, 418, -190, 44, 0, 0, 0], [0, 724, -418, 0, 0, 0, 0, 128, 393, -33], [0, -344, -880, 0, 0, 0, 0, -72, 172, 8], [5282, 0, 0, 1181, 360, -120, -41, 0, 0, 0], [0, -95, 352, 0, 0, 0, 0, 276, 186, 201], [450, 0, 0, -1954, 258, -444, -16, 0, 0, 0], [0, -67, -856, 0, 0, 0, 0, 470, 669, 32], [0, -42, -6232, 0, 0, 0, 0, -118, -187, 3], [-1752, 0, 0, 82, 316, 21, -259, 0, 0, 0], [0, 565, 76, 0, 0, 0, 0, 76, 154, 117], [2798, 0, 0, -1074, 178, 246, -190, 0, 0, 0], [0, -840, -660, 0, 0, 0, 0, -114, -79, -331], [3424, 0, 0, 1185, 8, -46, -143, 0, 0, 0], [510, 0, 0, 962, 336, -747, -59, 0, 0, 0], [-1833, 0, 0, -1319, -104, 559, 8, 0, 0, 0], [8665, 0, 0, 1973, 264, -77, 28, 0, 0, 0], [4702, 0, 0, 26, -6, 334, -150, 0, 0, 0], [0, -597, 2112, 0, 0, 0, 0, -298, -317, -60], [-2023, 0, 0, 357, -28, 392, -1, 0, 0, 0], [0, -2025, 4181, 0, 0, 0, 0, 92, -687, -108], [-3424, 0, 0, 871, 174, 698, 69, 0, 0, 0], [0, 1118, -2334, 0, 0, 0, 0, -188, -388, -222], [-958, 0, 0, -592, -20, 120, 340, 0, 0, 0], [0, 439, -4634, 0, 0, 0, 0, 344, 158, 143], [0, 88, 5824, 0, 0, 0, 0, 104, 82, -182], [2352, 0, 0, 504, -824, 80, -284, 0, 0, 0], [0, -1139, -12, 0, 0, 0, 0, 342, 1145, 188], [5754, 0, 0, -867, -332, 1184, 47, 0, 0, 0], [-4826, 0, 0, -1680, -60, 1025, 203, 0, 0, 0], [0, -1382, -9740, 0, 0, 0, 0, -370, -284, 152], [4136, 0, 0, 340, -210, -638, -192, 0, 0, 0], [-2854, 0, 0, 891, -44, -912, 209, 0, 0, 0], [0, 18, -7187, 0, 0, 0, 0, 598, 176, -80], [-2670, 0, 0, -2979, 114, -399, -168, 0, 0, 0], [0, 1208, 1477, 0, 0, 0, 0, -908, -421, 177], [0, -1873, -3866, 0, 0, 0, 0, -400, 394, 247], [0, -1108, 1310, 0, 0, 0, 0, -118, -726, -168], [-21, 0, 0, -1965, -666, 487, -248, 0, 0, 0], [6134, 0, 0, -2849, 386, 219, -92, 0, 0, 0], [0, 1343, 4089, 0, 0, 0, 0, 144, -370, 127], [0, -2135, -11121, 0, 0, 0, 0, -404, 307, -276], [0, 1206, 230, 0, 0, 0, 0, -144, -668, 318], [-6127, 0, 0, -681, 1058, -909, 40, 0, 0, 0], [-1478, 0, 0, 198, 1010, -981, -223, 0, 0, 0], [0, -654, -1376, 0, 0, 0, 0, -360, 864, 262], [0, -964, -4740, 0, 0, 0, 0, -522, -156, -50], [0, 1009, -7514, 0, 0, 0, 0, 934, -768, -291], [-10816, 0, 0, 2372, -256, -581, 473, 0, 0, 0], [7760, 0, 0, 1326, 8, 807, 443, 0, 0, 0], [11308, 0, 0, 145, 18, -1412, 17, 0, 0, 0], [0, -2158, 4534, 0, 0, 0, 0, -254, 732, 180], [0, 231, 12543, 0, 0, 0, 0, -434, -625, 60], [0, 370, 9394, 0, 0, 0, 0, -26, -336, -720], [-7260, 0, 0, 1443, -884, -292, 421, 0, 0, 0], [3243, 0, 0, 3695, 244, 1189, 12, 0, 0, 0], [0, -1802, -6176, 0, 0, 0, 0, 634, 664, -140], [0, -27, -10558, 0, 0, 0, 0, 320, 1480, 219], [0, -2133, -117, 0, 0, 0, 0, 328, 427, 178], [-772, 0, 0, 4026, -266, 602, 566, 0, 0, 0], [1565, 0, 0, 2766, -628, -587, -111, 0, 0, 0], [1527, 0, 0, -447, -942, -754, 563, 0, 0, 0], [-7308, 0, 0, 3044, 620, -50, 734, 0, 0, 0], [0, 1907, -5370, 0, 0, 0, 0, 1234, 237, -354], [0, 621, -1208, 0, 0, 0, 0, -330, -1512, -291], [4325, 0, 0, 2753, -148, 737, -90, 0, 0, 0], [0, 360, 12648, 0, 0, 0, 0, -868, -1106, 26], [-1332, 0, 0, -4039, -324, 448, 343, 0, 0, 0], [0, 844, -4964, 0, 0, 0, 0, -2, 1343, -61], [3726, 0, 0, 2334, 300, -360, 18, 0, 0, 0], [-7370, 0, 0, 1884, -876, 1403, -543, 0, 0, 0], [0, -2000, 12080, 0, 0, 0, 0, 202, -564, -682], [0, 2101, 10259, 0, 0, 0, 0, 174, -204, 485], [0, 4838, -4326, 0, 0, 0, 0, 62, 244, 228], [-17777, 0, 0, -3221, 362, -1339, -2, 0, 0, 0], [5967, 0, 0, 1227, -22, 836, -121, 0, 0, 0], [12402, 0, 0, 1045, -988, 1186, -123, 0, 0, 0], [0, 1040, 11574, 0, 0, 0, 0, -472, 541, -37], [0, -2263, 4524, 0, 0, 0, 0, 516, 66, -219], [12174, 0, 0, 1864, -348, -600, -28, 0, 0, 0], [-17132, 0, 0, -588, -1756, 1398, -362, 0, 0, 0], [0, 2802, -3708, 0, 0, 0, 0, 694, 97, -697], [0, -1217, 2673, 0, 0, 0, 0, 1010, 1715, 392], [-14672, 0, 0, 4106, 40, -148, -318, 0, 0, 0], [0, -4731, -4336, 0, 0, 0, 0, 608, -852, -781], [0, 2941, -12476, 0, 0, 0, 0, -2040, -235, 230], [-5984, 0, 0, -701, -384, 286, -737, 0, 0, 0], [0, -1494, 732, 0, 0, 0, 0, 300, -2053, 31], [0, 4130, 10188, 0, 0, 0, 0, 752, 1990, -272], [0, 3736, 682, 0, 0, 0, 0, -1088, 162, 286], [1161, 0, 0, -3089, 2326, -1783, 366, 0, 0, 0], [-17495, 0, 0, -405, 348, 50, -9, 0, 0, 0], [12200, 0, 0, -4579, 1798, -62, 175, 0, 0, 0], [0, -916, -10644, 0, 0, 0, 0, 868, -803, -1329], [2487, 0, 0, -3819, -816, 675, -272, 0, 0, 0], [0, -961, -9461, 0, 0, 0, 0, -2020, -2377, 774], [0, -6779, -14633, 0, 0, 0, 0, -1402, 537, -40], [0, 3704, 8776, 0, 0, 0, 0, 1112, -228, -772], [15061, 0, 0, 1857, -200, 2539, -40, 0, 0, 0], [0, -5042, 2622, 0, 0, 0, 0, 138, -14, 106], [0, -2908, 18089, 0, 0, 0, 0, 938, 105, 565], [-7198, 0, 0, 7424, -632, -1391, -97, 0, 0, 0], [0, -6420, -8390, 0, 0, 0, 0, -1000, 1188, 112]];
    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_r();".
// 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_r(:prec:=10)
    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_r();".
// 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_r( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_825_c();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<2,R![3136, 0, 44676, 0, 26364, 0, 2509, 0, 86, 0, 1]>,<7,R![112858624768036, 0, 1196094841641, 0, 4198643684, 0, 6208734, 0, 4096, 0, 1]>],Snew);
    return Vf;
end function;