
// Make newform 22.4.c.b in Magma, downloaded from the LMFDB on 09 March 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_22_c();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_22_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_22_4_c_b();".
// 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_22_4_c_b();".
// 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 := [5856400, 169400, 75340, 2710, 2911, -141, 71, -1, 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], [48229141584676800, -4059658693406480, 8011043329394989, -111071208987556, 28230146638036, -1356924294556, 151013926876, 22554025143], [-66484077419717320, 8498101996878245, -1313471371492594, 12754848436776, -5250112809736, 1256420838616, 955320989289, 14112299722], [426480737760227920, 13624366122837560, 13504262211521188, -772584075715295, 374269556401525, -11662655347575, 5732748190805, -123788106187], [-12007762986133200, 4037135429586600, -523534449789100, 722720174659769, -16065997834439, 2855478562109, -268932734519, 15778904729], [-22785233088495405, 582451195267480, -53736302216310, -38031215360567, -619537249643, -3489045673392, -23011705883, -15728307097], [32952393866979400, 20338656497650260, 1043207365589370, 629078544513089, -18738040845679, 16218883337689, -130622718559, 254952731119]];
    Rf_basisdens := [1, 1, 342693986325717620, 171346993162858810, 685387972651435240, 31153998756883420, 7788499689220855, 31153998756883420];
    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_22_c();"
function MakeCharacter_22_c()
    N := 22;
    order := 5;
    char_gens := [13];
    v := [4];
    // 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_22_c_Hecke();"
