
// Make newform 112.10.i.b in Magma, downloaded from the LMFDB on 06 September 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_112_i();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_112_i_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_112_10_i_b();".
// 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_10_i_b();".
// 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 := [4410000, -2341500, 1245325, -3085, 1116, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0, 0, 0], [962136423000, -2531161500, 1346196325, 41103264, 1206396, -1081], [-48478416000, 25783208800, -20388855, 23105664, -20704, 20739], [-13445117784000, 7150775701200, -25009225165, 6408179136, -5742096, 6283441], [12258477336000, 6436810520600, 11292574565, 5561870848, 24024872, 5096423], [6114081939000, -1632210794525, 9413731140, -1488519232, 4959877, -1283932]];
    Rf_basisdens := [1, 10405809000, 48560442000, 145681326000, 24280221000, 6070055250];
    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_i();"
function MakeCharacter_112_i()
    N := 112;
    order := 3;
    char_gens := [15, 85, 17];
    v := [3, 3, 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;

// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_112_i_Hecke();"
function MakeCharacter_112_i_Hecke( : Kf := false)
    N := 112;
    order := 3;
    char_gens := [15, 85, 17];
    char_values := [[1, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0], [-1, 0, -1, 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 := 10;
    raw_aps := [[0, 0, 0, 0, 0, 0], [0, 0, -78, 1, 0, 0], [-246, 5, -246, 5, 2, -1], [-134, 31, 1423, 1, 3, -8], [0, 0, 2475, -86, 51, -102], [32789, 151, 0, 0, 73, 73], [0, 0, 101526, 2087, 145, -290], [125285, 2136, 125285, 2136, -686, 343], [758040, -6865, 758040, -6865, -312, 156], [-2185725, 14197, 0, 0, 3387, 3387], [0, 0, -2210729, -22330, 729, -1458], [-7425827, -10488, -7425827, -10488, -8004, 4002], [11338167, 33597, 0, 0, -4477, -4477], [20962888, -64524, 0, 0, 14236, 14236], [17543715, 71874, 17543715, 71874, -7862, 3931], [0, 0, 3866913, 490386, -2500, 5000], [0, 0, -4156638, -479983, 97084, -194168], [-53318603, -296344, -53318603, -296344, -45308, 22654], [0, 0, -160205648, -273281, -10814, 21628], [12174294, 687838, 0, 0, -63998, -63998], [0, 0, -83252491, -1624810, 160486, -320972], [-95137612, -1081949, -95137612, -1081949, 309752, -154876], [-382307766, -667874, 0, 0, -74126, -74126], [-300776163, 1084644, -300776163, 1084644, 486272, -243136], [102649241, 6906215, 0, 0, -385911, -385911], [0, 0, 540122718, -4423073, 19575, -39150], [389094854, -3561171, 389094854, -3561171, 1717532, -858766], [151086489, -508668, 151086489, -508668, -126926, 63463], [0, 0, -188472568, -1105879, 673097, -1346194], [-481262631, -7611113, 0, 0, -1169351, -1169351], [1807576978, -5070958, 0, 0, -460722, -460722], [-4724284836, 1411759, -4724284836, 1411759, 2188484, -1094242], [0, 0, -1473019170, 4832335, -4441539, 8883078], [1919976886, 35830978, 0, 0, 126734, 126734], [-780142326, 4481397, -780142326, 4481397, 447698, -223849], [0, 0, 3225787819, -13009286, -6774639, 13549278], [0, 0, -1891786237, -16743276, 2382726, -4765452], [2417270618, 41950605, 2417270618, 41950605, 6871528, -3435764], [7033912059, 14376659, 0, 0, 5813301, 5813301], [3293394507, 80567246, 3293394507, 80567246, -11805720, 5902860], [0, 0, -1196675877, 1536378, 2271335, -4542670], [-1987832890, -30565616, 0, 0, 14188416, 14188416], [4618550691, -32250414, 4618550691, -32250414, -6667654, 3333827], [0, 0, -6380016304, 172316769, -9429905, 18859810], [-15057348801, 12297929, 0, 0, -1841721, -1841721], [0, 0, -6847146623, -151940400, -3561869, 7123738], [6808337350, 289410330, 0, 0, 3731638, 3731638], [-42755774294, 70788234, 0, 0, -6030282, -6030282], [0, 0, -5163338271, -46173696, 1263545, -2527090], [-17847673148, -249830945, -17847673148, -249830945, -1357554, 678777], [16144975440, 148833271, 16144975440, 148833271, -80164054, 40082027], [868804497, -315954543, 0, 0, -9792249, -9792249], [0, 0, 30627440435, -220615692, -12455980, 24911960], [-59979402531, 240333993, 0, 0, -28968657, -28968657], [-56223491274, -16245531, -56223491274, -16245531, 26063926, -13031963], [0, 0, -12759410574, -232473039, 60322522, -120645044], [0, 0, 23394740403, 46217092, 76069470, -152138940], [-35631757618, 622409533, -35631757618, 622409533, -78243388, 39121694], [0, 0, -39347283715, 459950958, 102612176, -205224352], [-12109888539, 255591419, 0, 0, 56669173, 56669173], [0, 0, -2365994873, 987810694, 73510911, -147021822], [62349433422, -256972536, 0, 0, 22671448, 22671448], [138839224168, 127901596, 0, 0, -21779020, -21779020], [0, 0, -88979419848, -529378441, -29048532, 58097064], [-80822243033, 258850510, -80822243033, 258850510, -302207380, 151103690], [-20824782021, -365549010, -20824782021, -365549010, 207558808, -103779404], [46144515560, 1304620515, 46144515560, 1304620515, 183153988, -91576994], [181064049731, 235695073, 0, 0, -146166081, -146166081], [0, 0, -23362731366, 537062409, -227809164, 455618328], [-148907528773, 42861485, 0, 0, 160091139, 160091139], [0, 0, 72764044944, -988083999, -162169281, 324338562], [-15549534603, 1766227372, -15549534603, 1766227372, -339429426, 169714713], [0, 0, 79346033134, -1672443507, -91729854, 183459708], [215830881103, 1707794986, 215830881103, 1707794986, -73185144, 36592572], [-262769509313, 1683431851, 0, 0, -333127651, -333127651], [-40517778423, 1240264760, -40517778423, 1240264760, 354148398, -177074199], [0, 0, 633010853718, 179639575, 69997519, -139995038], [-396938164352, 688585619, -396938164352, 688585619, 801287070, -400643535], [193017383766, 3418927797, 193017383766, 3418927797, -201062522, 100531261], [0, 0, 23446335698, -2181872445, 59658945, -119317890], [195940582656, -1515006108, 0, 0, -40568948, -40568948], [210176994617, -2380049693, 0, 0, -56304003, -56304003], [0, 0, -474242236167, 3087485544, 458050751, -916101502], [878119618205, -729348261, 0, 0, 153245237, 153245237], [-100498125463, -1676195408, -100498125463, -1676195408, 72271318, -36135659], [285922925295, -4245598486, 285922925295, -4245598486, 439405686, -219702843], [-111198338373, -9001778519, 0, 0, -173918025, -173918025], [-117103945817, -924357122, -117103945817, -924357122, -169569156, 84784578], [949195118703, 1849521649, 0, 0, 179377279, 179377279], [-75488212904, 4522123240, 0, 0, -226145736, -226145736], [-548208725118, -1639739291, -548208725118, -1639739291, -504800600, 252400300], [0, 0, 102273041688, 8398725175, -166725776, 333451552], [0, 0, 1015511132326, -1665849435, 421663030, -843326060], [-18677966121, -3597200205, 0, 0, -226914411, -226914411], [1100106679274, -2903950867, 1100106679274, -2903950867, 720103928, -360051964], [1447251726282, 4027950786, 0, 0, 135704542, 135704542], [602703224658, 2767866549, 602703224658, 2767866549, 386427466, -193213733], [0, 0, -609773997117, 3449998884, -669859320, 1339718640], [299819962157, -5186683272, 299819962157, -5186683272, -2743401622, 1371700811], [449070688810, 9169834349, 449070688810, 9169834349, -1563030918, 781515459], [-1618687655075, -10786838191, 0, 0, 681748679, 681748679], [0, 0, -118056413616, 8310091825, 574267617, -1148535234], [0, 0, 2433837944496, -1110422273, -1146585094, 2293170188], [-388763612001, 16773672582, -388763612001, 16773672582, -1107894596, 553947298], [0, 0, 1691920312255, 14265873470, 32062455, -64124910], [0, 0, 2200300290239, -7765401088, 892702688, -1785405376], [3233394274452, -9101129888, 0, 0, -195516912, -195516912], [2505871836408, -8037128169, 2505871836408, -8037128169, 5533353698, -2766676849], [0, 0, 2286364473792, 7090441599, 141946228, -283892456], [3084744824105, 13882264767, 0, 0, 1227922801, 1227922801], [3186550900997, 5824917076, 3186550900997, 5824917076, 1100409174, -550204587], [0, 0, 376400576000, 23758558657, -2165256059, 4330512118], [-1034239949289, 9474426845, 0, 0, 2120877379, 2120877379], [0, 0, -4891711933868, 3590362051, 928621762, -1857243524], [-5360990997098, 8003101134, 0, 0, -1563938222, -1563938222], [0, 0, 93947728875, 27444594860, -3729170540, 7458341080], [-3120735939488, 17807765028, 0, 0, 14996460, 14996460], [0, 0, -909759796152, 6720079047, -2569543356, 5139086712], [2193676133127, -20277912150, 2193676133127, -20277912150, -2542837488, 1271418744], [1273121582154, -30286497890, 0, 0, 2998430706, 2998430706], [0, 0, 4096595052047, 22057566656, 513646126, -1027292252], [495057231419, -37259567415, 0, 0, -1066849609, -1066849609], [-2464487083896, -12825859869, -2464487083896, -12825859869, -9014619706, 4507309853], [0, 0, 370094917113, 3455048760, -3131297003, 6262594006], [5546144333504, 5663887107, 5546144333504, 5663887107, -2670743732, 1335371866], [-678167369886, 1261814788, 0, 0, 516049692, 516049692], [4259945386717, 37284115560, 4259945386717, 37284115560, 1150200284, -575100142], [-7139149011402, 20471755749, -7139149011402, 20471755749, -1645847244, 822923622], [-1769093912438, 62410901410, 0, 0, -6200009218, -6200009218], [-3300795099401, 20958479690, -3300795099401, 20958479690, -2781934656, 1390967328], [0, 0, 2435928426013, -17965035268, 2297128797, -4594257594], [-665521890990, 5559536250, 0, 0, 5334704198, 5334704198], [-7397730605305, -7467297434, -7397730605305, -7467297434, -3945196734, 1972598367], [-1358709437617, 76335491497, 0, 0, -5773368761, -5773368761], [3745721822766, -29001570491, 3745721822766, -29001570491, 16061287390, -8030643695], [-2149090905649, 2876975933, 0, 0, -2417148285, -2417148285], [0, 0, -8848907380206, 41055113683, 2051071795, -4102143590], [0, 0, -1860749952482, -25951991827, -6552489412, 13104978824], [478596039111, -89198208711, 0, 0, -1210003113, -1210003113], [0, 0, 5158521465045, 37896781558, 6532237622, -13064475244], [4475511550780, 13258516840, 0, 0, 3402745064, 3402745064], [-3897291060264, 86056042915, -3897291060264, 86056042915, 6600306742, -3300153371], [0, 0, 11864071806784, -14790415745, 6938593956, -13877187912], [773615902956, 56516207592, 0, 0, 1069530184, 1069530184], [0, 0, 8535098532740, -82289367643, -9472717563, 18945435126], [1621912265952, -14929844696, 0, 0, -4446522888, -4446522888], [1069817833397, 27044692527, 0, 0, -9768285519, -9768285519], [0, 0, -5999619234915, 64849140030, 3950306006, -7900612012], [5662045781111, -101044937454, 5662045781111, -101044937454, -18837841274, 9418920637], [2297639464404, 141247430995, 2297639464404, 141247430995, -1307676760, 653838380], [-8769381680162, 15179949649, -8769381680162, 15179949649, 1778860194, -889430097], [-968174719590, -147172717752, 0, 0, 10666048264, 10666048264], [11938871680618, -11904760674, 0, 0, 6153386962, 6153386962], [-450424205169, 11476549974, -450424205169, 11476549974, -29457447222, 14728723611], [0, 0, -4988071434386, -11303660707, 5473695608, -10947391216], [-1019610489240, -147101165448, 0, 0, 9197438760, 9197438760], [-7220860736311, 13546114160, -7220860736311, 13546114160, 29994143414, -14997071707], [-9587173419465, 104408066262, -9587173419465, 104408066262, -23778198508, 11889099254], [6895195568414, 204840878196, 0, 0, 11927378124, 11927378124], [0, 0, -17188291966419, 121087695934, 8277605284, -16555210568], [-18013047394968, -12138778709, -18013047394968, -12138778709, 11577196668, -5788598334], [-3196966377351, -104772435985, 0, 0, 12785091137, 12785091137], [-3069563352494, 103010227866, 0, 0, -5082396634, -5082396634], [17251922240088, 146460406995, 17251922240088, 146460406995, 9381827044, -4690913522], [0, 0, 18036448822632, -188849774535, -8935083281, 17870166562], [0, 0, 29776596752463, -44657722338, -1807244755, 3614489510], [0, 0, 8213203936084, -70965286221, -19404664492, 38809328984], [0, 0, 24382961542655, 57025246512, -834226698, 1668453396]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_112_i_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_112_10_i_b();".
// 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_10_i_b(:prec:=6)
    chi := MakeCharacter_112_i();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 10));
    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_112_10_i_b();".
// 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_10_i_b( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_112_i();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,10,sign)));
    Vf := Kernel([<3,R![8143799049, 894217887, 77161662, 2489283, 64198, -233, 1]>],Snew);
    return Vf;
end function;