
// Make newform 7605.2.a.bz in Magma, downloaded from the LMFDB on 18 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_bz();".
// 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_bz();".
// 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], [1, -1, 0], [1, 0, 0], [0, 0, 0], [4, -2, 0], [-1, 0, 3], [-1, -1, 1], [0, 2, 3], [-1, 2, -4], [0, 4, -1], [7, 1, 0], [-5, -1, 0], [-5, -1, -4], [-6, 7, -6], [2, -7, 2], [-8, 7, -7], [-8, 1, -3], [1, -6, 3], [-5, 10, -7], [1, -7, -2], [-8, 2, 5], [-5, 4, -7], [9, -6, 12], [0, -3, -10], [-4, 3, 4], [1, -12, 4], [2, -8, 4], [3, 9, -3], [-14, 5, -4], [-5, 5, -7], [11, -9, 1], [-17, 3, -3], [12, -1, 4], [-10, -2, -3], [-17, -1, -1], [13, -6, 2], [3, -2, -8], [9, -5, 4], [-14, 12, -17], [-6, 4, 7], [1, 3, 10], [4, -3, -8], [-1, 16, -1], [5, -17, 14], [-2, 3, 9], [15, -13, 15], [1, -1, 5], [-12, -3, -2], [9, 0, 2], [6, 11, -3], [-6, -3, -8], [-8, -2, 9], [0, 2, 11], [-7, -7, -3], [18, -2, 5], [2, -2, 1], [18, -16, 22], [-17, 7, -3], [-6, 7, -17], [3, 0, 18], [21, -11, 11], [4, -5, 9], [-3, -14, 14], [-8, 8, 5], [-6, -11, -8], [-13, 9, -7], [-22, -3, 7], [-7, -13, 11], [-12, 0, -4], [5, 11, 0], [-2, -3, 16], [-6, 10, -13], [-3, 9, -14], [6, -1, 18], [14, -18, 17], [22, -10, 3], [-13, 2, -10], [-19, 14, -7], [-22, 19, -13], [1, 3, 15], [17, -9, 5], [-5, -11, 4], [3, -14, 4], [-20, 15, -4], [-12, 7, -12], [9, -7, -17], [-11, 1, -8], [2, -2, 14], [-20, 4, -6], [-15, 19, -27], [10, 16, -3], [-4, -9, 14], [-16, 2, -4], [-18, 18, -22], [10, -21, 23], [20, 9, -8], [-23, 0, -5], [-34, 10, -2], [-6, 10, -10], [-25, -3, 0], [5, 7, 22], [14, -10, -10], [17, 4, 15], [8, 25, -13], [22, -1, 4], [9, 16, -15], [-6, -27, 10], [-6, 15, 17], [4, -14, 17], [-20, 14, -22], [6, -11, 21], [15, -24, 4], [30, 3, 8], [8, -9, 7], [-9, 22, -8], [-7, -16, 6], [8, 19, -3], [0, -5, -22], [-4, 22, -9], [-7, -4, -7], [12, -18, 6], [13, -1, 22], [21, 3, 7], [-3, -3, -9], [-9, 3, 6], [-12, -3, 8], [-29, -1, -13], [30, -7, 6], [-10, 17, 13], [-4, 1, -15], [-15, 27, -24], [2, -23, 0], [-23, 18, 15], [-33, 4, -17], [-15, 14, -21], [26, 6, 5], [9, 24, -6], [29, 2, 4], [3, 2, 8], [-6, 18, -24], [8, -14, -15], [26, 4, -8], [-15, 1, -15], [34, -24, 35], [18, 12, 8], [4, -6, -19], [-5, 30, -17], [10, -14, 27], [7, 6, 15], [14, -11, -5], [-14, -30, 11], [27, -20, 12], [19, -16, 30], [24, 1, -5], [16, -17, -3], [-17, 28, -34], [-17, 0, -15], [13, -6, -3], [-28, 32, -19], [-13, 5, 5], [-21, 0, -29], [-24, 30, -13], [-33, 13, -25], [-4, -9, -1], [-2, 27, -2], [-49, 22, -38], [-4, 17, -1], [22, -14, 26], [-30, 4, -6], [-18, -2, 4], [-19, 1, -4], [-16, 3, -5], [5, -13, -13], [-8, -25, 4], [15, -45, 19], [35, -28, 38], [2, 21, 0], [11, 26, -12], [20, -24, -21], [-12, 28, 7], [27, -9, 13], [7, -2, -3], [-4, 1, 8], [-30, 9, -32], [18, -21, 3], [-10, 15, -22], [14, -17, 15], [36, -2, 0], [-21, 15, 19], [-12, 14, -25], [6, 8, 2], [2, -7, 23], [9, 4, -13], [-16, 5, 3], [33, 1, 19], [38, 7, 1], [24, -37, 8], [-4, 15, -27], [31, -30, 40], [-24, 24, 7], [14, 4, 12], [-50, -3, 3], [-31, 9, 11], [17, -29, 39], [-21, 21, -25], [-7, -18, 12], [-9, 22, 12], [-26, 12, -13], [23, -7, 15], [19, 0, 11], [-23, 45, -21], [-4, 13, -34], [-12, 23, -22], [-13, -5, -29], [18, -30, -6], [50, -27, 53], [-17, 15, -11], [-24, 25, -15], [-17, -2, 13], [10, -6, -9], [-50, 7, -12], [-12, 15, -8], [-38, -5, 9], [14, -19, 4], [27, 16, 15], [15, -22, 4], [23, -11, 1], [25, -25, 34], [-43, 3, 8], [-26, 27, -32], [-35, 7, -1], [22, 1, -16], [-12, -4, -1], [17, -6, 30], [15, -25, 42], [11, -45, 0], [-27, -37, 17], [-44, 7, -35], [-25, 38, -41], [-16, 16, 14], [31, -27, 23], [1, -29, 1], [33, -16, 4], [37, -23, 26], [12, 41, -22], [24, -1, -6], [68, -4, -2], [55, -7, 10], [29, -16, 47], [24, -30, 41], [12, -7, -29], [18, -4, -29], [2, 1, 20], [-40, 6, 13], [53, -3, 9], [14, -8, 41], [-16, -1, -44], [24, -7, 21], [34, -19, 21], [10, -20, 33], [-32, 32, -29], [13, -34, -4], [-31, -9, -14], [16, -7, 35], [5, 14, 9], [-28, -35, 10], [22, 3, 28], [-29, 10, -9], [9, 7, -8], [-14, 14, -25], [-2, -42, 5], [-17, 14, -24], [-18, 36, 24], [-30, 43, -25], [64, -20, 29], [5, 3, 29], [33, -8, 34], [26, -32, 6], [-25, 43, -21], [-33, -17, 10], [25, -17, -3], [-47, 16, 3], [63, -20, 33], [-5, 16, 18], [-26, 41, -44], [10, 8, -35], [-24, 37, -23], [50, 1, 23], [16, -32, 45], [46, -33, 44], [-2, -18, 35], [-9, -12, -3], [-3, 16, -2], [16, -38, -18], [-9, 14, -12], [5, 24, -15], [-32, 32, -4], [-9, -24, 0], [6, -8, 40], [19, -7, -1], [-15, 55, -25], [-59, -2, -17], [16, -21, -4], [1, -8, -22], [-23, 42, -28], [-1, 25, 7], [38, -37, 4], [33, 11, -18], [-20, 41, -26], [-23, 1, -33], [-20, 16, -10], [35, -7, -23], [-3, -6, -8], [2, -1, 14], [-52, 28, -62], [24, 2, -29], [-1, 7, -17], [9, -18, 47], [50, -35, 18], [7, -12, 1], [38, -12, 29], [17, -32, 34], [17, -27, 33], [49, -48, 41], [-22, -6, 9], [4, -24, -34], [-56, 19, -5], [-11, 47, -32], [-28, -5, 0], [14, -41, 27], [51, -17, 50], [30, -17, -31], [-51, 14, 18], [40, -36, 36], [19, -46, 17], [27, -23, 3], [-15, -4, 4], [-18, 59, -20], [53, -29, 43], [0, 24, -14], [-60, 48, -71], [-29, -9, 13], [-9, 13, -8], [25, -18, 15], [-18, -15, 0], [-35, 4, 8], [23, 19, 26], [-20, -6, -13], [-78, 6, -1], [6, 37, -10], [-36, -39, 13], [31, -25, -2], [22, -17, -26], [18, -30, 23], [-57, 28, -12], [9, 25, 18], [-17, -10, -15], [27, -1, 5], [4, -4, -10], [42, -19, -2], [-3, -54, 31], [-25, -11, -5], [12, 0, 6], [30, -11, 15], [63, -17, -14], [-11, 24, 11], [-31, 13, -16], [15, -18, 6], [-22, 9, -58], [25, 34, -3], [-4, 20, 11], [10, 2, 15], [66, 11, -5], [-13, -41, 3], [-30, 5, -15], [-47, 4, 5], [23, -6, 7], [-2, -4, -46], [-23, 12, -25], [-14, 13, -48], [-1, -26, 10], [-24, -22, -9], [-28, 9, -1], [17, 26, -4], [-54, -3, 18], [-11, 40, 1], [-14, -19, 11], [37, -18, 7], [30, 29, -12], [20, -33, -11], [-28, 0, 37], [-11, 3, -3], [-8, -6, -5], [-49, 53, -50], [47, -23, 68], [-30, 33, -59], [-50, 33, -44], [-12, -15, -15], [9, -19, -37], [26, 15, -2], [-21, 0, -9], [-14, 49, -37], [-29, 22, 34], [-18, -10, 14], [-49, 14, -65], [19, 29, 13], [-1, 37, -20], [-25, 13, 36], [-73, -10, -3], [8, -23, 17], [-8, -40, -3], [73, -18, 40], [-66, 53, -80], [27, -12, -33], [-31, 10, 3], [-10, 71, -31], [31, 19, 8], [15, 29, 22], [-76, 28, -44], [12, 16, 8], [8, 54, -25], [-24, 29, -24], [15, 20, -35], [-40, 22, 15], [-36, -40, 16], [76, -17, 22], [-21, -13, -13], [13, -30, 16]];
    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_bz();".
// 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_bz(: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_bz();".
// 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_bz( : 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![1, -1, -2, 1]>,<11,R![-1, 1]>],Snew);
    return Vf;
end function;