
// Make newform 336.4.bc.c in Magma, downloaded from the LMFDB on 04 September 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_336_bc();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_336_bc_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_336_4_bc_c();".
// 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_336_4_bc_c();".
// 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 := [531441, 0, -91854, -23328, 5670, 2016, -50, 224, 70, -32, -14, 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, 0], [6436341, 2452356, -556065, -433908, -64615, -7388, -1681, 2588, 1949, 180, -109, -36], [-192499740, -26447391, 24048252, 5111019, 1112616, -103283, -50236, -131909, -31292, 7489, 2952, 871], [-19131876, -3864429, 854388, 1395873, 229788, -7961, 9188, -6383, -5108, -797, 324, 109], [19131876, 11580165, -854388, -1395873, -229788, 7961, -9188, 6383, 5108, 797, -324, -109], [653377185, 216631098, -17899137, -41038974, -3274839, -987142, -135341, 296822, 159413, 3326, -11709, -1522], [250426809, 19125315, -31563513, -18160767, -669015, 486583, 149963, 156097, 56869, 403, -4941, -1643], [2834352, 1430298, 400221, -375435, -102492, 1154, 2470, 494, 1631, 569, -36, -58], [-65544390, -12734901, -13569606, -10260027, -3732822, 1335967, 542606, -83879, 5758, -425, 774, -1931], [-13581270, -6364170, 454896, 974187, 236277, 13022, 2878, -4846, -3808, -793, 207, 74], [40743810, 10517283, -3421197, -2110050, -300483, -17087, -9712, 18097, 9949, 454, -477, -125], [264480471, 165953934, -41698071, -40201758, -4010661, 1680538, 403685, 174346, 145867, 12982, -16407, -3554]];
    Rf_basisdens := [1, 2571912, 23147208, 2571912, 2571912, 23147208, 23147208, 826686, 23147208, 826686, 826686, 23147208];
    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_336_bc();"
function MakeCharacter_336_bc()
    N := 336;
    order := 6;
    char_gens := [127, 85, 113, 241];
    v := [6, 6, 3, 1];
    // 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_336_bc_Hecke();"
