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