
// Make newform 25.10.a.d in Magma, downloaded from the LMFDB on 25 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_25_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_25_10_a_d();".
// 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_25_10_a_d();".
// 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 := [4000, -652, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0], [-436, 3, 1], [-445, 33, 1]];
    Rf_basisdens := [1, 12, 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_25_a();"
function MakeCharacter_25_a()
    N := 25;
    order := 1;
    char_gens := [2];
    v := [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_25_a_Hecke(Kf)
    return MakeCharacter_25_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 := [[11, 1, 0], [30, 2, -1], [0, 0, 0], [1744, 132, 26], [-18298, 370, 195], [71808, -2592, 460], [111605, -7016, 168], [273798, -20934, -2549], [1174476, -17556, 3426], [727252, 119984, -6276], [1425052, -56940, -1090], [-3447538, -105792, 37572], [1962517, -961840, 38760], [-8142408, 200976, -2732], [22283108, 651880, 9384], [44311790, -1064528, -314856], [1775144, -399752, 345528], [41835342, 4664400, -199100], [29717410, -7831506, -322747], [98809132, -4103800, 1123200], [60459531, 11107704, -56864], [-103098848, 15961884, -728626], [-243751566, -8354490, 165897], [-367574409, 9709272, -1136808], [-110724742, -33078720, -62616], [-151725078, -29429760, -3058860], [1169030540, 28560072, 1867344], [1548858894, 15684882, 1573851], [710044754, -3104832, -3051852], [823960463, -36162032, -8818680], [-1595175324, 62578356, -17044970], [1304810832, -42854880, 11411820], [844496277, 42350688, -14711448], [220702526, -112378158, -12034413], [-1724694980, 53797040, -19050060], [-6444747528, -117762060, 7027090], [-5165319886, 167377872, 7935216], [1366829618, -321242322, -9685395], [7514800740, -165309096, 47474088], [3502664256, -186994896, 31481736], [-2583476338, -97858046, 39315519], [-9238223878, -534418800, 28648200], [10767630532, 78378140, -13465710], [-14195813083, 462241176, 47913768], [9272135598, -302923440, -115434336], [-3065435640, -583040280, 72319420], [1968459962, -341996610, -85574835], [12924293576, -1160274456, 74300676], [41747490976, -516377344, 30066780], [-24467217908, -595657536, -70017496], [9014453334, 101643360, 217386672], [18673239836, -945711488, -118522668], [22266777537, 529561800, 275774800], [-54674836998, -741362250, 48547125], [18116154534, 1577018112, 90358056], [13643955748, -3800195812, -24514710], [-36685589632, 3326156656, 31698816], [7894627212, 3535041060, 137376910], [-73145548124, -3547690944, 150608780], [42728832102, -743991840, 178478760], [71305985074, 5326399590, 239457677], [-129119266518, 2900488656, 172220748], [66919061094, 1599401682, -818439449], [-93144622728, 2882406060, 249836910], [-56251219822, 1759148448, -788727000], [-160287316220, 3852271184, -867139032], [-190900539938, -4129990470, 347217455], [10129105467, 5274508368, 1033441432], [-144828412282, 991586050, 162014979], [-63650397030, -8313866160, -1231638260], [-139566168690, 7888209312, -1316615016], [275355290424, 3476955708, -1284216162], [-36318848000, -11888421576, 1085078708], [-299741890254, 7198536384, -55573784], [-374236742118, -12370447506, -335271791], [138457506264, 8927981820, -1090108218], [291958863726, 17085832992, -611379888], [144628767108, 7445770080, -1653413216], [-179978150763, 17093766120, 1707805320], [-231732639211, 945452688, 2597284368], [-284465212802, -2422320334, -3119494449], [-374007001188, -6478465440, -2247890840], [12284485032, -2044465380, -5241684930], [377114615589, 9901681320, -1093785368], [351302149116, -7690783728, -3079236308], [285036904482, -24719149794, 2678596473], [375973246745, -20711005160, 2967861240], [-611057885871, -38212816848, -316899104], [955971677412, -20257422960, 953098440], [-251110948352, 22183764888, -2588987860], [465660170440, 18459991904, 4680223188], [-782426969028, 40219582524, 514855914], [-655914245068, -15921450252, 1304110662], [105663992752, -60549451120, -4513352820], [1027597797120, -7325536560, 4250706340], [113861893240, -32712530728, -1419621156], [-249195622846, -58890727232, 60613248], [-1255352701763, 34209971360, 6244788960], [-776328123474, 32990506794, 5659344151], [-306659710328, 82381385520, -9317646280], [-1804985470842, 49363391730, 783284359], [1727551187064, -3974072928, 1660867716], [1596556725768, 133707777528, 211766880], [1448828953233, 104808191136, 2727708096], [-688463161528, -19584486720, -1787874420], [-288633219589, 34366998576, -9299495400], [1215652689162, 29113778958, -14902301703], [2104359445567, 61643703776, 6974742168], [-2090351894480, -126748405060, -7256572410], [-970624142773, -81466620600, -3423936600], [-444211630296, 65264990352, -16256544104], [-965130414642, -72369837792, -2032153040], [-1010603733330, -95747425536, 12278523648], [-1797761097472, 130185067776, -15040982364], [1378275759492, -123669566460, 10337211190], [-1157890340718, 49481615040, -6285583560], [-847898652248, -107801207904, -1260149212], [1442693915048, -132628627640, 6879413364], [5631316883050, 24193391792, 7166780364], [4175055016754, 79966802518, 9246663873], [-482265801828, -97425817440, 27949804660], [1645391588986, -143536199136, -24805671904], [809980254456, 31714962816, -23336647560], [1832979693774, 46023727290, 19208637927], [2300931465582, 68115803490, -33250489985], [-5800034101568, -43993451440, 7848525660], [-772697920356, 79491426048, 45630138328], [3340987461768, 155967976356, -20585848734], [9740512579196, 44477209296, -14404371180], [-1607791410976, 136412216640, 21638262252], [-2349166870104, 348923441232, -12138139748], [4631412120812, 488571229516, 15128673858], [5635011521532, 301341435360, -952994540], [-7604172633336, -248890877328, 10303756216], [-12651819987963, -262223769360, -2958381960], [417542762093, 149349980856, -3276774984], [1843376223996, -199724784816, -65434575684], [-1368140092848, -13986286512, 4311519652], [-809822325302, -627556791040, 23998467264], [2341495413514, -192355513312, 14293117368], [-2747636620568, 174788556480, 22226300780], [-4311104706798, -2074188960, 12621892440], [6393566910176, -382402606056, 33266451276], [-10655317862614, 270956136526, -25747225575], [-3907961851688, 77884880304, 64729663244], [389649106096, 937030114832, -35370561648], [-6328412984750, 43474346592, -6107722936], [5411783029949, 474768265792, 39073736736], [9964220155614, -144579053262, -36462890957], [2235938782708, -265922196592, 60675810660], [-10490789988644, 522769148016, 18657136040], [20244587213702, 84734090560, -48032934840], [-16094953365946, 151043494050, -9583757313], [6288475930632, -674119752552, -74287428588], [509361878344, 114723793632, -87037687924], [-1271951605648, 1015255267720, -28168454580], [8547346544028, -803872913124, -10147638014], [13577721484942, 1098037288064, 73049761104], [9896649127867, -563539042632, 3437352632], [-4115538027128, -596633133280, -19678805580], [5460546647208, 528558635880, -20981493816], [5449197872585, 239568937312, -98228052816], [9946456662920, -455969004336, 90905925048], [-502300837458, -144958144830, 110957047995], [17014894196321, -1140329619704, 129978955320], [24209557487064, -623540437380, -33235684218], [19485497232032, -22774678260, 113641431390], [-2293626313772, -259550675280, 172953131024]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_25_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_25_10_a_d();".
// 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_25_10_a_d(:prec:=3)
    chi := MakeCharacter_25_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(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_25_10_a_d();".
// 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_25_10_a_d( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_25_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,10,sign)));
    Vf := Kernel([<2,R![13752, -394, -33, 1]>],Snew);
    return Vf;
end function;