
// Make newform 49.8.c.g in Magma, downloaded from the LMFDB on 01 June 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_49_c();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_49_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_49_8_c_g();".
// 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_49_8_c_g();".
// 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 := [810000, 216000, 149400, -22680, 9744, -378, 103, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0, 0, 0, 0, 0], [21568329000, 7856666100, 13150689930, -241778964, 191205693, 6596632, 2089856, 2419], [9362007000, 7051146300, -2766284640, 521375988, -35051121, 4986506, -221882, 51287], [4975101000, -4535559000, 855847440, -161305998, 10026716, -1542751, 68647, -11627], [78343411500, 1424943000, 507479700, 1049560974, -17965948, 13007813, 215659, 141661], [192094254000, 10330483500, 33045233760, -6228206292, 625838339, -59567354, 2650538, -832833], [-1685376396000, 1662073688700, -289928802240, 54644382408, -4123329861, 522625796, -23255012, 5145317], [-692595526500, -10997523000, -3916661700, -10024081914, 138658828, -100392593, -961699, -1093321]];
    Rf_basisdens := [1, 3180326625, 25442613000, 605776500, 4240435500, 8480871000, 25442613000, 4240435500];
    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_49_c();"
function MakeCharacter_49_c()
    N := 49;
    order := 3;
    char_gens := [3];
    v := [2];
    // 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_49_c_Hecke();"
