
// Make newform 25.10.b.c in Magma, downloaded from the LMFDB on 18 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_25_b();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_25_b_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_25_10_b_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_25_10_b_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 := [16000000, 0, 433104, 0, 1305, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0, 0, 0], [2252704, 0, -17275, 0, -35, 0], [0, 13296008, 0, 71485, 0, 77], [0, -378730064, 0, -908755, 0, -491], [0, -198655408, 0, -1291985, 0, -1177], [-22789928, 0, -171025, 0, -185, 0]];
    Rf_basisdens := [1, 13392, 3348000, 13392000, 13392000, 6696];
    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_b();"
function MakeCharacter_25_b()
    N := 25;
    order := 2;
    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;

// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_25_b_Hecke();"
function MakeCharacter_25_b_Hecke(Kf)
    N := 25;
    order := 2;
    char_gens := [2];
    char_values := [[-1, 0, 0, 0, 0, 0]];
    assert UnitGenerators(DirichletGroup(N)) eq char_gens;
    values := ConvertToHeckeField(char_values : pass_field := true, 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+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, 1, 0, 0, 0], [0, 0, -2, 0, -1, 0], [0, 0, 0, 0, 0, 0], [0, 0, 140, 4, -26, 0], [-18264, 76, 0, 0, 0, 17], [0, 0, 928, -832, 460, 0], [0, 0, -3974, 1521, -168, 0], [-273096, 92, 0, 0, 0, 351], [0, 0, -4764, -11160, 3426, 0], [-728268, 9832, 0, 0, 0, -508], [1423984, 2648, 0, 0, 0, -534], [0, 0, -137524, -15866, -37572, 0], [1952709, 73088, 0, 0, 0, -4904], [0, 0, -34976, 83000, -2732, 0], [0, 0, 894880, 121500, -9384, 0], [0, 0, 208484, -428022, -314856, 0], [-1818504, -193768, 0, 0, 0, -21680], [41881302, -359960, 0, 0, 0, 22980], [0, 0, -6018994, 906256, 322747, 0], [98905212, 786920, 0, 0, 0, 48040], [0, 0, -10112822, 497441, -56864, 0], [102948380, 1255264, 0, 0, 0, -75234], [0, 0, 10762890, 1204200, 165897, 0], [367582761, 1107576, 0, 0, 0, 4176], [0, 0, -29036476, 2021122, 62616, 0], [-152636430, 130872, 0, 0, 0, -455676], [0, 0, -42477008, -6958468, 1867344, 0], [0, 0, 37907538, 11111328, -1573851, 0], [-709555610, 1339848, 0, 0, 0, 244572], [0, 0, 17742938, -9209547, -8818680, 0], [0, 0, 23860004, -19359176, 17044970, 0], [1305768456, 8060136, 0, 0, 0, 478812], [0, 0, 46525842, 2087577, 14711448, 0], [-217171520, -324108, 0, 0, 0, 1765503], [1726577436, 12461464, 0, 0, 0, 941228], [-6445619820, 10080112, 0, 0, 0, -436146], [0, 0, 56289956, -55543958, -7935216, 0], [0, 0, 244074130, -38584096, -9685395, 0], [0, 0, -9901200, 77703948, -47474088, 0], [0, 0, 94011504, -46491696, 31481736, 0], [2579380632, -24980548, 0, 0, 0, -2047853], [-9242649238, 44136960, 0, 0, 0, -2212680], [10766945520, -11068168, 0, 0, 0, -342506], [0, 0, -159886682, 151177247, 47913768, 0], [0, 0, -116030340, 93446550, 115434336, 0], [3064350288, -68520688, 0, 0, 0, -542676], [1950665240, -23293308, 0, 0, 0, -8897361], [0, 0, 739766968, -210253744, 74300676, 0], [0, 0, 246313472, 381345408, -30066780, 0], [24486830948, 1371856, 0, 0, 0, 9806520], [0, 0, -255810876, -77083758, 217386672, 0], [-18641041188, 5827400, 0, 0, 0, 16099324], [22314962097, 107128840, 0, 0, 0, 24092280], [-54679708008, 65595660, 0, 0, 0, -2435505], [0, 0, 1600887228, 11934558, -90358056, 0], [0, 0, 2916195940, -441999936, -24514710, 0], [36627806496, 170542160, 0, 0, 0, -28891568], [7970970144, -129823352, 0, 0, 0, 38171466], [0, 0, -4074348184, -263328620, -150608780, 0], [42742629174, 130189008, 0, 0, 0, 6898536], [0, 0, -5560499606, -117050008, 239457677, 0], [0, 0, -346138644, 1277175006, 172220748, 0], [0, 0, 2283851714, 342225016, 818439449, 0], [-93062527716, -37495632, 0, 0, 0, 41047506], [0, 0, -448561748, 655293350, -788727000, 0], [0, 0, 498680600, -1676795292, 867139032, 0], [-190916620472, 403499324, 0, 0, 0, -8040267], [0, 0, 4640541086, -316983641, -1033441432, 0], [0, 0, -1479449774, -1235517912, -162014979, 0], [63960774798, 145316072, 0, 0, 0, 155188884], [0, 0, -4098299052, 1894955130, -1316615016, 0], [-275225994588, 831680736, 0, 0, 0, 64647918], [0, 0, -10238270872, 825075352, -1085078708, 0], [0, 0, -1128610292, 3034963046, -55573784, 0], [374482948416, -526450252, 0, 0, 0, 123103149], [0, 0, -9432443268, -252230724, -1090108218, 0], [-292144198350, 1260051072, 0, 0, 0, -92667312], [0, 0, 8237737928, 395983924, 1653413216, 0], [-179458726539, -110179464, 0, 0, 0, 259712112], [231343503019, -1235307696, 0, 0, 0, -194568096], [284953177128, 1411619308, 0, 0, 0, 243982163], [-374434352916, -752159792, 0, 0, 0, -213675864], [11496970956, -2485385664, 0, 0, 0, -393757038], [0, 0, -14052814730, -2075566705, -1093785368, 0], [-350735686548, 1096617320, 0, 0, 0, 283231284], [0, 0, 15465128610, -4627010592, 2678596473, 0], [-376069242681, -2631875464, 0, 0, 0, -47997968], [0, 0, -41304850342, -1546016747, 316899104, 0], [955784804820, 1607152512, 0, 0, 0, -93436296], [0, 0, -13930256648, 4126754120, -2588987860, 0], [0, 0, 23260664624, 2400336360, -4680223188, 0], [781709316456, 1996928088, 0, 0, 0, -358826286], [0, 0, -23446976764, -3762763256, -1304110662, 0], [104045278728, 1152146264, 0, 0, 0, -809357012], [-1028092690248, -2518580392, 0, 0, 0, -247446564], [0, 0, 25315046536, -3698742096, -1419621156, 0], [250129146174, -3327944896, 0, 0, 0, 466761664], [-1253906092611, 1181656928, 0, 0, 0, 723304576], [0, 0, -15487323674, 8751591560, 5659344151, 0], [-306683349224, -9234910144, 0, 0, 0, -11819448], [0, 0, 11895927650, -18733732040, -783284359, 0], [0, 0, 24578773968, 14276423448, -1660867716, 0], [0, 0, -135747222456, -1019722464, 211766880, 0], [-1450898674257, 4516315488, 0, 0, 0, -1034860512], [-689033967232, 209945544, 0, 0, 0, -285402852], [0, 0, 22509939902, -5928529337, 9299495400, 0], [0, 0, 41532702270, 6209461656, 14902301703, 0], [0, 0, -85356930038, -11856613131, 6974742168, 0], [2093424815388, -3498650768, 0, 0, 0, 1536460454], [-972420655573, 2863858200, 0, 0, 0, -898256400], [0, 0, 44590128320, -10337431016, 16256544104, 0], [0, 0, 75334948564, 1482555386, -2032153040, 0], [0, 0, -93493887348, 1126769094, -12278523648, 0], [1797844037848, 14750691048, 0, 0, 0, 41470188], [1377785604840, 12052752472, 0, 0, 0, -245077326], [-1158003758910, -5888619888, 0, 0, 0, -56709096], [0, 0, 102555872848, -2622667528, -1260149212, 0], [0, 0, -85322321624, 23653153008, -6879413364, 0], [0, 0, -110953772852, -43380190530, 7166780364, 0], [-4177666005192, -108204340, 0, 0, 0, -1305494219], [-479799843036, 19318948888, 0, 0, 0, 1232979396], [0, 0, 95122688668, -24206755234, -24805671904, 0], [0, 0, 36105722544, 2195379864, 23336647560, 0], [0, 0, -69709932042, -11843102376, 19208637927, 0], [2297233247880, -20306728028, 0, 0, 0, -1849108851], [-5799607809096, 6356502008, 0, 0, 0, 213146236], [764855317620, -18181028752, 0, 0, 0, -3921301368], [-3340518587172, 18944787648, 0, 0, 0, 234437298], [0, 0, 190653662216, 73088226460, 14404371180, 0], [0, 0, -89448701504, 23481757568, 21638262252, 0], [2345331987168, 25560230024, 0, 0, 0, -1917441468], [0, 0, -478621757308, 4974736104, 15128673858, 0], [5639695753284, -17347805672, 0, 0, 0, 2342115876], [0, 0, -325433964256, -38271543464, -10303756216, 0], [-12656441575275, 13217173632, 0, 0, 0, -2310793656], [-419460506189, 9988879320, 0, 0, 0, -958872048], [0, 0, 143454828792, -28134978012, -65434575684, 0], [0, 0, -32863067056, -9438390272, -4311519652, 0], [0, 0, -526992149212, 50282320914, -23998467264, 0], [-2340475934202, -17861294960, 0, 0, 0, 509739656], [-2741639416352, 1236086024, 0, 0, 0, 2998602108], [-4309320341310, 6376613232, 0, 0, 0, 892182744], [0, 0, 208544571064, -86929017496, 33266451276, 0], [0, 0, 49487125822, -110734505352, 25747225575, 0], [3897394622096, -27744359672, 0, 0, 0, -5283614796], [-399548227056, 70017485008, 0, 0, 0, -4949560480], [0, 0, 66213534700, 54843940646, -6107722936, 0], [0, 0, 482799017794, 4015376001, -39073736736, 0], [-9956656234464, 9989166932, 0, 0, 0, 3781960575], [0, 0, 175578365704, -45171915444, 60675810660, 0], [0, 0, 265297251560, -128735948228, -18657136040, 0], [20239026216534, -28569444752, 0, 0, 0, -2780498584], [0, 0, 134286135694, 142664814872, -9583757313, 0], [0, 0, -464367852072, 104875950240, 74287428588, 0], [0, 0, 91541371952, -11591210840, 87037687924, 0], [-1259763778824, -70825848464, 0, 0, 0, 6093913412], [-8533023317544, -39983654680, 0, 0, 0, 7161613242], [-13605809247150, 25257406624, 0, 0, 0, -14043881104], [0, 0, -305569803946, 128984619343, -3437352632, 0], [-4127917905264, 23650767896, 0, 0, 0, -6189939068], [0, 0, 520215431112, -4171602384, 20981493816, 0], [0, 0, -272018779546, -16224921117, -98228052816, 0], [0, 0, -204939194560, 125514904888, -90905925048, 0], [-488642352864, 63152351916, 0, 0, 0, 6829242297], [0, 0, -650755993214, 244786813245, -129978955320, 0], [0, 0, 130698568188, -246420934596, -33235684218, 0], [19501497203300, 57641531952, 0, 0, 0, 7999985634], [0, 0, -228429776680, 15560449300, -172953131024, 0]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_25_b_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_25_10_b_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_25_10_b_c(:prec:=6)
    chi := MakeCharacter_25_b();
    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_b_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_25_10_b_c( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_25_b();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,10,sign)));
    Vf := Kernel([<2,R![189117504, 0, 1062868, 0, 1877, 0, 1]>],Snew);
    return Vf;
end function;