
// Make newform 825.4.c.o in Magma, downloaded from the LMFDB on 20 May 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_o();".
// 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_o();".
// 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, -8, 16, 6, 2, -2, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0, 0, 0], [-19, 4, -6, -12, 5, -2], [13, -56, -48, 3, 7, -5], [27, -118, -54, -9, 12, -7], [-185, -12, 18, 36, -26, 6], [163, -714, -216, -69, 70, -39]];
    Rf_basisdens := [1, 33, 33, 33, 33, 33];
    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, 1, 0, 0, 0], [0, 0, 0, 3, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, -2, -3, 0, 5], [-11, 0, 0, 0, 0, 0], [0, 0, 20, 11, 0, 11], [0, 0, 14, -19, 0, -9], [88, -26, 0, 0, -10, 0], [0, 0, -36, 54, 0, 14], [88, 18, 0, 0, 44, 0], [-134, -32, 0, 0, -22, 0], [0, 0, -56, 198, 0, -32], [-272, -110, 0, 0, 44, 0], [0, 0, 22, -13, 0, -85], [0, 0, 112, 38, 0, -38], [0, 0, 60, 24, 0, 38], [174, -196, 0, 0, -106, 0], [-168, 100, 0, 0, 22, 0], [0, 0, 272, 242, 0, 58], [-546, -96, 0, 0, -74, 0], [0, 0, -16, -235, 0, 17], [-92, -130, 0, 0, 22, 0], [0, 0, 148, 359, 0, -7], [-402, -236, 0, 0, 132, 0], [0, 0, -16, 68, 0, 278], [-414, -370, 0, 0, -154, 0], [0, 0, 276, -244, 0, -32], [0, 0, 76, -947, 0, -21], [274, 512, 0, 0, 48, 0], [0, 0, -64, 242, 0, -276], [0, 0, 502, 303, 0, 211], [-1418, 88, 0, 0, 154, 0], [0, 0, -120, 618, 0, -48], [426, -82, 0, 0, 40, 0], [822, -330, 0, 0, 158, 0], [-1336, -406, 0, 0, -74, 0], [0, 0, -768, -1088, 0, -258], [0, 0, 356, 188, 0, 148], [0, 0, 340, 323, 0, -223], [0, 0, -614, -65, 0, -207], [1164, -836, 0, 0, -444, 0], [2854, 444, 0, 0, 4, 0], [60, 524, 0, 0, 632, 0], [0, 0, 340, 405, 0, -171], [0, 0, -394, 1637, 0, 275], [64, 236, 0, 0, -132, 0], [2404, 578, 0, 0, 814, 0], [0, 0, -676, 2082, 0, -222], [0, 0, 964, 379, 0, 589], [-754, 544, 0, 0, -356, 0], [0, 0, -162, -4355, 0, 91], [562, 124, 0, 0, -858, 0], [736, 916, 0, 0, -406, 0], [2262, -24, 0, 0, -630, 0], [0, 0, -188, 1936, 0, 486], [0, 0, -60, 2511, 0, 645], [754, -2216, 0, 0, -704, 0], [-1324, 1590, 0, 0, -338, 0], [0, 0, 916, -219, 0, -635], [-2560, -2206, 0, 0, 668, 0], [0, 0, 1462, 847, 0, -305], [0, 0, -746, -2083, 0, 687], [0, 0, 302, -5619, 0, 89], [-530, -1932, 0, 0, -478, 0], [0, 0, -1408, -870, 0, -444], [0, 0, 984, -854, 0, -116], [4706, -572, 0, 0, 730, 0], [0, 0, 864, 819, 0, -513], [0, 0, 1436, -4571, 0, -317], [5428, -1756, 0, 0, -722, 0], [0, 0, 3556, -740, 0, 606], [-2070, 744, 0, 0, -1046, 0], [0, 0, -268, 538, 0, -1454], [0, 0, 376, 25, 0, 1137], [-1764, 1456, 0, 0, 480, 0], [0, 0, 2652, -3400, 0, -28], [6314, 972, 0, 0, -116, 0], [0, 0, -80, -5768, 0, 1758], [5150, 1592, 0, 0, 228, 0], [-3066, -1260, 0, 0, -468, 0], [2856, -884, 0, 0, 832, 0], [8826, 1596, 0, 0, -24, 0], [-1832, -1940, 0, 0, -2372, 0], [0, 0, 1464, -7852, 0, 490], [4226, -182, 0, 0, -784, 0], [0, 0, -1756, 196, 0, -1836], [2266, 2068, 0, 0, 1032, 0], [0, 0, -2568, 12169, 0, 249], [2426, 3210, 0, 0, 410, 0], [0, 0, -1788, -1526, 0, 514], [0, 0, -4588, -3650, 0, -2374], [8790, 2172, 0, 0, 1386, 0], [0, 0, -392, -6110, 0, 566], [-528, 1692, 0, 0, -56, 0], [-5524, -4164, 0, 0, 364, 0], [0, 0, 6140, -5915, 0, -537], [6814, 5624, 0, 0, -1492, 0], [-3970, -1776, 0, 0, -668, 0], [0, 0, -970, -615, 0, 101], [-7582, -1096, 0, 0, 220, 0], [0, 0, 1826, 6015, 0, 691], [0, 0, -5302, 5773, 0, -1569], [0, 0, 1880, 61, 0, 3119], [7042, -1422, 0, 0, -2798, 0], [-1590, 7278, 0, 0, 816, 0], [0, 0, -1704, 6356, 0, -1434], [0, 0, 2380, -4570, 0, -254], [0, 0, 518, 7027, 0, -1499], [6076, 2368, 0, 0, -356, 0], [-14140, 744, 0, 0, 18, 0], [0, 0, 2998, -10617, 0, 4267], [0, 0, -6464, 2345, 0, 377], [0, 0, 1968, 4962, 0, 3224], [10918, -1372, 0, 0, 2486, 0], [-9884, 3292, 0, 0, -160, 0], [11666, 2660, 0, 0, -1076, 0], [0, 0, -8020, 8452, 0, 1924], [0, 0, -1692, 7568, 0, -1460], [0, 0, 6596, 11740, 0, 1338], [4968, 408, 0, 0, -2508, 0], [-2598, -5320, 0, 0, -2604, 0], [0, 0, -484, 9437, 0, 4117], [0, 0, -6026, 2983, 0, 1537], [0, 0, 1448, 382, 0, -642], [-8508, -7064, 0, 0, 496, 0], [-1184, -1158, 0, 0, -1808, 0], [8718, -3028, 0, 0, -2584, 0], [-17072, -2180, 0, 0, 3004, 0], [0, 0, 8608, -10772, 0, 1292], [0, 0, -1508, -12099, 0, 1121], [11066, 6538, 0, 0, -4396, 0], [0, 0, 344, -15973, 0, 4325], [12052, 4220, 0, 0, -4760, 0], [0, 0, -1512, 3380, 0, -118], [-11686, -4642, 0, 0, 2314, 0], [23428, 3200, 0, 0, 3814, 0], [0, 0, 1268, -23736, 0, -2218], [0, 0, 1258, 817, 0, -7], [0, 0, 4120, -11142, 0, 3372], [8748, 3426, 0, 0, 636, 0], [-20250, -5870, 0, 0, 1832, 0], [-2792, -2258, 0, 0, 1228, 0], [0, 0, 1580, -28668, 0, -1280], [0, 0, -5180, 7493, 0, 1963], [-12034, 8732, 0, 0, 1312, 0], [-19666, 1276, 0, 0, -3206, 0], [0, 0, 4088, 3397, 0, -4619], [0, 0, -3602, -2767, 0, -2213], [-10674, 7124, 0, 0, 270, 0], [0, 0, -1892, -17452, 0, 5016], [0, 0, 4888, 13175, 0, 1319], [-2702, -308, 0, 0, 388, 0], [0, 0, 12392, 3996, 0, 648], [0, 0, -80, 45771, 0, 781], [0, 0, 1852, -15154, 0, 434], [23320, -4796, 0, 0, -100, 0], [-18162, -11342, 0, 0, -844, 0], [21230, -1660, 0, 0, 1164, 0], [0, 0, -3852, -26307, 0, -999], [-8606, 8950, 0, 0, 1398, 0], [0, 0, -2912, -4802, 0, 54], [0, 0, -5518, 8513, 0, -7437], [0, 0, -666, -32113, 0, -3573], [26984, 1672, 0, 0, 180, 0], [0, 0, 3088, -14186, 0, -1580], [0, 0, 6212, 14164, 0, 3816], [-17518, -3136, 0, 0, -6158, 0], [0, 0, 5568, -15265, 0, 7455]];
    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_o();".
// 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_o(: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_o();".
// 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_o( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_825_c();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<2,R![25, 0, 91, 0, 19, 0, 1]>,<7,R![33732864, 0, 751360, 0, 1760, 0, 1]>],Snew);
    return Vf;
end function;