
// Make newform 6272.2.a.s in Magma, downloaded from the LMFDB on 26 October 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_6272_a();"
// To make the coeffs of the qexp of the newform in the Hecke field type "qexpCoeffs();"
// To make the newform (type ModFrm), type "MakeNewformModFrm_6272_2_a_s();".
// 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_6272_2_a_s();".
// 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 := [-3, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rfbasis := [Kf.1^i : i in [0..Degree(Kf)-1]];
    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_6272_a();"
function MakeCharacter_6272_a()
    N := 6272;
    order := 1;
    char_gens := [4607, 3333, 4609];
    v := [1, 1, 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;

function MakeCharacter_6272_a_Hecke( : Kf := Kf)
    return MakeCharacter_6272_a();
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 := 2;
    raw_aps := [[0, 0], [1, 1], [-1, 1], [0, 0], [-2, -2], [-1, 1], [-4, 2], [1, -3], [2, -4], [0, -2], [-6, -2], [8, 2], [0, -2], [-6, -2], [-2, -2], [6, 0], [1, -3], [-1, -7], [-8, 4], [0, 8], [-2, 4], [8, 0], [-9, -1], [2, 4], [-4, -2], [9, 3], [2, 6], [16, 0], [0, 2], [-10, -6], [2, 0], [3, 3], [-14, 4], [7, -5], [-6, 8], [2, 0], [15, 1], [-10, 6], [10, 2], [3, 5], [12, 0], [-7, -5], [4, -4], [-2, 6], [-10, 8], [-22, -2], [-4, 0], [12, -8], [-15, -3], [-5, -3], [18, 0], [-6, 4], [-16, 2], [21, -3], [18, -4], [0, -8], [-5, -11], [-16, -4], [6, -4], [6, 8], [3, 11], [13, -1], [-21, 3], [-4, 4], [-16, -2], [-6, 4], [2, -2], [-2, 14], [-18, 2], [-11, 7], [6, -4], [-2, -8], [-8, 12], [2, 8], [-14, 14], [-30, 2], [-4, -2], [-3, 15], [-6, 14], [-28, -2], [13, -3], [14, -4], [-10, -12], [-12, -14], [-12, -16], [0, -4], [2, 0], [6, -2], [-23, -5], [8, -16], [5, 17], [6, -6], [2, 20], [20, 0], [-16, 0], [-16, -4], [-11, -1], [-20, 6], [13, 9], [14, -12], [-14, -6], [-2, -16], [3, 7], [2, 14], [-22, 6], [-2, 4], [-5, -9], [6, 8], [24, 0], [-6, -4], [20, -4], [-4, 10], [-2, -10], [11, -21], [-28, -4], [-30, -10], [-21, -1], [-6, -10], [24, -2], [-6, 10], [13, -9], [10, 4], [17, -13], [0, 8], [3, 3], [4, 2], [40, 2], [-18, 14], [-42, -2], [15, 9], [6, -10], [-2, 16], [-2, -4], [4, 2], [-16, -10], [-44, -2], [-21, 13], [-11, 1], [3, 5], [6, -2], [-9, 15], [-22, -16], [-20, -12], [28, -4], [31, 1], [6, 2], [11, 13], [24, 2], [5, 5], [-28, -4], [4, 22], [-14, -16], [-8, 0], [30, -2], [8, -20], [6, 0], [-12, -12], [0, -2], [2, -24], [-23, 19], [10, 10], [34, 0], [2, 20], [-23, -3], [-18, -20], [-10, -6], [-4, 4], [-45, 5], [14, -18], [-5, -19], [-12, -24], [9, -21], [8, 0], [14, -8], [-14, 10], [-6, -20], [0, 8], [-20, 2], [-16, 8], [-7, 3], [-34, 4], [-21, 7], [-48, 10], [-10, -28], [6, 0], [15, 9], [-26, 16], [1, -3], [-14, -12], [-14, 22], [26, -8], [36, 12], [-44, 4], [-1, 33], [4, -4], [10, 20], [-10, -18], [32, 14], [10, -16], [-24, 12], [-14, -12], [-22, 6], [-5, -19], [-22, -24], [21, -15], [-39, 3], [10, 14], [10, 6], [14, -14], [17, -7], [-22, -2], [-17, -23], [2, 24], [-37, -5], [-12, -8], [8, 22], [0, 8], [44, -10], [48, 8], [24, 14], [28, -14], [-12, -8], [30, 8], [-30, 4], [17, -3], [64, -2], [-26, 0], [10, 28], [4, 40], [10, 10], [4, -14], [37, 21], [-8, -24], [22, 0], [-41, 15], [40, -4], [40, -10], [-2, 28], [-24, -4], [12, 4], [-18, 34], [13, 17], [4, -16], [2, -28], [14, 20], [22, -14], [-4, -4], [-21, -21], [22, 30], [36, -12], [42, 0], [2, 8], [20, 12], [14, 16], [-41, -7], [-16, -4], [-8, 6], [-21, -1], [15, -7], [12, 14], [34, -4], [62, 10], [-1, 9], [23, 25], [24, 10], [-9, -5], [2, 16], [30, 0], [28, -12], [-20, 30], [-37, -3], [26, -10], [14, 24], [-38, 0], [18, 4], [-4, -4], [-10, -10], [-54, -4], [-42, 10], [39, 23], [32, -28], [-20, 12], [66, 2], [37, 7], [23, -9], [14, 32], [-26, 16], [6, -16], [10, 10], [14, 12], [-22, 28], [39, -9], [30, 14], [-57, -1], [-46, 0], [21, -9], [16, -20], [7, 41], [45, -19], [-7, -15], [-32, 2], [-12, -26], [0, -40], [-6, 6], [-14, -14], [-18, -4], [10, 14], [67, -3], [54, -12], [38, -4], [-56, 4], [72, 10], [-54, -12], [-2, -14], [4, 4], [6, 48], [43, 23], [-16, 0], [18, 0], [38, 8], [-11, -35], [14, -12], [-15, -13], [-80, 0], [-42, 22], [-8, -18], [-18, -42], [-17, -9], [-50, -16], [20, -22], [14, 24], [-24, -10], [-22, 2], [-9, 27], [-32, -24], [21, 25], [4, 30], [-74, 4], [-66, 4], [-22, 6], [26, 4], [-22, -10], [-63, 3], [-4, -28], [-36, -14], [-34, 26], [-7, 51], [-30, 6], [36, 16], [-29, 5], [-31, 1], [26, -32], [-42, -24], [18, 14], [-2, -8], [22, 24], [-6, -10], [-39, 29], [66, -8], [18, 28], [14, -4], [18, 40], [18, -24], [-28, 32], [17, -19], [-34, 14], [11, 5], [-70, 4], [38, 14], [4, 4], [71, 3], [-12, 20], [18, 0], [-20, 20], [-10, -28], [-47, 21], [42, -4], [-10, 20], [-60, 14], [-64, -6], [37, -17], [-18, -26], [52, 12], [-18, -16], [35, -9], [-36, 8], [56, 24], [79, 9], [-28, 8], [-50, -22], [-2, 6], [15, -15], [-44, -12], [-19, -11], [-38, 16], [10, 28], [-86, 6], [56, 10], [-48, -8], [48, -2], [-39, -5], [30, 16], [0, 32], [48, -6], [-69, 5], [-30, 22], [10, -8], [-18, -26], [-59, 21], [-5, -25], [-18, 4], [12, 26], [-38, -10], [-88, 0], [2, 0], [17, -29], [-40, 16], [14, 30], [-12, 6], [0, 44], [-76, 6], [-45, -19], [28, 44], [9, 9], [12, -22], [27, -3], [22, 2], [-90, 8], [9, 1], [-42, -18]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_6272_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_6272_2_a_s();".
// 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_6272_2_a_s(:prec:=2)
    chi := MakeCharacter_6272_a();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 2));
    S := BaseChange(S, Kf);
    maxprec := NextPrime(2999) - 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_6272_2_a_s();".
// 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_6272_2_a_s( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_6272_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<3,R![-2, -2, 1]>,<5,R![-2, 2, 1]>,<11,R![-8, 4, 1]>,<13,R![-2, 2, 1]>,<23,R![-44, -4, 1]>,<29,R![-12, 0, 1]>],Snew);
    return Vf;
end function;