
// Make newform 1805.2.a.r in Magma, downloaded from the LMFDB on 19 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_1805_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_1805_2_a_r();".
// 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_1805_2_a_r();".
// 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, 1, 14, 5, -8, -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], [-1, 0, -5, 0, 1, 0], [-1, 9, 5, -7, -1, 1], [-6, 9, 12, -7, -2, 1], [-1, -19, -5, 9, 1, -1]];
    Rf_basisdens := [1, 1, 2, 2, 2, 2];
    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_1805_a();"
function MakeCharacter_1805_a()
    N := 1805;
    order := 1;
    char_gens := [362, 1446];
    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_1805_a_Hecke(Kf)
    return MakeCharacter_1805_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, -1, 0, 1, 0, 0], [1, 0, 0, 1, -1, 0], [-1, 0, 0, 0, 0, 0], [1, -1, 0, 0, 0, 1], [2, -1, -1, -1, 0, -1], [0, 2, -1, 0, -1, 0], [2, -1, 2, -1, 1, -1], [0, 0, 0, 0, 0, 0], [2, -1, 0, 2, 1, -2], [-3, -3, 1, -2, 0, -1], [0, 2, -1, -2, -1, 0], [4, 0, 1, 0, 1, 0], [2, 1, 1, 0, 0, -1], [4, 1, 1, -1, 0, 1], [-2, 1, 2, -2, 1, 2], [4, -1, 1, -1, 2, -1], [-8, -1, 1, -3, 0, 1], [1, -3, 1, 0, 0, 3], [-2, 2, -1, 3, 1, 1], [2, -2, 5, -2, -1, 0], [0, 2, 1, -2, 1, 2], [2, 0, -1, -2, 3, 0], [2, 0, 3, 4, -3, -2], [4, 0, -2, 5, -2, 0], [-4, 0, -5, 0, -1, 2], [-1, -2, 1, -7, 1, -2], [-2, 3, 1, -6, -2, 2], [4, 0, 0, -1, 2, 3], [-4, 0, 3, 2, 1, 0], [-2, -1, 5, -1, 0, -1], [-3, 1, 3, -2, 1, -1], [-2, 6, -2, -2, -2, 6], [-4, 3, -8, 1, -1, 3], [4, 5, 2, -5, -3, -3], [6, 5, -1, 6, 2, -1], [0, 1, -5, 3, 2, -5], [2, -3, 4, 3, 3, 5], [10, 0, 3, 5, -1, -1], [0, -6, -2, 3, 2, -5], [-2, -1, 4, -3, -3, 3], [-4, -2, 1, 4, 3, -2], [-7, 5, 2, -6, 3, -1], [-2, 3, -2, -7, 3, 5], [-2, 3, -4, 1, 1, -7], [-2, -4, -2, 4, 4, 0], [4, 7, -1, 3, -2, 7], [-10, 5, -4, -5, 1, -3], [-2, 2, 1, 3, 7, 5], [9, 6, 3, -1, 4, -6], [6, 2, 1, -3, -3, -2], [8, -4, -2, 0, -2, -4], [-2, 6, -5, 4, 1, 0], [-1, -2, 9, -5, -3, 2], [14, -5, 2, 1, 1, -5], [-14, 7, 3, -5, -2, 5], [-19, 7, -3, -10, 1, 3], [-10, 1, -7, 9, -4, -1], [6, -6, -3, 2, 1, -8], [8, 2, 1, 12, -3, 0], [6, -3, -1, 9, -2, -1], [5, 2, -5, 3, 4, 2], [-10, 1, -2, -3, -3, 3], [0, -6, 2, 5, 6, 5], [4, 1, 2, 5, -3, 5], [-2, 1, 1, -9, 0, -3], [4, -4, -5, 12, -5, 2], [10, -4, 5, -6, 1, -10], [-4, -6, -1, 2, -1, -2], [-16, 5, -8, -8, -3, 2], [9, 1, -4, -2, 1, 3], [4, 7, -5, -1, -6, 1], [2, -7, 1, 3, -2, -3], [-13, 4, -2, 5, 3, -2], [18, 0, 4, -6, 4, -2], [-2, -10, -2, 2, 6, 0], [-18, 2, -3, -10, -3, 0], [1, 0, -5, 3, 5, -4], [4, 4, 0, 2, 4, 4], [10, 1, 8, -10, 9, -1], [4, -8, -5, 11, -11, 0], [-6, -4, 11, -8, 7, -4], [-3, -5, -2, -2, 9, 1], [-6, 0, -3, -14, 11, 2], [4, 5, -3, 13, 2, 7], [-12, 4, -7, 8, -7, 4], [3, -8, 2, 1, 3, -2], [6, -7, -1, -6, 2, 3], [14, 4, -2, 10, 0, -2], [11, -1, 2, 10, 5, 1], [5, -8, 4, 5, -1, -4], [-5, 6, -3, 9, -4, -2], [20, -7, -2, 9, -1, -1], [-10, 1, 1, 2, -8, -6], [8, 5, -1, 5, -6, 5], [14, 6, 3, -4, -7, -4], [4, -2, 5, 5, 5, -3], [4, 0, 6, -9, 6, -8], [-6, 7, -11, -1, 2, 1], [15, -4, 5, -7, 10, 10], [-2, -2, 2, 2, 0, 6], [1, -4, -1, -15, 6, 0], [6, -4, 0, -16, 0, -4], [-11, 0, 2, -9, 9, -2], [15, 1, -11, 10, -8, -1], [16, -14, 0, 6, 4, -2], [0, 0, 7, 4, -5, 2], [11, 10, -1, -1, 6, 4], [8, -1, -3, 13, -6, -7], [4, -13, 4, -3, -1, 3], [14, -4, 2, 8, 6, 4], [-17, 2, 7, 11, 2, 4], [2, -1, 1, 21, -4, -1], [-14, 4, -1, -2, -7, 4], [28, -5, 9, 3, 4, -1], [2, 4, -6, 18, -4, 10], [-12, 3, -6, -8, -3, 13], [12, -9, 9, -2, 0, 4], [-13, -2, 4, -7, -9, 2], [-24, 9, -10, -9, 9, 3], [4, -7, 2, -13, 3, -1], [-2, -5, -5, -16, -4, -3], [-6, 3, 3, 3, 0, -7], [-2, 3, 9, 3, 8, 7], [-15, 10, -6, -19, -1, 4], [14, 16, -8, 6, -2, 4], [3, -7, -4, 10, 5, -1], [2, 1, 0, -12, 13, 7], [-6, 6, -1, -6, 9, -6], [3, -4, 8, -7, 1, -2], [-6, 13, 0, -3, -5, -7], [12, -2, 11, -12, 13, -2], [-14, -3, -2, 1, 3, 1], [8, 6, -3, 20, -3, -6], [12, -4, 3, 8, -3, 8], [-11, 11, -4, -16, -5, 1], [13, -3, 7, -10, 6, -5], [6, 10, 2, 18, -4, -2], [17, 8, 3, 5, -6, 0], [14, 6, -11, 6, 3, -2], [-4, -11, -3, -4, -4, 7], [-18, -1, -6, -5, 3, 11], [-16, 9, 0, 10, -7, -5], [30, -7, -2, 16, 5, -4], [-23, 15, -12, -22, -8, 3], [-21, 11, -10, 0, 1, 9], [14, -2, 11, 0, 1, 4], [-8, 9, -14, 11, -7, -1], [-10, -3, 4, -1, -1, -1], [10, -2, 0, 4, -10, 2], [-13, 18, 0, -13, -5, 0], [12, 0, -1, 4, -7, 2], [3, 1, -1, 10, -6, -9], [19, 5, -1, 2, -5, -3], [-2, 0, -1, 7, -5, 1], [-6, 5, -4, -15, 13, 5], [32, -11, 10, 27, 5, -3], [-28, 10, -2, -10, -8, 4], [-2, 7, -13, 6, 4, -7], [14, -7, 4, 9, -9, -7], [-10, 5, -14, -8, -13, -1], [15, 3, 6, -10, 4, -7], [-18, 10, -4, -4, 6, -4], [-10, 13, -1, 0, -6, -4], [20, 1, -8, 11, -11, 1], [4, 3, 4, -15, 5, 7], [2, 5, 7, -12, 10, 0], [24, 9, -3, 9, 0, -3], [2, 4, -2, 12, -16, -4], [7, 7, -5, 2, 8, 9], [-14, 4, 0, 4, -18, 6], [22, -8, 5, 8, 5, -14], [-17, 0, 0, 11, 0, 0], [10, -1, 9, -3, 10, -11], [-4, 10, 6, -32, 6, 10], [28, 2, -3, 22, -1, -6], [-19, 10, 0, -9, 2, -6], [30, 4, 2, -6, -6, -2], [22, 5, 10, -10, 3, -9], [-16, 11, -9, -2, -10, -8], [10, -3, -5, 22, -10, 3], [16, 9, 4, -6, -3, 8], [-12, 3, -11, 19, 4, 7], [0, -4, 3, 2, 5, 0], [-12, 14, -2, -16, -2, 12], [-14, 5, 12, 9, 1, 5], [-24, -17, 7, -12, 8, 1], [18, -1, 6, -7, 5, -19], [28, -10, 6, 8, 12, -8], [24, -9, 8, 5, 11, -3], [-8, 12, -2, -8, -8, 0], [22, -22, 6, 14, 10, 2], [-4, 0, -3, -19, 19, 5], [-16, 9, -4, 5, -11, -5], [17, -12, 7, -9, 1, 8], [-1, 15, -6, 14, -4, 1], [26, -15, 8, 1, 5, 7], [9, -1, -14, 22, -15, 1], [-26, 0, -2, -14, -4, -2], [-2, -2, 1, -4, 9, 8], [-16, 9, -7, -5, 4, -7], [-5, 5, 0, -4, 17, 11], [6, -3, -15, -3, -6, -3], [-10, -7, -2, -9, -1, 9], [-20, -9, 5, -20, 6, -3], [8, 0, 12, -30, 6, 6], [6, 7, -5, 19, -8, 17], [4, 3, 3, -3, 0, -5], [18, 6, 11, -2, -9, 0], [3, 4, -1, -1, 1, -4], [24, -21, 4, 17, 3, -3], [20, 17, -6, 1, -1, -5], [0, -7, -10, 14, -9, -9], [30, -1, 14, 2, -1, -10], [-1, 3, 7, 12, 9, 3], [6, -12, -9, 16, -9, -6], [18, -2, 14, -15, 4, -18], [0, 18, -4, -3, 0, -11], [9, 6, 6, -1, -4, -14], [-12, -5, -2, 2, 9, 0], [4, 8, 1, 10, -3, -8], [20, -7, -10, 16, 3, -13], [12, 0, 10, -18, 14, -6], [1, -6, -5, -25, -1, -6], [-8, 18, -4, -24, -6, 8], [31, -2, 8, 1, 11, -2], [-10, -11, -13, 10, -6, 7], [16, 12, 3, -2, -1, 12], [-30, 6, -16, 2, -6, 24], [16, 1, -15, 35, 0, -7], [28, -18, 5, 6, -15, -2], [-12, -5, 11, -15, 2, 1], [-40, 14, 5, -18, -11, 12], [10, -15, 10, -5, -13, 1], [13, 5, 5, 0, -8, 3], [4, -17, -9, 5, 0, -5], [-30, 4, -2, -9, -2, 13], [-4, 3, -4, 17, -13, -11], [10, -4, 8, -14, 26, 6], [2, 8, 3, 26, -5, 16], [12, -2, 1, 4, -1, 4], [-11, 10, -6, 9, -13, 8], [14, -4, -12, 34, -6, 2], [-22, 2, -9, 14, -5, -8], [-3, 15, -3, -12, -10, -11], [-4, 2, 9, 26, -11, -6], [10, -4, -7, 0, -17, -4], [10, -2, -9, 6, -17, 0], [-30, 16, 0, -8, 6, 0], [-16, 14, -9, 6, -5, -8], [-40, 9, 2, -12, -5, 2], [14, -6, 3, 10, 17, -4], [-5, 3, -1, -14, 8, -3], [-11, -5, 2, 0, 2, -7], [-36, 23, -22, -18, -11, 9], [-20, 15, -12, 5, 5, 1], [20, 1, 0, -7, -1, 17], [-1, -13, -10, 18, -15, -7], [-20, 22, -18, -8, -8, 8], [-26, -4, 0, -26, 2, -10], [-6, 7, 15, -29, 14, 1], [-10, 4, 3, -8, 1, 18], [2, -7, 19, -32, 2, 8], [-2, -18, -7, 9, 5, -2], [26, 9, 9, 3, -12, 11], [-8, -9, 22, -23, -9, 13], [-40, 5, -3, -13, -16, 15], [-26, -8, 9, -15, -1, 8], [4, -9, 13, -12, 2, -11], [9, -11, -3, -4, -5, -3], [-22, 5, -4, 15, 11, 13], [-15, 2, -17, 27, -13, 6], [-12, 3, -9, 13, -20, -9], [-18, -10, -9, 30, 3, 4], [6, 16, -6, -2, -6, -4], [-18, 11, 0, -27, -5, -7], [-22, 0, -4, -3, -20, -5], [-28, -4, -2, -26, -14, -6], [6, 14, -7, 7, 1, 6], [-7, 16, -28, 11, -16, 4], [10, 20, -13, 18, 5, -4], [-2, 10, 3, 3, -11, 5], [-26, 0, 6, -10, 0, -2], [-25, 6, -12, 21, -9, 18], [-2, 4, 6, -12, 14, 0], [2, -20, 17, -1, 17, 9], [32, -7, -4, 25, 7, -9], [-2, -2, -5, 32, -7, 0], [2, 4, 3, -2, 9, 6], [-4, 15, -9, -7, -14, 5], [33, -11, 4, 8, 13, -5], [-15, -11, -7, 4, -12, -1], [-16, 3, 11, -12, -2, -6], [-30, 2, -6, -26, -10, 4], [16, 18, -2, 10, -10, 16], [-6, -20, 6, -18, 6, -18], [10, 18, 4, -18, -2, -6], [32, -1, 9, 7, -18, -5], [-24, -6, -16, 20, -8, 0], [8, 13, -6, 7, -3, 7], [-8, 12, 3, 11, -27, 7], [16, -22, 21, -4, -5, -16], [4, -2, 9, -4, 3, -20], [18, -16, 11, 12, 3, -24], [16, 2, -16, 12, -14, 0], [-12, 20, -3, -22, 5, 10], [-16, -5, -15, 11, -2, -7], [-14, 7, -14, -4, 3, -8], [-4, -27, -3, -8, 24, 3], [-14, 4, -16, -8, -10, -16], [-44, 12, -18, -18, -12, 6], [-33, 9, -18, 2, -10, 9], [-3, 11, 2, -20, -11, -11], [-46, 11, -1, -9, 8, 5], [5, -6, 0, 9, 5, -12], [8, 4, 10, 18, -6, -6], [-1, -8, 12, 3, 4, 8], [30, -20, 0, 20, 4, -8], [16, -7, 8, -7, -5, -27], [12, 9, -9, 31, 6, 5], [20, -6, 3, -16, -1, -14], [24, -8, -8, -6, -4, 14], [26, 6, 5, 26, 15, -6], [-42, 26, -6, -33, 0, 10], [-9, -18, -6, -9, 5, -8], [4, -28, 7, 6, 21, 0], [30, -6, 6, 10, 4, 6], [6, -3, 6, -7, 11, 7], [22, -23, 20, 13, 5, -3], [33, -25, 17, 14, -3, -5], [-48, 16, -4, -24, -18, 14], [26, 16, -8, -5, -4, -8], [10, 16, -17, 26, 3, 0], [16, 0, -4, -14, -2, -24], [12, -8, 5, 1, 11, -15], [-6, 7, -11, 5, 8, -21], [33, -4, 22, -3, -7, -12], [-28, 33, -10, -14, 11, 15], [-8, 6, 6, 20, -14, 12], [13, -5, 22, 18, -15, -11], [-16, 17, 8, -14, 13, -4], [-4, 5, 23, -21, 20, -3], [28, 15, -7, 17, -4, 7], [-4, -8, 19, 6, -11, -4], [2, -16, -11, 30, -13, -8], [-44, -7, -4, -7, -7, -5], [20, 10, -14, -10, 0, 4], [12, -11, 0, 2, 1, -25], [-24, 18, -2, -16, 12, -8], [8, -7, -12, 27, -9, -5], [-12, 4, -2, -24, 20, 4], [-10, -12, 23, -32, -1, 0], [2, -2, 1, -28, 21, -14], [18, 0, -10, 28, -10, 4], [0, -9, -12, -4, 7, -14], [7, 0, -11, -21, -1, -8], [-28, 4, -6, -28, 8, -18], [16, 1, 17, -15, -10, -7], [20, 0, 20, -28, 10, 8], [58, 0, 10, -2, -10, -6], [21, 8, -5, 49, 2, -8], [-4, 2, -2, -20, 2, -6], [-42, 18, -11, -7, -7, 26], [13, -13, 19, -12, -1, -15], [22, 4, 21, -18, -11, -2], [25, -2, 12, 5, 1, 12], [10, -11, 5, -29, 4, -19], [-4, -2, 23, -20, 7, 4], [39, -7, 1, 24, 5, -13], [13, 2, 4, 25, -6, 22], [-10, 12, -13, -18, 1, 16], [22, 10, 2, 18, -6, 6], [-9, 21, -10, 10, -18, -11], [-30, 6, 12, -19, -6, 10], [-22, -1, -1, -11, 10, 5], [22, -24, -8, 24, -6, -4], [-16, -9, 4, 7, -19, -13], [12, 6, -7, 10, -19, 0], [-46, 19, -26, -11, 5, 3], [4, -2, 17, -1, -11, 22], [-28, -2, 6, 8, -6, 2], [1, 21, -4, -6, 9, 7], [-8, -26, 9, -20, 5, 0], [36, -20, 10, 14, 22, -2], [-14, 14, -17, 6, -11, 16], [4, -2, 21, 18, 11, 14], [-36, -2, 10, -19, 14, 1], [-2, -5, -10, -7, -15, -9], [-14, 2, -6, 0, -10, 12], [43, 9, -9, -6, 3, 1], [-9, 12, 23, 7, 0, -4], [-3, -3, -10, -44, 15, 15], [32, -20, -9, -2, 25, -10], [26, -22, 7, 2, -1, 16], [-15, -12, 18, -17, -3, 10], [-6, -23, -6, 15, -1, -13], [-14, 5, 16, -7, 13, -15], [-24, 21, -6, -3, -15, -13], [-9, 4, -20, -17, 4, 0], [36, -17, 14, 23, 11, -3], [-9, 25, -10, -10, -17, -13], [-1, 31, -8, -4, -17, -7], [-6, 3, 3, -39, -2, 15], [20, -39, 13, 22, 2, -28], [-6, -1, -1, -15, 12, 9], [39, -11, 4, 18, 1, 11], [-18, -12, -1, 16, -3, 10], [-2, 14, 6, -46, -6, -8], [8, 11, -19, -2, -6, 13], [-8, -19, -2, -4, 11, 18], [24, 1, 1, -9, 6, 5], [-2, -10, -9, 14, -3, 14], [-32, 2, -10, -4, -2, -20], [13, -29, -15, 10, 13, -9], [44, 0, 13, -16, -1, -18], [40, 3, -12, 57, 1, -3], [42, -18, 7, 23, 15, -2], [12, 1, -10, 39, -13, 23], [-12, 4, -10, 6, 14, 10], [42, -18, 5, 42, -5, 2], [-2, -12, 13, -24, 7, 18], [24, -5, -8, -8, -9, 5], [-18, 6, -29, 6, -15, 6], [-16, 18, -19, -1, 5, 31], [-4, -7, -2, 41, 5, 9], [-2, -3, 9, -7, 14, 9], [46, -8, -4, -4, 10, 4], [-10, -5, 4, 22, 5, 6], [27, 19, -10, 0, -7, 13], [4, 15, 17, -21, 16, 5], [-4, -22, -5, -6, -3, 10]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_1805_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_1805_2_a_r();".
// 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_1805_2_a_r(:prec:=6)
    chi := MakeCharacter_1805_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_1805_2_a_r();".
// 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_1805_2_a_r( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_1805_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<2,R![-4, -14, 7, 16, -8, -2, 1]>,<3,R![1, -20, 4, 28, -6, -4, 1]>],Snew);
    return Vf;
end function;