
// Make newform 175.6.b.d in Magma, downloaded from the LMFDB on 18 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_175_b();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_175_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_175_6_b_d();".
// 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_175_6_b_d();".
// 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 := [256, 0, 33, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0], [0, 1, 0, 0], [0, 17, 0, 1], [17, 0, 1, 0]];
    Rf_basisdens := [1, 1, 16, 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_175_b();"
function MakeCharacter_175_b()
    N := 175;
    order := 2;
    char_gens := [127, 101];
    v := [1, 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_175_b_Hecke();"
function MakeCharacter_175_b_Hecke(Kf)
    N := 175;
    order := 2;
    char_gens := [127, 101];
    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 := 6;
    raw_aps := [[0, 1, 0, 0], [0, 3, 3, 0], [0, 0, 0, 0], [0, 0, 49, 0], [-252, 0, 0, -97], [0, -53, -315, 0], [0, 251, 105, 0], [-272, 0, 0, -86], [0, 902, 230, 0], [-2470, 0, 0, -945], [264, 0, 0, -924], [0, -1260, 3822, 0], [-1022, 0, 0, 3818], [0, -922, -14022, 0], [0, -1575, 9857, 0], [0, 454, -27564, 0], [-32392, 0, 0, 5184], [-23070, 0, 0, -5706], [0, -4568, 20388, 0], [43024, 0, 0, -5304], [0, 4192, -4670, 0], [17080, 0, 0, 17635], [0, 3924, 56876, 0], [21686, 0, 0, -5722], [0, 13943, 55141, 0], [50218, 0, 0, -21172], [0, 20579, 16611, 0], [0, 29970, 502, 0], [133946, 0, 0, -18567], [0, -19812, 32798, 0], [0, 10736, 8600, 0], [286336, 0, 0, 21062], [0, 5318, -16884, 0], [147072, 0, 0, -76994], [240714, 0, 0, 49772], [159928, 0, 0, -62267], [0, 16012, 354098, 0], [0, 57194, -123434, 0], [0, 25933, 506141, 0], [0, 40909, -204329, 0], [-185956, 0, 0, -95088], [-477758, 0, 0, 97210], [304200, 0, 0, 4979], [0, -156198, 285820, 0], [0, 59494, 307784, 0], [-345424, 0, 0, 109048], [112452, 0, 0, -23175], [0, -126085, 564379, 0], [0, 30393, 281521, 0], [-318722, 0, 0, -91346], [0, 28478, -1226952, 0], [-69408, 0, 0, -155129], [-122230, 0, 0, 336604], [-526800, 0, 0, -245506], [0, 20444, 151474, 0], [0, 37322, 167730, 0], [-557258, 0, 0, 93336], [635264, 0, 0, 286656], [0, -131224, 285770, 0], [1982602, 0, 0, -28975], [0, 211617, 1651265, 0], [0, 27657, 2401555, 0], [0, -709953, -565017, 0], [1737512, 0, 0, -237530], [0, -720569, -749503, 0], [0, -365120, 649562, 0], [-106860, 0, 0, -227736], [0, -227476, 117754, 0], [0, -147062, 1770806, 0], [882662, 0, 0, 503936], [0, -839455, 530539, 0], [2951576, 0, 0, -181272], [0, 430593, 1589281, 0], [0, -8514, -3121828, 0], [2683900, 0, 0, -667880], [0, 845068, 709828, 0], [25618, 0, 0, -458771], [0, 745243, -350479, 0], [4179234, 0, 0, -189449], [-556098, 0, 0, -1015924], [1187000, 0, 0, 808820], [-3681898, 0, 0, -544185], [1191984, 0, 0, 521311], [0, 395360, 1430434, 0], [-2635512, 0, 0, -443286], [0, -664602, -3808542, 0], [-5205042, 0, 0, 338699], [0, 841546, -2105280, 0], [-5796038, 0, 0, 862990], [0, -213536, -7736144, 0], [0, -356573, -568277, 0], [3217160, 0, 0, -1744510], [0, -928538, -1317722, 0], [2310636, 0, 0, 951277], [-1606164, 0, 0, 1353413], [0, 307381, 2747757, 0], [-2190618, 0, 0, 1201736], [2992802, 0, 0, -898500], [0, -832940, 3349844, 0], [-356082, 0, 0, 2592713], [0, 611828, 1288216, 0], [0, -375106, 6022264, 0], [0, -493548, 1181140, 0], [-912474, 0, 0, -944072], [-975164, 0, 0, -933008], [0, -761595, -6017333, 0], [0, 800728, 1529696, 0], [0, 234227, -4056995, 0], [4642160, 0, 0, 573305], [659466, 0, 0, -2503388], [0, 441363, -4073789, 0], [0, 1168788, -3913142, 0], [0, 1717928, -5938274, 0], [9253832, 0, 0, 693906], [-4152640, 0, 0, -380521], [-3294590, 0, 0, 153024], [0, -349981, 14370371, 0], [0, -1615784, 158920, 0], [0, -2247548, -7562910, 0], [6387268, 0, 0, -460331], [-3677078, 0, 0, 1001750], [0, -1896014, 5741252, 0], [0, 1229525, 10518947, 0], [0, -2919012, -5453112, 0], [2673552, 0, 0, 2935340], [471798, 0, 0, -4203227], [-2871742, 0, 0, 4408319], [6229320, 0, 0, 1735810], [0, -1227928, -18083672, 0], [0, 1142295, -12058231, 0], [5265732, 0, 0, -3715079], [0, -2996284, 14374132, 0], [5585536, 0, 0, -3236363], [0, 516102, 21498528, 0], [-5255694, 0, 0, 4356892], [-13262922, 0, 0, -591356], [0, 3397915, -15359131, 0], [0, 845017, 305313, 0], [0, -130893, 2981593, 0], [-22937098, 0, 0, 3089521], [31242232, 0, 0, -244570], [-12544730, 0, 0, -4413741], [0, -523564, 1349132, 0], [0, -513270, 6453262, 0], [9806590, 0, 0, 4650670], [-5849072, 0, 0, -2979266], [0, 746052, -33234170, 0], [0, 3083000, 2417422, 0], [-14295200, 0, 0, 5973340], [0, 378976, 12460512, 0], [0, -261340, -5767098, 0], [6270242, 0, 0, -2983970], [0, -2519368, -16698180, 0], [0, 8388616, -6300840, 0], [0, -9517554, -3564430, 0], [-26241728, 0, 0, -607040], [13173856, 0, 0, -2631497], [3522342, 0, 0, -2295474], [0, -5700097, -1732259, 0], [672818, 0, 0, 351278], [0, 4171236, 9855400, 0], [0, 7538014, 19350376, 0], [0, 4067074, 38658834, 0], [-23948808, 0, 0, -6709920], [0, 2563564, -19945206, 0], [0, 2256405, -42181291, 0], [22817832, 0, 0, -4104200], [0, -8164473, -14202467, 0]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_175_b_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_175_6_b_d();".
// 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_175_6_b_d(:prec:=4)
    chi := MakeCharacter_175_b();
    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_175_6_b_d();".
// 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_175_6_b_d( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_175_b();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,6,sign)));
    Vf := Kernel([<2,R![256, 0, 33, 0, 1]>],Snew);
    return Vf;
end function;