
// Make newform 7605.2.a.bm in Magma, downloaded from the LMFDB on 25 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_7605_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_7605_2_a_bm();".
// 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_7605_2_a_bm();".
// 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, -2, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0], [0, 1, 0], [-2, 0, 1]];
    Rf_basisdens := [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_7605_a();"
function MakeCharacter_7605_a()
    N := 7605;
    order := 1;
    char_gens := [6761, 1522, 6931];
    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_7605_a_Hecke(Kf)
    return MakeCharacter_7605_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, 0, 0], [1, 0, 0], [0, -1, -1], [3, -2, 2], [0, 0, 0], [-2, 2, 2], [-3, 3, -4], [-4, 4, -5], [-4, -1, 2], [-1, -6, 2], [6, 1, 2], [6, -5, 3], [-10, 1, -3], [-4, 1, -1], [1, -9, 5], [-5, 7, -7], [7, 0, -1], [-9, 4, -7], [7, 3, -4], [3, 1, 6], [-2, 5, -7], [2, -11, 0], [-1, 3, -2], [-1, 2, 4], [-5, -3, 7], [-11, 1, -1], [3, -10, 0], [2, 4, 4], [6, 2, 5], [5, -1, 13], [-8, 0, -11], [-4, -8, 5], [-6, -4, 3], [-5, 11, -9], [-8, -5, 6], [-8, -4, -1], [-5, 8, -4], [5, 4, 6], [-14, 3, -3], [-12, 5, -4], [-10, 1, -4], [-6, 13, -13], [1, -3, 7], [-9, 3, -14], [12, -1, 3], [-7, 12, -13], [-8, -4, 5], [-14, 4, -11], [11, -9, -1], [-13, 0, 4], [-1, -20, 7], [1, 1, 11], [4, -3, 18], [-6, 5, -8], [-8, 10, 5], [-6, 1, -10], [4, 3, -2], [2, -6, 16], [14, -6, -3], [21, 0, -3], [-25, 4, -12], [0, -6, 3], [3, -4, -7], [9, 12, -4], [4, 3, 2], [21, -3, 15], [-2, 16, -11], [-5, 6, -7], [0, -6, 1], [-16, -4, 4], [-6, 17, -7], [9, -1, -3], [2, -19, 12], [2, -1, 15], [-5, 9, -1], [26, -15, 18], [-2, 23, -4], [15, -6, -4], [9, 15, -2], [17, -14, 13], [-20, 14, -27], [-8, 10, -3], [20, -13, 7], [-7, 10, -2], [23, -15, 21], [19, -9, 15], [-12, -2, -9], [0, 11, -5], [20, -8, 6], [8, -18, 4], [4, 10, 5], [12, -21, 14], [-19, -1, 1], [14, -2, -2], [-8, 12, -10], [-5, -2, 19], [-21, -1, 3], [-19, 15, -24], [-32, 12, -14], [4, 12, 14], [6, -13, 17], [-18, 5, -23], [-20, 12, 6], [-7, -11, 4], [3, -6, 1], [31, -21, 31], [-19, 9, 14], [1, 9, -1], [29, 4, -5], [-8, 23, 8], [-30, 4, 2], [5, 20, -5], [-7, 28, -16], [27, -13, 5], [23, -10, -3], [5, 2, -4], [11, -8, 20], [-21, 2, -13], [-11, 11, 9], [26, -19, 26], [-3, -31, 12], [2, 0, -10], [-2, 3, -1], [4, 2, -3], [-14, 34, -19], [14, -15, 25], [3, 15, -1], [-12, 0, -13], [-9, 15, -13], [-7, -6, 3], [11, 16, 7], [-28, 9, -5], [-7, -29, 13], [-21, 11, 16], [25, -13, 0], [3, -23, 24], [-26, -3, 12], [11, -4, -8], [-17, 0, -16], [-1, 10, -10], [12, 18, 2], [-4, 15, -16], [18, 4, 24], [-6, 26, 5], [-4, 19, 8], [30, -12, 8], [-30, 11, 0], [25, -29, 30], [12, -17, -8], [-25, 3, -26], [-25, -20, 3], [18, -11, -16], [-3, -2, 12], [-15, 18, 6], [1, -4, -17], [-9, 20, 15], [-7, 8, -18], [-1, 1, -20], [-17, 5, 12], [4, -21, 18], [-2, -22, 9], [9, -7, 28], [-4, -29, -2], [-18, -20, -5], [1, -4, 13], [-43, 23, -29], [19, -20, 0], [-5, -36, 15], [-16, -12, -14], [-30, 14, -20], [-40, 14, -22], [-12, -3, 1], [25, -16, -13], [16, -14, 39], [17, -7, 5], [6, 6, -7], [41, -12, 18], [5, -29, 17], [-7, -22, 22], [18, -3, -22], [10, -15, 4], [-24, 6, -37], [-19, -21, -4], [23, -7, 25], [-3, -25, -1], [-19, 16, 9], [-19, 1, -7], [23, -6, 25], [-18, 34, -30], [-16, 20, -13], [2, -5, -24], [-38, 14, -8], [-3, 36, -27], [-29, 9, -2], [-11, 6, 21], [-2, 0, -29], [21, -18, 13], [-3, 11, 11], [-21, -6, 23], [19, -16, 20], [0, -19, 20], [-6, -12, 12], [23, -8, 25], [-22, -2, 23], [-26, 22, -5], [28, 8, -13], [5, -4, 18], [27, -12, -4], [-26, 13, -4], [26, -2, -15], [-11, 23, -38], [-20, -14, -11], [-45, 19, -31], [7, -15, -1], [-22, 22, 9], [-20, 20, 34], [-53, 34, -57], [-12, -12, 25], [-5, 12, -37], [-19, -7, 18], [28, -15, -6], [-39, -1, -1], [-17, 11, -3], [-3, -22, -9], [-13, 19, -11], [-15, 9, -22], [13, -28, 0], [2, 16, 1], [22, -9, -11], [36, -7, 5], [-7, 17, -1], [-16, -18, 17], [25, -29, 11], [-54, 3, 6], [-17, 6, -18], [30, -3, -11], [24, -15, 7], [-8, 22, 7], [-1, 16, 5], [-7, -3, -8], [-24, 38, -44], [6, 6, -23], [24, 8, -15], [1, -18, 16], [-24, 15, -7], [-31, 19, -49], [43, 9, 7], [56, -6, 12], [14, -17, 15], [51, -19, 16], [8, -37, 26], [-5, -34, 27], [18, -7, 28], [-49, 7, 3], [-28, 11, 6], [46, -34, 41], [28, -17, -6], [43, -35, 45], [23, -20, -3], [-13, 20, -45], [-10, 17, 10], [-4, 23, 4], [41, 2, -4], [30, 7, -1], [1, 24, 1], [-49, 1, -16], [-7, 39, -19], [1, -41, 9], [39, -25, 52], [48, 1, 3], [-18, 31, 8], [18, 25, -8], [-47, 38, -34], [2, 12, -20], [-41, 16, 19], [8, -13, -26], [20, -52, 17], [-13, 22, 16], [46, -2, 4], [52, 2, 7], [22, 13, -11], [2, 0, 15], [31, -13, 24], [-19, -29, 16], [19, -20, -6], [-11, -9, -7], [-14, -25, 14], [27, -26, 23], [-9, -28, 11], [-42, 39, -36], [17, -27, -19], [-4, 27, -24], [55, -13, 10], [19, -14, 10], [18, -36, 10], [45, 6, 18], [3, 7, -22], [-20, 24, 16], [19, 4, -26], [-18, 0, -12], [-66, 4, -5], [24, -26, 43], [21, -41, -4], [-25, -7, -5], [-11, 62, -38], [-7, 44, -10], [16, -12, -43], [-59, 11, -33], [-16, 31, 5], [9, 33, -13], [26, -30, 31], [-56, 22, -24], [2, 16, 5], [-33, 16, -30], [9, 3, 23], [-40, 22, -12], [28, -3, -14], [-44, 4, -35], [53, -23, 36], [-49, -7, 9], [-35, -17, -8], [28, -21, 48], [5, 18, -26], [-40, 26, -57], [-15, 31, 4], [-16, 15, 6], [0, -58, 36], [-13, 8, 7], [42, -37, 5], [-11, -9, 29], [13, -4, 11], [14, -37, 31], [-33, -6, -19], [-55, 28, -18], [24, -4, -12], [3, 11, 46], [38, -20, 3], [-49, 0, -12], [11, -15, 51], [26, -20, -23], [24, -46, 40], [2, 5, -24], [34, -8, -17], [-6, -13, 41], [-35, -7, -12], [-17, -17, -15], [69, 0, -6], [60, -25, 21], [42, -11, -28], [84, -11, 14], [-5, 31, -13], [3, 14, -23], [-22, -21, 9], [-15, -17, -25], [-16, 13, -40], [37, -18, -26], [24, -35, -9], [7, -31, -32], [-44, 32, -27], [44, 10, 8], [13, 1, -17], [33, -21, -12], [12, 6, 11], [4, -10, 8], [15, -2, 23], [-20, -29, 3], [11, -43, 16], [-58, 7, 17], [29, 2, -24], [-41, 9, -39], [-61, 23, -48], [-38, 9, -28], [-48, 27, 10], [41, -32, -3], [34, -44, 5], [-25, 6, 11], [7, -37, -20], [-37, 21, -24], [-22, 10, -12], [13, 13, -10], [1, -35, -3], [25, -20, 40], [58, -13, -24], [43, 4, 19], [87, -8, 10], [-11, 15, -17], [65, -7, -4], [-11, 70, -27], [-55, -17, -8], [-59, 37, -13], [25, -54, -11], [2, 9, -20], [22, -30, 27], [40, -35, 10], [60, -19, 7], [40, 17, 15], [-21, 2, 7], [-1, 23, 1], [-17, -14, -15], [-6, 52, -17], [49, -25, 61], [-67, 45, -48], [25, -2, 15], [7, -10, 4], [16, -32, 22], [19, -13, -6], [-12, -12, -37], [-52, 13, -15], [-50, 7, -21], [33, 11, -2], [-3, -16, 21], [-28, 49, -30], [-73, 14, -38], [-31, 19, -43], [-7, 43, 26], [31, 35, 0], [-43, -2, -19], [24, 25, -9], [14, 31, -13], [-12, 48, 20], [-32, 20, 0], [-2, 39, -24], [-5, -53, 11], [57, 11, 0], [-6, -5, 24], [4, 12, -48], [-17, 13, -61], [-2, 22, -31], [31, -32, 20]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_7605_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


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