
// Make newform 392.4.a.k in Magma, downloaded from the LMFDB on 19 May 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_392_a();"
// To make the coeffs of the qexp of the newform in the Hecke field type "qexpCoeffs();"
// To make the newform (type ModFrm), type "MakeNewformModFrm_392_4_a_k();".
// 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_392_4_a_k();".
// 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 := [13, -10, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0], [-1, 4, 0], [-15, 2, 2]];
    Rf_basisdens := [1, 1, 1];
    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_392_a();"
function MakeCharacter_392_a()
    N := 392;
    order := 1;
    char_gens := [295, 197, 297];
    v := [1, 1, 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;

function MakeCharacter_392_a_Hecke( : Kf := Kf)
    return MakeCharacter_392_a();
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, -1], [4, 1, 0], [0, 0, 0], [-5, 1, -3], [25, 1, 6], [30, -3, -10], [-21, -7, 11], [60, -6, -17], [-61, 7, -14], [197, 9, 3], [89, -16, 34], [247, -17, 26], [-92, -8, 24], [31, 27, -19], [71, 10, 26], [148, -40, 51], [165, -48, -2], [-186, 50, 11], [70, 42, 28], [581, 14, 56], [428, -58, 83], [-458, 22, 28], [551, 52, -44], [877, -31, -2], [32, -27, -140], [-154, 0, 59], [123, 21, 63], [842, -33, -76], [37, -23, 62], [-286, -154, -28], [-1094, 10, -59], [1274, 157, -86], [-894, 130, 132], [-1108, 1, -24], [-251, -91, 175], [-823, 76, -118], [-2076, 24, 201], [-1067, 99, -34], [467, 10, 58], [727, 25, 233], [802, 36, 320], [711, 59, 117], [1188, -161, 434], [-65, -349, 74], [-149, -193, 195], [450, -198, 244], [3202, -106, -108], [-2323, 275, -275], [78, 247, -404], [-632, -209, 438], [-2201, 73, -422], [307, -156, 80], [-1441, 37, -30], [-446, -143, -26], [-650, -52, 765], [1337, -28, -366], [5042, 88, -33], [1483, 246, -318], [689, 85, -906], [-1, -331, -147], [-1218, 336, -240], [5108, -256, 328], [5284, -338, -175], [1161, 82, 240], [4659, 66, -30], [-5710, -42, 273], [-3021, -373, -78], [-476, -568, -109], [2187, -225, -798], [4428, -41, 98], [6321, -147, 693], [10638, 136, 49], [-1453, -850, 534], [-2635, 303, -90], [1921, 41, 425], [-6272, -699, -108], [798, -581, -712], [-606, -375, -1458], [-2754, 1, -438], [-7260, -16, -1032], [-6059, -195, -626], [-593, 687, -1697], [4441, 69, 6], [1685, -767, 1237], [-787, 643, -501], [3995, -589, -1054], [-1943, 522, -1160], [-225, 747, 1066], [-2032, -336, -336], [-4732, 560, 1969], [-5576, -274, 13], [2498, -240, -43], [7421, -41, -1130], [-9980, 592, -1615], [-5414, -1098, -508], [2408, 665, -1604], [1799, 1036, -1356], [9783, 505, 487], [-8664, -679, 924], [13047, 1029, -574], [386, 231, -28], [-14090, -278, -621], [-2951, -590, 384], [7407, -251, -2355], [-881, -432, 2656], [-17896, 580, -688], [16692, -713, 1546], [-1124, 422, 785], [9733, -239, 894], [1733, -699, -2751], [8966, -353, 1416], [5407, 1815, 218], [-7586, 1278, 1071], [4182, -438, 2812], [1515, 996, -1448], [4220, 488, -2504], [484, 870, -1559], [-10609, 1406, -494], [-12010, -266, 700], [-5695, -1632, -1290], [2195, 11, 2018], [6586, 1307, -1308], [-6207, 1923, -1415], [6550, -186, -1739], [16450, -124, -2008], [14441, 1264, -1230], [-16758, 896, -1745], [6650, 182, 3172], [18007, -386, 2074], [7169, 959, 1701], [4282, 1078, 84], [-4549, -49, 133], [-21305, 315, -2198], [6478, -1807, 3298], [15863, 471, -1782], [21028, 1729, -1108], [7716, -1900, -785], [12015, 27, 1306], [-7171, 1110, -1272], [1032, -2780, 1504], [3066, -685, -1620], [-20788, -218, 801], [-8096, -692, -2432], [2590, -413, 228], [4568, 400, -464], [1185, -367, 3878], [9877, 518, 32], [8093, 3411, 523], [15468, 2014, -197], [-3076, -1379, 2716], [1406, -2900, 720], [19454, 1022, 1596], [-10345, -873, -1047], [3112, 2620, -3261], [-13472, 800, 1968], [581, 1857, 1541], [-3123, -590, -1660], [-8962, 332, -3416], [21615, -2130, -4122], [-10498, -802, -2459], [9189, -2799, 5982], [-13382, -3242, -1292], [-6334, -3386, 1009], [-17580, 215, 2778], [-4527, -423, 4503], [-1620, 602, -539], [-4055, 3552, -3186], [-6039, 2933, 3206], [6201, -72, -5798], [6128, -3140, -1829], [-25695, 25, 2886], [-27332, -478, 1063], [5819, 840, 476], [-33087, -59, -733], [-5669, 3131, 2194], [21007, 1845, 1570], [-10637, -1626, 2666], [-10430, -658, -1788], [-27188, -371, 1852], [-31244, -714, 427], [-7030, -1502, 3012], [24890, -708, -1040], [14927, 2596, -308], [14046, -1432, -2655], [-36463, 1120, -3194], [-38358, 855, 1516], [33511, -255, 1697], [24800, -3145, -1114], [-30437, 859, -2209], [-5505, -4864, 4480], [-34338, 790, -6276], [-4505, 2829, 963], [22526, -1421, 2912], [-4621, 2101, -2327], [-19988, -2197, 742], [-46160, 2203, 1602], [-22474, 2971, 2672], [71, 807, -5814], [32534, -368, -5573], [21496, -207, 5080], [-36254, 1846, -7772], [-27057, 2082, 5198], [-7790, 401, -234], [10734, 1574, -4356], [32685, -920, 1602], [-24088, 3442, -6285], [31693, -1817, 4583], [-24370, 4156, -792], [11784, -3396, -2045], [24240, 1211, -4494], [41535, 1107, -4374], [25892, 2676, -4360], [-33020, -2620, 3037], [-23235, 4245, 4679], [-13070, 4933, 4834], [-42597, -2925, -745], [59770, -1567, 3774], [-26585, -2233, 5705], [65558, -1600, 5584], [33228, 4121, 944], [-40671, 775, 5574], [-21783, 358, -10020], [24811, -1681, -10091], [-13486, -6742, 52], [-26867, 965, 9166], [19466, 1909, 3850], [55710, 2624, 633], [-38637, 307, 3033], [39546, -3650, 625], [-10319, -1508, -5038], [-1572, -3396, -2561], [59292, -3052, 6104], [17102, 6041, 1106], [19804, 5280, -5368], [-24828, 2522, -12787], [-20436, -2785, 890], [-40442, -4985, 3636], [-59712, 1644, 1760], [34683, 7325, -830], [-26542, 4110, -14213], [7527, 5009, 383], [47502, -3052, 8845], [37273, -3260, 4110], [31918, -1516, 10616], [-57416, -130, 3511], [-53630, 1366, -4812], [9161, 1319, 4453], [-68003, -1641, 3537], [12493, -2845, -4898], [-20171, -2139, 1790], [101411, 1180, -776], [15503, 2699, -8181], [-12295, -4563, 4694], [14275, 1754, 3518], [73621, 1655, 383], [14277, -3908, 5102], [12671, -1755, -1699], [13821, -1387, -642], [-53218, -2591, 1730], [-48462, 4300, 6385], [35984, -2252, -2288], [-56554, -1297, -4600], [-32205, 4295, -7518], [17150, -6139, -1954], [-50431, -1021, 4719], [13101, 989, 1646], [35863, -4385, -3878], [47808, 828, 1520], [44244, 545, -9412], [52072, -303, -7932], [705, -2505, -7171], [-50830, 3165, 9458], [27477, -107, 14209], [-6227, 4913, -5346], [-4634, -3752, -5885], [-19314, -9022, -591], [-84695, 1068, 394], [-29051, -306, -3744], [-48421, 2089, -7381], [28311, 3135, -13049], [59061, 5389, -4505], [31404, 9244, -6920], [-27633, 1091, 6746], [14947, -115, 1903], [-73475, 5557, -12471], [22755, 11732, -1456], [-13809, -4349, -9654], [-50022, 3248, -547], [36125, 4721, -5538], [12292, 7157, -5616], [-10441, -4103, 2089], [47243, 7040, -7876], [-82507, -1697, -3194], [22181, -1867, -12242], [-15098, 7947, -11100], [-14921, -981, 7381], [-41643, -2835, 10254], [-40382, -3218, 6761], [-13381, 2337, 11226], [-50759, -4582, -296], [-75228, -683, -1108], [-1653, 5939, -4153], [8898, -9222, 5140], [10665, 5255, -8205], [62303, -2497, -11094], [82254, -4274, 15951], [-5097, -4685, 3578], [-68377, -9689, 2985], [-48692, -4679, -2672], [41604, 6222, 4323], [-35815, -3592, -4778], [59910, -3619, 18158], [9096, 568, 3343], [-13088, 8696, -10800], [12400, 4647, 6814], [-71626, 710, -1460], [-11425, -9113, 5191], [11779, 11595, -10190], [-29355, -5047, 3822], [-69239, 1711, 6861], [48904, -5433, 1662], [-25109, -609, 11458], [-52921, 9209, 506], [65643, -2792, 13276], [74873, -82, 6628], [43200, -2836, 801], [50450, -5010, 8761], [6150, -9012, 12847], [100973, -987, -6146], [-165, 2882, -2486], [-31884, 10045, -13272], [-14906, -1518, -1108], [10774, -5486, -2149], [10175, -2371, -5963], [5784, 6388, -12816], [61277, -3587, 11342], [-10062, -783, 10998], [294, -5180, 4280], [4270, 4396, 10967], [-26018, -1937, -1728], [-101599, 1141, 4774], [-44667, -7875, 7710], [36022, -7446, 1772], [104045, 4328, 974], [34038, 7654, 10204], [-7359, -15320, 14718], [-18695, 9695, 3339], [90321, -5761, -4842], [38355, 5758, 3974], [-20428, 808, -2039], [-71254, 4573, -4038], [-94757, 5967, -1038], [93048, -8826, 14949], [-25597, 8622, 18150], [-83106, -284, -15904], [116624, -2806, 3875], [-13335, -4053, -9319], [-16606, -3815, 3038], [-118676, -2244, 6872], [-36585, 603, -18742], [-116820, -85, -6258], [11053, -3543, -6661], [49004, -10164, 20349], [-27326, -2922, 5139], [-8666, -5023, -2998], [9349, -475, 9566], [-80813, 2487, 9843], [-91578, -996, 12592], [55480, -2488, -10001], [-43271, 2239, -15445], [60803, -4009, 6021], [-127638, -1444, 3184], [-45975, -3967, -18233], [-25253, -4214, -10430], [-29013, 4533, -5487], [91424, 3760, -7472], [-4380, -2145, -21710], [48173, 4954, -13412], [111533, -2551, 2766], [-36868, -1643, 21496], [-44833, -761, -1014], [58752, -5400, 9648], [-45551, -4930, -14260], [81272, 10924, -3232], [164067, 6519, -2013], [3430, 2880, -26287], [28497, 18816, -15034], [-97468, -1900, 1325], [49696, -12720, 31376], [30470, -7764, -12856], [-217206, 3515, 8404], [-50064, 11940, 12963], [46724, -240, -3407], [-58629, 7891, 15009], [120805, -6730, 20064], [26440, -9266, 14909], [-11701, 6971, 10354], [-95168, -4740, -2048], [80950, -6569, 9648], [37827, -6302, 20114], [-243762, 357, 1806], [174217, 5225, -8367], [-8861, 12168, -4340], [-47634, -12409, 1960], [3084, 4306, 2311], [205495, 182, 1638], [-13053, 1227, 834], [20113, 8103, 20317], [-98630, 6650, -22123], [-6271, -15930, 9684], [-32865, 3714, -23714], [217576, 2564, 7120], [-161215, -5357, 10079], [95175, 4751, -8982], [29617, -9380, -18162], [-120843, 11893, 12033], [-119073, -5333, 10235], [-82961, -12097, 13514], [74035, 4283, -15023], [83897, -14372, 29802], [70177, -3720, 1858], [-208624, -8096, -2592], [-225618, -170, -4708], [40959, -8361, -32390], [-106689, -14914, 14726], [134663, -2547, -829], [-54467, 6713, -24178], [-113422, 12514, 2431], [79673, -1535, 28247]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_392_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_392_4_a_k();".
// 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_392_4_a_k(:prec:=3)
    chi := MakeCharacter_392_a();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 4));
    S := BaseChange(S, Kf);
    maxprec := NextPrime(2999) - 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_392_4_a_k();".
// 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_392_4_a_k( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_392_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<3,R![9, -65, -1, 1]>,<5,R![1249, -109, -13, 1]>],Snew);
    return Vf;
end function;