
// Make newform 225.10.b.g in Magma, downloaded from the LMFDB on 25 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_225_b();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_225_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_225_10_b_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_225_10_b_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 := [1397124, 0, 2365, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0], [0, -2365, 0, -1], [0, 1183, 0, 1], [1183, 0, 1, 0]];
    Rf_basisdens := [1, 1182, 591, 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_225_b();"
function MakeCharacter_225_b()
    N := 225;
    order := 2;
    char_gens := [101, 127];
    v := [2, 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_225_b_Hecke();"
function MakeCharacter_225_b_Hecke(Kf)
    N := 225;
    order := 2;
    char_gens := [101, 127];
    char_values := [[1, 0, 0, 0], [-1, 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, -1, -5, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, -56, -2982, 0], [-16768, 0, 0, -1952], [0, 1384, -35573, 0], [0, -2200, -96839, 0], [201164, 0, 0, 968], [0, -64968, 39684, 0], [-31078, 0, 0, -12416], [-2475696, 0, 0, -75736], [0, -174696, 1299733, 0], [-7340714, 0, 0, 470096], [0, -152384, -6975326, 0], [0, -431368, -24099452, 0], [0, 929872, -15843931, 0], [93124864, 0, 0, 1613408], [75911686, 0, 0, 2256688], [0, -7444160, 6537054, 0], [110604928, 0, 0, 7061120], [0, 6480208, 9900631, 0], [467102400, 0, 0, -1798040], [0, 3161088, 52550310, 0], [107605986, 0, 0, 9306192], [0, 44039040, 107793409, 0], [-169361298, 0, 0, -10351392], [0, 23903736, 447287654, 0], [0, -39862608, -191141202, 0], [1468933354, 0, 0, 8752128], [0, -31516232, -76956565, 0], [0, 61762280, -1521534346, 0], [1784192784, 0, 0, -66294288], [0, -7286856, -2635901295, 0], [284023996, 0, 0, -109011528], [983447258, 0, 0, 95881216], [-7075840688, 0, 0, 41782120], [0, 83291496, 2230778605, 0], [0, -369358080, -663300382, 0], [0, -118197624, 5462687292, 0], [0, -276959232, 6327161625, 0], [-14254296920, 0, 0, -88867600], [-4702062226, 0, 0, -249453696], [-5783828168, 0, 0, 338177888], [0, -13201488, 3228960275, 0], [0, 414752688, -1072839141, 0], [18211706672, 0, 0, 357168344], [337416284, 0, 0, 1095702984], [0, -379867896, 8942228882, 0], [0, 231603136, 9769077542, 0], [-12227408454, 0, 0, 1223574352], [0, 1014300264, 19109507091, 0], [-22046425784, 0, 0, -1162136848], [56292235138, 0, 0, 461796352], [-23309039832, 0, 0, 2290507440], [0, -11592888, -24986612907, 0], [0, -1335183640, -5313271988, 0], [-88318635494, 0, 0, 497468672], [44925376408, 0, 0, 2931878152], [0, 2810356072, 34651261581, 0], [8725436190, 0, 0, -1732391376], [0, -2110595296, -35200689858, 0], [0, 2057660880, -20905917723, 0], [0, 2658536048, 34842840242, 0], [1760500752, 0, 0, -2262689712], [0, 1153824720, 43566529943, 0], [0, 4586012752, -29720978977, 0], [41166061932, 0, 0, -1068554680], [0, 4683425072, 7558291541, 0], [0, -8361924880, -64000370174, 0], [-185720263462, 0, 0, 3311404976], [0, 309268296, -2392105137, 0], [330474730824, 0, 0, -8531803872], [0, 6863128312, -118308811914, 0], [0, 8406882616, 195269502679, 0], [-33106482100, 0, 0, -11812472440], [0, 38429640, 110377302972, 0], [-550051781286, 0, 0, 5105403648], [0, 10832804408, 119552080217, 0], [-683654414586, 0, 0, -328887168], [-433433818394, 0, 0, -13684450368], [71167189136, 0, 0, 6879525232], [-32721826490, 0, 0, 22837566256], [-465795901344, 0, 0, 11476167456], [0, -23402229680, -14462935637, 0], [-92654644720, 0, 0, 26713363640], [0, 15413236416, -372423072282, 0], [693320843098, 0, 0, -17575974304], [0, 10914413504, 253910933453, 0], [532539491358, 0, 0, 5943751200], [0, 23694583736, 127766786214, 0], [0, 39043802992, 85623119738, 0], [1249831300200, 0, 0, 6046064640], [0, -12129453960, -946216563626, 0], [1140770559784, 0, 0, 17790773792], [1318470673244, 0, 0, 8935086488], [0, -29390410264, -38812781672, 0], [-898219441766, 0, 0, 17415237248], [1515694418446, 0, 0, 15262434656], [0, 24497892976, 384825602014, 0], [-376489825386, 0, 0, -26216020096], [0, 28201111904, 226770983618, 0], [0, -22553689440, -802073024169, 0], [0, -13676285712, -949524548670, 0], [-400983698574, 0, 0, -18494443488], [567956239868, 0, 0, 43777346472], [0, -6740865120, 1226224284529, 0], [0, -57913934448, -1819754048322, 0], [0, -44257826536, 2141444128531, 0], [-2610683444152, 0, 0, -36698388704], [3455097958058, 0, 0, -37971257088], [0, -46839190600, -2080631919646, 0], [0, -15889158968, -1226076593285, 0], [0, -111630031656, -1244642928075, 0], [2741428842316, 0, 0, 2037351672], [438677555032, 0, 0, -67802338280], [4811452722126, 0, 0, 65695825776], [0, 115548111776, 311716727634, 0], [0, -101783796760, 381427703296, 0], [0, -56123858560, -2244752350823, 0], [-4330376500880, 0, 0, -2931333280], [-1434045179138, 0, 0, 69197394640], [0, 71792112368, -2594976841509, 0], [0, 70625923968, 6295039059, 0], [0, -56987349840, 571379597442, 0], [-2601958364012, 0, 0, -181350055448], [2572658824774, 0, 0, -32384748448], [258444076394, 0, 0, 204881394608], [-8165341421232, 0, 0, 122189713296], [0, -176011281384, -2401607145530, 0], [0, 146029534776, 2846468825999, 0], [9086955841196, 0, 0, 142838447672], [0, 197755768024, 2186220645416, 0], [9239917815328, 0, 0, -156315305048], [0, -135412753144, -583628271235, 0], [-913451353650, 0, 0, -452832530016], [2355148096222, 0, 0, 147918559584], [0, 60640464240, -3205213941843, 0], [0, -340403226352, -4333577609578, 0], [0, -236022339008, 5035093471583, 0], [11812987869530, 0, 0, -69481838960], [11086919764932, 0, 0, 266826588680], [13958030488110, 0, 0, 36346010784], [0, -140385977448, -1095078583030, 0], [0, -6578790880, -143106963254, 0], [16575779996730, 0, 0, -64647207680], [-7137047712040, 0, 0, -407989324160], [0, -308030958040, 533493143523, 0], [0, 263582826152, -8875579967867, 0], [-14854311528340, 0, 0, 148711312040], [0, -216745209736, -2375544060464, 0], [0, -857579906456, 1894400842413, 0], [3794548304390, 0, 0, 236858567824], [0, -357332712864, 3347164632434, 0], [0, -235713894168, 7138234572108, 0], [0, 163782947248, -9129494486658, 0], [-1396028289472, 0, 0, 227633255440], [2144373941000, 0, 0, -136964454760], [16103210214266, 0, 0, 381948719872], [0, 796069693312, 5296553367981, 0], [28081406835886, 0, 0, -97093820704], [0, 242310797904, 4823507377830, 0], [0, -87299503544, 5862033970223, 0], [0, 555061904280, 5203432274194, 0], [5282930067096, 0, 0, 480902978256], [0, 391423723880, -11021417369519, 0], [0, -1291299938088, -6546527959896, 0], [29668453427432, 0, 0, -400763981160], [0, 676079548456, 15052856826105, 0]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_225_b_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_225_10_b_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_225_10_b_g(:prec:=4)
    chi := MakeCharacter_225_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_225_10_b_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_225_10_b_g( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_225_b();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,10,sign)));
    Vf := Kernel([<2,R![1192464, 0, 2545, 0, 1]>,<11,R![-4189882368, 35488, 1]>],Snew);
    return Vf;
end function;