
// Make newform 4010.2.a.h in Magma, downloaded from the LMFDB on 24 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_4010_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_4010_2_a_h();".
// 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_4010_2_a_h();".
// 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 := [-2, 0, 17, -4, -36, 17, 16, -8, -2, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0], [1, 3, -4, -1, 1, 0, 0, 0, 0], [-3, -3, 5, 1, -1, 0, 0, 0, 0], [2, -4, -4, 5, 1, -1, 0, 0, 0], [3, -5, -17, 17, 8, -8, -1, 1, 0], [4, 4, -21, -13, 25, 7, -9, -1, 1], [0, 9, 0, -34, 16, 16, -8, -2, 1], [-4, 8, 9, -30, 10, 15, -7, -2, 1]];
    Rf_basisdens := [1, 1, 1, 1, 1, 1, 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_4010_a();"
function MakeCharacter_4010_a()
    N := 4010;
    order := 1;
    char_gens := [2407, 3211];
    v := [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_4010_a_Hecke(Kf)
    return MakeCharacter_4010_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, 0], [0, 0, 0, 0, 0, 0, 0, -1, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0], [-1, 0, 0, 0, 0, 1, 0, 1, 0], [0, -1, -1, 0, -1, -1, 0, -1, 1], [-1, 0, -1, 1, 0, -1, 1, 0, 0], [-2, 1, 1, -1, -1, 0, -1, 0, -1], [-5, 2, 2, -1, 2, 0, -1, 3, 0], [-2, 1, 0, 0, 1, 0, -1, 0, -1], [-3, 2, 1, -1, 0, 1, 1, 1, -1], [-1, 0, 3, 3, 0, -1, 2, -1, -3], [-6, 1, 1, -1, 3, 0, -1, 2, 1], [-4, -2, -1, 1, 3, 0, -1, 0, 1], [-1, -1, -2, -2, 0, 1, -2, 0, 2], [0, -1, -1, -2, 0, -1, 2, 1, 0], [2, -3, 0, 2, -2, 0, 1, -2, 0], [1, -2, 0, 3, -2, 0, 0, -1, 1], [6, -1, -4, -1, -6, -1, 3, -5, -1], [3, -2, -3, 3, -2, 1, 3, -2, -2], [1, 1, -2, 0, -1, -1, 1, -2, 3], [-2, -3, 1, 2, 1, 1, -1, -1, 4], [0, -5, -2, -2, -1, 0, 1, 3, 0], [1, -3, 3, 0, -2, -2, -1, 0, 2], [-7, 1, -6, -7, 5, 8, -8, 4, 3], [-3, -1, 1, -1, 0, -1, 3, 1, 3], [-1, 2, 1, 3, -1, -1, 5, -1, 1], [3, -2, -6, -3, -1, 4, -1, -1, 0], [-1, 1, 5, 1, 0, -3, 6, 1, -2], [-5, -1, 8, 6, 1, -1, 3, 0, -2], [-4, 5, 3, 1, 1, 0, 1, 3, -4], [3, 2, 1, -2, -1, -4, 7, -2, 1], [-2, 3, -1, -1, 2, 2, -2, -3, 0], [-7, -2, 3, -1, 5, 1, -9, 2, 6], [2, -1, -5, 0, 0, 5, -6, 1, -1], [2, -2, 1, 4, -4, -1, 5, -4, -7], [-3, 10, 3, 0, 1, 0, -1, -3, -3], [6, -4, -3, 0, -5, -1, -3, -9, -2], [-3, 1, -1, 0, 0, 0, -10, 1, 2], [-4, 2, -4, 0, 7, 6, -8, 3, 0], [5, -4, -4, -4, 1, 1, -4, -1, 1], [5, -3, 0, 4, -4, -3, 2, -4, 0], [0, -2, 0, -5, 3, 3, -1, -2, 1], [-14, 5, 7, -1, 7, -2, -1, 3, -2], [-4, 4, 6, 3, 1, -3, -4, -1, 0], [4, -2, 6, 7, -6, -7, 7, -6, -6], [0, 2, -1, -1, -4, -2, 0, 0, -1], [2, -3, 2, -2, 1, 4, -3, -3, -3], [-4, 6, 9, 5, 1, -6, 9, -2, -7], [7, 1, 0, 3, -2, 0, 4, -1, 2], [-1, 9, -1, 2, -2, -4, 2, -6, -3], [1, 3, -10, -6, 1, 5, -3, 3, 4], [2, 6, 4, 5, -5, 1, 10, 2, -5], [-2, -1, -1, -3, 0, 0, -8, -5, 5], [-4, -4, -4, -5, 3, 1, -8, 2, 0], [6, -3, 0, 4, -8, -2, 8, -5, -3], [-5, 2, 1, -3, 9, 1, -8, -1, -1], [2, 4, -10, -8, -1, 6, 6, 8, 5], [4, 3, 4, 3, 3, 1, 6, -1, 0], [-4, -2, -2, 1, -2, 3, -5, -5, -4], [-7, 0, -9, -8, 4, 4, -8, 3, 7], [9, -9, -4, -2, 2, 1, 0, 1, 2], [-5, 6, 6, 1, 2, -4, 1, -2, -6], [0, 0, 2, -3, -3, -3, 1, -2, 1], [-3, 5, -4, 0, -5, -5, 6, -6, -3], [3, -5, 7, 8, -4, -6, 6, 2, 1], [-7, 6, -3, 1, 6, 9, -2, 2, 0], [-12, 5, 15, 7, 5, -4, -2, -1, -4], [4, -1, -9, -7, -10, -8, 7, -3, 3], [-2, 1, -6, -11, 8, 11, -14, 4, 7], [-7, -3, -5, -7, 11, 9, -12, 6, 4], [0, 10, 9, 7, -2, -6, 13, 5, -4], [6, -7, -5, 10, -7, -5, 7, 1, 1], [18, -6, -1, 6, -17, -11, 11, -13, 0], [4, 9, -5, -1, 5, -4, 7, -1, -5], [-8, 3, -11, -14, 6, 3, -7, 7, 3], [13, -7, -4, 5, -2, -8, -3, -6, 3], [-8, -1, 2, -5, 1, 5, 5, 3, -7], [3, -1, -2, -3, -8, -4, 8, 6, -3], [-1, 0, 0, 0, 0, 0, 0, 0, 0], [-9, -6, 3, 6, 5, 0, -4, 3, -1], [-5, 1, 2, 1, 0, -2, -3, 4, -1], [-2, -5, 3, 1, -6, 2, 0, 5, 1], [-1, -3, -8, -7, -4, 4, -13, -8, 2], [-7, 3, 3, -7, 2, 3, -12, 10, 2], [-3, -5, 3, 1, 4, -3, -2, 8, 8], [-8, 13, 4, -4, 6, 4, -7, 16, -1], [-2, -2, 14, 4, -4, 0, 2, 4, -3], [4, -12, 3, 12, -11, -9, 5, -12, -4], [1, -7, 8, 2, -4, 1, 6, 2, -1], [14, -14, -7, -3, 0, 6, -4, 1, 8], [-10, 10, 18, 1, 1, 1, 0, 11, -3], [6, -8, -10, -2, -4, -4, -8, -8, 9], [-12, 10, 6, 4, 13, 10, -6, 12, -3], [6, 4, -11, -10, 1, -1, 5, -2, 0], [7, 0, -3, -2, -5, -4, 9, 1, 5], [5, 1, 6, -1, 0, 4, 2, 12, -4], [-5, -8, 6, 7, 4, -2, -1, 1, 0], [-8, -4, -1, 1, -5, 0, -3, -6, -10], [2, 8, 7, -5, 0, 8, -2, 1, -7], [-9, 2, -9, -4, 11, 10, -5, 9, -3], [1, 5, -2, -3, 0, 0, 11, 2, 2], [-2, -3, 2, 7, -5, 3, 2, -1, -8], [20, -7, 2, 6, -8, -2, 18, 3, -1], [-15, 3, -4, -5, 10, 12, -22, 8, 6], [24, -8, -14, -1, -9, 5, -3, -10, 0], [-14, 4, -4, -3, 5, -1, -9, 0, 5], [11, -8, -7, 2, 2, 6, -8, -3, 4], [1, 5, 7, 2, 5, 2, -3, 1, -1], [-5, 7, -6, 6, -2, -1, 5, -10, 3], [10, -4, -4, 7, -6, -9, 5, -6, -3], [0, 8, 2, 12, -4, -2, 3, -6, 1], [9, 3, -17, -3, 4, 5, 1, 1, 4], [8, -15, -4, 1, -5, -3, 5, -2, 7], [-15, 11, -5, -3, 10, -1, 3, 16, 3], [-10, 5, 5, -4, -2, -1, 6, 5, 1], [7, -10, 0, -3, -3, -4, 1, 1, 2], [6, 1, 2, -5, -10, 1, 3, 5, -6], [2, 9, 0, 0, -3, 4, 10, 8, 0], [-17, 11, 16, 3, 6, -4, -5, 16, -4], [-5, -8, 3, -2, 4, -4, 0, 5, 4], [-2, -11, -8, -4, 6, 6, -5, 7, 18], [-5, 10, -3, -4, 13, 0, -10, -6, -2], [-6, 6, 6, -4, 2, 10, -4, 12, -6], [30, -19, -17, -5, -7, 6, -11, -16, 14], [-2, -15, -8, -6, 11, 2, -19, -5, 5], [-12, 9, -1, -6, 0, 1, -15, -5, 5], [-21, 7, 0, 2, 9, 7, -10, 14, 8], [13, 3, 8, 16, -13, -13, 16, -6, -14], [5, 3, -3, -5, -11, -1, -3, 3, -3], [-17, 16, 17, 4, 10, -2, 2, 11, -8], [2, -12, 3, 4, -10, -7, -6, -10, 0], [18, -5, 0, 7, 4, -7, -2, -10, -2], [-5, 0, 22, 11, 3, -2, -1, 3, -14], [-9, 1, -6, -15, 0, -4, -8, 0, 9], [2, -1, 21, 16, -4, -19, 19, -3, -1], [17, -15, 9, 11, -14, -13, 18, -12, 0], [12, -5, 2, -3, 7, 1, -9, -5, -4], [-8, 5, -3, -10, 3, 9, -1, 18, 8], [-2, -7, -6, -6, -3, -4, 3, 13, 8], [-3, 6, -6, -8, 5, 3, 5, 1, 2], [-11, 10, 14, 1, 10, 10, -7, -3, -5], [-1, -2, -10, -10, 2, 9, -3, 7, 10], [7, 4, -4, -8, 3, 7, 10, 2, 8], [-19, 4, 7, -3, 16, 13, -6, 23, 0], [-2, 5, -1, 6, 5, 5, -8, 5, 0], [-12, 6, -7, -20, 9, 5, -6, 14, 4], [-9, 7, 1, -6, 2, -2, -4, 4, 5], [-10, -4, 4, 2, -4, -4, -2, 4, -1], [-18, 3, -5, -5, 19, 10, -4, 15, 8], [-3, -10, 10, 6, 7, 1, -6, 4, 0], [-23, -5, -3, 3, 14, 1, -6, 15, 1], [-25, 11, 7, 2, 5, -2, -4, 18, -5], [1, -13, 9, 11, 0, 5, -11, 4, 7], [18, -13, -5, 2, -2, -13, -2, -6, 13], [8, 1, 9, 1, -14, -8, 10, 0, -12], [16, -11, -12, -5, -12, -5, 9, -3, 7], [13, -7, -5, -4, -16, 4, -6, -10, -4], [-8, 7, 15, 6, 14, 7, -10, 5, -7], [9, -7, -25, -12, -5, 0, 1, 3, 3], [5, -5, 5, 20, -5, -14, 18, -6, -10], [-5, 18, -1, -10, 7, 10, -2, 5, 0], [16, 7, 4, 11, 2, 3, 10, -5, 1], [-1, 5, 14, 17, -2, -2, 15, 1, -18], [17, 13, 4, 3, -5, -8, 15, -18, -13], [25, -10, -12, -1, -6, -8, -1, -23, -5], [9, 0, 0, 2, -4, -9, 10, -7, 1], [1, 11, 16, 18, -2, -13, 19, -6, -8], [-6, -5, 8, 12, 3, -10, 4, 9, 0], [8, -6, -6, -1, -16, -9, 2, -22, 2], [30, -9, -14, -1, -21, -3, 3, -14, 4], [1, -4, 12, 11, 8, 4, -8, 11, 5], [-4, -2, 7, 1, 13, 4, 3, 10, -10], [-8, -9, 6, -2, 5, 4, -17, -1, 1], [-22, -4, 15, 7, 3, 0, 7, 3, -10], [5, -18, -9, 6, -13, -2, 1, -13, 0], [-17, -2, -2, -19, 15, 4, -8, 7, 5], [-17, 13, 14, 2, 7, -15, 0, 0, 3], [-15, 4, -3, -16, 13, 12, -6, 11, 13], [9, -5, -30, -17, 1, 12, -18, 0, 9], [4, 16, 10, 3, 1, 5, 17, 10, -11], [9, -8, -1, 15, -8, -5, 18, -25, -4], [17, -18, 2, 26, 0, -13, 15, -13, 2], [-34, 6, -2, -4, 12, 2, -21, 4, 7], [11, 6, -13, 0, -7, 2, -6, -14, 10], [14, -5, -9, 5, 6, -8, -5, -13, 7], [-4, 15, 13, 2, -6, -7, 2, 5, 2], [1, 1, 6, -4, -16, -21, 25, -16, 3], [-21, 13, -1, -11, 9, 9, -3, 4, -1], [24, -17, -3, 18, -20, -13, 21, -19, -3], [-4, 14, 7, 4, 2, -5, 18, 10, -7], [3, -6, -7, 2, 6, 10, 2, 17, 5], [5, 7, 7, 6, 9, -8, -1, -14, -3], [-3, 2, 1, 6, -15, -8, 16, 3, -10], [1, -11, -7, -1, -3, 13, -13, 4, -2], [12, -7, 5, 7, -5, 6, 3, 7, 4], [4, 15, -1, -4, 4, -1, 21, 3, -5], [-3, 7, -2, -3, -7, 8, -12, -2, -4], [17, -12, -13, 0, -15, 4, 12, -13, 0], [17, -5, 3, -3, -10, -11, 9, -4, 12], [8, -24, -12, -5, 8, 1, -2, -4, 5], [-11, 6, 4, 9, 6, -12, 19, 17, 2], [-6, 6, -8, -21, 13, 5, -18, 12, 4], [-31, 18, 20, -3, 25, 0, 0, 20, -8], [-13, -18, 8, 1, 6, 0, -6, -7, -2], [15, -9, -8, 9, -7, -2, 11, -18, 5], [-8, 9, 4, 6, 1, 0, -3, -2, -18], [8, 9, -24, -19, -1, 9, -10, 1, 15], [-11, 23, 3, -7, 2, -5, -5, 6, -4], [0, -4, 5, -1, -8, -8, 11, 0, -8], [-31, 0, 6, 0, 2, 5, -1, 9, -8], [-25, -2, 11, 12, 20, 0, -6, -5, -6], [-5, 11, 8, -5, -2, 10, 9, 8, -14], [-17, -1, 6, -4, -15, 5, -6, 6, 0], [-1, -5, 10, -4, 3, -5, -10, 11, 11], [-8, -2, 14, -4, -3, -12, -10, 14, 0], [20, -4, 10, 12, -10, -4, 19, -14, 1], [-2, 3, 21, -9, -1, 8, -11, -4, -6], [-5, 16, 9, 11, -6, -1, -3, 1, -4], [17, -10, -11, 2, -19, -2, 27, -1, -17], [15, 1, -34, -20, -2, 15, -12, -5, 19], [-13, -3, 9, -8, -10, -6, -6, -16, 7], [-28, 11, 7, -12, -5, 5, -7, 15, 3], [14, -6, -12, 1, -18, -1, 16, -20, -9], [-14, 5, 3, 5, -1, 0, 0, -5, -1], [29, 3, -5, -2, -1, 0, 15, -10, -7], [1, 0, -6, -7, -15, -14, 0, -1, 6], [-7, 0, 21, 9, -1, -9, 7, -8, -1], [-35, 8, 5, -4, 18, -2, -14, 5, 6], [-3, -8, -4, -10, -6, -1, -17, 2, 0], [-13, -3, 12, -1, 3, 2, -2, 6, 0], [-24, -14, 3, -1, 2, 6, -11, -4, 3], [6, 3, 11, 2, -2, 3, 14, 9, -15], [-11, -10, 16, 21, 0, -10, 12, -7, 5], [-24, 0, 3, -14, 20, 7, -2, 26, -5], [-3, -4, -9, 4, -7, -2, -4, -9, 14], [40, -9, -23, -13, -22, -4, 16, -6, -1], [8, -3, 0, -8, -4, 12, -5, 9, 2], [-6, 9, 20, 19, 9, 7, 2, -5, -13], [3, 0, 9, 4, -9, -4, -13, -17, -4], [-22, -2, -7, -9, 16, 18, -21, -8, 0], [5, 2, 4, 6, 17, 1, 5, 1, -8], [-17, -1, 14, 11, 25, 2, -8, 16, 4], [19, 17, 4, -6, -12, -3, 10, -15, 3], [9, -7, -27, -9, -6, -1, -11, -4, 8], [-21, 11, -2, -14, 29, 17, -20, 20, 2], [0, 15, 6, 14, -2, 0, 8, 1, -10], [8, -24, -20, 2, 1, 16, -11, 1, 7], [34, -13, -24, -7, -12, 5, -10, -23, 9], [-21, 14, 0, -7, 6, 4, -4, -3, -16], [15, -17, 0, 4, -8, -3, 7, -7, 5], [-36, 14, 17, -2, 11, -11, -4, 12, 4], [-16, 8, 4, -6, -1, -8, -16, 12, -1], [-5, -13, 11, 15, 12, -5, 6, -1, -5], [-38, 2, -2, -3, 13, 19, -22, 4, 3], [40, -15, -24, -1, -10, 13, 8, -21, 4], [-5, 8, -1, 9, -1, -13, 14, 13, -7], [-25, 10, 21, -6, 10, -14, -13, 1, 0], [23, 9, 10, -1, -6, -12, 8, -17, -1], [-15, 5, 13, 9, 9, -3, 12, 23, -17], [6, 3, 3, 9, 4, -6, -5, -10, 9], [13, -14, -13, -11, -10, 9, -7, -18, -9], [54, -10, 4, -1, -21, -11, 17, -26, -2], [18, -20, -4, 8, -14, -2, 6, -14, -5], [-16, 12, 10, 8, -7, 0, -13, -12, -8], [-6, 14, 0, -1, 16, 9, -8, 20, -5], [-14, 5, -3, -3, -1, 4, 6, 13, -2], [-2, -3, 4, 3, -11, -3, 17, 13, -5], [13, -12, -22, -14, -11, 7, 0, -5, -6], [-6, 1, -5, 16, -4, -7, 7, -10, -10], [28, -4, -5, 11, -19, -2, 13, -17, -8], [-18, 4, 21, 16, 4, -7, 6, 28, -11], [-3, 11, 9, -8, 1, -14, -3, -3, 8], [-19, -7, -9, -7, 10, 1, -23, 12, 0], [-28, 9, 6, -10, 20, 18, -10, 35, 11], [-5, 2, 0, 4, 10, -17, 16, -3, 14], [16, -11, 17, -1, -21, -2, 6, -9, 1], [9, 12, -7, -9, 3, 15, 7, 11, -3], [-35, -1, 4, 11, 18, 0, -16, 8, -4], [15, 0, 4, 16, -19, -17, 21, 5, -6], [12, 7, -7, 16, -2, -5, 3, -3, -7], [21, -4, -18, -5, 16, 18, -26, -10, 13], [-16, 7, 8, 7, 12, 5, 11, 17, -18], [-10, 5, 15, 26, 2, -7, 3, 0, -1], [-25, 6, -8, 4, 4, -1, -24, 3, 8], [19, 6, 5, 12, -4, -8, 6, -27, -14], [1, -20, 20, 7, -9, -4, 17, -3, -7], [-18, 11, -3, -23, 16, -2, -10, 16, 9], [-5, 13, -11, 5, 19, 13, -7, 24, 1], [-9, 2, -17, -10, 6, 10, -19, -9, -9], [-5, -5, -8, -3, -3, -2, 22, -6, 17], [-23, -9, 31, 21, 21, -5, 1, 24, -4], [-13, 15, 0, 2, 8, 1, -1, 18, -4], [-22, -3, 23, 3, 11, -20, -19, 12, 6], [-2, 2, -22, -28, 17, 24, -28, 2, 7], [-16, 17, -4, -3, 16, 7, 6, 25, -14], [6, 6, -2, -10, -6, -6, -1, 18, 0], [-16, -11, 2, -8, 8, 6, -19, 13, 17], [28, -11, -11, 0, -13, -7, -1, -3, 8], [11, 11, -5, 0, -15, -6, -2, 8, 3], [36, -21, -30, -4, -7, 2, 2, -19, 7], [5, -17, 13, 20, -21, -8, 15, -9, -4], [-25, 2, -7, -10, -4, 22, -15, 1, -6], [-2, -10, 0, -9, -7, -17, 20, -4, 14], [14, 12, 12, 8, -6, -10, 9, -10, 3], [1, 23, 3, 0, -6, -18, 24, 2, -11], [5, -12, 12, 30, -14, -13, 18, -26, -18], [33, 7, 8, 0, -14, -7, 10, -32, -11], [-35, -17, -7, -9, 8, 9, -31, 12, 18], [-3, 10, 3, -18, -1, 0, 1, 11, 19], [-22, 24, 2, -7, 10, -3, 6, 13, 1], [27, 8, -1, 5, -9, 7, 1, -19, -4], [-33, 2, 3, -2, 14, -8, 6, 25, 10], [7, -17, 1, -4, -24, -14, 0, -10, 0], [-19, 16, -5, 11, 11, 7, 7, -13, -10], [-47, -2, -6, 3, 21, 10, -10, 9, -8], [9, -3, -9, 13, -12, 5, -5, -4, -4], [23, -10, -9, -1, -6, 15, 10, 7, 5], [14, -4, -2, 19, -13, 3, 22, -4, -13], [-9, 19, -10, -8, 0, -13, -8, 3, 7], [41, -13, -19, -8, -16, 18, -4, -22, 7], [-16, -9, 14, 12, -1, -10, 9, 1, 10], [4, -13, -5, 10, -1, 7, -4, 10, 0], [-22, 15, 14, 7, 0, 15, 8, 7, -21], [16, -1, -4, 1, -9, 1, 6, -19, -19], [14, -12, -17, -4, -5, 3, -19, -5, 1], [-7, -12, -9, 7, -2, 1, 9, 9, 18], [-3, 7, 13, 32, -16, -10, 23, -4, -9], [-49, 9, 15, 5, 16, -1, 4, 14, -8], [20, -7, -16, 0, -13, -20, 6, 2, 15], [24, -7, 6, 10, -25, -20, 31, 8, -1], [39, -17, -21, -16, -29, -6, 7, -16, -1], [5, -11, -5, 8, -13, 20, -15, -4, -3], [-4, 8, 3, 5, 1, 8, -23, -20, -13], [-7, -4, -2, -14, 18, 15, -41, 14, 21], [17, -7, -14, 15, 2, -14, 9, -8, 6], [-15, -2, 11, 3, 7, -3, -21, -22, 21], [11, -7, -5, 3, 4, -5, 7, 16, 15], [28, 15, -6, 5, -11, 9, 16, 4, -9], [-41, 2, -3, -28, 27, 20, -30, 35, 27], [41, -19, -18, -3, -5, 4, -2, -7, -4], [-6, 23, 1, 10, -4, -3, 13, -11, -9], [-14, 7, 16, -5, -8, 3, -11, 11, -3], [-10, 2, -9, -16, 14, 1, -13, 10, 17], [-17, -4, 1, 1, -1, 3, 19, -1, -23], [25, 7, -3, 16, -29, -10, 9, -28, -13], [31, -1, 19, 36, -10, -18, 40, -8, -24], [-11, 1, -10, -11, -5, -12, -16, 8, 1], [37, -15, -8, -6, -20, -3, 16, -19, 12], [-15, -8, -1, -6, 5, -18, -4, -1, 15], [6, -6, 11, 15, -15, 2, 24, -2, -4], [26, -18, -10, 6, -2, -6, 7, -28, -8], [33, 8, 16, 7, -7, -4, 15, -25, -10], [-27, 33, 31, 4, 7, -8, 4, 22, -10], [4, -3, -37, -28, 4, 9, -23, -12, 19], [7, -1, -16, -6, 11, 7, -2, -10, 18], [-3, -3, 8, 7, 3, 8, 3, 9, -10], [-21, 10, 3, 0, 5, -4, -24, 15, -9], [5, -16, 5, 4, -6, -8, 21, -9, 11], [28, -13, -9, 26, -20, -27, 18, -29, -8], [9, -7, -11, -13, 5, 7, 8, 9, 8], [6, 5, 9, 18, -5, -15, 37, -4, -10], [-33, 6, -6, -32, 12, 17, -10, 39, 12], [-19, -11, -11, -20, 1, 8, -35, -2, 9], [35, 10, -33, -27, 7, 15, -12, 1, 11], [-9, 0, -3, -14, 9, 10, 4, 18, 11], [2, -36, -20, 8, -5, -4, 4, -7, 25], [6, -16, -5, -1, 11, 20, -12, 9, 3], [-5, -9, -14, 1, -10, -4, -13, -17, -3], [10, -13, -5, -10, -7, -5, -11, -25, -10], [2, 13, -22, -12, 6, 14, 14, 19, -11], [3, 26, -4, -10, 19, 1, -9, -5, -3], [5, -17, -21, -14, 2, 4, 10, 9, -1], [13, -9, 3, 11, 8, -1, 8, 0, -1], [-1, -13, 9, 12, -4, 0, 10, -6, -15], [-8, 28, 25, 6, 1, -9, 1, -6, -32], [3, -27, -3, -1, 17, 13, -32, 10, 4], [-33, -8, -12, -16, -7, -7, 2, -1, 7], [-35, 19, 20, -7, 18, 10, -8, 7, -8], [28, 5, -17, 7, -1, 4, -4, -7, 0], [-27, -4, 9, 4, 5, -8, 21, 4, 8], [6, 11, 4, 13, -13, -3, -1, -19, -9], [-48, 22, 19, 0, 33, 7, -13, 29, -6], [9, -21, -21, 8, -5, -14, -20, -4, 10], [-11, -11, -9, 5, 1, 1, 2, -5, -4], [-55, -12, 1, -7, 19, -9, -21, -1, 18], [17, -2, -16, -15, 8, 24, 3, 11, 17], [-34, -4, 7, -14, 19, 3, -43, 16, 21], [24, -10, -1, 1, -17, 4, 27, -3, -12], [-43, -5, -4, -22, 15, -5, -19, 7, 29], [-6, 2, 11, 28, 8, -23, 36, 1, -5], [14, 5, -1, 17, -20, -6, 9, -19, -25], [-5, -7, 6, 2, 4, -17, -3, 16, 5], [3, -16, 11, 9, -7, -5, 16, -3, -11], [59, -21, -32, -1, -37, 0, 2, -32, -1], [-52, 2, -14, -7, 24, 19, -17, 12, 19], [-42, -9, -2, -6, 28, 2, -35, 17, 8], [-30, 42, 17, -14, 24, 27, -13, 24, -18], [18, -12, 17, 21, -4, -14, 34, -6, -2], [16, -10, -1, 23, -24, -14, 22, -34, 3], [0, -22, -13, -3, 25, 4, 0, 2, 3], [7, 38, 7, -10, -6, -10, 11, -3, -8], [23, -13, -7, 8, -9, 10, 22, 17, 9], [-32, 16, -15, -8, 23, 15, -43, 12, 4], [2, -26, -3, -10, 7, -5, 19, 13, 9], [27, -10, -13, -1, 6, -9, 15, -31, 1], [11, -16, -28, 0, 14, 21, -10, 1, -1], [-34, -8, -32, -35, 14, 5, -40, -2, 22], [39, -15, -20, 17, -25, 0, 13, -20, -16], [-32, 0, -17, -1, 6, 10, -10, 26, 15], [42, -26, 10, 1, -24, -3, 13, -10, -3], [26, -4, 4, -5, -10, -7, 2, -9, -13], [-43, 7, 34, 6, 23, -5, 8, 29, -4], [-29, 27, -6, -9, 25, 4, -10, 30, 2], [-2, 5, 9, 0, 2, -1, -12, -15, -6], [-41, -1, -10, -5, 26, 24, -27, 28, 3], [-45, 8, -4, -4, 15, 1, -3, 13, -3], [25, -27, -4, 7, -10, 10, -3, -18, 3], [-7, 27, 24, 10, -9, -33, 31, -8, -11], [-13, 19, 20, -7, -1, -6, 0, -10, 12], [0, -3, 12, 14, -2, -6, -1, -10, -33], [9, -15, -42, -17, -2, -8, -19, -26, 13], [-25, 19, 31, 2, 22, 10, 14, 28, -6], [-35, 24, 20, 13, 14, -6, 16, -2, -25], [-13, 22, 14, -25, 2, 10, -14, 21, 2], [-27, 22, 0, -13, 13, 14, 19, 25, -5], [55, -31, 0, 20, -29, -19, 18, -39, -2], [-52, 10, 13, 6, 43, -9, -2, 32, 10], [-17, 8, -25, -26, 19, 28, -26, 29, 18], [-9, 11, -19, -14, -1, 10, -35, 4, 18], [4, 14, 22, 4, -13, 2, 21, 2, -8]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_4010_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_4010_2_a_h();".
// 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_4010_2_a_h(:prec:=9)
    chi := MakeCharacter_4010_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_4010_2_a_h();".
// 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_4010_2_a_h( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_4010_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<3,R![2, 0, -17, 4, 32, -3, -20, -2, 4, 1]>,<7,R![8, 112, 311, 269, -52, -189, -80, 2, 7, 1]>,<11,R![-388, -376, 1261, 1403, -19, -413, -97, 25, 11, 1]>],Snew);
    return Vf;
end function;