
// Make newform 588.6.i.l in Magma, downloaded from the LMFDB on 16 March 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_588_i();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_588_i_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_588_6_i_l();".
// 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_588_6_i_l();".
// 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 := [1937664, 1392, 1393, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0], [1937664, -1393, 1393, -1], [-1937664, 3879505, -1393, 1], [4177, 0, 0, 2]];
    Rf_basisdens := [1, 1939056, 1939056, 1393];
    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_588_i();"
function MakeCharacter_588_i()
    N := 588;
    order := 3;
    char_gens := [295, 197, 493];
    v := [3, 3, 2];
    // 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_588_i_Hecke();"
function MakeCharacter_588_i_Hecke( : Kf := false)
    N := 588;
    order := 3;
    char_gens := [295, 197, 493];
    char_values := [[1, 0, 0, 0], [1, 0, 0, 0], [0, -1, 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 := 6;
    raw_aps := [[0, 0, 0, 0], [9, -9, 0, 0], [0, 3, 1, 0], [0, 0, 0, 0], [45, -45, 7, 7], [384, 0, 0, 6], [-963, 963, 1, 1], [0, -1124, 24, 0], [0, -3177, -1, 0], [5286, 0, 0, 40], [1656, -1656, 72, 72], [0, -1052, -150, 0], [633, 0, 0, 33], [-2884, 0, 0, 240], [0, -7806, 162, 0], [-8256, 8256, 234, 234], [6570, -6570, 50, 50], [0, 2898, -264, 0], [28058, -28058, -462, -462], [5511, 0, 0, -895], [42692, -42692, -174, -174], [0, 9810, -78, 0], [-22212, 0, 0, 320], [0, -105609, -399, 0], [22432, 0, 0, -1614], [-49467, 49467, -67, -67], [0, -11876, -2556, 0], [0, -46467, -711, 0], [-199438, 199438, 288, 288], [65742, 0, 0, 484], [-209058, 0, 0, 738], [0, -83640, 2164, 0], [-228972, 228972, 1922, 1922], [-235148, 0, 0, 528], [0, 294624, 246, 0], [-356872, 356872, 1008, 1008], [269974, -269974, 2484, 2484], [0, 34438, -4566, 0], [-163386, 0, 0, 5938], [0, 225273, 847, 0], [2259, -2259, 2025, 2025], [-114828, 0, 0, -2790], [0, -450867, 2733, 0], [-628748, 628748, -1974, -1974], [-473760, 0, 0, 998], [-83852, 83852, 996, 996], [-98872, 0, 0, -5124], [57212, 0, 0, 9492], [-139758, 139758, -6942, -6942], [0, -238708, 3498, 0], [0, 694764, 2870, 0], [961617, 0, 0, -1233], [-190400, 190400, 11550, 11550], [283782, 0, 0, -9234], [0, -470913, -17535, 0], [-325761, 325761, -4071, -4071], [1005075, -1005075, -9193, -9193], [0, -124068, 7932, 0], [-18272, 18272, 11898, 11898], [402624, 0, 0, 15866], [1550372, -1550372, 696, 696], [-186765, 0, 0, 18411], [-1567208, 0, 0, -9084], [-1505142, 1505142, 12638, 12638], [0, 1205078, 20448, 0], [0, 1218096, -12978, 0], [0, -429008, -2916, 0], [-1202442, 0, 0, -2340], [1639083, -1639083, -135, -135], [2758270, 0, 0, 7320], [679365, -679365, 23865, 23865], [0, -1351383, 35521, 0], [-3148904, 3148904, -21336, -21336], [0, 3155258, -384, 0], [-992168, 0, 0, 26436], [0, -1395228, -18124, 0], [2788026, -2788026, 29168, 29168], [0, 107550, -30492, 0], [0, 3841800, -9318, 0], [-3392576, 3392576, 29334, 29334], [3347094, 0, 0, 14694], [3781968, 0, 0, 4326], [4243701, -4243701, -31029, -31029], [488702, 0, 0, -61212], [0, 779016, -67152, 0], [0, 4002819, 27503, 0], [-360678, 0, 0, -824], [0, -4016842, 3552, 0], [803475, 0, 0, -82301], [-2884742, 0, 0, 83718], [0, 2844846, -32438, 0], [6531294, -6531294, -16814, -16814], [699748, -699748, 40500, 40500], [405597, 0, 0, -75105], [0, 975632, -58284, 0], [-2744832, 0, 0, -20424], [0, -6172557, 61689, 0], [-2048967, 2048967, 115629, 115629], [0, 8516836, 48024, 0], [0, -2599920, 77694, 0], [5662110, 0, 0, 22566], [1133988, -1133988, 168110, 168110], [9988926, -9988926, 47158, 47158], [0, 6195852, -92634, 0], [-1875906, 1875906, 55302, 55302], [-9753070, 9753070, 77964, 77964], [5208186, 0, 0, -35350], [0, -7250787, -81393, 0], [-767355, 767355, -114525, -114525], [-513274, 0, 0, -122508], [0, 2832696, 57096, 0], [2442450, -2442450, 93384, 93384], [4237776, 0, 0, 169082], [-5275456, 5275456, -72948, -72948], [8494502, 0, 0, -108894], [-7674036, 7674036, -89102, -89102], [-9975076, 0, 0, 31104], [5505174, -5505174, 44754, 44754], [0, 3512670, 117084, 0], [4164903, 0, 0, 39917], [7795886, -7795886, -90348, -90348], [-8095360, 0, 0, -28158], [0, -18708687, -28545, 0], [-1559505, 1559505, 40149, 40149], [0, 4936864, -88740, 0], [5370462, 0, 0, 39088], [0, 8318626, 65832, 0], [0, -5857392, -102864, 0], [5717740, 0, 0, 5676], [0, 15064608, 99654, 0], [-21885330, 21885330, -77874, -77874], [-6690825, 0, 0, -58623], [0, 2498088, 70680, 0], [-21349986, 0, 0, -72072], [0, -21437937, 39449, 0], [-21119882, 0, 0, 29916], [-9217887, 9217887, -26335, -26335], [5588760, -5588760, 90828, 90828], [6081303, 0, 0, -205329], [-16285098, 16285098, -89536, -89536], [14112712, 0, 0, -162324], [0, -7464612, -389998, 0], [17273390, -17273390, 127818, 127818], [6483723, 0, 0, 284097], [-3849772, 3849772, -151002, -151002], [-16413510, 0, 0, -221506], [-2704330, 0, 0, 220728], [-6809097, 6809097, -113025, -113025], [0, 4108840, 167292, 0], [0, 1898931, 283315, 0], [0, -3994006, -193704, 0], [-4934433, 0, 0, 430419], [7717232, 0, 0, 174228], [0, 3461802, 219666, 0], [-7128588, 7128588, -364176, -364176], [-11580141, 0, 0, -144915], [0, -4950844, 318060, 0], [0, 44624451, 13461, 0], [-7443274, 0, 0, -189228], [-10599837, 10599837, 317207, 317207], [0, -23530827, -393239, 0], [-5851710, 0, 0, -149896], [-26654266, 0, 0, -97374], [0, 14089764, -332808, 0], [32378208, -32378208, 110862, 110862], [12491364, -12491364, -375372, -375372], [28763500, -28763500, -152700, -152700], [1500574, -1500574, -344748, -344748]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_588_i_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_588_6_i_l();".
// 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_588_6_i_l(:prec:=4)
    chi := MakeCharacter_588_i();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 6));
    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_588_6_i_l();".
// 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_588_6_i_l( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_588_i();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,6,sign)));
    Vf := Kernel([<5,R![30913600, 33360, 5596, -6, 1]>],Snew);
    return Vf;
end function;