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