
// Make newform 225.10.b.e in Magma, downloaded from the LMFDB on 20 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_e();".
// 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_e();".
// 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 := [1, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0], [0, 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_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], [-1, 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, 2], [0, 0], [0, 0], [0, -3840], [86404, 0], [0, 74989], [0, 103811], [-716284, 0], [0, 684960], [-3194402, 0], [-2349000, 0], [0, 9367855], [29282630, 0], [0, 758362], [0, -307876], [0, 2373715], [60616076, 0], [-126745682, 0], [0, -55591326], [175551608, 0], [0, 30616675], [-234431160, 0], [0, 59455194], [-316534326, 0], [0, 121456129], [653802714, 0], [0, -702101248], [0, 919267554], [933452146, 0], [0, -46426691], [0, 869096444], [2497296252, 0], [0, 3981132447], [2855652604, 0], [-9633834218, 0], [-5382921008, 0], [0, 259716883], [0, -4706196322], [0, -4686204840], [0, 6178650999], [-666039820, 0], [5272067030, 0], [29389595264, 0], [0, 7437309191], [0, -2493373707], [-14552696512, 0], [51540674060, 0], [0, -23063606596], [0, 18791636590], [64108194474, 0], [0, 34828920993], [66582489344, 0], [-44165857934, 0], [-83623574172, 0], [0, 43263688059], [0, -48076751008], [-10950513586, 0], [78028730536, 0], [0, 32842017327], [64490563926, 0], [0, -48156632286], [0, 40815411867], [0, -14779122094], [39907073784, 0], [0, -92685514597], [0, -134447311991], [-429099282588, 0], [0, -10129878463], [0, -14639159014], [-70513210798, 0], [0, -32867481459], [581702288616, 0], [0, -208534929348], [0, 38020841617], [179179695740, 0], [0, -397509095508], [-179533434714, 0], [0, -171864863389], [-772080445938, 0], [-260632163546, 0], [-560165889116, 0], [168321099094, 0], [-448383294960, 0], [0, 542424716623], [-460548375760, 0], [0, -6604756194], [-691889120158, 0], [0, -186567364075], [1459396112658, 0], [0, -67106677188], [0, 18226573294], [882279896160, 0], [0, 254919902344], [1521310094372, 0], [-703413058924, 0], [0, 189009176], [1320565194206, 0], [1318532420630, 0], [0, 846057219682], [-1863685505730, 0], [0, 218620842290], [0, 354573115161], [0, 18873577314], [-356270174406, 0], [3879324111476, 0], [0, -2144381413631], [0, -2216226454686], [0, -2550519350467], [-704599188008, 0], [-1738792315174, 0], [0, -289146249196], [0, -1872977267759], [0, 1974373036767], [-3422533154276, 0], [5847549222112, 0], [-2666709413010, 0], [0, -48435779298], [0, -22368397384], [0, 2476927033847], [-5850767266300, 0], [-881006977178, 0], [0, 4332604865415], [0, -4492746058467], [0, -1932384116178], [-7085642139284, 0], [-4693802399998, 0], [-10664465643094, 0], [-8156633225088, 0], [0, 3323854039408], [0, -3539104175683], [2610519049604, 0], [0, -7092057027752], [844355459656, 0], [0, 4526522559023], [6977005641126, 0], [10723313306398, 0], [0, -6878409472773], [0, -6376930235614], [0, -6392232920111], [6037456732090, 0], [-2500427947548, 0], [4210815764586, 0], [0, -104103085144], [0, 4630531985906], [-24276192341790, 0], [-12554573272280, 0], [0, 6815977244553], [0, -8699363419681], [64335460220, 0], [0, 1660599057188], [0, 979160027355], [30225277196926, 0], [0, 4650485422982], [0, -4635853197216], [0, 664338330606], [-2712970973312, 0], [-1321393710640, 0], [1161241765474, 0], [0, 17045706751797], [1602145704530, 0], [0, 16942510637502], [0, 10787869616281], [0, 15312450994984], [-1923648167820, 0], [0, 9194658937571], [0, -23163638219280], [2762515385192, 0], [0, -8725119893337]];
    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_e();".
// 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_e(:prec:=2)
    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_e();".
// 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_e( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_225_b();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,10,sign)));
    Vf := Kernel([<2,R![16, 0, 1]>,<11,R![-86404, 1]>],Snew);
    return Vf;
end function;