
// Make newform 7600.2.a.bi in Magma, downloaded from the LMFDB on 24 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_7600_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_7600_2_a_bi();".
// 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_7600_2_a_bi();".
// 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 := [-2, -6, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0], [0, 1, 0], [-4, -2, 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_7600_a();"
function MakeCharacter_7600_a()
    N := 7600;
    order := 1;
    char_gens := [4751, 5701, 5777, 401];
    v := [1, 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_7600_a_Hecke(Kf)
    return MakeCharacter_7600_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, 0, 0], [-1, 1, 0], [0, 0, 0], [-1, -1, 0], [0, 1, 1], [3, 0, 1], [-1, 0, -1], [-1, 0, 0], [1, -1, 2], [-3, -2, -3], [-2, -1, -3], [4, 2, 0], [0, 3, 1], [-6, -1, -1], [4, 0, -2], [5, 0, -1], [-1, -1, -2], [-10, -1, -1], [-1, 3, 2], [4, -5, -1], [5, -2, 3], [2, -6, 0], [2, -2, -2], [-4, -1, 1], [2, 0, -4], [-2, -3, 5], [0, -1, 3], [1, 3, 0], [-9, 4, 1], [-6, -5, -5], [-10, -2, -4], [-4, 4, 4], [-5, 0, 3], [0, 8, 4], [-8, 8, 2], [10, 2, 4], [6, -8, -2], [-2, -1, -5], [-2, -3, -5], [-4, 2, 4], [-10, 4, 2], [4, -6, 0], [-15, -1, 0], [6, -4, -4], [-12, 3, -1], [1, -5, 4], [3, 3, -6], [10, -2, 0], [-3, 9, 2], [10, -8, -4], [8, -4, 4], [-1, -7, 0], [4, 0, -2], [-8, -3, -3], [-8, 3, 5], [10, 0, -4], [-14, 0, 4], [5, -3, -6], [20, 4, 0], [8, -3, -5], [6, 2, 6], [3, 8, 5], [-20, 4, 4], [11, 3, 6], [-9, 0, 3], [-1, 0, -11], [-13, 5, -4], [8, 3, 9], [-6, -2, 2], [-6, -4, 4], [3, 2, -3], [-7, 3, -4], [-4, 6, 4], [-7, 2, -3], [-3, -1, 0], [-16, -1, -1], [6, 3, 3], [-12, -4, 8], [0, 1, -5], [0, -3, -9], [-18, 11, 1], [-13, 2, -9], [-20, 7, -1], [2, -1, -1], [6, 7, 5], [-16, 17, 3], [-22, 4, 4], [19, 0, -1], [-8, -7, -1], [-4, -2, 4], [-16, 11, 1], [-8, 2, -6], [-10, -6, 4], [-2, -1, -3], [-10, -7, -1], [-9, 9, 2], [0, 4, 2], [-8, -12, -6], [-1, -1, -6], [6, -3, -3], [-10, 0, 2], [36, -4, 0], [4, 0, -8], [-4, 0, -6], [-14, -1, 9], [-7, -4, -7], [18, -7, -7], [2, 12, -2], [22, 5, 3], [28, -1, 1], [-26, 2, 4], [-14, -5, -7], [-28, 2, 2], [0, 11, 3], [2, -4, 14], [-10, 1, 5], [2, 2, 10], [5, -7, -4], [0, 8, 8], [-13, -5, -2], [-9, 6, -1], [0, -4, 2], [-7, 6, -7], [-12, 0, 8], [2, -10, -4], [-20, 0, 2], [2, 12, 4], [5, -1, 12], [17, -17, -6], [0, -4, -8], [6, 13, 3], [2, 9, 11], [-6, 3, -7], [2, 16, 14], [-7, 10, 9], [23, -4, 5], [21, 10, 13], [-5, 7, -2], [-7, -8, 11], [5, -16, -13], [-3, -3, 2], [-20, -4, 10], [9, 13, -4], [31, 5, -4], [9, -2, 5], [-4, 8, 8], [-22, 0, 6], [-4, -4, -10], [8, -1, -1], [24, 5, -3], [7, 12, -3], [-4, 0, 6], [-26, -10, -18], [-12, -3, 5], [15, -9, 10], [16, -12, -4], [-5, -11, -8], [-21, 12, -3], [-11, 0, -11], [-17, -2, 3], [-4, -4, -6], [-14, 11, -9], [40, -2, -4], [-4, -4, 0], [4, 17, 15], [22, -6, -4], [-2, 9, -13], [-28, 13, 5], [-20, 0, -10], [-12, 3, -5], [11, 13, -12], [9, 16, -9], [10, -4, 6], [5, 8, -7], [6, 11, -3], [-16, -14, -16], [30, 9, 15], [-38, 0, 0], [2, 3, 13], [8, 3, 1], [-13, 15, 0], [1, 13, 6], [4, 10, 0], [12, 8, 10], [-13, -9, 12], [-18, 20, 8], [21, -6, 9], [-4, -10, -10], [22, 9, -15], [-5, -9, -14], [10, -5, -1], [16, -12, -6], [4, 6, 2], [-33, 10, -5], [4, 12, 14], [16, -7, 7], [13, -12, 3], [8, -4, -16], [-1, -20, -1], [-25, -7, -10], [0, 20, 10], [12, 16, 4], [29, 8, 3], [16, -9, -3], [2, -6, 0], [-4, 0, 12], [23, -21, -6], [7, 9, 16], [7, 0, 13], [-13, 7, 2], [7, -10, 1], [-4, 16, -6], [12, 2, 0], [7, -5, 10], [-34, -5, -11], [-2, -5, -1], [-3, 19, 2], [10, 0, -8], [-50, 14, 4], [10, -20, -6], [8, -16, 6], [-22, 10, 12], [2, -17, 7], [23, -11, -10], [11, -3, 12], [2, 16, 16], [-38, 0, -8], [-28, 7, -1], [-20, 21, 5], [-34, -6, 4], [6, 7, -11], [3, -1, 14], [-12, 4, -8], [22, -16, -8], [22, 6, 2], [-3, -9, -2], [8, -12, -14], [40, -3, 5], [10, -22, -16], [-14, -1, -11], [20, -16, 8], [44, 5, 9], [-25, 7, 12], [-1, 6, -1], [16, 7, -11], [8, -2, 6], [38, 8, 8], [-8, 14, 18], [16, -10, -6], [-31, 1, 0], [-2, -17, -11], [57, 0, -5], [-33, -9, -12], [22, -3, -11], [-12, -17, -5], [-40, -7, 9], [18, 16, 12], [12, -12, -16], [-12, 14, -8], [-28, 14, -2], [-18, 11, -3], [12, 4, -8], [8, 3, 1], [-33, -12, -19], [-28, -10, -14], [7, 19, 10], [-31, -2, -15], [1, -6, -7], [35, -11, 8], [6, -11, -5], [39, 12, 9], [7, 1, 8], [-43, 0, -3], [-5, 7, -14], [2, 3, -5], [-5, -5, -4], [-16, -11, -25], [-1, -22, -5], [8, 24, 26], [24, -12, 8], [-2, -18, -16], [-13, -15, -4], [9, 15, -2], [11, 18, -5], [60, -8, -2], [-20, 2, 14], [3, 8, 15], [18, 8, 4], [51, -9, 2], [18, 20, 12], [-38, 17, 1], [24, -8, 14], [-22, -3, -3], [-4, -4, -20], [0, -20, -6], [0, 3, 9], [-6, -6, 16], [-62, -4, -6], [13, -15, 2], [-8, -25, -15], [-60, -2, -2], [-15, 0, 3], [37, 3, -8], [15, 11, -6], [42, -9, 9], [-70, 4, 0], [-3, -23, 6], [29, 4, 3], [-18, 12, -6], [-12, -12, 20], [12, 20, 14], [-34, -15, -11], [22, 5, 5], [12, 8, 8], [8, -2, 28], [0, -1, -3], [-30, 6, -12], [-76, 3, 3], [9, 20, 25], [22, -32, -8], [1, -17, -24], [5, -6, 15], [-37, -18, -5], [-16, 21, 5], [-13, 20, 7], [-34, -15, -19], [-9, 11, 2], [-9, 9, 12], [-10, 3, -19], [-48, 35, 7], [-8, -8, 6], [33, -34, -7], [-19, -17, -12], [22, 6, 22], [26, -2, -4], [-22, 3, -17], [5, 2, -19], [40, -32, -2], [5, -26, -11], [-5, 7, 8], [-47, 18, 5], [27, -6, 13], [-5, -20, 5], [30, 14, 0], [3, -2, -5], [-56, 14, -2], [14, 4, 20], [-29, -3, -8], [-24, -5, -13], [4, -32, -12], [-44, -6, 14], [6, -3, -27], [-56, 12, -6], [-40, 4, 8], [-20, -4, -2], [0, 20, -6], [-15, 13, 14], [-8, 0, -4], [13, 8, -11], [10, -6, 8], [-20, 13, -3], [4, 4, 10], [-40, 5, -3], [7, 15, 18], [12, -5, 5], [-24, 23, -3], [-10, -16, -10], [-4, 7, 11], [-6, -20, 8], [-62, -10, -20], [31, -3, -20], [-35, 11, 14], [-69, 18, 3], [32, 10, 26], [-4, -24, -20], [-1, 1, 4], [56, 8, 16], [-12, 6, -6], [9, 2, 17], [40, 9, 15], [-4, -10, -4], [-12, 6, -6], [5, 23, 6], [-42, -12, -6], [-37, -25, -38], [-14, 2, -4], [51, -19, 0], [44, -31, 1], [-42, 18, 2], [-28, 0, 0], [14, -8, 12], [9, 8, 19], [-46, 6, 4], [-8, 7, 21], [-46, 9, -9], [30, -28, 0], [50, 14, 12], [-40, 24, 2], [50, 8, 2], [60, 9, 19], [26, -8, 20], [70, -20, -6], [-38, 14, 12], [-48, 21, -1], [-32, 28, 6], [15, 5, -12], [66, 5, -13], [0, 8, 6], [-53, 15, 14], [-42, 25, 7], [36, -9, -19], [-22, -24, -2], [17, 1, 2], [-12, 5, -15], [25, 24, 25], [52, 15, 25], [16, -9, 7], [-2, 19, -19], [23, -10, 5], [-36, -16, -16], [-12, -4, -30], [-5, 28, 17], [31, -33, -8], [9, 7, 12], [34, 15, 15], [31, 24, 9], [55, 7, 2], [49, 0, 11], [-20, 0, 8], [11, -13, -10]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_7600_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


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