
// Make newform 7098.2.a.bo in Magma, downloaded from the LMFDB on 26 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_bo();".
// 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_bo();".
// 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_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], [1, 0], [1, 1], [-1, 0], [0, -3], [0, 0], [-4, -1], [3, 2], [-4, 2], [-7, -2], [5, 1], [5, -1], [5, -2], [-7, 1], [-3, -4], [-3, 4], [-2, 4], [2, -1], [-10, 0], [9, 1], [2, 2], [9, 0], [-11, -1], [-3, 8], [-9, 3], [-2, -4], [-11, 3], [-13, -4], [-13, -1], [-1, -5], [4, -6], [-8, 4], [16, -2], [-2, -11], [-8, 0], [4, 3], [-8, 2], [-5, -7], [-12, -4], [-3, -3], [0, 2], [-16, -1], [-3, 3], [-8, -9], [-2, -1], [9, -9], [18, -4], [2, -2], [4, 10], [7, -6], [-3, 9], [-11, 9], [-4, 4], [-5, -13], [-6, 11], [-9, -7], [-4, 0], [-1, -5], [-4, 6], [11, -1], [-4, 8], [-8, -4], [-5, 0], [-20, -3], [19, 7], [6, 12], [-14, -12], [11, 0], [-3, 2], [20, 8], [-14, 10], [-5, 17], [-4, -10], [-3, 7], [17, -11], [31, 0], [-18, 2], [11, -6], [-18, -4], [-1, 9], [1, 9], [-8, 10], [-1, 7], [26, 8], [6, -10], [-25, 0], [-3, 15], [2, -16], [0, -4], [24, 5], [-12, 4], [-9, -8], [0, 17], [4, 6], [-5, 9], [-24, 4], [21, -5], [-6, 9], [-20, 3], [-11, -11], [1, 3], [18, -1], [-5, 5], [-7, -5], [-17, 13], [13, -9], [-7, -7], [-37, 0], [-6, 24], [-5, 25], [-17, 5], [20, -16], [19, 3], [1, -6], [-14, -7], [0, 10], [-15, -10], [-22, 1], [13, 16], [11, 14], [26, 2], [-9, 20], [45, 1], [0, -10], [-44, -4], [5, -12], [-15, 21], [10, -17], [-14, -6], [5, -12], [-8, 18], [5, 11], [19, 8], [11, -3], [-6, -14], [45, 1], [-12, -18], [5, 8], [-1, -21], [-11, -1], [-16, -22], [24, 3], [-6, -16], [6, 6], [24, 13], [20, -10], [-1, 14], [16, -2], [22, 3], [2, -8], [-35, 9], [-12, 16], [3, -13], [-12, 5], [20, -6], [27, -7], [15, 16], [-3, -4], [16, -16], [10, -10], [-10, 19], [-9, -5], [-8, -12], [0, -22], [30, -6], [18, 0], [13, -14], [24, -19], [-34, 4], [8, 0], [18, 5], [-3, -2], [-28, -10], [4, 0], [27, -11], [6, 15], [14, 4], [10, -21], [-33, 7], [8, -7], [-8, 12], [28, -4], [-24, -10], [23, 14], [-15, -17], [-12, -12], [-40, 2], [-1, -6], [-54, 4], [29, -6], [-8, -6], [-16, 0], [-10, 0], [-20, -4], [12, 0], [38, 7], [26, 15], [-12, -2], [22, 18], [-24, 15], [-24, -19], [-26, 12], [36, 0], [-7, -15], [-18, 6], [-4, 6], [-6, -18], [-30, 20], [18, 0], [20, 15], [25, -10], [-3, -3], [23, 0], [2, 2], [23, -12], [11, -17], [-29, 2], [-18, -27], [15, 15], [-2, -9], [18, 22], [6, -8], [21, -7], [-34, -1], [-3, -25], [-29, -9], [16, -19], [23, -23], [2, 20], [-24, -20], [-2, 4], [28, -13], [20, 15], [9, 29], [20, -5], [45, -16], [60, 6], [54, 13], [16, -6], [-6, -15], [2, 27], [-20, -23], [16, -2], [8, 0], [-21, 4], [-38, 23], [-41, -3], [-10, 22], [-35, -3], [28, -2], [18, 10], [-3, -16], [-52, 10], [34, 18], [-18, -8], [24, 13], [-55, 5], [52, 2], [16, 10], [31, -17], [-45, -8], [33, 12], [7, -2], [32, 5], [39, -8], [32, -26], [-52, -11], [22, -32], [-49, 7], [25, 16], [64, -2], [-14, -18], [31, -17], [7, -12], [25, -29], [5, -41], [-10, 9], [50, 6], [-16, 25], [-45, 19], [32, -22], [44, -6], [22, 3], [7, -4], [-16, 34], [-38, -20], [75, -4], [38, 23], [-4, 18], [-44, 18], [39, 18], [-23, -13], [57, 17], [-39, 15], [15, -17], [-26, 22], [9, 35], [27, -21], [-1, 39], [33, -22], [-81, 1], [30, 19], [-5, 40], [-22, -8], [-7, 27], [16, 17], [27, -20], [-20, -31], [-30, -20], [19, -33], [-8, -25], [-32, 0], [-18, -36], [-6, -14], [37, -25], [41, -21], [-3, -9], [20, 16], [-11, -35], [-12, -4], [-28, 23], [-28, 15], [-21, 33], [-44, 5], [30, 6], [38, 18], [-55, 15], [62, 12], [21, -37], [-42, -6], [-43, 23], [10, 14], [40, 10], [-13, 21], [-18, 42], [-39, 5], [28, 24], [72, 0], [-32, 20], [12, -18], [16, 12], [56, -14], [-33, 9], [64, -10], [-6, -23], [-34, -20], [8, -15], [-29, -35], [-63, 8], [-7, 43], [-67, 12], [-18, -23], [52, -18], [27, -9], [-40, -20], [0, -7], [24, 24], [49, -5], [-38, -14], [50, 6], [36, -30], [-24, 5], [-69, 17], [-2, -25], [-60, -15], [13, 24], [-31, -19], [-42, -9], [-11, -18], [-39, 20], [-10, -29], [-74, 4], [3, -20], [-22, 0], [6, 38], [26, -4], [8, -42], [-63, 3], [-38, 16], [-5, 15], [-44, 14], [38, -2], [-4, 23], [-21, -9], [24, 6], [33, 34], [72, -2], [-8, -4], [-78, 14], [56, -1], [32, 6], [-51, -15], [-30, -11], [44, 1], [60, 0], [-26, -22], [-22, -32], [42, -17], [41, 17], [18, -19], [14, -16], [-63, 15], [-14, -3], [49, 8], [-8, 48], [-56, 18], [-30, -42], [-4, 18], [7, 24], [36, -18], [-55, 1], [-8, -28], [8, 36], [44, -12], [23, -46], [35, 11], [48, 12], [-24, -18], [-29, -40], [30, -11], [-7, 6], [1, 46], [-33, -31], [-3, 9], [-4, 30], [36, 14], [69, -6], [-7, -45], [60, -12], [-30, 27]];
    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_bo();".
// 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_bo(:prec:=2)
    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_bo();".
// 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_bo( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_7098_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<5,R![-2, -2, 1]>,<11,R![-27, 0, 1]>,<17,R![13, 8, 1]>],Snew);
    return Vf;
end function;