
// Make newform 8470.2.a.cy in Magma, downloaded from the LMFDB on 19 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_8470_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_8470_2_a_cy();".
// 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_8470_2_a_cy();".
// 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, 13, 26, 3, -10, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0], [-3, -20, -22, 8, 4, -1], [-6, -30, -14, 16, 3, -2], [-16, -60, -14, 21, 3, -2], [-11, 45, 41, -24, -7, 3]];
    Rf_basisdens := [1, 1, 5, 5, 5, 5];
    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_8470_a();"
function MakeCharacter_8470_a()
    N := 8470;
    order := 1;
    char_gens := [6777, 6051, 7141];
    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_8470_a_Hecke(Kf)
    return MakeCharacter_8470_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, 0, 0, 0], [0, 0, -1, 0, 0, -1], [1, 0, 0, 0, 0, 0], [-1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [-1, -1, 0, -1, 0, 1], [-2, 2, -1, 0, 0, 0], [-1, -1, 1, 1, 0, 1], [-2, 2, 0, 0, 0, 2], [2, 0, 1, 4, -1, 1], [0, 0, 1, 0, 1, 1], [-4, 0, -1, -3, -2, 0], [-4, 1, 0, -3, 1, 0], [-4, -2, 0, -4, -1, -2], [4, 2, 2, 0, -2, 2], [0, 1, 1, 2, -2, 0], [0, -2, 0, 2, -1, 1], [-3, 0, -1, 1, 2, -3], [0, -4, 1, -3, 1, 1], [3, 3, 2, 2, -1, 0], [1, -5, 3, 1, -2, 0], [0, 1, -1, -3, 5, -1], [2, 4, -1, 5, 1, 0], [-5, 4, -1, -6, 2, 2], [-5, 1, -3, -4, 3, 1], [-8, 1, 1, -3, 1, -1], [6, -1, 3, 6, -4, 2], [-7, -1, 3, 2, -1, 3], [3, -2, 2, 0, -2, 3], [-9, 2, -6, -2, 5, -2], [-9, 6, -6, 3, 3, 0], [1, -3, -1, -1, 0, -5], [0, 0, -5, 4, 4, 1], [4, 0, 0, 5, -3, -1], [10, -4, 4, 0, 0, -2], [3, 2, 1, -1, 0, 3], [-4, -1, 6, 0, 1, 3], [-1, -5, 4, -1, -3, 0], [-8, 3, 0, -7, -2, 0], [7, 2, 0, 9, 1, -4], [-1, -6, -3, -7, 3, -6], [-2, 1, 5, 5, 1, 1], [11, 2, 3, 7, 4, -1], [-5, 3, 1, 2, 6, -5], [-6, -6, -2, -4, -2, 0], [11, 2, 0, 0, 2, 3], [9, 0, 5, 3, -3, 1], [0, -1, 3, -2, 4, -4], [7, -2, -4, 7, 2, 3], [-3, 0, -5, 5, 2, 1], [-10, -6, 1, 2, -2, 1], [3, 1, -2, -2, 3, -4], [4, 3, 4, -3, 1, 3], [13, -9, 3, 1, -1, -4], [10, -6, 6, 6, -5, -2], [-1, -3, 6, -9, -4, 5], [-6, -1, 5, -9, -5, 1], [-6, 4, -3, 0, 1, -5], [-8, -1, 2, -7, 0, -4], [-9, 0, -2, 0, 1, 1], [4, -4, 2, 0, -6, 6], [-7, 4, 2, -3, 1, 0], [3, -11, 10, 1, -7, 1], [-4, 8, 2, 2, 0, 6], [9, -7, 2, -3, -3, -2], [8, 4, 9, 13, 2, 4], [-7, -6, 1, -18, 0, 2], [3, 2, -10, 4, -3, -10], [-14, 8, 1, -2, 6, -2], [0, 2, -12, 4, 2, -4], [8, 2, 3, 7, 1, -3], [-10, 2, -2, 2, -2, 4], [4, 0, 9, -3, 2, 8], [-10, 9, -2, 3, 2, 0], [2, 5, -12, -12, 2, -5], [10, 4, -1, -1, 4, -6], [-1, 4, -3, 6, -5, -4], [5, -8, 2, -1, -1, 2], [0, -3, 5, 9, -2, 7], [4, 2, -4, -5, -3, -5], [4, -5, -9, 0, 3, -2], [-14, -6, -2, 0, 4, -6], [-6, -4, 4, 8, -2, 8], [-8, -2, 1, -4, 0, -6], [7, -8, 2, 0, -6, -5], [-15, -1, 5, -2, -1, 1], [-10, 6, -6, -3, -6, 0], [-5, 9, -8, 7, 1, -1], [-8, -5, -1, -13, -3, 5], [9, -8, -2, 11, 1, -2], [-11, -3, -7, -15, 5, -10], [-20, -6, 1, -14, -7, -3], [-2, -1, 6, 8, 1, 5], [-4, 5, -2, 1, -5, 0], [7, 2, 1, -10, 2, -8], [0, -2, -4, 6, -2, 0], [3, 1, 0, -12, -1, 0], [-12, 5, -4, 5, -3, 7], [-12, -7, -7, -9, -2, -8], [14, -10, 3, -8, -1, 1], [2, -2, -9, -4, 2, -10], [-10, -1, -1, 12, 0, 0], [-10, 14, -3, 10, 8, -5], [0, 2, -6, 12, -5, -3], [-16, 2, -10, -13, 7, -1], [4, -4, 7, -4, 2, 8], [14, -1, 7, 15, -4, 0], [-15, 7, -6, 7, 1, 2], [-10, 11, 1, -7, 1, 1], [1, -4, 11, 7, 1, 5], [-2, 8, -7, 5, 6, -8], [-16, 1, -5, -20, 8, -8], [6, 7, 3, 10, -1, -1], [15, -1, 3, 7, -10, 3], [2, 12, -6, -6, 2, 6], [-11, -10, -6, -14, -3, -1], [9, -13, 0, -2, -4, -6], [10, 13, -3, 0, 8, 4], [-4, -5, 8, 13, -4, 6], [-3, 0, -7, -10, -6, -1], [-7, 4, 5, 5, 2, 9], [6, 3, -1, 3, -6, -6], [9, 1, 4, 7, -12, -1], [4, -2, 2, -2, -10, -2], [-14, -2, -2, -2, -1, -5], [7, 10, -3, -2, 1, 4], [-1, -4, 2, 12, 0, -5], [13, -2, -5, 18, 1, 4], [-18, 2, -4, -12, -10, -4], [-22, -4, -2, -4, -8, 2], [0, 11, 2, -5, -1, 9], [-18, -4, -6, -18, 0, -2], [-3, -11, 2, 8, -1, -8], [2, -10, 5, 3, 2, -2], [-15, 0, -3, -9, -5, -4], [-12, 6, 0, 15, -3, 3], [-17, 2, 0, -13, 7, -4], [22, -5, 1, 11, -6, -6], [-14, 5, -8, -2, -11, -3], [-7, 1, -13, -1, 10, -3], [9, 0, 12, 7, 4, -4], [-9, -10, 2, -4, 2, 3], [-13, -3, -16, -11, 12, -7], [-5, 1, -2, -9, 7, 6], [-3, 1, 0, -22, -1, -4], [-10, -2, -1, 8, -1, -1], [-14, -3, 12, -2, 3, 7], [26, 4, 6, 3, -4, 1], [-21, 15, 3, -5, -2, 3], [-25, -1, 4, -3, 4, 3], [4, 10, -1, 7, 2, 2], [-5, 2, 3, 4, -2, 2], [9, 7, -5, 6, -5, -1], [8, -9, 0, 15, -6, -12], [-3, 13, -8, 5, -3, -2], [3, -10, 5, 9, -6, -3], [6, -5, -9, -5, -9, 3], [-12, -3, 0, 3, -1, 13], [-10, -6, -1, -19, -3, -5], [7, -5, 6, 4, -3, -4], [-34, 4, -1, -9, 5, 7], [-6, 0, -5, -17, -1, -8], [-13, -6, -2, -3, -9, 2], [8, 4, 4, 7, -5, -3], [-17, -1, 5, -1, -3, 2], [-2, -15, -2, 5, 8, -2], [13, 2, 3, 9, -16, 3], [-10, -9, 4, -24, -1, -1], [-4, 17, -11, 6, 9, -6], [10, -5, 2, 32, -3, 3], [-18, 5, 0, 8, -6, 3], [-6, 1, -7, -3, -7, -11], [-11, 13, -2, 10, 5, -2], [19, -14, 16, 14, -11, -2], [30, -8, -5, 10, -3, -1], [-23, 13, -15, 4, 8, 1], [25, 4, 9, 13, 1, 3], [-22, -10, -1, 2, -5, -5], [-2, 8, -6, -4, 4, 6], [-1, -4, 1, 1, 0, 7], [1, 6, -4, -3, 5, -4], [-28, -6, 4, -27, 3, 9], [-24, 1, 6, -17, 0, -10], [-9, 1, -5, -17, 19, -6], [-20, 8, 0, -12, 0, 2], [-5, 5, -12, -6, 9, -12], [22, 7, 14, 27, 4, 8], [-3, 1, 0, 19, 1, 11], [28, -8, 10, -6, -5, 5], [5, 12, -3, 20, -3, 2], [10, 4, -5, -13, -5, -3], [6, 2, 7, 7, 7, 5], [-5, -6, 7, 11, -1, -2], [17, -1, 10, 38, -9, 10], [10, 0, 6, 27, -17, 15], [-20, -2, -14, -18, -6, 0], [4, -5, -7, -12, -5, -2], [-6, 11, -7, -4, 10, -4], [-26, 8, -10, -23, 9, -1], [2, 19, 5, 10, -4, 0], [-3, -6, 0, -18, -2, 3], [-2, -22, 4, -24, -4, 6], [-20, 1, 4, -20, -3, -11], [25, 0, -3, 29, 1, 1], [-4, -9, -5, -14, -5, 0], [-20, 19, -2, -12, 9, 5], [-7, 6, -7, 0, 1, 14], [-23, -3, -4, -12, 12, -13], [6, -2, -20, -5, 1, -13], [5, -2, 14, -9, -12, -4], [-10, -1, 3, 14, -5, 11], [-2, 18, -16, -10, 14, -6], [18, -3, -2, -10, -1, -7], [-1, -1, 6, -8, 0, 12], [-7, 10, -9, 22, 5, 8], [2, -7, 2, -6, 14, -3], [27, -13, 22, 1, -10, -1], [21, 12, 1, 2, 4, 10], [-2, 13, -2, 12, 7, 13], [0, -19, 7, -6, -6, 0], [-21, 20, -15, -6, -1, 2], [0, 4, 4, -24, 4, 6], [31, -5, 13, 13, 5, -2], [-42, 0, -6, -30, 10, 6], [9, 7, -5, 40, 2, 7], [-2, -6, -1, -20, 5, -11], [36, -8, -1, -7, 5, -7], [-2, -12, -8, -20, -2, -2], [-12, -10, -9, -9, 6, 6], [-1, 8, -3, 11, -7, 3], [20, 6, -8, 30, 2, 0], [-10, 15, -7, -16, 15, 2], [-18, 12, 0, -8, 6, 22], [4, 10, -10, -1, -1, 7], [17, 3, 4, 0, 0, 16], [4, -16, 1, -21, -6, -2], [-15, -4, -9, -20, 10, -2], [-18, 12, 7, 15, 0, 10], [-12, 9, -12, 4, -4, -15], [-3, 4, -18, 6, -8, -17], [7, 5, 2, 6, -6, 11], [8, 1, 7, -11, -4, -1], [-18, 2, -2, -18, 4, 0], [23, -16, 10, -12, -8, -9], [17, 3, 8, 16, -6, 17], [7, -2, 9, 30, -3, 10], [-4, 9, -1, 16, 4, -2], [2, -23, -7, -13, -4, 1], [5, -7, 3, -16, 10, 1], [-27, -5, -6, 1, 0, 1], [20, -12, 10, -2, -10, 10], [-26, -2, 8, 2, 0, 4], [-13, -14, -6, -7, 3, 0], [-5, -8, 3, 12, -6, -7], [-39, -2, 0, -1, 1, 10], [-6, 27, 6, 3, -1, 7], [-27, 18, -11, -20, 13, 10], [14, 1, 1, -20, 1, 5], [-10, 4, -16, -12, 12, -8], [-3, 1, 16, 3, -1, 8], [25, 6, 10, 23, 7, 6], [-10, 24, -10, -7, 9, 9], [-2, -9, -5, -31, 3, -11], [16, -11, -4, 12, -11, 9], [2, 10, 12, -4, -6, 10], [-6, 9, -5, -6, 13, 12], [38, -14, 9, 26, -5, -7], [-13, -2, 7, 5, -3, -8], [-17, -5, -6, -49, 7, -6], [-6, -9, -5, 4, -2, -16], [-22, -2, -6, 4, 0, 10], [-9, -15, 7, -25, -10, -8], [37, -7, 4, 8, -6, 1], [1, 1, -8, 10, 11, -4], [9, -11, 2, 5, -7, 2], [2, -6, 10, 34, -6, 2], [-39, 5, -12, 13, 7, 4], [10, 2, -10, -18, 6, -4], [44, -8, -6, 27, -2, -2], [9, 11, 1, 18, -6, -3], [-24, -4, -15, -5, 14, -16], [4, 15, -1, 23, 5, 7], [6, -5, 27, 10, -10, 16], [0, -2, 0, 4, 2, -8], [44, -5, 21, 4, -7, 7], [-14, 5, 1, -35, -7, -7], [26, -13, 1, -23, 4, -4], [26, 4, -3, 21, 0, -4], [-4, 10, -7, -18, 3, -13], [4, 6, 6, 13, -15, 3], [-20, 26, -2, -12, 2, 2], [5, 27, -4, -5, 5, 9], [-10, -22, 5, 1, -17, -10], [13, 21, -9, -10, 17, 6], [12, 15, 8, 21, -10, 2], [5, 8, 25, 29, -10, 21], [28, -10, 18, 0, -14, -2], [24, 8, 0, 26, -8, 0], [15, 24, -2, 7, -10, -12], [2, 16, -17, 14, 20, -5], [-5, -3, -3, -28, 25, -7], [32, -14, 26, -4, -14, 10], [20, 1, -9, 17, 3, -9], [1, -11, 13, 21, -16, 14], [7, -6, -1, 19, -3, 12], [15, 3, 10, 3, 3, 3], [5, 7, -11, -1, 4, 2], [13, -4, 15, 31, -10, 13], [5, 15, 8, -8, 9, 22], [-6, 5, -1, -24, 2, 8], [24, -23, 5, -6, 6, -6], [18, 0, 6, 14, -26, 10], [8, -4, 6, -23, 6, -2], [2, 2, -23, -8, 4, -20], [3, -7, -14, 3, 0, -13], [28, 3, 16, 4, -4, -3], [5, 8, -6, 19, -2, -2], [42, -9, -5, 23, -9, -3], [46, -2, -2, 39, -6, -5], [9, -28, 6, 18, -13, -11], [-28, -5, -17, -8, -1, -2], [-37, 9, 8, -25, -1, 3], [32, 7, -7, -1, -3, 7], [-15, -3, -2, -3, 18, -7], [-6, 3, -5, 3, -2, 2], [17, -6, -13, 3, 3, -17], [-6, 12, -14, -10, 16, -14], [33, -25, 1, -4, -12, 1], [-24, 1, -20, -12, 9, -1], [6, 14, -2, 22, -2, -10], [20, 10, -7, 4, -1, -9], [-4, 1, -3, 2, 8, -22], [28, -8, 3, 4, 7, -7], [-23, 11, -12, -12, 14, -8], [-16, 11, -32, -19, 7, -7], [-11, -21, -11, -32, -4, -11], [26, -12, -2, 20, -8, -14], [-44, 8, -1, -24, 8, 14], [-20, -19, 0, -10, 8, 2], [-24, 2, 0, 12, -6, 14], [-6, 6, -12, 2, -4, 8], [-22, -6, 7, -40, -2, 9], [-18, 12, -16, -2, 14, -6], [-20, -5, -11, -9, 9, 11], [-46, 0, -10, -2, 12, -8], [12, 6, 0, 1, 11, -17], [-36, -6, -12, -26, 14, -2], [13, -1, 7, -1, 13, -4], [-22, 4, 3, 40, 1, 1], [10, 11, -6, -10, 13, -7], [-10, 16, -8, -13, 2, 0], [15, 13, 14, 27, 1, 17], [-38, 18, -3, 8, 7, 11], [-2, 7, -8, -13, -14, 14], [-13, -8, -3, -32, 17, -14], [32, 10, 2, 0, 7, 2], [-10, 16, -14, -14, 8, -12], [35, 5, 3, 5, 16, -3], [-12, 17, 11, 6, 1, 7], [-12, 6, -22, 4, 14, -8], [24, 19, -8, 41, 10, -2], [-5, 11, -13, -18, 2, 5], [10, -13, 12, -6, 3, -7], [-43, 10, -3, 2, -10, -1], [33, -21, -9, -15, -3, -10], [6, -30, 3, 9, -5, 0], [-9, -13, -6, 5, 0, -3], [-28, -1, -4, 2, 5, -3], [9, 12, -4, 16, -7, -15], [-12, 15, -6, -6, 8, 3], [33, -13, 11, -14, -12, 3], [-29, -5, 0, 3, 4, 5], [11, -14, 7, 28, -13, 14], [-18, -16, -11, -38, -5, -11], [12, 3, 9, 38, -16, 20], [24, -16, 16, -22, -5, -3], [3, 20, -19, -5, -2, -3], [-23, 7, -4, -21, 27, 0], [-77, -4, -17, -31, 21, 1], [-51, 1, -9, -29, 24, 0], [-31, -1, 4, -4, 13, 10], [-38, 14, -17, -8, 6, 9], [26, -29, -12, 2, 7, -7], [-47, 5, 3, -10, 10, -11], [56, -17, -9, 18, -11, -12], [4, 19, -11, -16, 10, 4], [-16, 1, -1, -11, 15, -7], [7, 14, 8, 1, 5, 26], [-27, -21, -6, 3, -3, -18], [62, 5, 9, 54, -8, -4], [-25, 3, -7, 9, 4, -3], [28, -34, 12, -22, -12, 0], [2, -7, -12, 24, 16, 3], [33, 13, -11, 4, -6, -13], [-1, 11, 6, 30, -7, -2], [-3, -3, 1, 15, 7, -2], [19, -16, 7, 20, -29, 2], [-14, 5, -8, -8, 16, -16], [-3, 8, 9, -3, 1, -1], [-44, -10, -18, -20, 0, -18], [3, 12, -13, 19, -2, 7], [-3, -23, -6, -4, -4, -30], [31, -10, 2, -1, 1, -8], [-24, -12, 1, 7, -13, -5], [26, 6, -4, 2, -2, 20], [6, 8, 12, -2, -18, 8], [-6, 0, -6, -24, -4, -4], [-10, -20, -2, 9, 18, -8], [-29, 29, -17, 12, -8, -1], [-26, -14, -8, -33, -8, -2], [-23, 7, 8, -7, 9, -10], [10, -4, -9, 25, -6, -4], [7, -3, 9, -5, -7, -10], [17, 6, -11, -24, -2, -1], [21, -11, -14, -5, -11, -1], [59, 2, -5, 7, 4, 1], [-30, 2, -12, -18, -2, -16], [6, 22, -8, -14, 14, 2], [-16, 12, -1, -15, 3, 27], [28, 0, 19, 47, 6, 8], [-30, 22, -2, 0, -2, 18], [2, 2, -2, 32, 8, -6], [-24, 13, -4, -20, 17, -1], [20, -5, 11, 27, -2, 3], [35, -5, 9, 15, -10, -6], [9, 0, 0, 23, -23, 6], [-7, 1, -19, -9, 2, -20], [-25, 19, -11, -7, 14, 7], [-20, -1, -37, -11, 16, -15], [-3, 14, -16, 40, 12, -17], [32, 13, 26, 42, -8, 18], [-25, -19, 5, -2, -14, -1], [5, 17, -11, 34, 10, -7], [14, 6, -8, 18, 6, 6], [-6, -10, 4, -16, 2, -16], [-12, 15, -4, -2, 4, -6], [-5, -9, 7, -3, -24, 13], [-47, 6, 11, -30, 1, 6], [-13, -19, 19, 26, -23, 15], [59, -8, 21, 24, -3, -8], [50, 6, 3, 27, -13, -4], [-23, -10, 0, -29, 2, 4], [-22, 12, -20, -14, 20, -4], [-21, -9, -12, 10, 5, 4], [-2, -23, -10, -18, -16, 8], [7, -9, 21, -39, -13, 4], [10, -8, 0, -2, 26, 0], [36, 6, 4, 42, 6, -6], [-21, -14, 3, 11, -3, 0]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_8470_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_8470_2_a_cy();".
// 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_8470_2_a_cy(:prec:=6)
    chi := MakeCharacter_8470_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(3169) - 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_8470_2_a_cy();".
// 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_8470_2_a_cy( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_8470_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<3,R![-29, -45, 66, 13, -16, -1, 1]>,<13,R![484, 704, 160, -94, -32, 2, 1]>,<17,R![11, -139, -308, -183, -20, 7, 1]>,<19,R![-725, -1445, -896, -177, 20, 11, 1]>],Snew);
    return Vf;
end function;