
// Make newform 225.4.e.a in Magma, downloaded from the LMFDB on 25 September 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_225_e();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_225_e_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_4_e_a();".
// 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_4_e_a();".
// 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 := [9, -3, -2, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0], [-3, -2, 2, 1], [0, 5, 1, -1], [-9, 2, 1, 2]];
    Rf_basisdens := [1, 6, 3, 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_225_e();"
function MakeCharacter_225_e()
    N := 225;
    order := 3;
    char_gens := [101, 127];
    v := [1, 3];
    // 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_e_Hecke();"
function MakeCharacter_225_e_Hecke( : Kf := false)
    N := 225;
    order := 3;
    char_gens := [101, 127];
    char_values := [[-1, 1, 0, 0], [1, 0, 0, 0]];
    assert UnitGenerators(DirichletGroup(N)) eq char_gens;
    values := ConvertToHeckeField(char_values : pass_field := ISA(Type(Kf), Fld), 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]];
    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 := 4;
    raw_aps := [[0, -1, 0, 1], [1, -1, -1, 2], [0, 0, 0, 0], [0, 4, 0, 1], [0, 21, 0, -5], [-60, 52, -8, 8], [-26, 0, 25, 0], [30, 0, 25, 0], [-145, 122, -23, 23], [0, -182, 0, 39], [6, -6, 0, 0], [314, 0, -10, 0], [-89, 149, 60, -60], [0, -5, 0, -87], [0, -456, 0, 11], [-162, 0, -100, 0], [18, -67, -49, 49], [0, 26, 0, 195], [-211, 395, 184, -184], [252, 0, 110, 0], [508, 0, 205, 0], [0, 458, 0, -76], [0, -420, 0, 453], [-375, 0, 315, 0], [0, -581, 0, 131], [0, -724, 0, -370], [1120, -828, 292, -292], [449, 0, -80, 0], [-375, 0, 485, 0], [-220, 222, 2, -2], [-1891, 0, -225, 0], [-474, 564, 90, -90], [0, 199, 0, -179], [508, 23, 531, -531], [-1757, 1688, -69, 69], [0, -814, 0, 990], [154, 600, 754, -754], [1668, 0, -260, 0], [-2221, 1970, -251, 251], [0, 790, 0, -662], [1440, 0, 40, 0], [-863, 0, -1175, 0], [0, -784, 0, -170], [-420, -163, -583, 583], [1924, 0, -700, 0], [-290, 0, 330, 0], [1476, -1676, -200, 200], [0, -1270, 0, 543], [0, -4011, 0, 31], [-627, -372, -999, 999], [-4562, 0, 155, 0], [-512, 798, 286, -286], [0, -1289, 0, 200], [-2898, 0, -1365, 0], [3294, -2385, 909, -909], [0, -1080, 0, 88], [485, 0, -145, 0], [2082, 0, 1810, 0], [0, 834, 0, 1776], [0, -674, 0, 25], [-655, -1588, -2243, 2243], [2810, -598, 2212, -2212], [5709, 0, -490, 0], [3586, -3326, 260, -260], [0, -6545, 0, -127], [0, -1816, 0, -1644], [0, 2956, 0, 1150], [-2656, 855, -1801, 1801], [-2936, 995, -1941, 1941], [0, 5928, 0, -1211], [0, 2065, 0, -2717], [6310, 0, 590, 0], [0, 1704, 0, -2064], [-2970, 4642, 1672, -1672], [-4550, 0, 765, 0], [-2800, 212, -2588, 2588], [0, 3988, 0, 2119], [14, 0, 3990, 0], [-10934, 11569, 635, -635], [1938, -2927, -989, 989], [-10892, 11768, 876, -876], [0, 326, 0, 600], [9202, 0, -1990, 0], [-3482, 0, 25, 0], [0, 3698, 0, 1314], [0, -5365, 0, 2288], [3990, 0, 325, 0], [0, 2799, 0, -169], [0, -6664, 0, 275], [780, -2628, -1848, 1848], [5524, 0, -735, 0], [0, 7838, 0, 1964], [-7496, 0, 1650, 0], [5936, -5481, 455, -455], [-9212, 12033, 2821, -2821], [4503, 0, 205, 0], [-4627, 4588, -39, 39], [-1293, 0, -3970, 0], [3153, 0, 3125, 0], [-6323, 0, -115, 0], [0, -8601, 0, 656], [-11746, 0, -1790, 0], [1615, -4973, -3358, 3358], [0, -377, 0, -2741], [10936, -13411, -2475, 2475], [-4606, 0, -2845, 0], [0, -13121, 0, 916], [5358, 0, -1700, 0], [1918, -9712, -7794, 7794], [0, -19519, 0, 685], [-1181, 3440, 2259, -2259], [-16842, 0, 800, 0], [10684, -6545, 4139, -4139], [0, -6637, 0, 1159], [1992, 0, -2270, 0], [0, -1489, 0, -3580], [5015, -1663, 3352, -3352], [-12731, 0, -5525, 0], [-19850, 16302, -3548, 3548], [0, -10292, 0, 7784], [-17534, 14784, -2750, 2750], [0, 990, 0, 78], [0, 1164, 0, -84], [20388, 0, 2655, 0], [0, 11536, 0, -3370], [-12913, 0, -555, 0], [0, 898, 0, 2039], [-22590, 0, 210, 0], [0, -2836, 0, 2811], [1190, -3008, -1818, 1818], [10950, 0, 3625, 0], [6315, -5018, 1297, -1297], [3896, 2164, 6060, -6060], [-9916, 0, 3330, 0], [18701, -19126, -425, 425], [4823, -2742, 2081, -2081], [9508, 0, 350, 0], [-5056, 9180, 4124, -4124], [30704, -31760, -1056, 1056], [-990, 0, -11095, 0], [8062, 0, -11005, 0], [0, 9256, 0, 985], [-25235, 21132, -4103, 4103], [-10381, 0, 7215, 0], [-555, 0, -975, 0], [0, -5882, 0, -6516], [0, 9820, 0, 328], [0, 17294, 0, 8266], [17108, -21347, -4239, 4239], [12843, 0, -8315, 0], [10244, 1190, 11434, -11434], [-11343, 0, -5285, 0], [26773, 0, 2670, 0], [-4056, 10530, 6474, -6474], [0, -24891, 0, 8556], [0, 6326, 0, 8220], [-42950, 0, 3300, 0], [0, 16738, 0, -12216], [-22496, 0, -8170, 0], [-6209, 12704, 6495, -6495], [0, 26339, 0, -1594], [8408, 0, 8235, 0], [-11371, 17110, 5739, -5739], [13102, 0, 18650, 0], [1784, 5385, 7169, -7169], [0, -28740, 0, -1737], [-16298, 0, -12110, 0], [0, 22034, 0, -10084]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_225_e_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_225_4_e_a();".
// 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_4_e_a(:prec:=4)
    chi := MakeCharacter_225_e();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 4));
    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_4_e_a();".
// 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_4_e_a( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_225_e();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<2,R![64, -8, 9, 1, 1]>],Snew);
    return Vf;
end function;