
// Make newform 7098.2.a.cf in Magma, downloaded from the LMFDB on 18 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_7098_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_7098_2_a_cf();".
// 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_7098_2_a_cf();".
// 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 := [1, -2, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0], [0, 1, 0], [-2, 0, 1]];
    Rf_basisdens := [1, 1, 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_7098_a();"
function MakeCharacter_7098_a()
    N := 7098;
    order := 1;
    char_gens := [4733, 5071, 6931];
    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_7098_a_Hecke(Kf)
    return MakeCharacter_7098_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+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 := 2;
    raw_aps := [[-1, 0, 0], [1, 0, 0], [1, -1, 0], [1, 0, 0], [3, 1, 1], [0, 0, 0], [2, -2, -1], [1, 1, -3], [-2, 3, -2], [-1, -2, 1], [2, -3, 1], [3, 3, -2], [3, -1, 0], [2, -3, 6], [-1, 4, -6], [2, 3, -1], [3, 1, 2], [-1, 0, 0], [1, -2, 1], [10, -4, 4], [6, 4, 1], [-5, 7, -6], [5, -1, 11], [9, 0, 3], [5, -7, 10], [-12, 6, -3], [-1, -3, 5], [7, -6, -2], [-6, 1, -8], [-2, 1, 0], [0, -6, -5], [-4, 4, -5], [-2, -3, -8], [8, -9, 13], [15, -5, -1], [-6, -5, 3], [-8, -2, -8], [8, -5, -1], [-4, 10, -11], [4, 4, 6], [-9, -2, -8], [-9, 13, -6], [-8, 0, 7], [-8, 15, -4], [20, -6, -1], [13, -9, 9], [-12, 8, -15], [-10, -7, 4], [13, -10, 13], [3, -13, -4], [8, -13, 9], [12, 6, -2], [0, 13, -6], [10, 2, 11], [10, 5, 5], [7, 2, 1], [-1, 6, -1], [-10, 2, 8], [2, 7, -2], [24, -1, 5], [3, 1, -6], [3, 14, 0], [-15, 15, -17], [-4, 14, 4], [1, 13, -1], [-1, -12, 13], [-3, -15, -1], [-7, 3, 14], [19, -14, 21], [-8, 19, 8], [2, -8, -12], [-10, 3, -15], [20, -2, 6], [-21, 4, -5], [-4, 1, 2], [16, -9, 18], [4, 16, -1], [-23, 16, -14], [-10, 14, -7], [2, 7, 17], [13, 0, -12], [-1, -5, 1], [-27, 13, -24], [11, -17, 15], [15, -11, 2], [-16, 15, -24], [14, 2, -12], [0, -9, 12], [6, -22, 9], [17, -19, 21], [-12, 21, -13], [-4, -6, -1], [-7, 27, -9], [-14, 14, -27], [-24, 4, -17], [17, -5, 15], [14, 6, 14], [16, -15, -1], [18, -14, 4], [-2, -3, 14], [5, 26, -8], [-4, -25, 12], [22, -12, -6], [-13, -1, -2], [14, -23, 21], [-25, 11, -24], [-7, 15, -8], [23, 5, -7], [-8, -14, 17], [26, -2, -11], [-9, 32, -8], [-1, 13, 5], [20, 3, 10], [4, 7, -4], [15, -26, -5], [-3, -13, -13], [-14, 16, -19], [-8, 23, -22], [-7, -9, -15], [6, 4, 4], [10, -9, 28], [-2, -10, -13], [5, -29, 16], [4, -17, 22], [-13, 0, -11], [4, -15, 9], [11, 5, 12], [-17, 2, -5], [-2, -9, -5], [-7, -11, -9], [9, -29, 16], [11, 15, -14], [-12, -12, 20], [21, -4, 15], [-10, 11, -18], [-16, 4, -5], [-11, 15, 23], [-10, -19, 9], [-15, -9, -1], [14, 1, 14], [-17, 5, 6], [-21, 11, -19], [-5, -7, -21], [17, -10, 30], [11, -23, 1], [2, -5, -5], [-38, 0, -15], [5, 2, 10], [3, 13, -8], [7, 3, 27], [-11, 14, -19], [-19, 2, -4], [13, -23, 0], [-7, -15, 3], [17, 16, 11], [40, -14, 9], [-23, 17, 8], [8, 16, -17], [10, 22, -14], [-21, -10, -8], [5, 3, -14], [11, 13, -22], [32, -11, -2], [-5, -12, -13], [-12, 35, -11], [2, 11, -13], [22, -25, 25], [3, 13, -15], [18, -14, 27], [-17, 25, -13], [23, -8, 9], [4, -2, -4], [-26, 12, 16], [-23, 11, -24], [-24, 2, -11], [-8, 3, 6], [3, 37, -15], [30, -31, 26], [-8, 13, -25], [1, 23, 2], [-17, 20, -3], [34, -28, 13], [2, -5, 15], [26, -18, 14], [23, -24, 11], [-22, -15, -4], [20, 8, -17], [18, 4, -15], [-21, 9, 9], [-12, 2, -24], [-20, 41, -37], [24, 0, -11], [-16, -3, -6], [2, -20, 4], [5, -21, -20], [-16, 29, -14], [16, 14, 15], [-42, 13, 16], [14, -20, 29], [14, -45, 29], [9, 2, -18], [7, 1, 35], [3, 5, 34], [3, -2, -1], [-18, 10, 3], [-20, -9, 24], [-16, -13, 12], [37, -19, 47], [-12, 4, -16], [7, 29, -15], [-22, -15, -4], [-12, -19, -2], [-21, 7, 9], [-43, 4, -19], [13, 5, 11], [20, -11, 35], [31, -20, 6], [-49, 35, -44], [-45, 19, -29], [2, 12, -12], [-40, 10, -14], [-23, -19, 2], [20, -39, 24], [13, -23, -23], [-13, -30, 20], [-30, -20, 15], [-30, 13, -1], [-26, 39, -20], [-17, -2, 23], [-16, 21, 26], [20, -33, 40], [39, -32, 34], [-24, 19, -28], [-16, 2, 13], [-24, 39, -23], [-3, -42, 23], [-57, 30, -50], [12, 0, -28], [-8, -2, 28], [-39, 15, -28], [-29, 35, -26], [-7, 18, 0], [4, 6, 33], [-36, 17, 5], [25, -41, 35], [-8, 16, -29], [-3, -46, 27], [-41, 1, 5], [-3, 23, 11], [-29, 8, 23], [-23, 16, -2], [-9, 28, -22], [8, 22, -2], [13, -27, 22], [3, -14, 24], [15, -22, 42], [12, 3, 25], [-9, -4, 12], [-42, 11, -2], [-20, 10, -19], [18, -27, -35], [1, 33, -13], [-25, 16, -38], [2, -13, -26], [2, 9, 35], [-24, 28, -3], [-22, -6, -13], [-46, 5, -3], [15, 6, 38], [14, -26, 44], [8, 23, -23], [-56, -7, 0], [42, -1, 0], [-59, 3, 13], [-10, 6, 19], [-7, -7, 13], [1, -16, 3], [-39, -14, 7], [4, 14, 8], [31, -6, -26], [30, -4, -17], [-12, -26, 8], [-27, -8, 26], [-40, 10, -29], [-40, 15, -22], [-12, 4, -16], [35, -15, 47], [6, 12, -27], [56, -25, 49], [-66, 2, 8], [-18, 49, -1], [30, -16, -10], [-9, -21, 24], [16, 44, -17], [5, -26, -20], [-34, 5, 19], [20, -24, -23], [-19, -10, 30], [7, 15, 16], [15, -16, -39], [3, 4, -6], [-15, 53, 3], [-3, 30, -20], [-19, 25, -23], [1, 7, -9], [8, -22, 23], [-15, -7, -33], [-34, 23, -16], [6, 33, -21], [16, -39, 21], [55, 0, 13], [35, 17, 6], [-9, -14, 28], [-18, 21, 9], [58, -5, 30], [33, -11, -7], [-3, -10, -42], [-40, 23, -41], [9, -32, 39], [-33, -7, 0], [53, 17, -12], [30, -31, 21], [-62, -12, 3], [39, 1, 12], [8, -7, 34], [69, -38, 69], [-30, -7, 11], [-23, 5, 14], [-58, 25, -32], [-29, 15, 17], [-61, 41, -68], [-45, 25, -21], [16, -54, 11], [-46, 27, -35], [-54, 4, -23], [6, 52, -20], [4, 15, -9], [-1, -24, 12], [37, -14, 7], [-37, 11, -13], [-22, 11, -22], [7, -4, 18], [52, -17, -17], [-60, 23, -28], [-13, -8, -2], [1, -21, 36], [33, -40, 7], [44, 4, 23], [-27, -13, -24], [3, -51, 29], [-30, 33, -20], [9, -61, 24], [59, -27, 22], [-4, 3, -22], [19, -59, 11], [-53, -6, 3], [-22, -6, -1], [-12, 18, 41], [-65, 4, -5], [-13, 36, 14], [-50, 28, -15], [-43, -4, -9], [8, -13, 20], [-20, 25, 8], [63, 11, 9], [-62, 32, -68], [9, 12, 7], [8, -12, 38], [45, 4, 37], [-23, 21, -21], [59, -23, 9], [-34, -14, 19], [-54, 10, -7], [58, -22, 31], [-6, -34, -8], [18, 33, -28], [-47, 30, -75], [51, -27, 23], [-49, 25, -61], [10, 7, 17], [36, -39, 61], [-15, 54, -21], [44, 6, -20], [-31, -18, -9], [4, -9, 30], [-55, 27, -56], [-4, -1, 29], [-33, 23, -62], [52, -19, 9], [-32, -16, 23], [-38, 42, -13], [-5, -3, -36], [28, -51, 49], [-54, -8, -26], [-4, -43, -18], [47, -10, -20], [36, 16, -19], [-8, -4, 16], [-19, -18, 27], [-27, -3, 39], [-21, 19, -7], [51, 17, 3], [45, 26, -25], [26, -32, -15], [42, -18, -23], [-8, -1, 0], [-54, 26, -18], [14, -32, 23], [25, -43, -18], [-14, -47, 16], [10, -18, 39], [-69, 18, -18], [-4, 10, 25], [-9, 34, -2], [47, -15, 23], [-28, 3, -20], [2, 25, -40], [-30, -42, 12], [4, 12, 35], [-14, 26, -32], [17, -57, 38], [34, -31, -18], [-16, 26, -25], [-37, 50, -39], [23, -25, 6], [37, -12, 29], [16, -33, -29], [6, -35, 14], [-34, 42, -12], [-17, -44, 14]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_7098_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_7098_2_a_cf();".
// 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_7098_2_a_cf(:prec:=3)
    chi := MakeCharacter_7098_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_7098_2_a_cf();".
// 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_7098_2_a_cf( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_7098_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<5,R![1, -1, -2, 1]>,<11,R![-13, 20, -9, 1]>,<17,R![41, -8, -5, 1]>],Snew);
    return Vf;
end function;