
// Make newform 7098.2.a.cc in Magma, downloaded from the LMFDB on 19 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_cc();".
// 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_cc();".
// 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, 0, -1], [1, 0, 0], [0, -1, 2], [0, 0, 0], [-3, 1, -1], [-2, 3, 0], [-2, 0, 1], [-2, -3, 3], [1, -3, 0], [1, 4, -1], [3, -2, 5], [-4, 2, -1], [1, 2, -2], [-1, 1, -2], [-1, 4, -1], [1, -2, -2], [12, -3, 1], [-6, 4, -8], [9, -5, 9], [1, 4, -5], [2, -9, 4], [-4, 1, -1], [1, 4, -3], [-1, 9, -7], [8, -7, 10], [-3, -8, 2], [8, -8, -5], [-6, -6, -3], [1, 3, -3], [-3, 7, -5], [6, 6, -1], [5, -3, 0], [-6, 7, -12], [-1, 9, -8], [8, 0, 2], [5, -9, -6], [-5, 1, -7], [-6, -2, 2], [-13, 6, -8], [-5, 2, 5], [1, -3, 3], [12, -8, 11], [1, 5, -3], [-2, -3, -4], [1, 3, 1], [6, 10, -7], [14, 5, -7], [7, -8, 11], [-5, 13, 6], [10, -6, 0], [0, 0, -5], [3, 3, 17], [-3, -9, 8], [-10, 11, -7], [16, -17, 11], [-6, -4, -14], [2, 2, 13], [1, -1, 6], [15, 0, 9], [13, -4, 6], [20, -7, 20], [12, -8, -6], [8, 1, -10], [10, -13, 3], [-14, 7, 0], [3, -10, 11], [0, -5, -3], [12, 2, 9], [22, -16, 20], [1, -13, 12], [10, 10, 0], [-14, 3, -19], [10, 6, 5], [-18, 10, -5], [-9, 11, 1], [3, -8, -20], [-1, 9, 7], [-1, 17, -8], [15, -18, -4], [14, 7, -6], [-11, 6, 13], [-6, 9, 8], [21, -18, 11], [-4, 2, -11], [-10, 8, 14], [8, 20, -13], [-5, 15, -13], [16, 5, -4], [-1, 19, -14], [21, -13, 3], [6, -1, 12], [3, 17, -1], [13, -17, 21], [26, -11, -6], [-4, 2, -8], [-7, 33, -18], [6, 16, 2], [22, -14, 1], [23, -4, 2], [30, -10, 23], [16, -2, 6], [-5, 14, -1], [-1, -1, -22], [9, 6, -3], [-9, 34, -21], [-18, -13, -4], [11, -1, 7], [-13, 5, -19], [-5, 2, -10], [10, -9, 0], [-2, -8, -25], [2, -10, -15], [14, -13, -5], [-4, -23, 14], [15, -7, 11], [34, -10, -3], [18, -25, 18], [22, -8, 0], [38, -6, 5], [7, 19, -9], [13, 16, 1], [10, 8, 13], [-10, -11, 17], [19, -1, -14], [-21, 2, -9], [36, -23, 37], [-23, -3, -8], [-8, 27, -16], [21, -20, 17], [9, -8, -3], [16, -8, 16], [8, -5, 25], [-30, 14, 3], [-19, -7, -1], [10, 1, 10], [-3, 23, -2], [-2, 7, -2], [16, -16, 7], [-3, 24, -13], [12, -23, 22], [8, 17, -6], [-19, 24, -6], [12, -13, 30], [7, -17, 6], [11, -7, -3], [7, -16, -12], [9, -18, 15], [-22, -15, -4], [-22, 7, -33], [-3, 2, 30], [19, -28, 29], [14, 13, 8], [34, -11, -1], [3, -9, 11], [-27, 22, -21], [17, -21, 27], [0, -10, 0], [-7, -8, -18], [-19, 30, 3], [-33, 10, -15], [40, -2, 3], [26, -15, 31], [5, -25, -10], [-1, 35, -18], [15, 5, 18], [16, -9, -18], [13, 17, 5], [-8, 27, -32], [0, 9, 13], [-28, 28, -26], [-26, 24, -32], [27, -20, 23], [37, -11, -9], [4, 10, 17], [18, -27, 26], [-22, 12, -13], [-25, -11, 18], [-15, 42, -33], [0, 5, 27], [1, -11, 29], [3, -23, 16], [-8, -6, -8], [-4, -13, 15], [26, 4, 7], [-41, 25, -39], [3, 29, -25], [-22, 23, 18], [8, -4, -18], [-15, -7, 24], [-5, 7, -1], [14, -34, -1], [-2, 16, 0], [45, -8, 7], [44, -14, 11], [-37, 29, -35], [-8, 20, -15], [21, -15, 29], [35, 3, 8], [-29, 14, 18], [-38, -5, 8], [-7, -6, -13], [8, 7, 1], [-63, 5, -13], [0, 0, 9], [-12, 10, 31], [-20, 19, 12], [-4, 0, 16], [4, 9, -12], [-30, -16, 7], [-6, -10, -11], [6, 15, 26], [10, -11, 15], [10, -49, 20], [-1, 3, -28], [31, -12, -10], [41, -22, 31], [10, -15, -24], [-26, 32, -24], [18, -30, 24], [13, -34, 5], [-28, 6, -5], [-36, 9, -20], [-11, 18, -38], [13, -7, -3], [31, -15, 2], [-32, 30, -29], [34, -3, -13], [14, 28, 3], [34, -12, 47], [49, 10, -12], [26, 4, -9], [15, -9, -15], [-7, 1, -28], [18, 3, -1], [5, -10, 14], [-28, 28, 20], [28, -24, -2], [-5, 4, -9], [-17, -22, -5], [9, -8, 20], [-23, 13, -21], [-19, 25, -32], [-50, 25, -44], [31, 1, -1], [-24, -9, -7], [-6, 1, -24], [-2, -29, 6], [-36, 13, -31], [1, 20, 18], [-25, 4, 2], [-38, 30, -48], [-37, 12, 19], [7, 16, -22], [7, -32, 14], [-13, 27, 2], [1, -24, 26], [0, 26, 23], [11, -17, 23], [-33, 13, -40], [0, -5, 12], [-23, -4, 8], [8, -52, 13], [21, 3, 2], [7, 35, 5], [-37, 9, -47], [-29, 1, 20], [21, -22, 4], [14, -8, -26], [-45, 1, -22], [0, 12, 3], [28, -38, 11], [-24, 39, -46], [-23, -37, 19], [-26, -1, -14], [40, -37, 39], [-36, -19, -7], [-12, -32, 6], [19, 4, 0], [-7, 17, 11], [-8, 24, -14], [1, -14, 6], [23, -33, 25], [-4, 12, -17], [-44, -4, 16], [-56, -1, -20], [-11, -29, 13], [-13, 33, -22], [46, -28, -10], [27, -7, 4], [24, -14, 10], [3, -8, -29], [7, -59, 25], [17, -6, 42], [-17, 27, -48], [1, 21, -11], [-13, 42, -28], [7, 30, -31], [38, 17, -3], [15, -6, 16], [44, -21, 26], [-1, -22, 38], [-6, -51, 14], [-2, 49, -22], [47, -31, 21], [44, 7, 16], [-58, 26, -49], [-17, 37, 0], [7, 11, 40], [14, -1, -27], [-37, 4, -31], [-35, 18, -48], [15, -17, -42], [46, 0, 11], [-2, 3, 8], [-37, 20, -8], [-27, 45, 2], [26, -7, 53], [-31, 48, -1], [11, -54, 15], [-1, -29, 30], [-29, 23, -31], [-23, 54, -23], [14, 0, -27], [-28, 37, -29], [55, 23, -4], [31, -12, 27], [-36, -14, 13], [4, -25, 10], [-5, -14, 15], [38, -31, 22], [-17, -21, 13], [53, -25, 54], [-7, 21, 7], [54, -8, 40], [-17, -17, -12], [-11, -6, 44], [-6, 21, -13], [2, -45, 6], [-42, 50, -49], [-29, 4, -8], [-17, 25, -54], [38, -32, 21], [-3, 50, -36], [41, 4, 31], [-36, 7, -1], [65, -13, -7], [-11, -12, -27], [58, -31, 34], [0, 14, 19], [19, -8, 27], [47, -28, 57], [14, -68, 39], [-52, 35, -38], [-22, 3, -21], [15, 15, -1], [-19, 27, 29], [-62, 3, -9], [39, -54, 48], [37, -35, 37], [28, 11, -31], [30, 34, -17], [56, -10, -15], [-44, 41, -54], [-14, 0, -16], [54, 1, -1], [-22, -10, 2], [-16, -19, -1], [-40, 27, -44], [24, -27, -28], [17, 63, -29], [-33, 41, -19], [-51, 27, 9], [-50, 24, 6], [32, -8, 13], [-44, 31, 1], [50, 3, 18], [36, -37, 58], [-79, 7, -4], [25, -5, 18], [-20, 13, -13], [72, -16, 38], [44, 17, -9], [12, 4, 19], [13, -52, 21], [-13, -41, 10], [-41, 42, -53], [19, -11, 34], [-29, 29, -13], [21, 9, -43], [41, -36, 29], [-9, 29, -32], [20, 38, -14], [28, -60, 37], [43, -60, 50], [-5, 23, 23], [84, -24, 36], [-30, 25, -31], [-4, -29, 14], [16, -39, 36], [-26, 29, -4], [8, 47, -37], [-35, 33, -11], [47, 3, -21], [-12, 6, -19], [20, -46, 28], [-3, 67, -37], [-49, -8, 15], [8, -4, -31], [21, -13, -49], [-33, 26, -46], [45, -43, 23], [-21, 2, 8], [8, -9, 8], [-4, 44, -15], [24, 6, -29], [-18, 40, 42], [5, 3, -49], [-2, -16, -2], [47, 4, 25], [28, 12, -11], [-13, 35, -5], [36, -17, 3], [-17, -20, 15], [48, -17, 53], [23, 5, 44], [-20, 36, 21], [18, -16, 10], [27, -50, -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_cc();".
// 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_cc(: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_cc();".
// 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_cc( : 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![1, -4, 3, 1]>,<17,R![7, 14, 7, 1]>],Snew);
    return Vf;
end function;