function MakeCharacter_49_c_Hecke( : Kf := false)
    N := 49;
    order := 3;
    char_gens := [3];
    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 := 8;
    raw_aps := [[-1, 0, 2, 1, -1, 0, 0, 0], [6, 0, -6, 1, 0, 1, 0, 0], [7, 3, 58, -7, 7, 0, 1, -1], [0, 0, 0, 0, 0, 0, 0, 0], [910, 0, -910, 196, 0, -30, -9, 0], [255, 37, -37, 0, -115, -37, 0, -37], [14087, 0, -14087, 251, 0, -243, 29, 0], [34, -316, 10578, -34, 34, 0, 11, -11], [-1741, 285, -32209, 1741, -1741, 0, 208, -208], [6135, -2055, 2055, 0, -2703, 2055, 0, -353], [101192, 0, -101192, -3328, 0, 1550, 527, 0], [-4592, -1396, 4343, 4592, -4592, 0, -10, 10], [-93987, -1905, 1905, 0, 19143, 1905, 0, 1513], [27080, 2988, -2988, 0, 27900, -2988, 0, 1212], [9580, -1206, 363334, -9580, 9580, 0, 2915, -2915], [148219, 0, -148219, 29326, 0, -4578, -4760, 0], [219962, 0, -219962, -78463, 0, 14649, -5428, 0], [-133928, 8660, 394077, 133928, -133928, 0, -2962, 2962], [18898, 0, -18898, 65381, 0, 42281, 7106, 0], [861522, 61410, -61410, 0, -27246, -61410, 0, -5466], [1607891, 0, -1607891, 158366, 0, -20854, 110, 0], [-80361, -81879, -905441, 80361, -80361, 0, -3864, 3864], [-2411958, -30186, 30186, 0, -22698, 30186, 0, -14502], [282892, 21924, 3888895, -282892, 282892, 0, -9032, 9032], [-738325, -25459, 25459, 0, -684635, 25459, 0, 1939], [5742869, 0, -5742869, -436645, 0, 11985, 11935, 0], [137571, -62535, 8254619, -137571, 137571, 0, 29142, -29142], [471074, -142200, 8101742, -471074, 471074, 0, 15965, -15965], [5113543, 0, -5113543, -317237, 0, -189119, -15617, 0], [3352173, -6309, 6309, 0, -574557, 6309, 0, 43717], [19171942, -128354, 128354, 0, -300178, 128354, 0, -43174], [1016965, 40455, 7790839, -1016965, 1016965, 0, -55370, 55370], [-20944667, 0, 20944667, 4621, 0, -474669, 70351, 0], [-2196850, -433630, 433630, 0, -8318, 433630, 0, 153742], [-534079, 370101, -8425498, 534079, -534079, 0, -108881, 108881], [7109956, 0, -7109956, 1330980, 0, 858870, 67905, 0], [-9321703, 0, 9321703, -404684, 0, -365528, 233314, 0], [-825427, -534821, -27150513, 825427, -825427, 0, -15932, 15932], [-44654553, 293583, -293583, 0, 2179407, -293583, 0, -357871], [-2779670, 613974, 12477595, 2779670, -2779670, 0, 47952, -47952], [-49422974, 0, 49422974, 4077580, 0, -283374, -172165, 0], [12654618, 1102960, -1102960, 0, 1046720, -1102960, 0, 102440], [-1030372, 252270, 45153818, 1030372, -1030372, 0, 192077, -192077], [-1239191, 0, 1239191, -3026589, 0, 128997, 405525, 0], [6406683, -630123, 630123, 0, 3174093, 630123, 0, -494189], [-30448804, 0, 30448804, -3044362, 0, 2864, -170107, 0], [-35507238, 1649630, -1649630, 0, 1722622, -1649630, 0, 239362], [53292378, -1115390, 1115390, 0, -4287982, 1115390, 0, 413318], [-82023298, 0, 82023298, 2387774, 0, -2659836, -182341, 0], [-10592619, -3308751, -108304924, 10592619, -10592619, 0, 39879, -39879], [1316531, -2692893, -2192566, -1316531, 1316531, 0, -673337, 673337], [-92465685, -1320645, 1320645, 0, -480453, 1320645, 0, -47883], [-13267369, 0, 13267369, -14264892, 0, 2464620, -282972, 0], [-244748247, 1628565, -1628565, 0, -15483627, -1628565, 0, -480397], [9656335, -4090281, -38762936, -9656335, 9656335, 0, -962865, 962865], [-120408596, 0, 120408596, -14641529, 0, -1545693, -1115130, 0], [34996673, 0, -34996673, 8339756, 0, 423744, 1341506, 0], [4603531, 4411145, 108505863, -4603531, 4603531, 0, 160274, -160274], [351067003, 0, -351067003, -2742334, 0, 1792586, -348364, 0], [-158997063, 7526895, -7526895, 0, -6943689, -7526895, 0, 1183121], [53056586, 0, -53056586, -2693576, 0, -893102, 787765, 0], [29816682, -5451096, 5451096, 0, -25967928, 5451096, 0, -65912], [-382065744, 5029012, -5029012, 0, 3778436, -5029012, 0, 1357844], [220386260, 0, -220386260, -1572901, 0, -2984805, 383384, 0], [-13759446, -2496222, -234626839, 13759446, -13759446, 0, 160542, -160542], [13634726, -3406518, -191878915, -13634726, 13634726, 0, -3189560, 3189560], [-37458993, -798555, 267758209, 37458993, -37458993, 0, -3756342, 3756342], [629936439, 8277533, -8277533, 0, -17977691, -8277533, 0, -320549], [-328077482, 0, 328077482, -8432369, 0, -1353609, 250196, 0], [455646105, 416935, -416935, 0, 51889007, -416935, 0, 1131857], [-320569129, 0, 320569129, -5712259, 0, -16097349, -1835445, 0], [13466402, 3371196, 603633416, -13466402, 13466402, 0, 3328503, -3328503], [458281472, 0, -458281472, 17681501, 0, -20951743, -4014166, 0], [-2061582, 16078494, 143426197, 2061582, -2061582, 0, 5466648, -5466648], [-242360795, -8225735, 8225735, 0, -37930375, 8225735, 0, 3504095], [69010978, 14734272, -45419168, -69010978, 69010978, 0, 2872217, -2872217], [1051634347, 0, -1051634347, -2860211, 0, -4236729, 1774969, 0], [-38165911, 17704333, -105317420, 38165911, -38165911, 0, -2681825, 2681825], [21296729, 9763425, -1025839288, -21296729, 21296729, 0, 1065841, -1065841], [-279476173, 0, 279476173, -22617393, 0, -12288351, 8168637, 0], [-836836680, -18567300, 18567300, 0, 16602636, 18567300, 0, 3398076], [307312037, -17773785, 17773785, 0, -67324833, 17773785, 0, 2263017], [-243366248, 0, 243366248, 27644074, 0, -1749720, 5349799, 0], [348974271, 32847793, -32847793, 0, -93990199, -32847793, 0, 475343], [-68293438, -16000616, 1031087980, 68293438, -68293438, 0, 517093, -517093], [-9254212, -23812926, -259260028, 9254212, -9254212, 0, 534103, -534103], [-10701225, 35519805, -35519805, 0, 65119941, -35519805, 0, 2158731], [71129438, -9773066, -307313337, -71129438, 71129438, 0, -4205630, 4205630], [2275013133, -20230725, 20230725, 0, -55659549, 20230725, 0, 283021], [-1443446376, 11343512, -11343512, 0, -77238536, -11343512, 0, -7614248], [58192003, 24575877, -1327760759, -58192003, 58192003, 0, -7412620, 7412620], [-295281040, 0, 295281040, 126375539, 0, 35377419, -4429916, 0], [-644409092, 0, 644409092, -104276677, 0, 35492879, -1591294, 0], [783315117, -36939855, 36939855, 0, -61983567, 36939855, 0, 10779623], [55152461, -23416949, 1808237847, -55152461, 55152461, 0, 3270124, -3270124], [-227991222, 945450, -945450, 0, 107883738, -945450, 0, 11417838], [71452975, 8388099, -1992339698, -71452975, 71452975, 0, 4421925, -4421925], [203866859, 0, -203866859, -62707060, 0, -60823620, 3684200, 0], [-223502246, -32677132, -404294394, 223502246, -223502246, 0, 10491887, -10491887], [-251687007, 27154125, 596042578, 251687007, -251687007, 0, -5366853, 5366853], [782678679, 8730083, -8730083, 0, 85861219, -8730083, 0, -12027419], [1436475223, 0, -1436475223, 208609915, 0, -20662383, 7670271, 0], [-201588634, 0, 201588634, 97066667, 0, -5907945, 368310, 0], [201103310, -18281034, -3551074417, -201103310, 201103310, 0, -2436310, 2436310], [-387148922, 0, 387148922, 142656888, 0, -12027330, 12013323, 0], [580544687, 0, -580544687, -142529048, 0, 22564696, 19880104, 0], [-1068092340, -4518024, 4518024, 0, 46298280, 4518024, 0, -1446256], [-99605219, 8239605, -1285065206, 99605219, -99605219, 0, 21521837, -21521837], [1339357084, 0, -1339357084, 84347437, 0, 5946621, 10700272, 0], [-1936693357, 37782845, -37782845, 0, 120085333, -37782845, 0, 11830243], [-33613098, -21282444, 679526492, 33613098, -33613098, 0, -20610915, 20610915], [-1488140381, 0, 1488140381, -182844949, 0, -12545143, -5095645, 0], [525764187, 91231881, -91231881, 0, 127824177, -91231881, 0, -11880609], [-455965846, 0, 455965846, -112771865, 0, -37832141, -21107210, 0], [5074328402, 22975410, -22975410, 0, 210710562, -22975410, 0, 18186102], [2214589921, 0, -2214589921, -89722940, 0, 92091420, -23454500, 0], [5654892304, 101241876, -101241876, 0, 100686084, -101241876, 0, -16888572], [4171162892, 0, -4171162892, -271114669, 0, -20430573, -6249176, 0], [276164546, 102622902, -2340339271, -276164546, 276164546, 0, -869732, 869732], [-463731090, -74672910, 74672910, 0, -336475854, 74672910, 0, 16096686], [-575934739, 0, 575934739, 199860568, 0, 144560380, 14560138, 0], [-1493112897, -4284379, 4284379, 0, -455012147, 4284379, 0, 2322307], [-30518039, 21386085, 8310600448, 30518039, -30518039, 0, 16382315, -16382315], [2879087974, 0, -2879087974, 44511250, 0, -141861372, -35877935, 0], [74884929, 73942515, 389634275, -74884929, 74884929, 0, -11792934, 11792934], [1921799802, -13601100, 13601100, 0, 309033588, 13601100, 0, -20132292], [505621696, -57771364, 3576109847, -505621696, 505621696, 0, -5761546, 5761546], [140137219, -105605631, 833464303, -140137219, 140137219, 0, -58446934, 58446934], [2210193106, -32220798, 32220798, 0, -276003534, 32220798, 0, 10548294], [241534934, 116755378, -595274009, -241534934, 241534934, 0, 38048692, -38048692], [1796520514, 0, -1796520514, -358109618, 0, -90925904, 179257, 0], [-3849252594, -44801106, 44801106, 0, 223127646, 44801106, 0, -36694518], [-367639216, -46339310, -4729724178, 367639216, -367639216, 0, 18621481, -18621481], [-3185531437, -155720163, 155720163, 0, 125132853, 155720163, 0, 24004971], [54519775, -70911585, 7716342484, -54519775, 54519775, 0, -70108645, 70108645], [-1290523475, -259116825, 259116825, 0, 30633375, 259116825, 0, -6535695], [6351770021, 0, -6351770021, -449611873, 0, 85472205, 14097355, 0], [-3304129858, 0, 3304129858, 199358797, 0, -77944859, -36836996, 0], [-10285569291, -166387485, 166387485, 0, -60146901, 166387485, 0, -24615691], [-12482557283, 0, 12482557283, 430891594, 0, 31362126, -11926406, 0], [15970072348, 168256680, -168256680, 0, -137599944, -168256680, 0, -14517024], [-386770777, 137498235, -3425470312, 386770777, -386770777, 0, -8069523, 8069523], [-798734516, 0, 798734516, 841741645, 0, -5302787, -48913760, 0], [321610452, -5904024, 5904024, 0, 885732792, 5904024, 0, 71368416], [-10467259183, 0, 10467259183, -94844223, 0, -147931101, 25155357, 0], [2752483200, -292449240, 292449240, 0, 242088072, 292449240, 0, -38553208], [-4589753993, 165922389, -165922389, 0, -343484163, -165922389, 0, 78582123], [7195474907, 0, -7195474907, -827363938, 0, 253551066, -27681306, 0], [818050116, -248720706, -10414686964, -818050116, 818050116, 0, 13515609, -13515609], [-534145417, -184289511, -9617274553, 534145417, -534145417, 0, -32700752, 32700752], [601236197, 165524833, 5688794214, -601236197, 601236197, 0, -16108745, 16108745], [-21225133482, 226378320, -226378320, 0, 408444960, -226378320, 0, 35040600], [16018427606, -33515526, 33515526, 0, 166120986, 33515526, 0, -2925018], [764013208, 143413182, 1055179246, -764013208, 764013208, 0, 90691875, -90691875], [-1271292722, 0, 1271292722, -7812525, 0, 54233667, -2762664, 0], [-12340058928, 11119680, -11119680, 0, -1329805152, -11119680, 0, -43006752], [456098718, -244078104, -19826121020, -456098718, 456098718, 0, 22823307, -22823307], [-771389006, 272677074, -1679772347, 771389006, -771389006, 0, -55254294, 55254294], [-5409578638, 396087308, -396087308, 0, 53724652, -396087308, 0, -84691916], [15662581817, 0, -15662581817, 1476048182, 0, -566950890, -58559168, 0], [86778887, -115472427, -11375941771, -86778887, 86778887, 0, 82047630, -82047630], [-14624946603, 98916795, -98916795, 0, -535922013, -98916795, 0, -159113323], [-13597183002, 423692342, -423692342, 0, 1776067558, -423692342, 0, 39083986], [71961121, -525354165, 10066918543, -71961121, 71961121, 0, 138681254, -138681254], [17361662353, 0, -17361662353, -1924192949, 0, 224247021, 130993861, 0], [26362460396, 0, -26362460396, -925219168, 0, -429814650, 2356235, 0], [10556032240, 0, -10556032240, -492801399, 0, -425957895, 55325376, 0], [-15607441483, 0, 15607441483, -899951648, 0, 8704516, 106146874, 0]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_49_c_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_49_8_c_g();".
// 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_49_8_c_g(:prec:=8)
    chi := MakeCharacter_49_c();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 8));
    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_49_8_c_g();".
// 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_49_8_c_g( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_49_c();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,8,sign)));
    Vf := Kernel([<2,R![86713344, 15867648, 6740160, -590304, 170656, -936, 448, -6, 1]>,<3,R![28723950837729, 230950410516, 28579252842, 85273776, 20707299, 53424, 5770, -28, 1]>],Snew);
    return Vf;
end function;