function MakeCharacter_22_c_Hecke( : Kf := false)
    N := 22;
    order := 5;
    char_gens := [13];
    char_values := [[0, 0, 1, 0, 0, 0, 0, 0]];
    assert UnitGenerators(DirichletGroup(N)) eq char_gens;
    values := ConvertToHeckeField(char_values : pass_field := ISA(Type(Kf), Fld), 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]];
    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, -2, 0, 0, 0, 0], [1, 0, 0, 1, -1, -1, 0, 0], [-5, 0, -8, -8, 4, 1, -1, 0], [1, 2, 0, 2, -2, 2, 1, 1], [-13, 0, -6, 8, -15, -3, 3, 2], [4, -3, 4, 10, 0, 3, 0, -3], [30, 0, 1, 1, -26, -4, 4, 3], [-55, -2, 0, -57, 36, -8, 2, 0], [42, -6, -70, 0, 70, 0, -6, 6], [-9, 10, -120, 50, -50, 10, -9, -9], [74, 25, 74, 94, 0, 21, 0, -21], [27, -32, 80, -48, 48, -32, 27, 27], [57, 24, 0, 81, -35, 17, -24, 0], [255, 7, 167, 0, -167, 0, -14, -7], [-169, -9, 0, -178, -20, 12, 9, 0], [-50, -47, -50, -72, 0, -39, 0, 39], [-26, 40, 203, -69, 69, 40, -26, -26], [-273, 0, -228, -228, 246, 27, -27, -28], [91, -59, -43, 0, 43, 0, 51, 59], [211, 0, 334, 334, -262, 51, -51, -32], [45, 17, 418, 205, -205, 17, 45, 45], [102, -19, 102, 206, 0, -55, 0, 55], [457, 0, 214, 214, -445, -12, 12, -92], [-521, 61, -435, 0, 435, 0, -26, -61], [-809, 10, -809, 132, 0, -10, 0, 10], [128, -45, 128, -364, 0, -17, 0, 17], [41, -52, 600, 844, -844, -52, 41, 41], [149, 72, 0, 221, -117, 95, -72, 0], [226, 64, -544, 0, 544, 0, 108, -64], [-51, -80, 0, -131, 440, 116, 80, 0], [207, 0, -62, -62, -64, -143, 143, 28], [-759, 143, 363, 0, -363, 0, -55, -143], [1013, 0, 1376, 1376, -1071, 58, -58, 108], [47, 28, 178, -1094, 1094, 28, 47, 47], [441, 0, 458, 458, -442, 1, -1, -2], [-417, 107, 0, -310, -312, 64, -107, 0], [-733, 25, 0, -708, -970, -14, -25, 0], [1351, -281, 1351, 1781, 0, -234, 0, 234], [-1344, -41, -1344, -598, 0, 111, 0, -111], [283, 71, 0, 354, 580, -32, -71, 0], [1097, 144, 0, 1241, -808, 84, -144, 0], [-1745, 0, -396, -396, 1708, 37, -37, 52], [-25, 46, -390, -1404, 1404, 46, -25, -25], [-211, 0, -1210, -1210, 156, 55, -55, -350], [-1358, 116, -192, 0, 192, 0, -146, -116], [2076, -60, 2624, 0, -2624, 0, 74, 60], [-497, 38, -497, 926, 0, -146, 0, 146], [2051, -99, 0, 1952, -3334, 182, 99, 0], [96, -404, 469, 745, -745, -404, 96, 96], [752, 263, 752, 3016, 0, 307, 0, -307], [633, 516, 633, -1528, 0, -52, 0, 52], [-2429, 89, 0, -2340, -350, 266, -89, 0], [-2783, 217, -1419, 0, 1419, 0, -683, -217], [1010, -269, 1010, -988, 0, 281, 0, -281], [-67, 189, -3182, -4507, 4507, 189, -67, -67], [-314, -342, 2150, 0, -2150, 0, 188, 342], [2733, 0, 2070, 2070, -2730, -3, 3, -386], [137, -78, -1052, -4478, 4478, -78, 137, 137], [-4820, -507, -4820, -3426, 0, -233, 0, 233], [1897, 0, 3880, 3880, -1221, -676, 676, -144], [2731, -361, 0, 2370, 1912, -688, 361, 0], [-779, 1052, 1002, 1138, -1138, 1052, -779, -779], [2415, 255, -4141, 0, 4141, 0, 234, -255], [-245, 217, 0, -28, 22, -350, -217, 0], [1638, 0, -2119, -2119, -1578, -60, 60, 155], [-1852, -703, -1852, -2022, 0, 199, 0, -199], [1727, 595, 2055, 0, -2055, 0, 90, -595], [500, -672, 7055, 2067, -2067, -672, 500, 500], [-6364, 0, -5403, -5403, 6270, 94, -94, 385], [2307, 493, 0, 2800, 3050, 270, -493, 0], [-373, -153, 175, 0, -175, 0, -921, 153], [-429, 434, 2386, -2928, 2928, 434, -429, -429], [309, 44, 1748, 1908, -1908, 44, 309, 309], [-4972, -850, -3366, 0, 3366, 0, 648, 850], [-1103, 0, 1614, 1614, 1699, -596, 596, 236], [-402, 579, -402, 1872, 0, -191, 0, 191], [625, 558, -2270, 880, -880, 558, 625, 625], [6068, -378, 82, 0, -82, 0, -22, 378], [3857, 0, 632, 632, -4159, 302, -302, 948], [-5002, 1003, -5002, -8806, 0, 849, 0, -849], [-4055, 169, -6851, 0, 6851, 0, 458, -169], [1635, -117, 0, 1518, -336, -1080, 117, 0], [4730, -169, 4730, 9112, 0, -223, 0, 223], [-50, -1100, 8121, 2401, -2401, -1100, -50, -50], [9580, 100, 6500, 0, -6500, 0, -470, -100], [-1043, -12, 0, -1055, 267, -281, 12, 0], [-4047, -659, -4047, -1361, 0, -704, 0, 704], [2733, 0, -624, -624, -2211, -522, 522, -204], [5288, -1270, 5398, 0, -5398, 0, 582, 1270], [6980, -176, 4932, 0, -4932, 0, 576, 176], [3049, 0, 4704, 4704, -3738, 689, -689, -370], [-1975, 0, 120, 120, 2310, -335, 335, -1066], [2023, 1281, 0, 3304, -5246, 1154, -1281, 0], [1229, -1107, 2900, 3631, -3631, -1107, 1229, 1229], [-1591, 999, 2664, 2773, -2773, 999, -1591, -1591], [-681, -679, 0, -1360, -6078, -66, 679, 0], [-5757, 401, 0, -5356, 7228, 244, -401, 0], [826, -1904, -5963, -7215, 7215, -1904, 826, 826], [9056, 0, 4769, 4769, -8570, -486, 486, -47], [-7384, -1447, -7384, -6970, 0, -1325, 0, 1325], [2949, -684, 0, 2265, -3484, -196, 684, 0], [-1235, 1130, 14758, 1128, -1128, 1130, -1235, -1235], [-8397, -178, -8397, -10498, 0, -290, 0, 290], [-10079, 666, 0, -9413, 2424, 1688, -666, 0], [-10220, 460, -2916, 0, 2916, 0, -724, -460], [480, 0, 9707, 9707, -650, 170, -170, 805], [-1076, 236, -187, -5107, 5107, 236, -1076, -1076], [-3573, 1171, -8149, 0, 8149, 0, 451, -1171], [-2433, 0, 2886, 2886, 1936, 497, -497, -1660], [1333, 157, 9670, 2321, -2321, 157, 1333, 1333], [6864, -145, 6864, 9206, 0, -337, 0, 337], [3911, 1229, 0, 5140, -8848, -1008, -1229, 0], [-11113, 1183, 1095, 0, -1095, 0, -1037, -1183], [-4207, -722, 0, -4929, 14492, 1044, 722, 0], [-567, -828, -8104, 6228, -6228, -828, -567, -567], [13241, -80, 0, 13161, -13915, -691, 80, 0], [-4611, 0, -11194, -11194, 2937, 1674, -1674, -32], [-6606, 1069, -6606, -4314, 0, -775, 0, 775], [-1189, -80, -10156, -9268, 9268, -80, -1189, -1189], [-3297, -359, -5827, 0, 5827, 0, 1779, 359], [-5834, -356, 2348, 0, -2348, 0, -1540, 356], [20605, -875, 20605, 12083, 0, -160, 0, 160], [1625, 0, 8114, 8114, -1808, 183, -183, -530], [-4800, -1940, -3020, 0, 3020, 0, 2112, 1940], [-3911, 1375, -3911, -5321, 0, -540, 0, 540], [4375, 411, 0, 4786, -120, -80, -411, 0], [9101, 0, 15978, 15978, -9952, 851, -851, 278], [407, 784, -11090, 10330, -10330, 784, 407, 407], [-2962, 198, 3174, 0, -3174, 0, 2712, -198], [1891, -2550, -3412, -6190, 6190, -2550, 1891, 1891], [-2021, -2873, -2021, -19763, 0, -694, 0, 694], [-13931, 0, -6792, -6792, 13844, 87, -87, 558], [-20617, -445, 0, -21062, 12174, -358, 445, 0], [9996, 403, 9996, -5548, 0, -625, 0, 625], [-9195, 2401, -9195, -6533, 0, -268, 0, 268], [14498, -1480, 16412, 0, -16412, 0, 1252, 1480], [11411, 1367, 0, 12778, -15842, 382, -1367, 0], [-1734, 0, 10607, 10607, -270, 2004, -2004, 1083], [-13729, 0, -16132, -16132, 14416, -687, 687, -328], [9322, 0, 5585, 5585, -10670, 1348, -1348, 1759], [-4955, 436, 0, -4519, -8305, 3619, -436, 0], [-277, 316, 976, -4532, 4532, 316, -277, -277], [-2684, 1001, -2684, -1824, 0, 1771, 0, -1771], [-26597, -997, -26597, -5507, 0, 830, 0, -830], [785, -488, -22614, 5262, -5262, -488, 785, 785], [-7541, -33, 0, -7574, -4918, 974, 33, 0], [-16637, 0, -15296, -15296, 19410, -2773, 2773, 1756], [-1383, -61, 2995, 0, -2995, 0, -1682, 61], [-14825, -835, -12583, 0, 12583, 0, -501, 835], [13283, 0, 8674, 8674, -11370, -1913, 1913, 3204], [18767, -1227, 0, 17540, -22454, 2802, 1227, 0], [7079, -519, -14527, 0, 14527, 0, -1522, 519], [-14471, 1586, 0, -12885, 4897, -151, -1586, 0], [-3863, 4238, 9160, 14962, -14962, 4238, -3863, -3863], [-1954, 0, 6547, 6547, 5470, -3516, 3516, 571], [4040, -4541, 4040, 10782, 0, -2957, 0, 2957], [-14103, 0, -7892, -7892, 15298, -1195, 1195, 2098], [-9686, 0, 6169, 6169, 8754, 932, -932, -3393], [13463, -875, 13463, -3487, 0, -474, 0, 474], [915, 0, -8120, -8120, 884, -1799, 1799, -4004], [26727, 1053, -4383, 0, 4383, 0, 1567, -1053], [2853, -657, 19110, -881, 881, -657, 2853, 2853], [13236, -1484, 17944, 0, -17944, 0, 3230, 1484], [-14293, 151, 0, -14142, -8756, 696, -151, 0], [5038, -1169, 5038, 2358, 0, 1381, 0, -1381], [-1375, 1518, 14276, -20174, 20174, 1518, -1375, -1375], [-5798, -170, 4870, 0, -4870, 0, -2410, 170], [2055, 28, 12108, 28108, -28108, 28, 2055, 2055]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_22_c_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_22_4_c_b();".
// 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_22_4_c_b(:prec:=8)
    chi := MakeCharacter_22_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_22_4_c_b();".
// 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_22_4_c_b( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_22_c();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<3,R![4748041, 368251, 224168, -11455, 1931, 185, 42, -3, 1]>],Snew);
    return Vf;
end function;