
// Make newform 828.4.a.e in Magma, downloaded from the LMFDB on 11 March 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_828_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_828_4_a_e();".
// 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_828_4_a_e();".
// 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 := [-69, -34, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0], [0, 2, 0], [-23, -3, 1]];
    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_828_a();"
function MakeCharacter_828_a()
    N := 828;
    order := 1;
    char_gens := [415, 461, 649];
    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_828_a_Hecke( : Kf := Kf)
    return MakeCharacter_828_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, 0], [0, -1, 0], [14, -1, 0], [0, -3, 6], [33, -3, -1], [10, -5, 2], [38, -2, -6], [-23, 0, 0], [41, 5, -5], [-29, 8, -11], [-72, -13, -4], [199, 9, 17], [-24, -4, -52], [129, -16, -9], [50, 42, 28], [-212, 22, -4], [118, 4, 16], [168, 53, 62], [-315, -42, -57], [87, 37, -115], [498, 2, -46], [-130, 69, 64], [276, 48, 18], [410, -11, -54], [-330, -30, -192], [758, -63, 60], [458, 36, -158], [740, 90, 126], [818, -29, -134], [-259, 94, 87], [653, -56, -209], [632, -10, 106], [-403, -200, 159], [394, -56, -112], [1427, 10, 129], [16, 100, -266], [2229, 80, -1], [388, -202, 176], [-1682, 28, 164], [1519, -226, -199], [-320, 347, -188], [-552, 225, -222], [-293, 263, 133], [-2611, -121, 307], [-980, -157, 58], [3984, -26, -88], [-332, -48, -692], [-222, 343, -240], [-1376, 318, -206], [303, 113, -327], [961, 260, 719], [-2436, -145, 236], [4702, 49, 320], [-1557, -327, -27], [-1734, -166, -222], [4265, -91, 331], [328, 280, 40], [-2825, -535, 793], [-1530, -391, -150], [-1316, 219, 94], [-7104, -36, 162], [988, 142, 796], [-2327, 738, 347], [-3368, -224, 466], [-1194, 470, 528], [-455, -128, -893], [-6780, -104, -370], [-7336, -248, -428], [507, 37, -187], [-635, -741, 47], [4146, 126, -894], [2918, 113, 1428], [1940, 563, 1200], [-1044, -694, -652], [-5900, -24, 188], [6736, 232, -742], [2941, -57, -761], [-3368, -15, -256], [-8089, -375, -75], [-3124, 418, 724], [-2746, -79, 42], [5868, -654, 360], [-1592, 103, 1168], [1657, 272, 247], [7073, -526, 871], [1906, 152, 284], [-6318, 673, -574], [165, -405, -885], [-2532, 1288, -556], [2970, 30, 222], [-1350, 951, -900], [6877, -844, 427], [2299, 60, 113], [195, -1206, 917], [5630, 518, 1078], [-9191, 623, -241], [-2124, 704, 978], [4602, 715, -400], [-6409, 1389, 57], [8193, 960, -1213], [6964, 784, 398], [-6860, 740, -928], [-4640, -735, -1216], [642, -603, 1436], [-4269, -5, 821], [2945, -1178, -593], [158, -424, 928], [11384, -536, 1456], [1139, 1895, 1941], [17184, 178, 884], [-8810, -727, -1862], [-5638, -338, 280], [2076, 1718, 1628], [7880, -1654, 1188], [-2596, 580, 2698], [-548, -379, 634], [8917, 500, -1645], [8543, 393, -2051], [-14810, -827, 1208], [1158, -596, 2360], [-7323, 1477, -553], [8974, 436, -364], [22951, -2, 425], [14324, -612, 192], [8134, -331, -2482], [354, -627, -826], [12696, 12, 1584], [16444, 1509, -1298], [17638, -339, 778], [18693, -318, 323], [-5194, -275, 1540], [12636, 1302, -1840], [10356, 1155, 800], [-11907, 987, -753], [-2948, 199, 1708], [16316, -256, 2782], [3664, 2006, -2912], [-3506, 970, -328], [15346, 1968, -460], [-5861, -1352, -575], [-3814, -232, 3400], [-10693, 586, -1479], [9900, 1434, -2628], [15770, 1510, -3624], [-4246, -1765, 2620], [-12370, -1706, 2172], [-377, 1865, -3391], [-10617, 4042, 425], [12275, 1824, 2197], [11742, -1722, 1988], [3654, -451, 234], [-4516, 2392, 336], [-3431, -610, -1069], [2846, -1300, 2598], [-31118, 384, 254], [-15126, 387, 1532], [7547, 2291, 2809], [-16852, -1407, 936], [-9370, -3409, 3634], [-379, -330, 355], [31846, -1214, -268], [-5703, 198, 467], [35698, -1792, -958], [21920, 77, 4912], [29654, 2620, -2534], [-29288, -2176, 520], [18850, 1228, -956], [17510, 1662, -3480], [-33273, -1273, -2775], [-24908, 1387, -1570], [595, -905, -5183], [-2638, 1303, -3572], [-12436, -810, -4518], [-8587, 254, 495], [-27654, -2391, -5706], [-24947, -2356, -2969], [16751, 107, 313], [5498, -966, 210], [25254, -1653, 38], [-19039, -728, 4935], [-13644, 2292, -1248], [5695, 1173, -4967], [-13382, 1364, 1940], [-21012, 529, -3522], [24102, 197, 1350], [-15522, 4642, 2588], [-2450, 2788, 2254], [-7509, -1313, 605], [-3176, 3016, 680], [-4531, 651, 1995], [-2872, -10, 1936], [-41580, 2735, -1930], [-24470, -2548, 6728], [-32136, 2259, 786], [9916, 1544, 5258], [-49024, -1249, -1512], [23248, 68, -266], [-4528, 2776, -5810], [-129, 2508, -2007], [-17248, 5914, -1370], [-5792, -1796, 4408], [-16645, 1209, 5397], [-11184, -2361, -7480], [13208, -1198, -6752], [40309, -1399, -2953], [15860, 2571, 5130], [-47543, -948, 2843], [-1201, 3525, 4609], [-5415, -1094, 4439], [-18947, 1423, 1651], [-55957, 221, -1439], [-19580, -2882, -3440], [12066, -2280, -6798], [-15716, 2632, 1004], [-41964, -254, -5062], [6427, 5222, -1799], [-40583, 4241, -1657], [-8180, -2335, 3638], [-27849, 3741, 1245], [28773, 3971, 3071], [-8408, -4487, -4550], [4345, -5537, 3011], [25402, -8803, -3608], [-11575, -2798, 823], [34097, -5189, 1107], [41652, 1949, 5460], [-33225, -4770, 3789], [17682, -1158, 6554], [-36320, -5216, 7820], [31970, -508, 876], [24814, 6723, -2348], [-56264, 3167, -674], [11922, -4620, -4548], [47348, 3852, 2208], [-298, -5279, 6244], [34104, 760, 6026], [-1976, -5869, -3808], [-29767, -2314, 4135], [13967, 4222, -3587], [26256, -3264, 1692], [-43149, -780, -1759], [31455, 2420, -4855], [33545, -1967, -5889], [12854, 4520, -2840], [-25839, 8072, 4047], [23935, -4846, 3853], [-18022, 6160, -1118], [-1446, -4126, 2918], [70156, -2621, -94], [-5234, 1077, -4190], [25512, 675, -6492], [9902, 8512, -3542], [-13850, 307, -10766], [22670, 1012, 8740], [73235, -106, -2843], [27108, 4365, 2612], [65944, -3525, -494], [64841, 855, -2249], [-27137, 2685, 4549], [-30704, 2194, -4988], [32908, -1240, 5168], [31434, 7076, 3212], [-16914, -5915, -8830], [-66634, 568, -3944], [-50294, -1292, -590], [105848, -3859, -308], [-1064, 5498, -11086], [-34410, -5118, -4198], [-48931, 1183, 5107], [53915, -4577, 633], [32994, -5036, 3434], [86620, -2062, 1522], [-18274, 3503, -3192], [85507, 1783, 3181], [-17881, 1466, -3], [109144, 1150, -640], [17158, -9588, 376], [53364, -1071, 6176], [-23244, 8622, 1380], [-30993, 732, -1647], [-2952, 3927, -4858], [-15004, -4059, -2282], [-32566, -5966, 3936], [45812, 7214, -11028], [-36796, 6350, -7784], [99130, -6412, -368], [67762, -3560, 6872], [1652, 6166, -2400], [-14078, -2126, -14224], [-40674, 5936, 6372], [29658, 1901, 12468], [-20258, -11168, 6392], [-70146, -6684, -3618], [22071, 2673, -943], [82762, -3810, -5260], [-45278, -2563, 10336], [-34673, -2861, -18151], [113251, 2278, 10877], [84077, -4616, -921], [-73734, -4003, 8306], [32126, 9032, 5188], [-41102, 561, -728], [-87225, 4980, 2733], [-9800, -3934, -1544], [10089, -5457, 2135], [12108, 1960, 2736], [9692, -656, 13986], [-50228, -1985, -13246], [37002, 2872, -2812], [3937, 5632, 11975], [-22486, 6292, 5128], [3038, 5135, 1030], [-36887, 10634, -2177], [12990, -11652, 6882], [-38154, -339, -7354], [6959, 6986, -9359], [-12007, -8286, -7421], [-64668, 4074, 7538], [-97337, 4655, -1387], [-58940, -1546, -1844], [-15410, -10949, -14630], [-51045, -387, 9465], [23908, 7498, 16288], [-22436, -1127, 5444], [-96896, -4540, -8390], [-48176, 6103, 2746], [-3675, 11124, 10223], [-105420, -903, 678], [17298, 5717, -16854], [4159, -2203, -9935], [20415, -299, 7173], [20741, 7304, 4275], [-25133, -7028, -1087], [48034, -7532, -5678], [-128949, -1260, 5121], [-115060, 5353, -5172], [-74994, -4371, -3438], [-59599, -3609, 7767], [76368, -17178, -1636], [-45731, -4321, -3953], [34092, 7302, 6438], [101930, 7098, 8380], [24678, -8642, -4450], [-24276, 8157, -8184], [77448, -5070, -9264], [8589, -3435, 6635], [106140, 6912, -15208], [54706, 182, 8474], [67552, 1437, -13828], [-71537, -9764, 781], [-87509, 4973, -7607], [-68970, 4004, 12], [12742, -3224, -18662], [52638, 3227, 21878], [-81414, -3204, -12492], [124358, 5315, 6568], [-14712, -7509, 20346], [-24831, -7465, 9819], [-82808, -4426, 12956], [-9956, -10901, 5368], [36677, -3751, -1181], [105463, 1324, -7543], [-47240, -2277, -27094], [13805, 4836, -10977], [-37061, 7081, -2159], [88271, -10859, -1691], [46380, -11599, 9350], [-117014, -3244, -9800], [-39365, -6776, 3521], [64764, 11016, -23512], [8901, 8808, 12579], [42382, 9557, 13790], [32844, 9006, -6712], [61069, -18491, -5933], [106603, 10508, 5657], [-148460, -1261, -13606], [-75918, -3050, 1676], [-6448, -17598, 12946], [-83623, -2767, -6333], [32972, -5125, 21652], [72470, -4990, -11372], [-35112, 8236, 11672], [3695, 4415, -17891], [-32910, 10165, 6980], [-32429, -15646, 7697], [-42247, -3780, -7305], [134202, 1172, 3692], [7116, 129, 25082], [120582, -11991, -2988], [119318, 5081, -19002], [-54798, 5760, -1824], [-106251, -12668, 9831], [64260, -968, 26312], [-13574, 5495, 3140], [-132600, 7133, -10972], [16424, -818, 11268], [-156274, -7163, -230], [10514, -4395, 12588], [20690, -8038, -16412], [123433, 8707, 14563], [-18107, 4267, 335], [166966, 2057, 6964], [87778, 11339, 2162], [76363, -19387, -2431], [22231, 15652, -14831], [93242, -74, -9744], [-142499, 1203, -8521], [-21842, -4741, -20060], [-104136, -448, -7092], [-2603, -19443, 18823], [53179, 10339, 1709], [71348, 7949, 29650], [-61138, 20142, -3582], [101638, 6598, 10864], [56609, -17777, -7817], [21540, 17248, -468], [200576, 1602, 11628], [-37688, 19028, -9874], [201048, 3666, 6756], [117146, -10479, 6898], [148644, 3282, -8122], [22580, 6932, -33980], [-82372, 5092, 2296], [-57, -549, 30425], [10111, 1039, 3545], [28326, 10034, -22230], [-32694, -3630, -28032], [-29773, 1198, 3093], [201493, 7666, 6239]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_828_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_828_4_a_e();".
// 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_828_4_a_e(:prec:=3)
    chi := MakeCharacter_828_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_828_4_a_e();".
// 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_828_4_a_e( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_828_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<5,R![552, -136, 0, 1]>],Snew);
    return Vf;
end function;