
// Make newform 2496.4.a.bo in Magma, downloaded from the LMFDB on 12 October 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_2496_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_2496_4_a_bo();".
// 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_2496_4_a_bo();".
// 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 := [-90, -54, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0], [-1, 4, 0], [-69, -8, 2]];
    Rf_basisdens := [1, 1, 3];
    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_2496_a();"
function MakeCharacter_2496_a()
    N := 2496;
    order := 1;
    char_gens := [703, 1093, 833, 769];
    v := [1, 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_2496_a_Hecke( : Kf := Kf)
    return MakeCharacter_2496_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], [3, 0, 0], [-5, 0, -1], [-8, 1, 1], [7, 1, -2], [-13, 0, 0], [34, 0, 0], [12, -3, 5], [12, -4, 0], [-114, -2, -6], [18, -1, -3], [-184, -8, 18], [155, 6, 29], [-130, -2, -28], [109, -15, 12], [-184, -6, 20], [-27, -15, -16], [-416, 28, 14], [-306, -3, -29], [-327, -9, -18], [616, -8, -6], [-84, 16, -36], [543, 7, 4], [-543, 2, 51], [136, 32, -38], [162, -2, 46], [-774, 2, 8], [-152, 44, 48], [-222, -56, -32], [-796, -24, 38], [44, -22, -74], [328, -12, -80], [-469, 54, -67], [242, 32, 162], [833, -40, -47], [-530, 65, 59], [-1156, 96, 70], [-1244, -65, 31], [-547, -23, 188], [1022, 58, -58], [-1006, 38, 72], [252, -60, 226], [-634, 50, 180], [-346, -100, -216], [-1513, 120, 27], [-1544, -26, -50], [-1948, 4, 108], [1870, -33, -15], [-1383, 91, 222], [82, -140, -220], [-2168, 4, -58], [813, -93, -194], [-704, -120, -118], [1666, 22, 424], [-188, 92, -86], [6006, -2, -128], [-1038, -58, -178], [-840, -79, -391], [-794, 12, -168], [-5901, -34, 45], [-4520, -158, 190], [-1383, 132, 341], [1554, -61, -91], [7496, -132, -44], [1778, -24, -320], [215, -12, 719], [2542, 137, -233], [-7998, -40, -56], [-704, -152, -516], [3828, 228, 346], [2895, -6, -411], [905, -275, 116], [1330, 224, -10], [2314, 108, 404], [4176, 121, 581], [4095, 255, 664], [1428, -34, -612], [4388, -300, -102], [-6379, 78, -301], [-2344, 332, -274], [-3468, 244, 596], [1218, 340, -108], [1455, 391, -320], [-6848, -84, 422], [-5494, -194, 196], [2336, 340, -112], [-951, -50, 591], [2464, 52, 942], [1027, -108, 19], [-6820, -107, -727], [-4866, 242, -256], [-8749, -367, 86], [-11314, 311, 193], [1158, -30, 720], [6982, -111, -193], [7966, 182, 144], [-11245, 92, 219], [8192, 4, -18], [-13430, -96, -182], [8302, 336, -468], [-7734, -404, -2], [-10703, -280, -791], [6678, 610, -432], [-5496, 16, -846], [-6884, 194, -358], [3418, 432, -920], [5899, -733, -532], [-10511, 310, 127], [7870, -502, -108], [7586, -688, -968], [12742, 88, 426], [-19868, -32, -306], [-3257, 78, -1319], [1602, 539, 1045], [-9554, -127, -1269], [-11610, 544, 76], [-13850, 73, 743], [5332, 28, -848], [38, -710, -610], [6600, -136, 620], [3172, 348, -1734], [1612, 500, -1310], [-13492, -122, 300], [6491, -55, -558], [-21262, -19, 463], [-18592, -350, -1572], [2302, 148, -744], [-18896, 516, -148], [-5576, -806, 18], [-7358, 580, 556], [7882, -1181, 29], [3369, -673, 310], [11142, 370, -460], [-4216, -672, -1966], [25283, -90, 133], [19658, -156, 844], [-1327, -136, 689], [12782, -125, 105], [-8968, 1558, 152], [-3332, 348, -1174], [-7676, 405, -1491], [10021, 520, 1277], [-4342, 70, 460], [11891, -403, -1154], [3188, -408, 422], [-22293, -35, -1806], [26336, 100, -906], [-10084, -512, 1038], [10292, -224, -1232], [20607, -149, -716], [-8768, 124, -282], [1508, 1316, -430], [-5356, -758, 450], [2142, 458, -564], [-17752, 630, 274], [-10070, 94, 1836], [8024, 588, 2564], [-32841, 610, 773], [-52, -772, -1086], [10221, -1132, -1191], [35265, 433, -228], [14120, -568, 298], [-18090, -489, -2311], [-3672, 1116, 552], [27565, 150, 451], [28507, 481, -1738], [26246, 104, -1510], [15818, 496, 808], [8808, -1752, -142], [8590, -38, -2370], [33645, 151, -786], [-21292, -648, 558], [-21308, 832, 1516], [34744, 448, 2370], [-20818, 622, 520], [-8086, 1176, 1928], [1206, -93, 1609], [-687, 1052, 2677], [15206, 614, -2160], [21818, 20, 1124], [24928, 129, -703], [-27002, -10, -252], [-3712, 760, -798], [41333, 570, 583], [31785, 1093, -2092], [480, -1162, -2408], [27948, 1076, -2006], [-2724, 173, 1493], [-23012, 28, -2438], [48529, 645, 300], [19712, -604, 30], [25755, -297, -896], [11026, -300, -690], [-26459, 360, 1477], [1922, -686, -812], [9544, -732, 2678], [13210, 1200, -360], [-17998, 568, -1088], [14445, -2290, 971], [5538, -130, 3420], [-39565, 688, 1087], [51278, -600, -654], [5074, 592, 816], [-2560, -444, 2398], [13401, -687, -1764], [-6864, 954, 1828], [-25738, -1645, 2621], [11296, -1384, 3020], [-27339, 2946, 751], [17544, -578, 586], [-15856, -1524, -2794], [-24588, -1354, -652], [-4428, -1092, 200], [49691, -1223, -1342], [-22605, 727, -2316], [-10042, 800, -1180], [-34784, -1540, -3180], [-3274, -1700, -1928], [-26135, -73, 222], [30021, 304, -3475], [-16706, 900, -2776], [516, -139, -1607], [-14903, -2362, -1113], [7358, 715, -5939], [-6950, -2474, -504], [49846, 928, -3140], [-23742, -2096, -3960], [17986, -70, -2584], [-4788, -1118, -3114], [-4151, 2837, 1872], [11612, -12, 4714], [-39678, -932, -602], [-85720, -313, 127], [-16878, -2604, -1044], [-24962, 1620, 1114], [50809, -969, -3402], [-14100, -296, -5234], [-38191, -1764, 1157], [18102, 2314, 2864], [-470, 2074, 5824], [-20917, 963, 1204], [63712, 582, 2074], [16220, -1196, 2648], [50572, -652, -2862], [-24339, -2874, 531], [3720, 716, 948], [-36252, 1889, 3709], [-40611, -223, 704], [28996, 133, -723], [-6812, 484, -3896], [32274, 2140, -1100], [7783, -158, 3957], [50655, 2277, -714], [-68718, -816, -2024], [43782, -362, -3734], [-8593, 1205, -2110], [-45662, 2712, 1768], [8640, 1433, -3643], [-5388, -3182, 1104], [3526, 1872, -6172], [-35208, 2166, 502], [-3236, -1704, -6200], [-54326, 3936, 2504], [-20470, -808, -2232], [19193, -90, -2537], [-50208, -2548, 6104], [-7057, 108, 4607], [26379, 838, -3427], [59270, 1619, 1753], [-18254, -142, 3794], [-43024, -2660, 3134], [-15106, 3757, 3939], [5052, -2528, -2066], [95706, -1806, -1440], [30574, 832, 4196], [-36168, 1635, 867], [-15895, -2545, 4154], [-33900, -1568, -3274], [-11970, -3556, 4072], [2446, -2946, -6244], [62286, 2070, 3952], [-8008, -511, 1153], [5242, 390, -1652], [-12176, -1632, 8834], [26786, -2325, 2501], [15196, 1956, -2504], [26136, 348, 2654], [-10695, -1184, 6881], [19502, 685, 8071], [44708, 468, -5262], [-1168, 3238, 3568], [-47192, -2336, -1916], [-28823, 1922, -1013], [-37071, 4029, 5344], [-49644, -24, -3898], [-22924, 574, 1364], [-1526, -1392, -2178], [-8496, 3658, -68], [65096, 2124, 1784], [-23122, -3761, 7589], [44714, 1680, 1632], [-1417, 5256, 1491], [102186, 810, -2104], [37696, -536, 2404], [-8606, 1096, 4714], [-21916, -2136, -4090], [-83158, 2006, 2376], [-49290, 660, -3864], [-41465, -2331, 7598], [-20050, -1108, 6720], [-13930, -4718, 2028], [59087, 1568, -3205], [-55004, -2332, -3038], [-52944, -288, -6596], [11253, 2941, 216], [-96234, -80, -5804], [-12459, -3985, -5210], [-1857, 3055, -5592], [-79756, 1148, -3270], [-103506, 396, 3696], [17110, 3158, 5180], [21750, 1584, 196], [-153396, -694, -648], [27826, 2241, -4721], [-21707, -4774, 775], [29800, 2428, 5550], [-25108, 1099, -7037], [-90178, -2015, -10465], [-46436, 584, -612], [101330, -1238, -694], [78230, 1260, 5312], [-72018, -1374, 1118], [66580, 1072, -6860], [-78277, -655, -9214], [40672, 3225, -2187], [-65965, 5535, 3632], [58440, -2620, -5402], [60235, 354, 6961], [54332, -2104, -7130], [-145118, -562, -4860], [-21808, 2564, 2790], [84804, -3068, -918], [193, -3684, 741], [-33450, 1318, 10528], [-40321, -4188, -1353], [-18506, 1022, -1780], [29962, -1048, -6816], [111072, -649, 6115], [-57539, -231, -9196], [-29160, 5722, -1196], [184246, 293, 2339], [-45776, 1492, 7326], [-45143, -1452, 3581], [84620, 2026, 6390], [-67232, -4884, 934], [72712, -984, -7382], [-11755, 1761, 1124], [15741, 2627, -4358], [-47024, 4864, 786], [-8601, -1097, -112], [-50952, -2892, -3266], [7970, 2548, 7324], [-49118, -4962, 7148], [25173, -2413, -1454], [60902, 482, -6232], [-30952, -2660, -1786], [-125825, -776, -3493], [91258, 2705, -6449], [-63036, -1940, -10102], [51180, 2840, -3136], [-17102, 2018, -9244], [-40027, 4461, 5696], [-166928, 1186, 1700], [-7524, 780, -224], [55950, -7156, -8200], [68151, -1565, 3800], [-61836, -756, 1608], [-82230, -632, 1968], [51170, -6668, -5244], [-66520, -2876, 6414], [-84447, 1176, 10425], [-15577, -1610, -8255], [-86148, 7053, 3049], [32937, -5954, -6785], [-65420, 4371, -1357], [-106021, 497, -1498], [120268, 23, -6773], [84060, -184, 982], [-82512, 837, 8881], [-106350, 4614, 4548], [-92572, 5132, -1110], [-5623, 224, 6017], [-31157, -4595, 6086], [64936, -2220, 5000], [12549, -1535, -7444], [-53464, 4972, 6070], [153116, 2567, -2229], [75514, -776, -1720], [24384, -368, -11164], [82227, 228, -4261], [-130640, 648, 1442], [-69198, 7648, 2160], [-69724, 2773, 8865], [50553, 1962, 7907], [-39901, 3076, -8485], [36940, -2036, 3504], [150478, -988, 5856], [-170891, -2282, -8517], [49242, 935, 6913], [84091, 641, -3102], [-103142, 4592, 6024], [137028, -4090, 228], [21080, -5520, -788], [-6078, 190, 10296], [-36146, -2864, -17380], [-100592, -2078, 1036], [-51143, 3511, -8426], [-18908, 1196, -5544], [111369, 3414, -1785], [-57412, -2060, -7960], [-200566, 1906, 5826], [67244, 2848, -9418], [123373, 399, 5594], [-50316, -1120, -2040], [-69490, 7128, 5188], [7417, 5244, -6443], [-108482, 5674, 6472], [-14719, -6094, -7037], [-73688, 347, -6369], [-102390, 5494, -3828]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_2496_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_2496_4_a_bo();".
// 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_2496_4_a_bo(:prec:=3)
    chi := MakeCharacter_2496_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_2496_4_a_bo();".
// 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_2496_4_a_bo( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_2496_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<5,R![-1616, -140, 16, 1]>,<7,R![-16224, -832, 22, 1]>,<11,R![46272, -1840, -20, 1]>],Snew);
    return Vf;
end function;