
// Make newform 825.4.c.p 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_p();".
// 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_p();".
// 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 := [8464, 0, 5292, 0, 913, 0, 54, 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, 1, 0, 0, 0, 0, 0, 0], [0, 2808, 0, 821, 0, 54, 0, 1], [92, 0, 27, 0, 1, 0, 0, 0], [0, -452, 0, -45, 0, -1, 0, 0], [-344, 0, -45, 0, -1, 0, 0, 0], [0, -29696, 0, -8189, 0, -610, 0, -13], [1840, 0, 614, 0, 47, 0, 1, 0]];
    Rf_basisdens := [1, 1, 1656, 18, 36, 18, 1656, 36];
    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], [-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 := 4;
    raw_aps := [[0, 1, -1, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, -2, -9, 0, -1, 0, 1, 0], [-11, 0, 0, 0, 0, 0, 0, 0], [0, 8, 3, 0, 5, 0, -5, 0], [0, 6, -19, 0, 7, 0, 1, 0], [-36, 0, 0, -10, 0, -4, 0, 0], [0, -8, -8, 0, 0, 0, -16, 0], [-22, 0, 0, -10, 0, -18, 0, 2], [128, 0, 0, 28, 0, 10, 0, 10], [0, -52, -8, 0, 2, 0, 18, 0], [82, 0, 0, 30, 0, 30, 0, 26], [0, -2, 133, 0, -19, 0, 7, 0], [0, -32, 74, 0, -26, 0, -10, 0], [0, -68, -50, 0, 24, 0, 8, 0], [244, 0, 0, 84, 0, -28, 0, -48], [6, 0, 0, 52, 0, -46, 0, 14], [0, -32, 136, 0, 12, 0, 4, 0], [-240, 0, 0, 116, 0, -20, 0, -72], [0, -124, 213, 0, 47, 0, 37, 0], [-328, 0, 0, 70, 0, -80, 0, -24], [0, -180, -47, 0, -35, 0, 27, 0], [254, 0, 0, -332, 0, -24, 0, -12], [0, 84, 426, 0, -24, 0, -28, 0], [46, 0, 0, -54, 0, -28, 0, 24], [0, -188, 222, 0, 38, 0, -54, 0], [0, -324, 307, 0, -1, 0, -55, 0], [-550, 0, 0, 200, 0, 36, 0, 24], [0, -48, 128, 0, 34, 0, -134, 0], [0, 14, -251, 0, 5, 0, 27, 0], [484, 0, 0, -176, 0, 2, 0, 26], [0, 120, 426, 0, 120, 0, -180, 0], [-1596, 0, 0, 438, 0, 78, 0, -38], [-654, 0, 0, 10, 0, -76, 0, 120], [1056, 0, 0, 106, 0, -272, 0, -72], [0, 232, -508, 0, 10, 0, 94, 0], [0, -444, -98, 0, -94, 0, 102, 0], [0, -60, 889, 0, -143, 0, 63, 0], [0, -54, 1027, 0, 125, 0, -61, 0], [-316, 0, 0, -200, 0, 216, 0, 156], [-498, 0, 0, -644, 0, 102, 0, 106], [40, 0, 0, -552, 0, -112, 0, -168], [0, 368, -1483, 0, -137, 0, -131, 0], [0, -170, 657, 0, 127, 0, -63, 0], [-1888, 0, 0, -16, 0, -60, 0, 240], [-44, 0, 0, 570, 0, 132, 0, 160], [0, 468, -1262, 0, -134, 0, 550, 0], [0, 452, 1605, 0, -55, 0, 351, 0], [2810, 0, 0, 4, 0, 296, 0, 116], [0, -218, -2831, 0, 143, 0, -279, 0], [-1568, 0, 0, 212, 0, -242, 0, -490], [-2926, 0, 0, -716, 0, 154, 0, 178], [-204, 0, 0, 756, 0, 528, 0, 192], [0, -660, 1828, 0, -118, 0, -70, 0], [0, -108, -495, 0, -15, 0, -345, 0], [5074, 0, 0, -440, 0, -112, 0, -4], [1064, 0, 0, 230, 0, -224, 0, -408], [0, -640, 2845, 0, -109, 0, -51, 0], [-4318, 0, 0, -10, 0, -266, 0, -518], [0, -474, -3, 0, 381, 0, -401, 0], [0, 614, 1233, 0, -293, 0, 301, 0], [0, -34, -1753, 0, -337, 0, 517, 0], [-1000, 0, 0, -1444, 0, 300, 0, 452], [0, -204, -4988, 0, 214, 0, -26, 0], [0, -920, 1936, 0, -106, 0, 258, 0], [1492, 0, 0, -336, 0, -74, 0, 174], [0, -4, -3981, 0, -103, 0, -277, 0], [0, -1404, -637, 0, -145, 0, 393, 0], [1514, 0, 0, 364, 0, 1054, 0, 426], [0, -708, -2834, 0, -16, 0, -52, 0], [-5256, 0, 0, -1312, 0, 34, 0, 282], [0, 452, -2134, 0, 850, 0, -562, 0], [0, -1292, -2747, 0, -153, 0, 225, 0], [-5276, 0, 0, -1332, 0, -160, 0, -212], [0, -520, 674, 0, 394, 0, 462, 0], [4090, 0, 0, 748, 0, -216, 0, -284], [0, -124, 1942, 0, -248, 0, 556, 0], [-7990, 0, 0, -824, 0, 512, 0, 388], [-5290, 0, 0, -196, 0, -484, 0, 364], [-7276, 0, 0, -1272, 0, 496, 0, 468], [-6770, 0, 0, 2044, 0, 250, 0, -154], [976, 0, 0, 388, 0, 440, 0, 8], [0, -884, -2754, 0, -328, 0, -156, 0], [-6880, 0, 0, 1650, 0, -582, 0, 506], [0, 256, -90, 0, 374, 0, -1042, 0], [3670, 0, 0, 404, 0, -176, 0, -844], [0, -2228, -4903, 0, -881, 0, 1021, 0], [-5114, 0, 0, -3090, 0, 676, 0, 136], [0, -1780, 754, 0, -78, 0, -698, 0], [0, -1744, -1616, 0, -256, 0, -668, 0], [-3408, 0, 0, 1380, 0, 618, 0, 522], [0, -1032, 2048, 0, 40, 0, 408, 0], [5964, 0, 0, -2524, 0, -488, 0, 240], [-13092, 0, 0, -96, 0, 80, 0, -28], [0, 388, 2727, 0, 119, 0, 593, 0], [18, 0, 0, 2752, 0, -1032, 0, -76], [802, 0, 0, -2072, 0, -120, 0, 292], [0, 1246, 3431, 0, 31, 0, 885, 0], [-1722, 0, 0, -32, 0, -368, 0, 564], [0, 2010, 4557, 0, 629, 0, -1521, 0], [0, 754, 3009, 0, -73, 0, -535, 0], [0, -280, 8599, 0, -85, 0, -971, 0], [7550, 0, 0, 486, 0, 236, 0, 1088], [12700, 0, 0, -74, 0, 262, 0, -166], [0, 768, -44, 0, 126, 0, 1050, 0], [0, 136, -12748, 0, -236, 0, -1528, 0], [0, 3318, -4885, 0, -199, 0, 231, 0], [1768, 0, 0, -1280, 0, 1460, 0, -304], [218, 0, 0, 168, 0, -1734, 0, -294], [0, 1526, 13321, 0, 65, 0, 711, 0], [0, 916, -8615, 0, 419, 0, 349, 0], [0, -2768, -5864, 0, 1014, 0, -874, 0], [-1156, 0, 0, 3672, 0, -478, 0, -1854], [10928, 0, 0, 2896, 0, -1520, 0, -764], [2330, 0, 0, 60, 0, 840, 0, -452], [0, 3028, 9314, 0, -186, 0, 322, 0], [0, -1440, -1974, 0, -1262, 0, 782, 0], [0, -3140, 2580, 0, 1070, 0, 722, 0], [-10116, 0, 0, -4296, 0, 72, 0, 96], [4286, 0, 0, 1416, 0, -1028, 0, -508], [0, 0, 913, 0, 659, 0, 369, 0], [0, 1502, -2649, 0, 2357, 0, -1077, 0], [0, 4360, 2634, 0, 1142, 0, -1606, 0], [-9756, 0, 0, 844, 0, 1328, 0, 356], [-1066, 0, 0, 4758, 0, -670, 0, 758], [-4902, 0, 0, -2128, 0, -926, 0, 970], [5896, 0, 0, 3952, 0, -160, 0, 320], [0, 336, 18608, 0, -56, 0, -1152, 0], [0, 1392, -4935, 0, -1853, 0, -75, 0], [-5860, 0, 0, 522, 0, -2478, 0, -778], [0, 1936, -9279, 0, 121, 0, 1911, 0], [-22808, 0, 0, 1824, 0, 192, 0, -644], [0, 1936, 12116, 0, 762, 0, -2746, 0], [578, 0, 0, 4386, 0, -2040, 0, -620], [-11458, 0, 0, 6136, 0, 1114, 0, -1326], [0, 468, 4436, 0, 846, 0, -1270, 0], [0, 3786, 2207, 0, -1385, 0, -963, 0], [0, -1904, -10600, 0, -2466, 0, 1098, 0], [1038, 0, 0, -5274, 0, -1842, 0, -30], [-13236, 0, 0, 2898, 0, -1878, 0, -562], [12814, 0, 0, -3614, 0, 818, 0, -1930], [0, -4324, -6714, 0, 910, 0, -2062, 0], [0, -3884, -97, 0, -845, 0, 173, 0], [-11006, 0, 0, 2168, 0, 470, 0, -130], [-11400, 0, 0, 116, 0, -1500, 0, -140], [0, -500, 11117, 0, 111, 0, -1943, 0], [0, -2762, -20023, 0, -2477, 0, 413, 0], [11484, 0, 0, -2240, 0, 2810, 0, -1238], [0, -664, -3318, 0, -1718, 0, -506, 0], [0, 3500, 16699, 0, 1065, 0, -2041, 0], [4402, 0, 0, 100, 0, 1772, 0, 2156], [0, 336, -4064, 0, 220, 0, 1084, 0], [0, 4008, 16453, 0, 621, 0, 19, 0], [0, 5372, 7198, 0, 2922, 0, -1042, 0], [-24008, 0, 0, -1512, 0, -1320, 0, -376], [14752, 0, 0, 1090, 0, 1018, 0, -2846], [24590, 0, 0, 508, 0, 1172, 0, -44], [0, -1432, -11031, 0, 1031, 0, -1891, 0], [-6458, 0, 0, -1582, 0, 268, 0, 440], [0, 96, -9626, 0, -478, 0, -370, 0], [0, -4254, -163, 0, -173, 0, 1069, 0], [0, 702, 6649, 0, -1119, 0, 1407, 0], [6780, 0, 0, -3120, 0, 2792, 0, 592], [0, 2696, -7542, 0, -376, 0, 1284, 0], [0, -4952, -14862, 0, 698, 0, -2170, 0], [4176, 0, 0, -3884, 0, 3154, 0, 306], [0, 6108, -1529, 0, -2427, 0, -1389, 0]];
    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_p();".
// 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_p(:prec:=8)
    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_p();".
// 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_p( : 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, 6640, 0, 1081, 0, 58, 0, 1]>,<7,R![1028100096, 0, 27778816, 0, 250320, 0, 876, 0, 1]>],Snew);
    return Vf;
end function;