
// Make newform 7497.2.a.be in Magma, downloaded from the LMFDB on 17 September 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_7497_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_7497_2_a_be();".
// 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_7497_2_a_be();".
// 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 := [4, 4, -5, -2, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0], [0, -1, -2, 1], [2, -5, -2, 1], [-8, 1, 4, -1]];
    Rf_basisdens := [1, 2, 2, 2];
    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_7497_a();"
function MakeCharacter_7497_a()
    N := 7497;
    order := 1;
    char_gens := [1667, 5050, 6616];
    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_7497_a_Hecke( : Kf := Kf)
    return MakeCharacter_7497_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, 0], [0, 0, 0, 0], [0, 1, 0, 0], [0, 0, 0, 0], [0, 0, 1, -1], [0, 1, 0, 0], [-1, 0, 0, 0], [-4, -1, -2, 0], [-4, -2, -3, -1], [0, 0, -2, 0], [2, 1, 1, 3], [0, -1, 1, -1], [-4, -1, 2, 2], [8, 0, 3, 1], [-2, -1, -1, -3], [-4, 1, 1, 3], [-2, -3, -3, -1], [2, 3, -1, -1], [8, 0, 2, 2], [-4, 0, -6, -2], [0, 0, 4, -2], [-6, -1, -7, -1], [8, 0, 2, 2], [-6, 2, 0, 0], [0, -2, 4, 2], [-4, 1, 5, -1], [-4, -3, -4, -6], [-8, -2, 1, 3], [4, -1, -3, -1], [4, 0, 1, 5], [0, -2, -3, -1], [-6, -5, -4, 0], [-4, 1, -3, -5], [-8, -2, 4, 4], [-6, -2, -6, -6], [4, 2, -4, -4], [0, -1, 0, 4], [0, 0, 2, 2], [6, -1, 4, 0], [4, 1, 0, 4], [-2, 0, 6, 0], [4, 0, 4, -2], [6, 6, 0, -2], [0, -1, 3, 1], [0, -2, -5, -1], [2, -1, 1, -1], [-10, 1, -1, -3], [4, 7, 4, -2], [10, -1, -2, -2], [-6, -2, 0, 4], [4, 8, 5, 1], [-8, -3, -3, 1], [0, -6, 0, -2], [2, -3, -1, 1], [4, 3, 3, 9], [-14, -4, 4, 2], [-12, 3, -2, 2], [-8, -5, -10, 0], [6, -2, -2, -2], [-2, -2, -4, 0], [10, 3, 3, 1], [-22, 0, -6, -2], [-6, 6, 2, 0], [4, 0, 8, 4], [2, 1, 9, -3], [4, -2, 6, 0], [20, 4, 7, 1], [-12, 5, 5, -1], [-8, -2, 0, -4], [4, -9, -6, -2], [4, -1, -3, -1], [12, 1, 5, 5], [0, 0, 0, 0], [6, 0, 2, -2], [-20, -4, -4, -4], [-10, -3, 3, 5], [-6, 2, 0, 4], [-10, 3, -13, -1], [8, 6, -3, 1], [-24, -1, -12, -4], [0, -4, -10, -2], [6, 2, -13, 1], [8, 0, -4, 0], [-4, 5, -2, 2], [2, 1, -9, -3], [-16, -7, -5, -1], [16, 2, 0, 6], [2, -2, -7, -5], [0, 3, 5, -1], [-8, 6, 0, 4], [-12, -6, -8, 4], [2, -1, -4, -4], [12, 4, 10, 2], [-22, -6, -4, 2], [-2, -5, 9, -1], [-6, 3, 12, -4], [-14, 0, 2, -2], [-4, -7, 4, -4], [-10, 0, -8, -6], [-2, 10, 0, 4], [-2, 1, 5, 7], [4, 5, 13, -1], [8, 6, 4, 4], [-2, 6, 8, 4], [-8, 8, 0, 4], [-4, -5, 0, -4], [26, -7, 3, -3], [16, 1, 3, -7], [2, -2, 12, 6], [6, 5, 11, 7], [6, -7, 5, -5], [-2, -2, 13, 7], [8, 4, 2, 0], [2, -7, -3, -13], [-8, -2, 11, 1], [8, 8, 7, -5], [-12, 4, 4, 12], [-8, -6, -12, -8], [12, 2, 13, 1], [12, -5, 13, -3], [-8, 5, 4, -4], [6, 0, -4, -8], [4, 5, -8, -4], [-4, -4, 7, 5], [14, 7, 5, -5], [6, -2, 8, 8], [22, 4, 4, 4], [-10, -7, 2, 6], [-18, -4, -4, 2], [-10, -6, 14, 2], [4, -4, 5, 3], [12, 6, 12, 8], [14, 1, 3, 5], [-18, 2, 1, -5], [-2, 4, 8, 0], [4, -5, -12, 0], [-8, 3, -1, 5], [-2, -5, 21, 3], [-14, -4, 10, 6], [8, -4, 3, -9], [-12, -4, -10, -6], [16, 2, 1, 17], [-18, 3, 3, -7], [-16, -2, -15, -5], [14, 4, 12, 0], [-2, -3, -12, 4], [-14, 3, -3, -7], [30, 6, 18, 10], [18, -12, 4, -6], [16, 7, 11, 15], [-16, -5, -1, 1], [2, -2, 14, 2], [-4, 6, -11, -9], [-18, -1, -10, 6], [-12, -6, 8, 4], [8, -6, -1, -15], [-40, 0, 5, 3], [16, 5, -14, -6], [-2, 2, 4, -8], [10, 4, 16, 16], [-20, -10, 0, 0], [-12, 1, 11, -3], [4, -4, -15, 3], [-4, 12, 6, 2], [6, -2, 14, 14], [2, 7, 10, 14], [-8, -8, 8, 0], [16, 2, -2, 12], [18, 2, 0, 4], [-10, -8, 0, 4], [-32, -1, -15, -3], [16, -7, -8, 0], [32, 8, -1, -3], [-2, 4, 15, -3], [12, 5, -10, 0], [-32, -5, -2, -6], [2, -9, -1, 5], [-24, 2, -13, -1], [4, -1, -8, -6], [-28, -3, -12, 0], [8, -6, 25, 3], [16, 0, 8, -4], [16, 9, 13, 7], [-30, 6, -8, 0], [6, 8, -6, 0], [-10, -10, 2, -2], [2, 4, 16, -4], [12, 11, 14, 0], [-12, -15, -15, 3], [16, 4, 14, 2], [-22, -3, -13, -13], [-8, 8, -2, 10], [0, -4, -23, 3], [-20, 9, 5, 7], [-16, 4, -3, 3], [-6, 6, -4, -12], [-14, -10, -14, -6], [10, 6, 0, -8], [-30, -8, -4, 0], [-20, 2, -12, -4], [4, 2, -13, -5], [0, 2, 6, 14], [0, -1, 14, 6], [16, 7, 14, 2], [6, 3, -19, -5], [-4, -3, -13, -15], [-6, 6, 6, 8], [6, -8, -8, -2], [-4, 10, 3, 7], [22, -6, -4, 2], [4, -1, -21, -3], [-8, 7, 5, 15], [-34, -11, -1, 9], [8, -4, -4, 8], [-10, 11, 0, 12], [16, -4, 10, 8], [8, 16, 13, 3], [-26, 8, -6, -2], [0, -2, -9, -7], [-8, -1, 9, -13], [10, 4, -3, -1], [12, 14, 18, 6], [-14, 8, -22, -6], [-22, 7, -15, -1], [-4, 4, 6, -6], [38, 4, 14, 10], [-8, 5, -2, 14], [28, -8, 11, -3], [36, -3, 8, 6], [0, 12, 6, -6], [-38, -4, -23, -5], [-38, -3, -23, -9], [-28, -4, -14, 2], [0, 5, 17, 11], [-26, 0, 12, -2], [-10, 5, 5, -13], [-46, 1, 5, 1], [36, 2, 11, 11], [36, 10, 11, 5], [-12, 2, -14, -18], [0, 16, 15, 1], [-6, -12, -20, 2], [44, -9, 4, -2], [2, 12, 7, 5], [-4, -5, -10, -18], [26, 7, 10, -2], [0, 6, 0, 4], [-2, 9, 10, -6], [20, 12, 11, 5], [-14, 0, -20, -6], [6, -2, 3, 1], [-30, -6, -10, -14], [-40, -11, -23, -11], [-8, -12, -10, -20], [-22, -8, -20, 4], [44, 5, 25, 5], [26, -6, 0, -8], [-34, 1, -5, 9], [32, -1, 10, 10], [-54, -6, -4, -4], [28, 6, 8, 8], [-2, 4, 4, 10], [10, -7, -7, -7], [20, 10, -8, -2], [-20, -7, 4, -12], [-28, -1, -4, 2], [-8, 11, -5, 1], [-36, -9, -13, -7], [-48, 0, -8, 4], [40, -7, -11, 3], [-10, 9, 9, -11], [-4, -8, -7, -25], [-40, -15, -6, 10], [12, 6, 8, 8], [14, 14, 6, -2], [-12, 3, -20, -18], [22, -2, 14, -4], [22, 10, -9, 5], [14, 0, 9, -5], [4, 2, -10, -10], [-26, -11, -25, 1], [40, 10, 0, -4], [12, 8, -4, 0], [14, -6, -6, -2], [-22, 11, -1, 13], [18, 6, 6, 4], [12, 7, -9, 9], [8, 6, 10, 8], [16, 15, 30, 0], [30, 4, 6, 10], [-12, -8, -5, -1], [10, 5, 2, 14], [30, 4, 12, 12], [6, -1, 14, 2], [-12, -1, -11, -9], [8, -9, 8, 12], [-10, 2, -6, 8], [-46, -12, -26, -22], [-2, -9, -8, 0], [-50, -6, 4, 2], [-24, 1, 14, 14], [-18, 16, -6, 2], [-8, 0, -24, 8], [-20, -8, -21, -7], [-16, 2, 2, -18], [-26, 2, 18, -10], [0, 17, -9, 3], [10, 5, 21, -3], [6, -4, 12, 6], [26, 6, 16, 0], [28, 6, -6, 6], [-28, 6, -10, 0], [28, -6, -5, -1], [-12, 4, 7, -7], [6, 0, -16, 2], [-4, 11, 12, 16], [0, 2, 4, -4], [24, 6, 23, 9], [22, -1, -5, 11], [20, -13, -7, -13], [24, 12, 2, 2], [-6, -6, 18, 2], [4, -7, -29, 1], [32, 12, 13, 3], [24, 4, 2, -8], [12, 15, 20, 8], [24, 6, 0, 8], [-26, -9, -17, -7], [-8, -10, -12, 4], [-28, 0, -13, -9], [6, -14, 12, 0], [12, 8, 13, 13], [6, 17, -19, -5], [8, 12, -6, -6], [-30, -11, -19, 3], [-6, -19, -14, -2], [6, 6, 17, 19], [0, 13, 14, 14], [-38, -15, -13, 3], [0, 11, 8, 22], [-58, -14, -29, -15], [-4, 17, 7, 1], [8, -3, -18, 2], [0, 6, -19, 15], [-22, -8, -22, -2], [44, -8, 15, 5], [36, -8, -8, -6], [-32, -14, 5, 11], [-6, -9, -24, -16], [22, 4, -16, -20], [-16, -3, 22, -8], [16, 1, -13, -19], [28, 23, 17, -9], [-40, -12, -10, -6], [-2, 14, 17, 3], [-28, -1, -1, 5], [-22, -3, -5, 17], [12, -8, -2, 10], [-40, -18, -9, -1], [-22, -6, 20, 14], [2, -6, -20, 4], [-32, 9, -4, 0], [-36, 5, -11, -11], [-24, -4, -24, -8], [-24, 5, 0, -18], [-10, 0, -7, 19], [8, 5, 6, -14], [-16, -8, -20, -4], [-18, 2, 4, -12], [-8, -7, -3, -3], [36, 4, 32, 8], [16, 10, -23, -17], [-20, -7, 11, 9], [-22, 14, 0, 14], [-30, 0, 6, -2], [-22, -19, -10, -6], [-36, 8, 0, -8], [28, 17, -2, -6], [32, -7, 7, -11], [20, 1, 24, -8], [-52, -11, -30, -14], [-24, -1, -7, -17], [-6, -21, -13, -19], [-36, -12, -33, -25], [-14, -9, -1, 21], [10, 3, 14, -6], [12, -4, -7, 19], [42, 2, 6, 6], [6, -3, -19, -9], [8, 18, -6, -6], [-36, -15, -7, 11], [20, 7, 36, 12], [-4, 3, -13, -1], [4, -1, -6, -20], [-28, 3, 9, -3], [-52, -11, -25, -19], [-34, -8, 4, 18], [-16, -3, 7, 21], [10, 11, 31, 5], [8, -9, -1, -27], [10, -21, -13, -13], [32, -5, 25, 7], [12, 6, 17, 23], [14, 2, 6, -2], [8, 7, -15, -13], [-24, -20, -2, 10], [-22, -10, 8, 0], [44, 9, 11, 13], [-56, -9, -14, 0], [-2, -7, -32, 4], [-18, -9, -13, -13], [46, 4, 0, -4], [18, 2, -2, 8], [32, -8, -4, -16], [-14, -6, -9, 5], [-18, -10, 16, -8], [-8, 10, -17, 9], [-28, -2, 12, 4], [28, -7, 0, -8], [-54, 3, -1, -7], [-30, -4, -24, -16], [-30, -7, -5, -9], [24, -4, -11, 15], [-50, -1, -25, -15], [54, -9, -1, -9], [-14, 16, 6, 18], [-24, -12, -14, -2], [-4, -4, 31, 7], [8, 11, -6, -8], [10, -5, -18, -14]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_7497_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_7497_2_a_be();".
// 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_7497_2_a_be(:prec:=4)
    chi := MakeCharacter_7497_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_7497_2_a_be();".
// 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_7497_2_a_be( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_7497_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<2,R![2, -8, -5, 2, 1]>,<5,R![-4, -20, -13, 2, 1]>,<11,R![-64, -80, -23, 2, 1]>,<19,R![-32, -80, 7, 10, 1]>],Snew);
    return Vf;
end function;