
// Make newform 112.8.a.g in Magma, downloaded from the LMFDB on 27 November 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_112_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_112_8_a_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_112_8_a_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 := [-492, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0], [-1, 2]];
    Rf_basisdens := [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_112_a();"
function MakeCharacter_112_a()
    N := 112;
    order := 1;
    char_gens := [15, 85, 17];
    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_112_a_Hecke( : Kf := Kf)
    return MakeCharacter_112_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 := 8;
    raw_aps := [[0, 0], [-35, -1], [63, -9], [-343, 0], [1710, 126], [-3199, 189], [-19236, -90], [21679, -243], [-44964, 252], [79788, 2394], [71806, 594], [-135916, 9450], [32424, -6174], [-763982, 378], [-242718, -17442], [-72858, 6552], [2091831, -1107], [-140329, -23193], [-2835824, 34020], [309636, 21924], [1969814, 14148], [-2328308, 106596], [-617925, 135009], [-8620710, -74160], [-370468, 38934], [7470351, -272313], [5291986, -82458], [-2598564, -372960], [-815992, -150066], [-5492100, 148806], [21191560, 470232], [-9432801, -68787], [72126, -102564], [6547009, -653373], [-25265286, -798588], [-2856320, 488376], [-10189543, 57429], [-2922734, -1984878], [-32783730, -823158], [-75040707, -53055], [-26451276, 1712592], [9362297, 103005], [-46916628, -470988], [-92589016, -377622], [105337458, -312228], [-49057778, 410346], [-178243592, 1220940], [167943412, -1924020], [-41349105, 82557], [147583877, -887679], [-180454110, 1738296], [9587604, -6884388], [10027556, -1666818], [10086489, 107163], [-57331638, 3439224], [12481380, -5370876], [181449933, -3554991], [-154072352, -1760400], [247400270, 6704208], [34856922, -6919920], [-375097793, -135675], [645349803, 1184715], [916212031, -622755], [-246397872, -9250200], [-359162776, -15891822], [-849414486, 2339820], [329268034, 12474378], [524162480, 3772818], [-462668358, -10061982], [-29417059, -5345487], [-948666726, 8283528], [106102392, -11564784], [426490876, 15890580], [118778810, 6396516], [338290846, 17301438], [-444927294, 20256462], [-534182868, -9607374], [-371168035, 33670593], [-875233440, -19948446], [618219140, 33682230], [-294334719, -52066917], [1345874966, 17495352], [1363707732, 13336092], [-711418120, -43977654], [-610471232, 29200824], [551333640, 1050084], [-16109910, 45322200], [1974626720, -1466262], [-2788030455, 14104629], [-368039912, -52891272], [-2171388261, -6922431], [-1778786226, 43708482], [2293539964, 2932524], [481546560, 16206876], [-3071559704, -9462852], [-2722396068, -12704580], [-374849811, -64298943], [185971128, 94275378], [2552586883, -31071087], [1034992010, 85245804], [-1173112082, -58118634], [4225951266, 72974916], [-2016040971, -3039849], [-236797824, 82222938], [467905846, 65735334], [-2550788926, -122437440], [-1069301163, 82328463], [-403882458, -11877588], [-4204862688, -64225224], [-2758440790, 56173824], [372572032, 120853728], [317235476, 62594154], [-3194787720, -28452942], [785936431, -165663387], [84773428, 201069540], [-11019308904, 35409402], [-770199899, 128581047], [-6170371746, 56899674], [-8075276640, -94567914], [-2145676458, -77726754], [3559312211, -74359053], [-10003118914, -80083836], [7142588817, 74646549], [-3277131072, -118437732], [-2053496249, 179657109], [2296670616, 24350382], [11135309804, 14979762], [-5161237410, -183828510], [8390922274, 42057414], [-1518011761, 235898703], [-13221422030, 111844530], [-6500955120, -9011016], [-482437868, -94116708], [-976437124, -328256334], [5730128964, -276500394], [13139726936, -22407462], [4248348027, 262391067], [-6327314861, -356492151], [5546742117, 324073449], [-4682417448, -244259694], [5086883347, -232293663], [-23606088762, 87543288], [-7170814040, -125251056], [-6682942548, 53107488], [343061327, -547389009], [16772061642, 223750926], [1363380389, -767212047], [-2525359788, 365186214], [20619490297, 343376091], [2322264228, 216722268], [2797354220, -625710582], [-27046893762, 90744948], [-2721935036, 143833536], [-6551831286, -158997186], [-8772482276, 603215424], [-31913698224, 93983904], [-865826552, -178836336], [14523070884, 676830222], [-11498752762, 556247412], [3990438543, -330407937], [-24959784930, -369669258], [-10069852014, -213574536], [18214372804, -773547516], [-11996036913, -476902683], [-869087130, 434747628], [4272611994, 69472206], [13069605544, 767761848], [18170772515, -315389997], [-26754463384, -819261702], [-3190014387, 123686505], [41085808416, -93555252], [31574537897, -277008795], [34787308644, 17014788], [12630866498, 302634360], [-7972191626, 263298762], [-1194814866, -1155863268], [-34783137692, -187722360], [-43180990428, 611709210], [-36927830324, -412695108], [-20182163617, -113633361], [36589627540, -918625428], [-34383218835, 151100271], [25337703848, -164817450], [8105429010, 344599848], [17798215920, -593925696], [30130707537, -345627099], [13587549302, -1325461536], [27919945711, 686722077], [31100162558, -483553476], [22141869834, -1143961722], [-33707768542, 1072634400], [22771387896, -347873148], [-11631493100, 397683216], [93927104313, -200095947], [-43555172820, 872858952], [-20258879802, 530977140], [36677453216, 1105933122], [-96530772916, -6743142], [11519435550, -533978172], [-32272814280, 1163001744], [-6967364658, -2283085224], [-71604089270, 755700246], [-98324745421, 646646355], [43496331326, -1229604732], [23221461627, 100356921], [25884085983, 1893419487], [-40063207142, 583709814], [-62190127926, 1803711546], [35183605620, 1410132150], [-76063853075, 1155545271], [14880592856, 344999466], [64174363071, -340295193], [233300800, 82051704], [78590735391, -493881435], [13593626088, -1697236416], [38014476164, -1129696794], [33119968072, -1324861272], [-9914247504, 673379442], [-15314638944, 3045180600], [-58931050512, -680278410], [13059872024, 1525716486], [46685050888, -2118581136], [-151899186870, 373960440], [-131629411532, -745958052], [46859226015, 1231157277], [62665660808, 2174733414], [-64818277230, 1105358616], [114227647788, -586336716], [409720276, -1430415180], [45169228038, -1823133690], [54177254528, -3800693610], [-81328278647, -2206460061], [-57432318512, 1250590320], [12254787858, 1110607848], [67698563275, 1580837769], [116198445384, 2988539784], [35774858588, 1189445094], [13697166738, -3289062420], [114688819992, -464284044], [-146912789772, 814986900], [-125542233234, 26116902], [-118655524757, 3452064345], [-30009567308, 2873479860], [165351152270, 231842520], [11191016382, -955500588], [18659504262, 1548703746], [181327188616, 2361827160], [82431512583, 3225686085], [113130358042, 1457324946], [-75064157352, 1719505368], [-1224213142, -1350331668], [-128263025310, 2385381024], [-107024545668, 3713307948], [137250507842, 3746498616], [38582094663, -2020056345], [22001240076, 4668711768], [-117512784160, 1525699854], [90509581981, 1101978135], [68119493967, -1065436281], [-100203705700, -3742748802], [-32568789356, 481051116], [79362079746, -5370853950], [210666266447, -2977664409], [-237978242593, 454212927], [57445454892, -267747066], [249854716153, -2201820381], [11328021882, -1382942484], [-267145267830, 2512891584], [123982664188, 574853328], [-130681438512, 1510380270], [129642109709, 5321306961], [161021116510, -4371479658], [181600027910, -2522328444], [-57095418992, -7134792336], [-46247231758, 4545755424], [-223763443148, 1358483940], [-256708400742, 2798040546], [-70321612510, -2533941900], [-188045765548, -3210106410], [202735092819, 4240805193], [78376574724, -3343239684], [109310985184, -7195322232], [-296263680510, -778761018], [128583595763, -80081757], [192641669563, -3703312359], [-111471142800, 4775351616], [124930187786, -523489176], [325705081578, -2489454828], [24169537378, -6019585146], [-51925452390, 4467907080], [-181019654874, -6605893728], [75730527075, -10923889383], [-344219201064, 80297154], [202094331411, 1196076609], [-178589959714, -8467567416], [379341160149, -395411463], [149500899856, 7002325584], [-562028598159, -486201051], [239331467697, 509391171], [-346084548299, -4118726745], [185620658972, 3846012462], [178739234544, 939088710], [116827072000, -626981040], [232402634490, 6387053274], [-77939018510, -2304266454], [168325707566, 3749851476], [13952614986, 4564266210], [-257621374885, -6267358125], [48564865836, 14069368908], [94619603774, -1121217552], [421576541652, -2260344420], [-42348527076, 13463756082], [335075357382, -4467298500], [107525114986, 3898891962], [320607816660, 1072262772], [314001535106, -2706084072], [412064883573, -8563812201], [-137146389672, -8166334680], [756348069806, -140034636], [130879626810, 7520902200], [-608796601343, -3986675253], [-210112138282, 1840056372], [-482359630977, -1260050337], [100143196396, -7988215788], [-111253913136, 2338590618], [34773461912, -10818843030], [322740031534, 9543305142], [-156197097917, -9120232287], [689245522536, 3285719640], [9057664296, 10218165174], [-517688203078, -3944947860], [-594798012888, 3433858974], [-633521393918, -770520114], [163172285577, -729309645], [-363772596332, -172118520], [-620727446493, -9700758207], [-179920333024, -6310290042], [-41002905510, 3577907016], [321991483226, -12719040768], [-19348107086, 13489922574], [558470077226, 7650878004], [387610882248, 3823334802], [281918021217, 14434138341], [568612468324, -11252203452], [669426997200, 9833445846], [193614998022, 9125867646], [344783865377, -6793663995], [177232169062, 13434222438], [196286874252, 7879160772], [749096609835, 4000376763], [792157557541, -1530896841], [-284963269390, 12861660168], [236562287838, 15921807048], [-136947104630, 8789865174], [-147105480694, 7509463668], [-149777170074, 3126233124], [-69650478450, -1245141630], [671025497079, -9948814947], [-354708816606, -2723227920], [80421461412, -1262158380], [406498521914, -1189380780], [-1079965268634, 2552199732], [150072936960, -8770941648], [-588080667156, 5285492352], [153969338887, -26975570427], [124459977680, 5867836506], [216971498541, -15645991599], [-660701528660, 13282692444], [70194874304, -4419599814], [51529226436, -20564960976], [-922850507495, -2816852085], [-28845156168, -4806252360], [558097920354, -23672194308], [-810862919384, -3470434416], [503825284154, 15662290140], [-1018909071705, 7539860565], [70918786692, 25879745052], [290336091374, -31997217132], [112553697396, 8895540078], [189086333156, -26224276554], [1048060681101, -2795240223], [266339736168, -24120954270], [-418869991640, 17302308912], [412843975290, 30863421288], [1090907677237, 16328514951], [-235408631136, 23075262216], [-464174080676, 7550529588], [-701467599721, 22746712815], [-996940568648, 5682508020], [-2526063414, -3314308410], [-361009836640, -5982664590], [382746206535, 10029612591], [-283413497820, 12233382840], [-721431946655, 23303183787], [-255159489336, 26095931568], [-1432600870738, 7187010012], [-499344545882, -1331020566], [-248679379536, -9348536358], [250004403220, -34093614744], [-116732160708, -23135457870], [-1045718441761, 5147119647], [346675299834, -22019897592], [37814243800, -40266539208], [1647648477972, -5850467226], [-1226787141531, 1712193057], [605861069506, -24767328906], [1694827649870, 4796999928], [-840665406264, 18056947482], [-593511576287, -30044652597], [-752966065635, -4653580545], [599175882998, 30690049500], [375351478512, 1445306814], [1477392394518, -19077708762], [-862468010792, 23925218940], [1698982211642, -4181145696], [-1186212231015, 13919209029], [180891547764, 9142605612], [203701331386, -586752930], [69386805684, -10723604850], [-398437140276, -35927859924], [-21326527224, -2886272802], [1318383676379, 26582050395], [-91280168184, 20677041000], [-2470185083499, -2179537857], [-290488958872, -28646138430], [-775600426293, -19562124861], [1102475464878, 32705962758], [-472616092926, -10669456728], [522302436565, -22239230049], [-1765445182578, -22902392934]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_112_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_112_8_a_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_112_8_a_g(:prec:=2)
    chi := MakeCharacter_112_a();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 8));
    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_112_8_a_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_112_8_a_g( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_112_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,8,sign)));
    Vf := Kernel([<3,R![-744, 70, 1]>],Snew);
    return Vf;
end function;