
// Make newform 1773.2.a.e in Magma, downloaded from the LMFDB on 24 January 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_1773_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_1773_2_a_e();".
// 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_1773_2_a_e();".
// 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, 3, -1, -5, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0, 0], [2, 0, -5, 0, 1], [-2, 1, 5, 0, -1], [-3, -3, 5, 1, -1], [3, 3, -9, -1, 2]];
    Rf_basisdens := [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_1773_a();"
function MakeCharacter_1773_a()
    N := 1773;
    order := 1;
    char_gens := [1577, 199];
    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_1773_a_Hecke( : Kf := Kf)
    return MakeCharacter_1773_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]];
    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 := [[0, 1, 1, 0, 0], [0, 0, 0, 0, 0], [0, -1, 0, 0, -1], [-2, 1, 0, 1, -1], [2, 2, 1, -2, 0], [-2, -2, 0, -2, 1], [-1, -2, -3, 0, 1], [-2, 0, -2, 0, 1], [1, 0, 0, 1, 2], [0, -3, -1, 0, 3], [0, 2, 3, -1, 0], [-1, -1, -5, -1, 2], [-1, 3, 5, 3, -3], [-6, 0, 3, 1, 1], [-2, 3, -1, 0, -1], [2, 1, -5, 0, 0], [3, -3, -2, 5, 2], [-3, -3, 0, 1, -3], [-6, 2, -1, 0, 2], [1, 7, 5, -2, -2], [-3, 4, 2, 3, -5], [5, -3, -5, 6, 4], [1, -3, 0, 2, -3], [-4, -3, -1, 2, -3], [-10, -2, 1, -1, -1], [-1, 0, 2, -4, 0], [-5, -10, -8, 4, -2], [-1, -5, -1, -3, 4], [0, 6, 7, -1, 0], [3, -4, 0, -5, 4], [4, 6, 9, -5, 5], [3, 3, -3, 0, 1], [-10, 4, 8, -1, -5], [-1, 2, 0, -3, 2], [-7, 2, 4, -3, 1], [9, 4, -3, 0, -2], [-10, 6, 8, -1, -8], [-10, 1, 3, 7, 0], [-5, 5, -2, 6, -6], [3, 15, 6, -5, -10], [-8, -5, 6, -3, 4], [5, 1, -4, -4, 1], [8, 3, 1, 1, 7], [5, 6, 6, 0, -1], [1, 0, 0, 0, 0], [0, 7, 5, 7, -5], [4, -4, -5, -6, -2], [-8, 5, 3, -1, 5], [9, 4, 3, -3, -1], [-5, -3, 9, -1, 1], [-5, 6, 11, 6, -1], [-4, -12, -1, 10, 5], [0, 11, 3, -14, -10], [-1, -2, -3, -2, -5], [0, -4, 2, 2, -8], [-12, 6, -3, 3, -12], [11, -3, -3, -2, 4], [-2, -4, 2, 5, -7], [-7, -3, 0, -1, -9], [8, -6, -13, 1, -3], [-11, -13, -5, 11, 9], [-1, -3, -9, -1, 4], [-10, -13, -4, -4, 5], [-15, 0, 7, 0, -3], [-5, 10, 10, -8, -7], [-8, -2, 4, -7, -3], [7, -14, -13, 1, 9], [10, -5, -3, 7, 6], [-2, 9, 6, -13, -11], [10, 11, -1, -3, -10], [-9, 5, 3, 0, -6], [-8, -22, -7, 8, 11], [-6, 2, 8, -3, 1], [-3, -1, -3, -3, 9], [-7, 10, 11, -1, -6], [-6, 1, 5, 1, 1], [6, -4, 4, 0, -3], [-5, 10, 7, 2, -4], [-4, -1, -12, -10, 9], [14, 5, -2, -5, 2], [1, 8, 5, -2, 6], [7, -8, -12, 8, 8], [8, -2, -8, -6, 0], [-5, 10, 0, -1, -8], [1, -20, -11, 10, 19], [-13, 6, -1, -3, 1], [16, 10, 10, 0, -8], [-8, 1, 5, 7, -9], [-3, -2, 1, 2, -2], [6, -14, -21, -5, 13], [-4, -14, -4, 10, 11], [0, -8, -1, 3, -1], [-3, 15, 6, -8, -11], [-2, -15, -14, 16, -5], [3, -6, 7, -3, 11], [2, 9, 7, -14, -9], [14, -3, -5, -10, 3], [-9, -23, -3, 3, 16], [-4, -22, -10, 6, 7], [-5, 4, 2, -6, -12], [-14, -25, -8, 2, 11], [24, -4, -11, 2, 9], [-6, -6, -1, -1, 4], [-3, 1, -14, 7, -6], [21, 7, -4, 1, 1], [3, -15, -21, 7, 8], [17, 21, 16, -5, -3], [12, -10, -14, 6, 6], [-13, 17, 12, -11, -4], [13, -16, -23, 9, 0], [-11, 14, 2, -8, 0], [-6, -8, 9, 5, -5], [8, 26, 11, 9, -9], [-17, -20, -3, 8, 2], [-1, 15, -2, 1, 8], [-4, 14, -6, 3, -14], [-7, -2, -3, -8, -4], [-19, 2, 13, -9, -9], [0, -6, 11, -1, 4], [13, -9, -9, -7, 8], [10, -1, -6, -1, 3], [0, 1, 8, -7, -13], [-3, 4, 1, -6, -11], [3, -15, -6, 23, 14], [-24, -17, -14, 9, -3], [11, -13, -13, 1, 12], [5, 8, -9, -6, -6], [17, -8, -2, 2, 11], [11, -7, -4, 2, -6], [-5, 13, -4, -7, -10], [3, -6, 9, -8, 3], [-7, -12, -5, 23, 4], [-18, -18, -5, 8, 15], [22, 7, -5, 2, 2], [19, -6, -17, -4, 2], [-5, -15, -18, 10, 5], [25, 1, 5, 6, 1], [-13, -10, 6, 8, 11], [-12, -7, 0, 12, 6], [4, 17, 5, -6, -11], [-10, 6, 0, 4, -19], [-17, 14, 11, -8, -12], [-21, 1, -3, -3, -1], [-8, -17, -9, 0, -6], [-7, -23, -14, 22, 4], [17, -11, -2, 3, 19], [-11, -8, 12, -13, -8], [-6, -1, 7, -17, 5], [10, 12, 2, 5, 18], [-13, -5, 0, -9, 8], [0, 5, 12, 18, 0], [14, -9, -7, -10, 17], [8, -17, 7, 22, 0], [8, -17, 3, 11, 16], [-15, 9, -5, -5, 1], [13, -4, -9, 13, 11], [17, 11, 13, -12, 1], [15, 11, -12, 15, -5], [5, 1, 1, 6, 21], [-29, 7, 22, -10, -3], [5, 29, 24, -15, -18], [-28, 12, 20, 7, 5], [18, -14, -20, 1, 0], [14, -7, -35, 4, 1], [4, -11, -11, -13, 10], [3, -2, 8, -1, 9], [-9, 30, 39, -4, -20], [11, -21, -21, 18, 28], [-41, 4, -3, 2, -6], [9, -21, -12, -8, 5], [4, 20, 12, -10, -19], [28, 3, -17, 24, 1], [-6, -10, 0, 2, 0], [-14, 26, 14, -20, -13], [-2, 7, 21, -5, -25], [6, 7, -6, -5, -11], [-18, 13, 21, -12, -34], [-6, -14, -7, 11, 3], [31, -9, -15, 8, 27], [-1, -9, 21, 3, 15], [-12, 26, 38, -7, -12], [25, -6, -10, 11, 12], [-18, -24, -2, 9, 5], [1, -1, 10, 11, 6], [-7, -1, 14, -7, -6], [-2, 7, -10, 12, -10], [24, 0, -11, -2, 10], [-3, 18, -14, 8, -10], [8, -8, -6, -2, 5], [7, -17, -3, 17, -3], [-5, 15, 2, -8, -14], [10, -3, -3, 11, 4], [7, -24, -18, -3, 18], [-13, -27, -7, 2, 23], [-11, 18, 5, -36, 2], [19, 20, -2, 5, 8], [9, -22, -12, 17, 8], [16, 10, 0, 4, 2], [17, 10, 2, -11, 2], [6, 8, -7, 24, 1], [25, -14, 2, -3, 12], [8, 24, 2, -16, 5], [-9, 20, 1, -4, -22], [5, 34, 29, -7, -5], [-16, 0, -1, -3, -25], [-44, -5, -9, 1, 10], [-37, 4, 17, -12, -11], [6, 15, 20, -3, -21], [-7, -6, -26, -7, 17], [-9, 30, 41, -4, -18], [-14, -13, -17, -7, 17], [-15, 19, 4, -25, -7], [-8, -5, 4, -6, -22], [-10, -14, 4, -15, -15], [19, 19, -2, -23, -17], [20, -26, -37, 1, -3], [4, -18, -15, -11, 1], [9, -22, -17, 24, 0], [-4, -16, -19, 21, 1], [16, -4, -2, -20, -17], [26, 4, 4, 4, 21], [-5, -34, -10, 27, 6], [1, 16, -4, -17, -26], [3, 14, 7, -35, -3], [19, -9, -6, 2, 13], [14, -28, -39, -2, 3], [-38, 12, 17, 15, 4], [12, 16, -5, -16, -18], [-2, -10, -4, -29, 8], [2, -17, -7, 39, -4], [21, -14, -29, 11, 25], [4, 25, -2, 9, -14], [-4, 34, 18, -14, -12], [-15, -1, 21, 10, 20], [-7, 24, 9, 11, 15], [18, -1, -8, 18, 0], [-3, -21, -31, 0, 14], [22, 14, 4, 14, 7], [10, -4, -12, 19, 22], [12, 25, -1, 29, -9], [15, 5, 14, -16, 14], [15, 4, 4, -20, -17], [-27, -20, -18, 22, -6], [13, 16, -5, -6, -6], [16, -17, -1, -2, 13], [-6, 4, 5, -12, 5], [-17, -29, 17, -1, 15], [30, 3, -16, 5, 8], [6, 13, -9, -2, 4], [2, 35, 13, -12, 4], [28, -8, -3, -3, -5], [-7, 14, 23, -6, 10], [1, 16, 6, 15, -8], [21, -1, 5, 0, -7], [1, -12, -11, 7, 27], [6, -9, -2, 25, 2], [-4, -9, -10, -4, -1], [-32, 21, 28, -20, -2], [18, -16, -25, -7, -7], [33, 17, 0, 6, -6], [8, -7, 20, -4, 23], [-35, -29, -18, 10, 15], [17, 2, -17, 9, -1], [22, 23, 16, -9, 4], [15, -22, -6, 27, 22], [14, 0, -11, -6, 7], [-24, -2, 6, 12, -20], [11, 34, -14, -7, -14], [12, -28, -14, -13, 26], [10, 33, 28, -15, -3], [28, -19, 10, 10, 5], [-12, -7, -15, -24, 11], [-4, -18, -15, -2, -6], [11, 11, -19, 11, -13], [17, 15, 2, -3, 17], [-17, -16, -1, 16, 14], [0, -1, -1, 5, 7], [-4, 6, 29, -2, -21], [18, 9, 13, -5, 7], [-24, 1, -14, 0, -13], [28, -8, -23, -2, 12], [-25, 26, 11, -11, 8], [-8, 9, -6, -12, -16], [-7, -11, 15, -14, 10], [-10, 20, -2, 8, -19], [-12, 31, 17, 14, -12], [7, 0, 2, -1, 15], [-15, 7, -4, 17, 3], [-30, -5, 6, -1, -6], [26, -2, -20, 5, 20], [15, -8, 23, 14, -3], [9, 15, 28, -20, 12], [9, -12, 9, 7, 11], [-39, -37, -16, 17, 20], [28, 53, 37, -21, 4], [-9, 26, 30, -31, -4], [-3, 29, 19, -7, -3], [-30, 14, 43, 2, 7], [-32, 1, 18, -11, 4], [-36, 20, 24, -6, -38], [18, -13, 1, -3, 23], [-23, -4, 11, 3, -32], [18, -4, -7, 3, 13], [13, 3, -6, -1, 15], [-18, 2, 15, 4, -25], [33, 0, 20, -1, 6], [6, 3, -10, -18, 12], [-31, -10, -12, 10, -2], [-1, -3, -18, 4, 17], [-3, 6, 9, -4, -29], [-3, -5, 24, -10, -4], [5, 22, 13, -26, -28], [-1, -20, 7, -23, -8], [-47, -3, -11, 9, -10], [9, -19, -18, -10, 17], [24, 44, 1, -15, -25], [-14, -14, -8, 1, 14], [26, 26, 21, 7, -17], [5, -15, -2, 11, 28], [-6, -11, 27, 3, -22], [-20, -17, -17, 1, 21], [5, -11, -28, 1, 9], [-10, 27, 5, -36, -22], [-21, 3, 30, 15, 15], [-10, 23, 19, -21, -28], [-5, -27, -14, -3, -3], [8, 14, -7, -14, -28], [-34, 0, -16, 0, 7], [22, 44, 26, -6, -13], [-7, -26, -11, 0, 23], [-18, 6, 5, -1, -2], [-15, 23, 13, 2, -5], [27, 13, -10, -4, -15], [-45, 19, 44, -34, -12], [-15, 18, 25, -14, -12], [-3, -14, 3, 24, 7], [6, -1, 8, 4, 15], [-17, 11, 15, -6, -15], [8, -17, 7, -15, 0], [-4, -11, -14, 2, 30], [-11, -8, -5, 3, -3], [-9, 3, -24, -7, 1], [52, -20, -1, -11, 29], [3, 3, 19, 4, 12], [33, -27, -13, 20, 26], [-18, 26, 25, -11, -43], [16, -16, -17, 33, 3], [-16, 3, 22, 13, 2], [-27, 0, 18, -11, -7], [-7, -29, -35, 23, 1], [-20, 28, 5, -9, -1], [21, 1, -33, 18, 7], [-4, 11, -4, 4, -24], [-28, 37, 27, -15, -27], [10, -12, 10, -28, 2], [-11, -9, -3, 6, 14], [-28, -39, -11, -2, 10], [-22, 10, -7, 6, -12], [13, 9, 3, -7, 1], [-21, 21, -2, 15, 4], [10, 5, 11, -4, -12], [23, -3, -19, 10, 31], [24, 21, 11, 7, -11], [-32, 13, 32, 19, 7], [14, -14, 17, -8, -13], [-32, -16, -10, 11, 5], [-3, -7, -23, -4, -16], [-22, 35, 21, 3, -7], [-39, 23, -14, -11, -21], [-7, -8, 10, 11, 22], [-10, -31, 8, -7, 3], [14, -32, -31, 25, 16], [24, -15, 6, -4, 14], [-13, 20, 2, -12, -10], [-12, -41, -12, -19, 24], [-9, -20, 7, 42, 7], [31, -16, -30, 5, 23], [18, -14, -19, 15, 44], [44, -1, 6, -19, 31], [-40, -42, 5, -10, 6], [-68, 7, 1, -1, -20], [18, -22, -34, -15, 12], [2, 40, 3, 5, -28], [-20, 34, 35, -27, 1], [8, 57, 45, -4, -21], [13, -6, 0, 18, 4], [15, 4, -24, 9, -10], [36, 2, -13, 12, 26], [1, -25, -30, -1, -15], [-2, -35, -45, -4, 29], [14, -5, -3, 1, 24], [-2, 0, -12, 5, -4], [-14, 14, -7, 24, 9], [-15, 2, -16, 14, 15], [37, -9, -26, 7, -4], [0, -16, 11, 32, 13], [-8, -26, 12, 11, 24], [-38, -12, -9, 3, -11], [-29, -18, -28, 9, 19], [32, 34, 29, -11, -9], [-15, 5, 1, -16, -3], [-9, -17, 9, 0, -33], [18, -9, -24, 12, 24], [32, -6, -31, -10, -16], [6, 5, 3, 3, 24], [6, -18, -20, -17, 11], [-1, -20, -19, 36, -2], [-22, -22, 35, -15, 18], [-49, 20, 23, 8, -29], [12, 42, -2, 2, -7], [-4, -11, -16, -2, -24], [-21, -22, -14, 20, -28], [-18, 23, 36, -9, -40], [43, 30, 9, -9, -6], [-12, -14, 27, 8, -8], [-27, -32, 8, 9, 6], [36, 35, 16, -15, -4], [-45, 9, 14, 9, 21], [33, 6, 17, 5, -9], [24, 20, 3, -28, -4], [-6, 20, 7, -44, -5], [-17, 7, -16, -3, -26], [-1, -37, -10, -16, 14], [-26, -4, -28, 1, 1], [-9, -30, -27, -1, 0], [-24, -39, -14, 0, -6], [3, 16, -13, -30, 2], [4, 32, 14, -9, 7], [21, 2, 6, 36, 2], [-16, -30, -23, -2, 22]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_1773_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_1773_2_a_e();".
// 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_1773_2_a_e(:prec:=5)
    chi := MakeCharacter_1773_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_1773_2_a_e();".
// 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_1773_2_a_e( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_1773_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<2,R![1, 3, -1, -5, 0, 1]>],Snew);
    return Vf;
end function;