
// Make newform 7616.2.a.p in Magma, downloaded from the LMFDB on 09 January 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_7616_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_7616_2_a_p();".
// 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_7616_2_a_p();".
// 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, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rfbasis := [Kf.1^i : i in [0..Degree(Kf)-1]];
    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_7616_a();"
function MakeCharacter_7616_a()
    N := 7616;
    order := 1;
    char_gens := [5951, 3333, 3265, 2689];
    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_7616_a_Hecke( : Kf := Kf)
    return MakeCharacter_7616_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]];
    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, -1], [1, 0], [-4, 2], [2, -2], [1, 0], [-2, -4], [-2, 6], [-4, 6], [5, -7], [6, -4], [8, -5], [-4, -5], [2, 4], [7, -11], [0, 0], [-4, 7], [-5, -5], [2, -8], [12, -3], [10, -8], [-4, 12], [2, 0], [7, 5], [-6, 4], [4, -12], [14, -2], [10, -4], [6, 0], [3, 3], [-8, 0], [4, -1], [7, -13], [12, 1], [20, -3], [-14, 10], [-4, 6], [-16, 1], [20, -5], [-20, 1], [6, 4], [-3, -11], [2, -10], [0, -6], [4, 5], [-12, 6], [10, -8], [-5, 19], [16, 2], [0, 4], [-20, 5], [-17, 13], [2, -12], [16, 6], [4, 8], [10, 0], [6, -6], [-6, 2], [-17, 5], [-19, 9], [16, -6], [14, -8], [-25, -1], [23, -15], [12, 10], [-3, 13], [16, -4], [18, 8], [22, -4], [-16, 2], [-5, -9], [-8, 17], [12, 3], [-12, 14], [8, 14], [7, 9], [-11, 11], [-4, -4], [8, -10], [-3, 25], [-8, 23], [-18, 8], [4, 8], [-8, 7], [0, 16], [8, 6], [-1, 1], [0, 8], [-8, 13], [4, 4], [0, 15], [-10, 20], [7, -5], [30, -8], [9, 1], [4, -2], [4, -19], [18, 10], [2, 2], [-18, -14], [-2, -20], [0, -18], [-16, -17], [2, 4], [-12, 18], [-4, -24], [10, -20], [-28, -5], [-10, 36], [35, 3], [3, 9], [20, -34], [-32, 0], [29, 5], [34, -8], [8, -3], [24, -2], [26, 4], [-29, 19], [8, -24], [-8, -4], [-18, 32], [12, 10], [36, -17], [26, 12], [-18, -14], [44, -3], [-10, -4], [-36, 0], [-16, 9], [18, -14], [2, -8], [24, -9], [14, 10], [22, -18], [14, -12], [-12, 0], [4, -12], [8, -38], [-24, 13], [18, -20], [14, -38], [34, -4], [-10, 10], [20, -4], [6, 20], [-7, -5], [2, 8], [35, 7], [-28, 6], [-31, 7], [-19, 21], [-11, 17], [14, -28], [8, 4], [-20, 31], [-3, 15], [40, -28], [-12, -21], [36, -18], [21, 7], [-20, -11], [-8, 18], [35, -23], [-15, 5], [-30, 36], [-8, -13], [-24, 12], [-24, 41], [8, -20], [-16, -4], [-12, -14], [19, -35], [42, -14], [-13, 17], [-32, 2], [0, 8], [10, -6], [-30, -12], [32, -48], [36, -9], [38, -32], [-20, 30], [3, 15], [10, -14], [-16, -18], [14, -38], [0, 34], [-28, 4], [56, -3], [18, -40], [-12, -4], [16, -10], [-38, -10], [-7, -9], [-28, 0], [-32, 44], [-40, 27], [8, -20], [-10, 30], [41, -3], [-44, 4], [-34, 44], [-24, 40], [-4, 0], [36, -4], [20, -35], [-26, 18], [26, -56], [-38, 4], [-46, 20], [-14, -26], [-6, 14], [8, -3], [-60, 15], [36, 4], [-18, 22], [10, 26], [-15, 11], [43, -15], [16, -3], [-24, 49], [22, -46], [4, -6], [-7, 11], [-50, 4], [-14, 46], [14, 32], [-42, 10], [20, 5], [-4, -16], [0, 40], [16, 15], [-18, 18], [-26, 0], [-26, -12], [52, -34], [36, 24], [-24, 12], [-36, -6], [62, -16], [-42, 34], [-32, 5], [-3, 3], [65, -15], [20, -41], [-32, 61], [-29, 3], [-16, -17], [4, 1], [-47, 7], [-45, -1], [49, 15], [-58, 28], [52, -5], [42, -14], [-35, 37], [-28, -13], [14, 18], [-8, -34], [-1, -9], [-29, 13], [-11, -25], [-4, -3], [20, -20], [-33, 29], [-30, 2], [-20, 18], [32, -33], [-33, -23], [-12, 16], [26, 0], [-17, -1], [22, 18], [-68, 10], [12, -31], [-13, 29], [-20, -31], [40, -34], [-26, 12], [-28, 32], [4, -12], [-26, 2], [-31, 13], [36, -29], [-28, 22], [-36, -14], [0, 24], [58, -34], [46, 24], [23, 27], [-2, 44], [9, -23], [28, -24], [-20, -25], [-58, -4], [-12, 6], [43, 15], [-22, -10], [-64, -12], [42, -52], [12, 38], [10, -44], [18, 4], [-28, -4], [-21, 43], [48, -9], [11, -9], [24, -63], [17, -11], [-28, -20], [-6, 18], [28, 11], [-32, 67], [-6, -30], [-22, 66], [-64, 34], [-52, 29], [-34, 32], [-12, 31], [6, -24], [18, -14], [-13, -5], [-28, 12], [-30, 50], [46, -34], [67, 11], [62, -4], [-30, 38], [60, 0], [-54, 24], [-24, 61], [14, 10], [-20, -20], [12, 24], [36, 1], [-44, 21], [-72, 37], [54, -16], [20, 3], [-5, 9], [70, 4], [39, -73], [52, 25], [-12, 20], [-43, 23], [-67, 17], [49, 25], [-48, -13], [-14, 30], [2, -54], [-32, -23], [-5, -33], [-19, 11], [-14, 32], [-16, -46], [-24, -35], [18, -30], [4, -44], [30, 24], [-61, 5], [43, -9], [18, 36], [-32, -2], [43, -43], [24, 7], [-48, 29], [4, -54], [-20, -15], [-24, 61], [62, -40], [-8, -29], [64, -16], [34, -50], [40, -23], [36, -42], [32, -16], [52, -44], [-36, 32], [4, 43], [-58, 64], [2, 42], [44, -2], [20, 13], [12, -28], [12, -24], [56, -42], [-24, -36], [12, 34], [24, -20], [-22, 12], [5, -55], [38, -12], [21, -15], [62, -4], [66, -22], [66, 6], [-42, 30], [-43, 47], [46, 20], [57, -61], [0, 3], [-48, 65], [-12, -6], [12, -8], [49, -49], [0, 5], [50, -36], [44, -9], [27, 9], [-41, 33], [-55, 65], [-24, 60], [-32, 5], [-32, 5], [10, 40], [-5, -41], [-21, 41], [50, -82], [12, -15], [-16, 1], [12, -54], [-10, -34], [30, -60], [-18, -10], [22, -8], [68, -34], [-48, -14], [-95, 17]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_7616_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_7616_2_a_p();".
// 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_7616_2_a_p(:prec:=2)
    chi := MakeCharacter_7616_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_7616_2_a_p();".
// 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_7616_2_a_p( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_7616_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<3,R![-1, 1, 1]>,<5,R![-1, -1, 1]>,<11,R![4, 6, 1]>,<19,R![-4, 8, 1]>],Snew);
    return Vf;
end function;