
// Make newform 112.10.a.c in Magma, downloaded from the LMFDB on 23 April 2024.
// 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_10_a_c();".
// 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_a_c();".
// 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 := [-576, -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)
    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+1)]];
    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], [7, 5], [-1365, -21], [-2401, 0], [-22470, 1050], [50141, 225], [-435204, 1590], [-254387, 13455], [-39900, 7140], [1003164, 119490], [-1094366, -39330], [-10361788, 143010], [9508296, 517890], [-2096858, 345870], [37271262, -200430], [-1619874, -464520], [66821181, 1119735], [113900843, -866205], [-166465136, 1654380], [83992860, -6323940], [-22342138, 6043140], [-134821388, 2213820], [91552881, 6075435], [395828874, 6785040], [-2084740, -13989690], [-431689125, 8773275], [-197920226, -24992550], [33054228, 9401280], [136383752, -6929370], [-38538564, -11295690], [-2024056424, -11806200], [-3450295443, 20710335], [1475534958, 95981340], [-2080374149, -3585015], [1541892162, -97417740], [3226468192, 62130600], [3848138021, 197659305], [-4143893834, -66492090], [11410340802, -103900170], [10528747593, 180291285], [-13708148868, -33941040], [-12045985315, -110424375], [-26537698284, -9917460], [-10602989656, 277133850], [14407677882, 197811180], [12771295810, -220997610], [-12846821816, 192380580], [51755175052, 407098260], [-15001338723, -1177552785], [-24454653559, -232186995], [21133781874, -1231830600], [11963394636, 1556937060], [-8326745980, 2969550], [-48778240077, -1015790175], [-10848046902, 133671480], [72880788540, 994354620], [77806476153, -39656955], [-20035122464, -1064447280], [126626784230, -842995440], [-85379809206, -308244720], [35761615477, 207930015], [-26171668761, 333473295], [-99816370787, 2847550815], [-133045436496, -1156257000], [185109082760, -1110817710], [6858494466, -3281457060], [-45316947818, 238057470], [129346407344, 1436462370], [-51100938786, 4641966630], [-216291521383, 585350325], [194036549658, 82458120], [-454466042136, 412354320], [206756516932, -5560525620], [-634800362686, -1056445740], [-533299138454, 578556090], [-56801936226, -3025428990], [64241117628, 10158475530], [-118128065335, 5101893045], [41894126112, 11353006770], [-85020800956, -120919050], [586806008019, 5162690265], [-325131099730, 6436001880], [34161716556, 9326587620], [-105113100904, 16109569530], [-473445314048, 19855366920], [909820248312, -5336804340], [129666642858, -6630359400], [925759316000, 8046067050], [370498534917, 16568205945], [-411492250712, 9377633160], [-391306544559, 5710359435], [544940799186, 29210333550], [-38837560124, 41629924980], [-245711700768, 11232986100], [-725985460136, -20577041100], [-1253744065980, -7500564540], [324786741321, 17623044645], [1577367201816, 27827742930], [-2401109946767, -2848500045], [2429663341538, -27319656420], [-578657970038, -29487793230], [587483809146, -22007134380], [-240385551105, -31343043555], [-2360053291584, -36936845190], [-1781818891022, -49172682510], [586178058242, 76756752000], [-1855926813993, -72211274835], [1806712108614, -43240087860], [-2940404729376, -12032145720], [-1929185494054, -964416960], [-680703548672, 39289883040], [-3321712237948, 58730718690], [405119296056, 99424271730], [-57313169291, 99081531855], [-792267490964, 131826589020], [-497882060328, -49097278230], [6822399941791, 13740549165], [3736521372402, 2128621350], [-21193458432, -1834348530], [-1935921449886, 84129799530], [-3990962989825, 46458995175], [1864760876606, 138701821860], [-1232028158907, -34428848175], [-3995442884448, -131495412300], [-5146097300939, -56410539705], [1480350630168, 4487420070], [2751197768444, -103273955190], [4959941412258, -72718545810], [4858088769646, -90825667110], [-2864313815965, -49157155125], [5456015451286, -128961820890], [1907212578576, -16380842520], [-3291091757300, 102330419940], [6344459915852, -164463516630], [2168782238532, 294050862870], [-12107564888776, -24660670230], [4901789848599, -260104412865], [-6003272543303, 56100888675], [1390870883073, -96965020275], [8414932536216, -103045366830], [-5273579972927, -104517176445], [-5283931768194, 239967244440], [-11576316716840, -272703024720], [19605053452356, -106276080960], [4386080800451, -315644378805], [20469191697318, 65479370610], [-8972848440871, -161995558995], [-16486004939628, 101390502630], [-13258009528589, -54650417535], [-6091468024356, -156333733500], [-6087402347812, 197668927890], [12412674580446, -64671161580], [9731119426540, -411297253920], [9763881073926, 334929670050], [-28538794004204, -201334442400], [7101555397392, -353180304960], [-21995066252936, -85155552720], [-23930309206524, -252630881730], [-890316765898, 592082922420], [19092923103891, -556014545685], [21238247221626, 47669929650], [9129249372546, -111823374600], [-27227446929092, -182050196580], [-16405351263819, 591751795695], [10098364564614, -306139850100], [-5362426010634, 177060077970], [-3612818005544, -213720305400], [-37503682296577, 436537727415], [-43158296765464, -267862170870], [-20574595886271, 24319364325], [10235249140224, 171342007620], [16517177754581, -208826036775], [562700137020, -218664462660], [21256475405906, 3543475320], [8558574405514, 576668996550], [31209832121790, -140248466340], [19407935301676, -147123453960], [37467607791060, 592532653650], [5550136154836, 343694682180], [26245995863843, -597125115045], [24430944959692, -787140689580], [32587690332855, -800391911595], [34900650806888, 1074506568030], [17921882794914, 1008123856680], [36517129984752, 708338000160], [-30457463336139, -1150335214575], [-20865484198114, 783550524960], [37471909052221, -290529205425], [-88117892012050, -79281723780], [-60734534298858, 1116038832330], [63586758031202, 619487100000], [-20259986384760, 510179498220], [5974525447900, -550434452400], [10374943084485, -485003579895], [-6180824297628, -1175901243720], [-39363286328394, 1864991344500], [-89512967705056, -433346087790], [23097916847036, -2310655886910], [-108349029540066, 126113028900], [-21044789624376, 1964853374640], [87166782973110, -1194721725960], [-58018481477642, 188813010330], [-102010625106145, 157095003015], [30760197225086, 1690137491940], [46403818828857, 155153728395], [-92022210614061, -123143706885], [-93595388564090, 890119739610], [23079097081950, 1880356888830], [-28849386813420, -2525987835210], [48940310477023, -2057076019035], [28232133590936, 617885134650], [-4272923644773, 79898817675], [-54538013553248, -436784526360], [44595784179093, -1561311033345], [52562469029784, -1393508897280], [-77431757575228, -977565080250], [-75988226699912, -2322108953640], [1680784303632, 2585162353890], [-157453299900576, -1361836572600], [43770337994640, 1438510325070], [-78406274554792, -3110472446130], [206095699511800, -1462843779120], [-4175108539062, 1098403769400], [81862864023724, -2523408941340], [-67134877821795, -1033343868225], [125758710167816, 2635838959950], [-74697079159038, -819914132520], [28590757765236, 3070482674700], [163948130623564, 2079368337420], [-108988346101182, 113498639730], [53678061624800, -1764530406450], [-16606413120773, -1564968415455], [2281315184368, -5878422955440], [-42352370463966, 2997271002600], [-71556219866999, 4540302119835], [-48765698225160, -469252728840], [-107828896940548, 5176072777590], [-126719526465990, -2218261722180], [-44926561028568, -5245967237700], [-52064675791380, -6864603297300], [-167635515901398, 2164526560770], [-68361324243527, 977076187515], [15253971164908, -1629455336820], [-20801544607114, -4195963747080], [35420910694302, -1734779549580], [-188472269778198, -2293439306850], [-173229978953864, -2247008117400], [146409084152709, 714608812935], [-98235385367330, 294191644950], [150818147139240, 123538280040], [156479651458562, 1490385341340], [-44205188818014, 3227374858080], [-371551628607708, 2200907901780], [68964834591506, -181568288520], [-132576283064757, -1505702031405], [-39525637759740, -5062985399640], [123530112208064, -4805577009450], [-133419257930945, 2537592585525], [-278560912442085, -631572530085], [-87061734674404, 2580857910270], [103843625319052, 4995496032660], [-266281090500858, -2126995573290], [61002643403387, 2282189165595], [102089527969331, -298321712325], [-154126447049652, -3354159089610], [-218194415485445, 661703262705], [-529125488825166, 2427301040220], [-236971843739526, -8803511904000], [-131129820522956, 3988677283920], [390723179821104, 2677844645910], [233709215636729, -5774799358395], [291412474513594, 2206116427410], [224426157413654, -7279445354940], [-83556843994352, -8945746624080], [-244860434842030, -8849047574880], [324515983032556, -2894698646820], [122186016926718, -7475662032090], [110882860904090, 11691380880900], [-16251791084044, 7086921418710], [-744162215269767, -1590354180765], [-156229872935556, 11205900247140], [672121192841440, -16713554760], [-273159620221362, -4652758443750], [-552307449394897, 7336425028455], [103212873432025, -446644807605], [-216838943760528, -4428092373600], [-7800677052118, 12867164873640], [-45836913971022, 7336989714180], [-240395082792914, -8480741831910], [664004757014298, -3386574643320], [-207346817084178, 8231200249440], [-603345452452407, -1377068025165], [224950650610584, -18600324776670], [267897415920225, 11560690952835], [87162133303622, -5540215426200], [-477598181253711, 7166152125405], [-450184636563536, -8607452144400], [584693291237685, -11498699558415], [-72756264470085, 12409831989465], [857723338470607, -2256260721795], [95999148836444, 15792060879630], [117694843288272, -14999789587650], [-538489661945024, 1705009083120], [-168404670653682, 10944580746750], [-55575029741690, -6536117480130], [-172451830029010, -12517794889740], [108672292355502, 24913158542790], [-375079257253393, -1909913902065], [-176874357678060, -4180282855980], [674041351050038, -1314232814160], [416219094432876, -17372774769660], [-924974842995540, -8985168807510], [-1083040050429498, -11501733875940], [349245725310718, 3721478411070], [479311672967820, -11403229913460], [303421295199890, 4774262051160], [115469522882175, 25953494669085], [496115819060712, -6997776546600], [184266608884526, -19769743308780], [-285093156842790, -6520572610440], [445342058655235, -6130231465095], [586500194397350, 23096661707700], [398006807404563, 3507532345755], [-598748671794476, -23100576255540], [294468429140304, 33781394010], [198363421065656, 12678514084890], [9732390972298, 17937330270930], [-281283976932959, 17783069113395], [252179854207608, -11777644461240], [-454302816934104, -16545278707650], [1104929123907890, -11322075374820], [977588762126952, 21469355117910], [1047653739174238, -19194722757630], [1163316676576971, 2641887071745], [-467095688983172, 15034348700280], [-869566846498623, -12139604026605], [971729643979712, -1178710587810], [1073709886620378, -16664793762360], [-451097380640662, 11213956846080], [1317663153402190, -3904330263390], [-125944459479502, 17826204063780], [747831496598088, -38176398667470], [1248380596533, -34283525621055], [410370650265724, 36682752835260], [-992104018905360, 1047299110830], [905274846866322, 12912328486890], [2152819762642325, -3802744360575], [375061794690850, -41528073336750], [1963754516556084, -14520326915940], [59352840226071, 7956849372015], [764137617939871, 3975320903085], [-741520825126270, -6221936763000], [117154858518534, -10781607341400], [-1586191600021322, -13260247666470], [1445395485169874, 9303183261540], [1506619999036278, -10096119694620], [-853385074188654, 26569261766190], [787389004829133, 18110166066615], [299360737323138, 23238837066480], [1233968993830812, -8596253590260], [428926722564962, 38659485920580], [1531996286685270, -31236859701900], [-924809501882592, 24040687102320], [1841568655674180, 10509490162080], [-575269383729467, 56490252981255], [447656573936720, -7575794297190], [-48898611918471, -65625922256475], [948394028120596, -20074027797180], [-116056838525632, 53426597247450], [-192291771142356, -10608311234640], [252437346030499, 65244765855105], [454438874185800, -38276823210360], [210368629713930, 39381102046860], [1735289883842200, -19037971478160], [-1070104672441582, 16605046333260], [-764093576990667, -40448498945625], [-2410799534202852, 35427426041700], [-296217196603090, 1549660783860], [-186600701473452, -29857191919170], [-2185053418653532, -42794470249290], [-603886051185879, -25341901241595], [3786966376873896, 9320368876770], [2553629566375384, 29609941147920], [-274300566184902, 71796187946280], [-4434320579829329, -933116736195], [852218291858976, 12422461371960], [-2142626436251228, -10177186238100], [-170777181100813, -8499341505645], [-1386451862005880, -64607645656260], [-996580049692458, -17464292815350], [-490591859289568, 83087181477090], [-648730791723693, 78355126191555], [1335463621664940, 45618752935560], [911416632418915, -56815816390695], [3124806841459416, 8254981007280], [1899284421005246, 11360131802460], [-3103516326866438, -39642331122810], [-1131161734082352, 61785544979130], [603083041833724, 19124594639640], [-5654558339611764, -1381748911830], [2006100010049555, 39379022107515], [971476885310202, 24667227729480], [-44498580614552, 62028904439880], [3985549600209492, 19862469265830], [-1799374922338455, 69288084902445], [3014470630154158, -29466614825910], [14534135746742, 2965001117400], [-1856844639576120, 47166398955690], [19887031422979, -70422728597415], [-1085838615573369, 89737425941445], [-433797526715434, 54858344113980], [-1890605521782768, 32084832281670], [-1196784167698350, -28066804136910], [-4729781602368344, 38286231206580], [775872416024138, -65232545424480], [369853268005557, -1638696930135], [1461377482734924, -48863660070540], [1857041313963766, 85298191000290], [4038911070049044, -38869265458530], [-1816737314348460, -52833975312300], [-4919828679119352, -34790543581290], [-4072087030219369, 45397286276895], [1875888054521976, 85131004952280], [2225078286546759, -41190382512435], [5634691116263048, 17736519483810], [-692600107383681, -37241386594785], [1045766917025706, 94717610025570], [4366629538001586, -46406645795160], [5112629863236007, 51925239303885], [358651112524194, -139378182212730]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_112_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


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