
// Make newform 2695.2.a.j in Magma, downloaded from the LMFDB on 25 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_2695_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_2695_2_a_j();".
// 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_2695_2_a_j();".
// 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, -4, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0], [0, 1, 0, 0], [-1, -4, 0, 1], [-1, 3, 1, -1]];
    Rf_basisdens := [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_2695_a();"
function MakeCharacter_2695_a()
    N := 2695;
    order := 1;
    char_gens := [2157, 1816, 981];
    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_2695_a_Hecke(Kf)
    return MakeCharacter_2695_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, -1, 0], [-1, 0, -1, 0], [1, 0, 0, 0], [0, 0, 0, 0], [1, 0, 0, 0], [-1, 0, 2, 0], [-1, -1, 0, 1], [0, 3, 2, -1], [-2, -1, 0, 2], [-2, 2, -1, -1], [2, -3, -4, -2], [-2, 4, 3, 2], [4, 2, 4, 3], [-1, 4, 3, 5], [-4, -2, 0, 1], [-7, -2, 1, -1], [5, -1, 5, 2], [-1, -1, -3, 1], [-4, -1, 3, -6], [-3, -4, -3, -4], [0, -4, -5, -2], [0, 1, -1, -5], [4, -7, -4, -2], [7, 3, -3, -6], [-5, 0, 0, -3], [3, 5, -4, 2], [1, 9, 10, 2], [-2, -2, -7, -4], [-3, -2, -1, 6], [-12, -1, -1, 1], [5, 6, 2, -3], [2, -10, -6, -9], [-7, 8, 0, 4], [-4, 7, 1, 4], [2, -2, 7, 2], [4, 2, 0, -5], [-9, -3, -2, -3], [-7, 3, 5, 9], [-3, -5, -7, -1], [-7, 10, 3, 6], [-10, -10, -11, 0], [5, -13, -4, -6], [-5, -7, 7, 3], [2, -1, -6, -12], [-2, -12, -8, -6], [17, 7, 11, 2], [-7, -1, 3, -1], [-13, 14, 3, 4], [1, -2, 5, 3], [-4, 8, 4, 4], [-11, -2, -3, 2], [-4, 8, 3, 7], [-12, -2, -7, -5], [-10, -7, -8, -1], [9, -4, 0, -2], [-13, -1, 6, 10], [0, 2, -5, -4], [1, -4, 2, -5], [13, -3, -1, -5], [-24, 1, 0, -1], [-1, -10, -11, 5], [-10, -1, -8, -2], [9, 8, -9, -5], [2, 6, -7, 8], [6, 13, 5, -6], [-6, -5, -10, -10], [-17, 2, 4, -2], [0, 8, 7, -3], [8, -14, -11, 1], [8, -5, -3, 1], [-4, -11, -12, -10], [-3, 6, 8, 4], [1, -4, 10, 6], [-5, -13, -15, -2], [-1, -9, -3, 5], [-8, -4, 5, 11], [1, 6, 4, -4], [12, 8, 8, 9], [-9, -1, -2, 10], [-1, -1, 8, 9], [4, 5, 10, 11], [-8, -18, -13, 1], [0, -3, -5, 5], [-15, 4, 3, 2], [10, -4, 4, -2], [-1, -7, -7, -7], [5, 2, 0, 4], [3, -7, 16, 2], [0, -6, 1, -4], [10, -8, -9, -12], [10, -4, -4, 0], [2, 8, 9, -2], [9, -16, -14, -3], [-7, 8, 8, 11], [0, -8, -13, -15], [10, 9, 1, -11], [5, -12, -15, 1], [-8, -12, -9, 1], [10, 6, 7, 4], [8, 10, -4, 4], [0, 3, -11, -4], [0, 0, 4, -3], [-4, 16, 2, 1], [-9, 4, 11, 17], [30, -7, 3, -3], [-16, 12, 3, 9], [-6, 0, 16, 17], [-22, -4, -1, -4], [-10, 1, -10, -5], [-13, -1, 1, 8], [7, 15, 17, -9], [3, 1, 19, -2], [6, 19, 23, -2], [5, -10, -2, -13], [-4, 0, -2, -4], [-27, 1, -3, 4], [-21, -7, 3, 11], [-14, 17, -4, 3], [-3, 12, 12, 9], [11, 11, 17, 3], [-25, -4, -3, -2], [7, -19, -3, -6], [-8, -5, -13, 1], [9, 19, -1, -10], [-15, 8, 3, 12], [-5, -10, -24, -6], [8, -6, 11, 4], [-19, -5, -17, -3], [-13, -13, -14, -15], [-7, -5, -17, -5], [-11, 1, 3, 9], [8, 4, 17, 6], [-10, 19, 3, 5], [-2, 10, 6, -6], [10, -22, -15, -2], [-13, -8, -17, 10], [-10, 6, -13, 3], [-7, 10, 13, -8], [7, -23, -7, -6], [-16, -8, -2, 5], [-9, 6, -18, -1], [-31, 6, 6, -8], [-13, 16, -17, 1], [24, 15, 14, -2], [-3, -9, 6, 7], [-25, -2, 2, 6], [2, 6, 8, -1], [-16, 21, 16, 18], [-3, 10, 13, 2], [2, 6, -16, 0], [-12, -10, -13, -11], [-3, 0, -2, -15], [24, 17, 4, 0], [-11, 4, -4, -6], [-2, -14, 1, 8], [15, -9, 25, 4], [5, -1, 16, 18], [-5, 17, 23, 26], [-7, 28, 6, 0], [-8, 15, 10, -12], [-5, 22, 15, 24], [-33, 2, 6, 7], [32, 5, 12, 10], [4, -7, 0, -9], [4, 13, 8, 6], [-7, 18, 10, -11], [-1, 25, 0, -1], [10, 5, -17, -18], [-3, 6, -4, -7], [13, 12, 1, -7], [-26, -15, -7, -11], [0, -3, 0, 11], [14, 5, 21, -2], [-18, 4, 8, 11], [33, -22, -14, -6], [19, 19, -8, -1], [22, -8, -12, -6], [13, 16, -3, -4], [-15, -15, -4, 3], [12, -28, -18, -20], [11, -7, 5, 17], [26, 6, 12, 4], [-4, 6, 23, 7], [9, -5, 6, 13], [-3, 3, -22, -8], [7, 14, 7, 20], [-2, -16, -6, 14], [0, -4, -14, 20], [-2, 7, 22, 17], [-2, -12, 0, -8], [-1, -3, 18, 0], [-22, -21, -24, -10], [7, -15, -12, -8], [-4, -11, 10, 8], [7, 16, 11, -8], [-23, 7, 16, -9], [-24, -20, -19, -15], [-4, -8, -21, 1], [18, 21, -1, -16], [-3, -1, 15, -3], [9, 13, 0, 5], [-27, -27, -19, 10], [-2, 20, 27, 7], [-3, 32, 12, 12], [5, -16, -10, 17], [-10, 11, 17, 7], [-10, 3, -9, -9], [-8, 11, 4, -10], [12, 16, 0, -11], [15, 14, 7, 22], [22, -27, -2, -7], [6, 9, 1, -4], [19, -12, -6, 9], [-12, 9, 10, 13], [-4, -9, 0, -2], [-11, -24, -15, -13], [19, 12, 6, -5], [-22, 4, 20, 16], [-14, 12, 3, -8], [-9, 46, 30, 1], [10, 7, -21, -10], [-5, -18, 14, 17], [-35, 3, -9, -11], [-29, -4, 8, 8], [9, -27, 0, -6], [19, 9, 14, -8], [-13, -21, -11, -17], [6, 14, 6, 3], [-39, -21, -1, 15], [25, 17, 3, -4], [22, 6, 1, -15], [23, 1, 0, 5], [13, 13, 32, 11], [-26, 21, 23, 6], [-15, -10, -3, -3], [48, 6, 20, 9], [29, -3, -20, -19], [23, 10, 17, 25], [-6, 3, 13, -20], [-16, 9, 12, -14], [13, -28, -11, -5], [-21, -24, 11, 8], [27, 15, 38, 8], [15, 6, 5, -6], [14, -9, 0, 2], [13, 13, -9, 10], [22, 11, 3, -5], [-2, -4, 25, -1], [14, 15, -4, -14], [-13, 4, -12, 14], [1, -11, 4, 23], [-20, 35, 10, 11], [-18, 29, 0, 14], [9, -37, -21, -17], [42, 10, 16, 2], [31, 1, -4, 21], [1, -30, -25, 6], [10, 2, 24, -7], [-9, -8, -25, -2], [-9, -4, 27, 18], [-1, -23, -20, 8], [-13, -18, -7, -6], [13, 28, 31, 5], [2, -21, -27, -20], [-6, -12, -5, 1], [26, 10, 0, -16], [-36, 6, 4, 8], [19, 6, -7, 1], [24, 8, 6, -14], [18, 4, 5, 6], [-8, 3, -13, -4], [-6, 19, -18, -10], [-16, 13, 3, -11], [16, 11, 10, 21], [-10, 1, 2, -15], [33, 4, -2, 23], [23, 5, -11, 4], [-2, -3, -21, 11], [-3, -10, 14, -13], [-27, -21, -14, -26], [21, 20, -8, 17], [-16, 22, 15, 19], [28, -1, -2, -17], [25, 21, 28, 3], [-40, 9, -12, 3], [-12, 25, -10, 0], [-32, -6, -18, -21], [-6, -18, -22, -9], [0, -5, -29, 17], [38, 12, 30, 2], [-8, -13, 8, -11], [-29, -22, -30, 12], [24, 21, 46, -3], [28, 13, 16, 2], [-21, -33, -31, -8], [4, -26, 23, -12], [19, -31, -16, -17], [17, 24, 20, -3], [-12, 25, 15, -8], [24, -1, 3, -23], [-4, 2, -7, 24], [12, -13, -7, -7], [-17, -19, -30, -11], [-9, 15, 16, 24], [12, -21, 27, 10], [-24, -19, 19, 15], [-28, -3, 0, 12], [26, 12, 14, -2], [16, -4, 10, 2], [26, 15, 4, 17], [-6, -25, -17, -40], [15, 22, -20, -15], [2, -13, -12, -4], [34, -20, -19, -20], [23, -14, -12, 4], [54, -6, 12, -2], [-5, 9, 7, 13], [14, 33, 24, -9], [14, 19, -3, 28], [-40, -22, -29, -1], [-13, 36, 17, 0], [5, 24, -1, -5], [29, 26, 38, 17], [29, -13, -5, -14], [-5, -3, 20, -6], [24, 15, -7, -13], [-23, 26, 16, -3], [-8, 0, -22, -3], [22, -23, 3, -16], [12, -20, -13, 11], [15, -3, 2, -3], [-8, -30, 12, 10], [19, 28, 8, 5], [19, -44, -28, -25], [32, -35, -11, 3], [-38, 7, 23, 12], [12, 2, -12, 15], [48, 26, 54, 22], [23, 17, 7, 27], [26, 12, -10, -23], [51, 5, 8, -2], [-13, -8, -43, -11], [-10, -33, -30, -32], [-1, -31, -6, -24], [-17, 3, -4, -14], [-20, 0, -38, 3], [29, -33, 7, -9], [-44, 14, 4, 19], [-41, 9, -15, 9], [-33, -7, 4, 1], [37, 13, 4, -6], [-2, 10, 2, 32], [4, 13, 15, -20], [28, -17, -3, 3], [4, -33, -19, 7], [41, -32, -18, -21], [-11, -13, -6, -24], [-20, 5, 20, 15], [-16, 9, -32, -2], [-2, 28, 10, 24], [30, 22, 29, 15], [7, 6, -6, 8], [-54, -19, -28, -5], [5, 8, -33, -8], [23, 43, 23, -8], [0, -38, -33, -24], [-37, 20, 18, 25], [19, -27, -22, -18], [10, 18, -4, 16], [40, -6, 50, 9], [7, -34, 11, 5], [6, 31, 30, -19], [-19, 5, 30, -6], [-3, 9, -24, -4], [33, -23, -4, -20], [31, 12, 35, -6], [-39, -19, -22, 12], [16, -47, -24, -29], [-42, -15, 20, 18], [-6, -5, 5, -8], [23, 45, 29, -24], [1, 23, 39, -15], [-14, 30, 0, 2], [-23, -8, -7, 16], [2, -8, 19, -12], [-5, -23, -32, -1], [24, -11, -33, -8], [-25, -7, 18, -22], [-14, -8, 1, 9], [-3, -1, -32, -3], [6, -20, -14, -4], [4, 1, -11, -12], [35, 28, -4, -1], [6, -16, -22, -35], [36, -20, -16, -18], [-29, 24, 3, 2], [16, 14, 10, 25], [-6, -17, -25, 6], [3, -21, -28, -19], [-10, 19, 6, 18], [49, -1, -5, 14], [10, -29, -23, -10], [-5, -19, -15, 1], [28, -3, 32, 7], [-7, -9, -21, 1], [-54, 12, 0, 8], [1, -32, -27, -25], [-5, 7, 37, 30], [9, -8, -37, 11], [-13, 9, -8, 18], [-37, -26, -19, 15], [-11, 12, 37, 46], [35, 0, 9, -11], [23, -33, -36, -10], [-40, -13, -23, -23], [27, 30, 23, 1], [2, -3, -12, 16], [-16, -29, 19, -15], [-16, -19, -27, -14], [21, -14, -33, 27], [-25, -37, -16, 25], [0, 24, -1, -17], [39, 11, 7, 11], [45, -21, -12, -17], [-31, 6, 7, -27], [-2, -35, -17, -45], [-9, 1, -24, -14], [-33, 0, 23, 7], [-13, -7, -40, -17], [-9, -34, -21, 13]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_2695_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


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