
// Make newform 7605.2.a.bp in Magma, downloaded from the LMFDB on 24 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_bp();".
// 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_bp();".
// 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 := [[0, -1, 0], [0, 0, 0], [1, 0, 0], [-4, 0, 0], [2, -2, -2], [0, 0, 0], [-6, 1, -2], [3, -3, 5], [2, -4, -1], [2, -4, 4], [2, 5, -2], [-4, 8, -6], [0, 0, 6], [-2, 6, -2], [3, 3, 3], [-3, 5, -5], [2, 2, -6], [4, 1, 4], [10, -8, 10], [0, 0, 4], [-2, 0, -2], [-4, -6, 1], [-4, -3, -4], [-6, 6, 0], [6, 0, -2], [4, 8, -2], [12, -4, 6], [-9, 3, -1], [-8, 4, -7], [-10, 2, -1], [-8, -2, 2], [-6, 2, 2], [-2, 5, 2], [-8, 6, -9], [-4, 4, -8], [4, 2, -1], [4, 2, 4], [-6, -2, -4], [-20, 1, 0], [-14, -2, -1], [-4, -2, -4], [-11, 3, -3], [0, 2, -2], [6, 2, -4], [-7, 5, -1], [-18, 7, -10], [-11, 11, -17], [-20, 0, -4], [1, 9, -11], [6, -8, -4], [-15, -3, 3], [14, 2, 6], [0, 12, -9], [10, 0, 6], [3, -1, 13], [-4, -11, 12], [-2, -8, -2], [4, -14, -1], [-6, -8, 8], [-10, 8, -6], [-2, 8, 12], [1, -11, 11], [-16, 2, -12], [-4, -10, 8], [12, -8, 16], [-10, 10, 7], [-2, 17, 2], [-18, 2, 6], [-16, 9, 0], [19, -15, 11], [2, -10, 3], [2, -8, 6], [-6, -8, -8], [-10, 6, 12], [8, -14, 21], [-10, -8, 9], [0, -8, 4], [18, -10, 8], [-6, 6, 0], [10, 0, 8], [18, -12, 22], [8, -4, 11], [2, -10, 16], [-2, -12, -6], [11, -7, 13], [-26, 4, 3], [2, 8, 4], [24, 12, -4], [12, -16, -10], [12, -14, -12], [11, -1, 15], [24, -6, 16], [24, -18, 26], [2, 8, 6], [-10, 11, -22], [-7, 1, -19], [10, -6, -18], [2, 10, -8], [-12, 20, 2], [-17, 9, -5], [-12, 0, -22], [-5, 15, -15], [-18, -12, 7], [-4, 28, -6], [-12, -10, 1], [-14, -14, 0], [-16, 8, -12], [22, -18, 9], [8, 2, 24], [-24, 16, -13], [6, -6, 6], [-2, -4, -22], [34, -22, 35], [-24, 26, -31], [-25, -11, 5], [-4, 4, -18], [18, -4, 4], [8, -7, -4], [10, 9, -2], [10, -8, 2], [4, -1, 12], [-2, -6, 6], [10, 1, 10], [12, -21, 24], [12, -28, 12], [-6, 18, 2], [-10, 24, 12], [4, 8, 0], [22, -10, -18], [8, -12, 2], [22, -19, 14], [-32, -5, 0], [0, 18, -1], [8, -20, -6], [16, -20, 14], [-12, 3, 8], [-18, 27, -22], [18, 18, -6], [27, -29, 37], [2, 0, 2], [8, 8, -8], [-16, 6, -24], [-34, 0, -14], [-20, -8, 16], [-4, -8, 15], [-38, 20, -24], [2, -20, -8], [-18, -4, -4], [10, -43, 22], [13, -7, 21], [2, -10, 6], [-22, 8, -2], [-48, 16, -24], [-12, 25, 0], [22, -22, -4], [-28, 12, -6], [12, 10, -13], [6, -6, -30], [20, -4, 8], [34, -14, 38], [-10, 16, 11], [-26, 28, -20], [-26, -6, -8], [24, -14, -12], [31, -21, 29], [-14, 4, -27], [14, -11, -2], [36, -20, 10], [4, -11, 12], [18, -10, 11], [4, -18, -22], [20, -3, 16], [-40, 14, 4], [-10, -2, -2], [-50, 15, -22], [-12, 0, 8], [-4, 20, -12], [24, 4, -10], [-32, 22, -18], [20, -5, -16], [12, -38, 26], [-10, 18, -8], [18, 10, -4], [-30, 38, -31], [32, -27, 40], [-2, 18, -20], [10, 24, 0], [-4, 24, -20], [2, -24, 12], [2, 10, -10], [-18, 8, -22], [13, -31, 13], [-24, 14, 19], [-22, 22, -22], [14, -24, 15], [10, -18, -13], [-21, 21, -9], [18, 8, 8], [-22, -27, 14], [37, -11, 25], [16, 24, -8], [11, -31, 5], [-16, 40, -14], [24, -17, -8], [10, -40, -2], [-30, 36, -44], [-21, -15, 9], [-15, 17, 5], [4, -6, 6], [-30, 29, -38], [-12, 36, -14], [-14, 6, -20], [-16, -32, 18], [-38, 32, -43], [-28, 10, -6], [20, 15, 0], [-14, 12, -20], [-20, 22, 16], [12, 3, 28], [-9, 23, -11], [40, -21, 16], [-10, 19, 14], [20, -22, -6], [30, -22, 30], [-20, -7, 4], [3, 21, -29], [-14, -4, -36], [2, 12, -2], [-6, 10, 12], [-24, -10, 20], [30, -8, 22], [5, -49, 27], [42, -25, 14], [-40, 22, -20], [14, 4, -24], [-24, 16, 8], [-21, 25, -29], [-10, -10, -15], [-26, 8, 16], [-42, 22, -28], [16, -25, 0], [17, -5, 27], [-30, 32, 14], [19, 9, 11], [39, -25, 49], [-38, 8, -8], [-38, 14, 12], [22, -42, 42], [-2, -19, -6], [8, 25, -20], [32, -22, 34], [28, -4, 0], [-7, -27, -7], [8, -27, -4], [-2, -24, 12], [10, 34, -2], [-24, 20, -17], [-34, 14, -46], [-6, -15, -14], [20, 10, 2], [-24, -24, 4], [49, -23, 1], [-2, 4, 8], [32, -36, 10], [-39, 25, -29], [1, 31, -25], [36, 20, -20], [-4, -18, 10], [-18, -10, -4], [38, -15, -14], [-13, -7, -29], [-6, 40, 6], [-2, -2, 4], [-11, -17, -13], [22, 0, 30], [18, 10, 8], [-56, 28, -20], [-4, 0, -7], [-29, -3, -9], [-26, 4, -8], [14, 8, 15], [-43, 35, -13], [37, 9, -11], [53, -1, -3], [20, -12, -32], [-4, 18, -32], [24, -46, 26], [-34, 11, -34], [38, 17, -14], [-20, -4, -2], [38, 30, -14], [-20, 27, -32], [-34, 2, 11], [-14, 26, 20], [20, 22, -12], [-8, -30, 8], [4, 22, -19], [-5, 31, -23], [-34, -14, 10], [20, 32, -10], [-8, 16, -48], [-10, -1, 18], [10, -51, 26], [8, -19, 28], [6, -7, -26], [24, 14, -18], [-10, 24, 15], [3, -7, 19], [20, -2, 4], [-38, 28, -18], [-6, -12, 3], [-16, 16, 36], [58, -18, 42], [24, -14, 18], [10, -28, 3], [-53, 5, -17], [2, -36, 40], [-62, 16, -22], [-20, 30, 10], [-10, -22, 4], [18, -21, 10], [0, 2, -38], [46, -14, -22], [2, -12, 32], [-14, -28, 28], [51, -31, 55], [47, -23, -11], [-42, 8, 4], [30, -48, 39], [35, -21, 17], [0, -55, 16], [-14, 25, -10], [-28, -10, 3], [19, 3, 23], [-61, -7, 1], [20, -27, 16], [-20, -7, -4], [-2, -4, 28], [-11, 23, 9], [22, -18, -14], [-6, 24, -12], [30, -32, 12], [-28, 36, -52], [-53, -3, -19], [26, -2, -21], [44, -38, 38], [23, -27, -25], [-12, -18, 2], [-6, 10, -54], [-50, 27, 18], [-39, -21, 19], [6, -30, 38], [-26, 18, -42], [-42, -12, 24], [0, 16, -13], [38, -19, 38], [-16, -6, -34], [14, -36, -8], [-42, 23, -6], [52, 1, 4], [4, 18, -16], [-34, 24, 12], [35, -13, -13], [-8, 32, -4], [-22, -8, -4], [34, 2, 22], [-26, -13, -10], [24, -8, -4], [52, -39, 52], [32, -8, -8], [20, -44, 0], [15, 15, -25], [-22, -14, 22], [-20, -16, 0], [40, -20, -6], [-4, 2, 26], [10, -24, 18], [16, -56, 12], [-18, 22, -18], [50, 8, 10], [38, -28, 2], [-2, 8, 20], [48, -34, 10], [7, -49, 1], [-40, 6, 11], [2, 24, 11], [-8, 38, 9], [-40, 16, -4], [10, -12, -32], [-43, 29, -19], [-72, 8, -7], [6, -1, 2], [60, -14, 24], [-16, 28, -38], [-18, 24, -2], [8, 6, -8], [12, 12, -8], [-2, -18, 4], [-32, -20, 16], [4, -32, -34], [16, -20, 7], [-54, 7, -10], [-14, 12, -20], [-6, 25, 2], [-54, -16, 6], [-20, -28, 4], [46, -18, -12], [-16, -16, 24], [60, -20, 46], [-14, 50, -16], [10, -56, 14], [-38, 10, -25], [28, -31, 52], [-47, -37, 11], [6, -26, 36], [46, -58, 58], [-14, 28, 20], [-4, -20, 34], [6, -18, 29], [-17, -9, -5], [-46, 22, 22], [6, 8, -52], [-48, 28, -76], [-28, -6, -36], [4, -14, -28], [2, -2, 49], [-16, -17, -12], [-42, 22, -66], [46, -29, -10], [26, 2, -2]];
    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_bp();".
// 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_bp(: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_bp();".
// 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_bp( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_7605_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<2,R![-1, -2, 1, 1]>,<7,R![4, 1]>,<11,R![104, -16, -6, 1]>],Snew);
    return Vf;
end function;