
// Make newform 32.7.c.b in Magma, downloaded from the LMFDB on 12 January 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_32_c();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_32_c_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_32_7_c_b();".
// 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_32_7_c_b();".
// 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, 0, 0, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0], [0, 48, -12, 16], [0, 0, -64, 0], [0, 192, 0, -64]];
    Rf_basisdens := [1, 3, 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_32_c();"
function MakeCharacter_32_c()
    N := 32;
    order := 2;
    char_gens := [31, 5];
    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_32_c_Hecke();"
function MakeCharacter_32_c_Hecke( : Kf := false)
    N := 32;
    order := 2;
    char_gens := [31, 5];
    char_values := [[-1, 0, 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 := 7;
    raw_aps := [[0, 0, 0, 0], [0, -1, 0, 0], [-14, 0, 0, -1], [0, 2, -5, 0], [0, 17, -14, 0], [-2174, 0, 0, -5], [-1326, 0, 0, -34], [0, -125, 102, 0], [0, 246, -139, 0], [19394, 0, 0, -137], [0, -952, 40, 0], [31314, 0, 0, -221], [-52462, 0, 0, -68], [0, 1513, -740, 0], [0, -1156, -322, 0], [-17166, 0, 0, -197], [0, -1955, -3128, 0], [59554, 0, 0, -1173], [0, 4063, 3094, 0], [0, 306, 3655, 0], [54882, 0, 0, 2686], [0, 2244, 5270, 0], [0, 12739, -2176, 0], [-930750, 0, 0, -850], [729586, 0, 0, 4710], [-213230, 0, 0, -2261], [0, 39066, -11101, 0], [0, 8041, -12930, 0], [200994, 0, 0, -6409], [-27614, 0, 0, 6768], [0, -5440, 38700, 0], [0, -32113, -30566, 0], [-519214, 0, 0, -6868], [0, 19041, 36692, 0], [1540370, 0, 0, 1479], [0, -118762, 14261, 0], [990626, 0, 0, -27773], [0, 74919, -40380, 0], [0, 65162, 9367, 0], [-4012670, 0, 0, -1853], [0, 59099, 348, 0], [-1626990, 0, 0, 46495], [0, 208400, 9860, 0], [-2520398, 0, 0, -61642], [-4767694, 0, 0, -3561], [0, -123726, -9221, 0], [0, 279427, 67852, 0], [0, 148472, -171464, 0], [0, 87703, -99776, 0], [-14334094, 0, 0, -47481], [-4576094, 0, 0, 32334], [0, 5644, 304466, 0], [-22388206, 0, 0, -27170], [0, 161741, -284376, 0], [-10052606, 0, 0, 9632], [0, -346654, 323527, 0], [16562466, 0, 0, -20481], [0, 211604, -293118, 0], [8066738, 0, 0, 43435], [5609474, 0, 0, -23466], [0, -250427, -288082, 0], [-6913934, 0, 0, -201161], [0, -209877, 419454, 0], [0, 314878, -160939, 0], [-27207310, 0, 0, 11900], [5079554, 0, 0, -107321], [0, -81471, 81422, 0], [-19597918, 0, 0, 18424], [0, -1414619, 176324, 0], [39004802, 0, 0, 77503], [1591298, 0, 0, 41208], [0, -1273510, -301293, 0], [0, 859724, -2482, 0], [44793010, 0, 0, 119459], [0, 456909, 306316, 0], [0, 1032672, 200464, 0], [32065426, 0, 0, 448035], [-19984542, 0, 0, 223431], [8227922, 0, 0, 46062], [62107442, 0, 0, 145452], [0, -993769, 1094582, 0], [-36571214, 0, 0, -367841], [0, -1122756, -1294734, 0], [76399122, 0, 0, 71502], [0, 823582, 877013, 0], [0, 1526957, -1401646, 0], [-23161422, 0, 0, -521450], [-1427630, 0, 0, -1044660], [-27552478, 0, 0, -318801], [0, -590172, 661606, 0], [0, 2930963, -657942, 0], [0, -743240, -1324952, 0], [0, 2116186, -302889, 0], [0, -3372551, 1572736, 0], [0, -4140341, 759104, 0], [0, -5219442, 1205849, 0], [-1272094, 0, 0, 153731], [-11505838, 0, 0, 1032444], [0, 878577, -1974058, 0], [105120610, 0, 0, -235845], [0, 3376183, -1568698, 0], [-87263550, 0, 0, 685355], [0, -3189013, -97138, 0], [-2583182, 0, 0, -174692], [0, 1757581, -101558, 0], [-256689342, 0, 0, 433432], [0, 2456289, 3775394, 0], [-158070174, 0, 0, 130288], [0, 4980966, -2835431, 0], [-11368382, 0, 0, 2214894], [0, 111928, 437468, 0], [-133732302, 0, 0, 119391], [-157196830, 0, 0, 1311958], [0, 3501065, -2669974, 0], [0, 3312558, -2325447, 0], [393548722, 0, 0, 761990], [0, -2727633, -994874, 0], [0, 2378946, -823977, 0], [48275362, 0, 0, 433007], [0, -4708269, 2162248, 0], [-24517294, 0, 0, 476911], [64104178, 0, 0, 129302], [427026898, 0, 0, 626803], [0, -4130967, 3897216, 0], [0, -10618149, 3086956, 0], [-499314654, 0, 0, 1130619], [-396838126, 0, 0, -13533], [0, -8421596, -4077474, 0], [0, 6966022, -1397383, 0], [-143076926, 0, 0, -3521305], [0, -9282153, 1083248, 0], [0, -16341862, 4852759, 0], [0, 6717516, -6796198, 0], [-192661678, 0, 0, 969255], [-99379726, 0, 0, -3063876], [-89829838, 0, 0, -3367882], [461959698, 0, 0, 1660883], [0, 3169939, 4377092, 0], [-558602974, 0, 0, 1207187], [-625334766, 0, 0, -1233316], [0, -10248263, 9752322, 0], [311101490, 0, 0, -812413], [0, -926466, 15054277, 0], [0, -787219, -11955978, 0], [285770850, 0, 0, -779773], [0, -3029230, 13717283, 0], [-101429966, 0, 0, 2311371], [-623470798, 0, 0, 228412], [0, 12784357, -7221668, 0], [0, 22509272, -9188688, 0], [105639778, 0, 0, 1531487], [320972898, 0, 0, 1157432], [0, 13082651, 860778, 0], [0, 16634382, -3509899, 0], [0, 10036417, 14491888, 0], [0, -15177228, 7453162, 0], [0, 8057366, -10092339, 0], [608089586, 0, 0, -3557898], [699210786, 0, 0, -1140690], [-256173278, 0, 0, 2576199], [0, 4710411, 14450758, 0], [-698181390, 0, 0, 5328364], [0, 6642098, 10346419, 0], [0, -12719151, -12317080, 0], [-45386414, 0, 0, 6710302], [0, -22675450, 18523489, 0], [0, 27185240, -2249916, 0], [517733714, 0, 0, -3649677]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_32_c_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_32_7_c_b();".
// 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_32_7_c_b(:prec:=4)
    chi := MakeCharacter_32_c();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 7));
    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_32_7_c_b();".
// 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_32_7_c_b( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_32_c();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,7,sign)));
    Vf := Kernel([<3,R![1937664, 0, 3360, 0, 1]>],Snew);
    return Vf;
end function;