function MakeCharacter_336_bc_Hecke( : Kf := false)
    N := 336;
    order := 6;
    char_gens := [127, 85, 113, 241];
    char_values := [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, -1, 0, 0, 0, 0, 0, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, -1, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1], [2, -2, 0, 0, 0, 0, -2, 0, 0, -1, 0, 0], [2, 0, 0, 0, -2, 0, 1, -1, -2, 0, -1, 1], [6, 32, 8, 0, 0, 0, -8, -2, 0, 6, 0, 0], [3, -4, 3, 6, -4, -4, 3, -5, -2, 1, -2, -2], [-27, -11, 4, 0, 0, 0, -5, -9, 0, 9, 0, 0], [-3, 1, 2, -6, 16, -4, -3, 1, 0, 5, 0, 0], [2, -4, 4, 12, -6, -2, 4, -5, -2, 1, 5, 10], [-73, 75, -2, 0, 0, 0, 11, -11, 0, 2, 0, 0], [1, -48, 7, 0, 0, 0, 1, -8, 0, -8, 0, 0], [-8, 8, 4, 0, 28, 4, -4, 6, -4, 10, 4, 0], [0, 16, -16, 0, 0, 0, -16, -12, 0, 28, 0, 0], [-15, -15, 30, 90, 0, 0, 15, -15, 0, 15, 0, -14], [-24, 0, 24, 48, 48, 0, 0, 0, 0, 24, 13, -13], [-2, 6, -2, -24, 26, -4, -7, 5, -2, 6, 31, 31], [245, 138, -25, 0, 0, 0, -31, -6, 0, 6, 0, 0], [-259, -330, -71, 0, 0, 0, 26, 26, 0, -71, 0, 0], [8, 26, -26, -120, 60, -8, -26, 22, -8, 4, 0, 0], [-147, 130, 17, 0, 0, 0, 45, -45, 0, -17, 0, 0], [-44, -30, 1, 0, 0, 0, -44, 43, 0, 43, 0, 0], [12, 12, -6, 0, -18, 18, 6, 3, -18, -3, -7, 0], [49, 34, -71, -222, -6, -6, -31, 28, -12, -34, 0, -18], [-387, -596, 108, 0, 0, 0, -108, -73, 0, 35, 0, 0], [-31, 32, -31, -6, -24, 60, -17, 47, 30, -29, 12, 12], [65, 23, 142, 0, 0, 0, 19, -123, 0, 123, 0, 0], [-36, 23, 13, -72, 170, -26, -36, 23, 0, 49, 34, 17], [315, 216, -99, 0, 0, 0, -1, -1, 0, -99, 0, 0], [0, 12, -12, -48, 24, 0, -12, 12, 0, 0, 20, 40], [1143, -82, 82, 0, 0, 0, 82, -45, 0, -37, 0, 0], [24, -41, 69, 168, -26, -26, 54, -67, -52, 41, 0, -21], [-11, 0, -3, -6, 8, 0, -7, 7, 14, -3, -66, 66], [430, 978, 42, 0, 0, 0, -42, -4, 0, 38, 0, 0], [63, -60, -3, 126, -258, 6, 63, -60, 0, -66, -52, -26], [95, 33, -62, 0, 0, 0, -59, -59, 0, -62, 0, 0], [765, -798, 33, 0, 0, 0, 99, -99, 0, -33, 0, 0], [155, -1063, 50, 0, 0, 0, 155, -205, 0, -205, 0, 0], [-80, 36, 40, 0, 236, -4, -40, 38, 4, 78, -134, 0], [-9, -44, 81, 222, -14, -14, 51, -58, -28, 44, 0, -132], [73, 0, 51, 102, -22, 0, 62, -62, -124, 51, -42, 42], [-356, -1316, -292, 0, 0, 0, 292, 136, 0, -156, 0, 0], [195, -191, -4, 390, -788, 8, 195, -191, 0, -199, 68, 34], [-363, -5, 358, 0, 0, 0, -254, -254, 0, 358, 0, 0], [-4, 152, -152, -600, 300, 4, -152, 154, 4, -2, -46, -92], [-725, 436, 289, 0, 0, 0, 394, -394, 0, -289, 0, 0], [932, 184, -184, 0, 0, 0, -184, 160, 0, 24, 0, 0], [2573, 4670, -226, 0, 0, 0, 226, 101, 0, -125, 0, 0], [178, -250, 178, 432, -326, -212, 197, -303, -106, 34, 99, 99], [829, 186, 119, 0, 0, 0, 457, 338, 0, -338, 0, 0], [-117, 118, -1, -234, 466, 2, -117, 118, 0, 116, 316, 158], [68, -34, 34, 0, 0, -68, 34, -68, -68, 34, -182, -364], [609, -1137, 528, 0, 0, 0, 104, -104, 0, -528, 0, 0], [-396, 128, 198, 0, 1118, -70, -198, 163, 70, 361, 313, 0], [-99, -94, 189, 570, 2, 2, 93, -92, 4, 94, 0, 18], [-227, 0, 27, 54, 254, 0, -100, 100, 200, 27, -114, 114], [-12, 40, -12, -168, 184, -32, -48, 32, -16, 44, -31, -31], [-3312, -1682, 75, 0, 0, 0, 52, -23, 0, 23, 0, 0], [1551, 1386, -165, 0, 0, 0, -179, -179, 0, -165, 0, 0], [-20, 316, -316, -1224, 612, 20, -316, 326, 20, -10, 26, 52], [899, -662, -237, 0, 0, 0, -162, 162, 0, 237, 0, 0], [-276, -16, 138, 0, 674, -154, -138, 61, 154, 199, 529, 0], [-218, 2114, 810, 0, 0, 0, -810, 60, 0, 870, 0, 0], [147, -238, 147, 546, -490, -112, 210, -266, -56, -35, 374, 374], [1482, 709, 724, 0, 0, 0, 64, -660, 0, 660, 0, 0], [108, -96, -12, 216, -456, 24, 108, -96, 0, -120, 250, 125], [285, 3395, -312, 0, 0, 0, 285, 27, 0, 27, 0, 0], [-2909, 198, -198, 0, 0, 0, -198, 525, 0, -327, 0, 0], [89, 0, 3, 6, -86, 0, 46, -46, -92, 3, 46, -46], [-598, -1640, -400, 0, 0, 0, 400, 378, 0, -22, 0, 0], [349, -516, 349, 1002, -820, -364, 425, -607, -182, 15, 52, 52], [177, -227, 50, 354, -608, -100, 177, -227, 0, -127, -152, -76], [863, -489, -374, 0, 0, 0, -461, 461, 0, 374, 0, 0], [327, 4730, 213, 0, 0, 0, 327, -540, 0, -540, 0, 0], [664, -500, 500, 0, 0, 0, 500, 116, 0, -616, 0, 0], [-333, 137, -180, -258, 188, 188, -231, 325, 376, -137, 0, -88], [145, 0, -219, -438, -364, 0, -37, 37, 74, -219, -50, 50], [5389, 3038, -1605, 0, 0, 0, -687, 918, 0, -918, 0, 0], [189, -70, -119, 378, -994, 238, 189, -70, 0, -308, -616, -308], [5113, -5349, 236, 0, 0, 0, -252, 252, 0, -236, 0, 0], [-184, -104, 92, 0, 356, -196, -92, -6, 196, 86, -326, 0], [2260, -160, 160, 0, 0, 0, 160, -954, 0, 794, 0, 0], [485, 0, -381, -762, -866, 0, 52, -52, -104, -381, 190, -190], [1316, 4260, 460, 0, 0, 0, -460, 124, 0, 584, 0, 0], [-1554, -612, 549, 0, 0, 0, -330, -879, 0, 879, 0, 0], [-168, 207, -39, -336, 594, 78, -168, 207, 0, 129, -726, -363], [52, 244, -244, -1080, 540, -52, -244, 218, -52, 26, -354, -708], [-36, -6641, 600, 0, 0, 0, -36, -564, 0, -564, 0, 0], [-136, 168, 68, 0, 508, 100, -68, 118, -100, 186, -560, 0], [4204, 1080, -1080, 0, 0, 0, -1080, 972, 0, 108, 0, 0], [-393, -173, 390, 1302, 88, 88, 129, -85, 176, 173, 0, 528], [-305, 442, -305, -822, 654, 336, -358, 526, 168, -31, -158, -158], [-8485, -9625, -1140, 0, 0, 0, 635, 635, 0, -1140, 0, 0], [-294, 894, -894, -2988, 1494, 294, -894, 1041, 294, -147, -107, -214], [579, -4639, -758, 0, 0, 0, 579, 179, 0, 179, 0, 0], [184, 328, -92, 0, -132, 420, 92, 118, -420, 26, -46, 0], [-94, 476, -838, -2172, 228, 228, -590, 704, 456, -476, 0, 109], [-95, -84, -95, 1074, -1348, 548, 221, 53, 274, -453, 200, 200], [12725, 6449, 384, 0, 0, 0, -173, -557, 0, 557, 0, 0], [1647, -1198, -1635, 0, 0, 0, 1647, -12, 0, -12, 0, 0], [426, 472, -472, 0, 0, 0, -472, -1258, 0, 1730, 0, 0], [754, 0, -6, -12, -760, 0, 374, -374, -748, -6, -65, 65], [48, -98, 48, 300, -302, 4, 99, -97, 2, -52, -603, -603], [255, -70, -185, 510, -1390, 370, 255, -70, 0, -440, -284, -142], [-415, -376, 39, 0, 0, 0, 24, 24, 0, 39, 0, 0], [-1255, 109, 1146, 0, 0, 0, 1418, -1418, 0, -1146, 0, 0], [396, -316, -198, 0, -1306, -118, 198, -257, 118, -455, 741, 0], [65, 250, -463, -1278, 74, 74, -287, 324, 148, -250, 0, 142], [155, 0, -111, -222, -266, 0, 22, -22, -44, -111, 620, -620], [4281, 6260, -812, 0, 0, 0, 812, 67, 0, -745, 0, 0], [8286, 3608, -223, 0, 0, 0, 1070, 1293, 0, -1293, 0, 0], [-2829, -2756, 73, 0, 0, 0, -1473, -1473, 0, 73, 0, 0], [288, 540, -540, -2736, 1368, -288, -540, 396, -288, 144, 716, 1432], [5995, -6642, 647, 0, 0, 0, 270, -270, 0, -647, 0, 0], [-8595, 994, -994, 0, 0, 0, -994, 2201, 0, -1207, 0, 0], [-1169, 0, 639, 1278, 1808, 0, -265, 265, 530, 639, 416, -416], [-2078, 90, 818, 0, 0, 0, -818, 896, 0, 1714, 0, 0], [123, -110, 123, -78, 214, -272, 42, -178, -136, 149, 510, 510], [-48, 208, -160, -96, -128, 320, -48, 208, 0, -112, -622, -311], [-328, -130, 130, 1176, -588, 328, 130, 34, 328, -164, -152, -304], [-1299, 1514, -215, 0, 0, 0, -1929, 1929, 0, 215, 0, 0], [5969, -326, 326, 0, 0, 0, 326, -2541, 0, 2215, 0, 0], [396, -864, 1476, 3672, -504, -504, 1116, -1368, -1008, 864, 0, -93], [-672, 0, 534, 1068, 1206, 0, -69, 69, 138, 534, -115, 115], [8187, 4199, -110, 0, 0, 0, -211, -101, 0, 101, 0, 0], [198, -1272, 1272, 4692, -2346, -198, 1272, -1371, -198, 99, 19, 38], [1373, 7628, -2197, 0, 0, 0, 1373, 824, 0, 824, 0, 0], [827, -3, -160, -978, -332, -332, 169, -335, -664, 3, 0, 776], [-7979, -19338, -1450, 0, 0, 0, 1450, 485, 0, -965, 0, 0], [-9647, -4450, 627, 0, 0, 0, -747, -1374, 0, 1374, 0, 0], [2861, 3986, 1125, 0, 0, 0, -1854, -1854, 0, 1125, 0, 0], [412, -998, 998, 3168, -1584, -412, 998, -1204, -412, 206, -654, -1308], [-54, -19432, 107, 0, 0, 0, -54, -53, 0, -53, 0, 0], [2448, -296, 296, 0, 0, 0, 296, -574, 0, 278, 0, 0], [-403, -738, 1409, 4026, -134, -134, 805, -872, -268, 738, 0, 10], [10917, 23172, 308, 0, 0, 0, -308, 207, 0, 515, 0, 0], [-511, 928, -511, -2502, 2408, 188, -881, 975, 94, 323, -1460, -1460], [6987, -8022, 1035, 0, 0, 0, -370, 370, 0, -1035, 0, 0], [500, 156, -250, 0, -1094, 406, 250, -47, -406, -297, 573, 0], [447, 0, 279, 558, -168, 0, 363, -363, -726, 279, -184, 184], [670, -86, -782, 0, 0, 0, 782, 460, 0, -322, 0, 0], [-1590, 1392, 198, -3180, 6756, -396, -1590, 1392, 0, 1788, 494, 247], [-167, 2124, 2291, 0, 0, 0, 98, 98, 0, 2291, 0, 0], [-210, -1566, 1566, 6684, -3342, 210, 1566, -1461, 210, -105, 275, 550], [9677, -8780, -897, 0, 0, 0, -827, 827, 0, 897, 0, 0], [456, -184, -228, 0, -1324, 44, 228, -206, -44, -434, -410, 0], [14190, 20520, -2000, 0, 0, 0, 2000, -930, 0, -2930, 0, 0], [-591, 540, -591, 306, -948, 1284, -219, 861, 642, -693, 1576, 1576], [29755, 15359, 874, 0, 0, 0, -963, -1837, 0, 1837, 0, 0], [621, -1091, 470, 1242, -1544, -940, 621, -1091, 0, -151, 720, 360], [931, -3146, -2567, 0, 0, 0, 931, 1636, 0, 1636, 0, 0], [1736, -1028, -868, 0, -5368, -160, 868, -948, 160, -1816, 510, 0], [-7996, 1704, -1704, 0, 0, 0, -1704, -1920, 0, 3624, 0, 0], [-317, 693, -1184, -2946, 404, 404, -895, 1097, 808, -693, 0, 160], [-33339, -31726, 1613, 0, 0, 0, -46, -46, 0, 1613, 0, 0], [-1424, 970, -970, -1032, 516, 1424, -970, 1682, 1424, -712, -916, -1832], [5385, -11407, -3362, 0, 0, 0, 5385, -2023, 0, -2023, 0, 0], [-757, 558, -853, -1770, 526, 526, -821, 1084, 1052, -558, 0, -1372], [-3789, -2384, 2776, 0, 0, 0, -2776, -1567, 0, 1209, 0, 0], [-840, 2120, -840, -7680, 8120, -880, -2340, 1900, -440, 1720, 893, 893], [-1713, 2059, -346, -3426, 6160, 692, -1713, 2059, 0, 1367, -556, -278], [-1080, 1404, -1404, -3456, 1728, 1080, -1404, 1944, 1080, -540, 32, 64], [-5979, -2094, 2094, 0, 0, 0, 2094, 1057, 0, -3151, 0, 0], [1544, 339, -919, -3480, -482, -482, -98, -143, -964, -339, 0, 2435], [-865, 0, 1671, 3342, 2536, 0, 403, -403, -806, 1671, -48, 48], [123, 10, 123, -798, 1054, -512, -138, -118, -256, 389, 94, 94], [-1845, -5977, -4132, 0, 0, 0, 863, 863, 0, -4132, 0, 0], [-14651, 15896, -1245, 0, 0, 0, -2151, 2151, 0, 1245, 0, 0]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_336_bc_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_336_4_bc_c();".
// 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_336_4_bc_c(:prec:=12)
    chi := MakeCharacter_336_bc();
    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_336_4_bc_c();".
// 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_336_4_bc_c( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_336_bc();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<5,R![16083058761, 0, 10590781509, 0, 6898376178, 0, 49602429, 0, 272898, 0, 597, 0, 1]>,<13,R![49422707712, 0, 42650496, 0, 11724, 0, 1]>],Snew);
    return Vf;
end function;