
// Make newform 7935.2.a.w in Magma, downloaded from the LMFDB on 13 December 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_7935_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_7935_2_a_w();".
// 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_7935_2_a_w();".
// 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, -3, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0], [0, 1, 0], [-2, -1, 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_7935_a();"
function MakeCharacter_7935_a()
    N := 7935;
    order := 1;
    char_gens := [5291, 4762, 7411];
    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_7935_a_Hecke( : Kf := Kf)
    return MakeCharacter_7935_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, -1], [-1, 0, 0], [1, 0, 0], [0, -1, 1], [0, 2, 1], [1, -1, 0], [-1, 2, -1], [-1, -1, 0], [0, 0, 0], [2, -5, 0], [2, 3, -1], [-5, 0, 2], [3, -4, -3], [-1, -1, -5], [2, -2, 1], [0, 5, 6], [0, 1, 2], [-11, 5, 2], [-5, 2, -2], [-7, 2, 1], [-3, 3, 0], [-4, -4, 0], [-9, 0, 1], [-6, 0, -4], [-5, 9, 5], [-9, 2, 1], [9, 1, 3], [4, -1, 0], [-1, 7, 6], [-8, 5, -2], [5, -5, -4], [-2, -2, 4], [5, -7, 1], [-7, 0, -8], [-2, -6, 9], [-3, 5, 7], [2, 9, 1], [10, 4, -4], [2, 0, -5], [-6, -4, -6], [-1, 5, -1], [0, -8, -10], [14, 2, 7], [12, 4, 2], [6, -12, -6], [-10, -2, 0], [7, -12, 2], [-4, -2, 2], [-12, 4, -4], [-8, 12, 2], [-16, 0, 4], [1, 0, -11], [1, -3, 10], [2, -12, 0], [4, 6, 11], [-4, -3, 8], [2, 9, -4], [7, -6, -10], [20, -2, 6], [-2, -2, -13], [12, -3, -7], [7, 0, -11], [1, 1, -8], [-10, 14, 6], [-9, -10, 4], [-2, -2, 5], [-2, -5, 3], [-22, 4, 2], [10, -6, 4], [1, 2, -14], [18, -6, 5], [8, -10, -9], [-13, -4, 2], [17, -13, -5], [2, 10, 2], [-9, -2, 7], [8, -2, -4], [2, -8, -16], [-24, 8, 8], [-23, 0, 2], [-6, 0, -11], [-13, -7, -12], [-4, -6, -10], [-18, -5, -1], [-3, -11, -13], [8, 8, 21], [-6, 15, -4], [-7, 0, -10], [0, 10, 12], [1, -5, -12], [20, 3, 4], [10, 4, 7], [-7, 13, 10], [-13, 12, 5], [26, -11, 1], [-3, -8, -3], [17, 1, 1], [6, -20, 5], [0, 0, 4], [3, -7, 11], [-12, 22, 6], [16, -23, -16], [8, -7, -2], [-14, -6, -18], [-15, 3, -10], [4, 2, 14], [-6, -6, 12], [2, 16, 11], [-12, -12, -14], [-4, 5, 7], [19, -21, -6], [-6, -16, -8], [21, -10, -1], [30, 4, 4], [-13, 1, -12], [-14, -4, 9], [1, 0, -6], [0, 8, 7], [-8, -14, 1], [-14, 14, 11], [-10, 2, 0], [13, -1, 8], [-18, -15, 2], [-4, 8, -9], [-1, 23, -7], [-14, -4, -5], [-9, -3, -14], [0, -3, 10], [-34, 7, 5], [-7, -2, -4], [-20, 5, 1], [26, -18, -14], [3, -5, 0], [16, -9, 5], [6, -3, -4], [-3, 3, -16], [6, 12, -18], [-5, 26, -4], [0, 11, 10], [-9, -2, -15], [-11, -6, 18], [-21, -1, 11], [26, 8, -4], [34, -1, -8], [-34, -7, -11], [-24, 6, -2], [18, -26, -4], [-12, -18, -10], [-19, -10, 10], [18, -12, -14], [-4, 2, 12], [6, 2, -11], [-19, 13, 10], [2, 22, -10], [-17, -2, -24], [0, 16, -8], [28, -26, -10], [-8, -19, 2], [1, -21, 7], [-10, -6, 11], [4, -2, 22], [-12, -18, -12], [21, -5, 16], [-2, -2, -16], [-21, 8, 3], [-17, 0, -11], [33, 2, 8], [-4, 18, -12], [16, 14, 14], [24, 14, -1], [26, 16, -10], [-1, 2, 0], [12, -4, -10], [4, 1, -11], [-10, -14, -8], [-6, 16, 13], [-23, -11, 5], [-10, -13, -20], [3, 0, 16], [-19, 1, 18], [-23, 5, -4], [14, 4, 1], [-2, 2, 0], [-20, -12, -13], [12, 17, 4], [-6, 24, -5], [3, -9, -24], [-33, -12, -12], [-22, 5, -5], [-7, -10, 9], [-1, -19, -22], [-26, 32, 8], [35, -3, 0], [-27, 2, 17], [3, -27, -1], [4, -1, 12], [49, -1, 0], [-9, 5, -21], [-50, 4, -2], [-2, 28, -4], [-2, 24, 5], [19, 3, 17], [15, -21, 2], [-35, -7, 8], [-20, 26, 5], [-8, -6, 16], [-25, 7, -8], [2, 16, 17], [-13, 16, -9], [-19, -11, 9], [-2, 14, -4], [12, -2, -4], [7, -5, 13], [-43, 7, 13], [-22, 7, 20], [-23, -1, 4], [4, 14, 28], [21, 2, -3], [30, -9, 10], [-18, 10, -15], [-10, -15, -27], [-50, -10, 8], [2, -5, 2], [9, 22, 20], [-20, 6, -9], [15, 0, 12], [34, -16, -12], [-15, 4, 7], [20, 12, -4], [49, -14, -7], [17, 25, -22], [1, -27, 16], [12, 24, 2], [-10, -5, -6], [5, 20, 18], [19, -15, -9], [-29, 7, -6], [-12, 2, -8], [14, -21, -8], [0, -9, 4], [25, -26, 3], [10, -5, 25], [14, 16, 2], [-9, -15, -13], [12, -18, -28], [-6, -6, -14], [19, 9, -6], [18, -4, 1], [34, -34, -20], [-41, 0, 7], [-23, 11, 13], [18, -28, -4], [-21, 34, 13], [10, 12, -6], [-48, 18, -1], [0, 13, 6], [-35, 7, -4], [-22, 2, -32], [64, -16, -9], [38, 12, 24], [-41, 20, 8], [14, -33, -18], [-24, 21, -5], [-22, -3, -3], [2, 14, -24], [17, -23, -32], [-4, -18, -11], [-42, -6, -4], [28, -11, -1], [18, 22, -22], [-12, -1, -29], [-3, 28, 8], [9, 10, -6], [16, 10, -14], [-3, 21, -4], [-27, 35, 2], [16, 8, -19], [-40, -13, 3], [-7, -9, 26], [-2, -18, -3], [2, 2, 24], [1, -21, 8], [36, -16, -6], [10, 20, -12], [13, -33, -12], [-18, 41, 20], [14, -1, 5], [34, 12, 14], [1, 21, 27], [40, 2, 10], [0, 18, -28], [23, -14, -27], [8, -28, -10], [-6, -20, 25], [-7, 33, 16], [36, -12, -24], [-37, 19, 6], [-14, 24, 11], [-12, -1, 10], [-14, -10, -14], [-14, 13, -9], [-3, 20, 9], [20, -38, 4], [-2, -2, -15], [-6, 16, 24], [19, 1, 18], [14, -38, 1], [54, 2, 18], [22, -34, -19], [-31, 7, 10], [-30, -8, -10], [22, 2, 11], [-34, 4, 1], [16, -46, -10], [-15, 0, 5], [-17, 7, 8], [6, 11, 10], [31, 22, 17], [28, -11, -29], [-31, -15, 1], [35, 5, 30], [1, 8, 24], [16, -14, 14], [52, -10, -6], [28, -19, 0], [-43, -11, 16], [-9, -33, 24], [-35, -3, -28], [66, -6, 10], [35, 20, -11], [9, 2, 32], [-22, -10, 7], [-12, -21, -19], [-6, -24, 1], [-26, 16, 12], [4, -26, 24], [-8, 14, 0], [20, 22, 16], [-25, -7, 23], [-5, 34, 38], [6, -6, -16], [8, -10, -2], [-30, 12, -18], [5, -21, 14], [-12, -1, 16], [63, 4, -7], [-32, 35, 9], [-7, 31, 34], [-20, 6, 26], [-37, 0, -27], [12, -41, 1], [33, -1, 28], [43, -14, -11], [-21, -20, -4], [35, -11, 14], [36, -6, 18], [22, 12, -25], [-10, 0, 8], [2, 18, 13], [40, -18, -20], [-35, 14, 20], [-11, -14, -1], [54, 8, 2], [52, -26, -2], [12, 4, 2], [-52, -22, 4], [10, 2, 15], [-19, -28, -4], [10, 6, -18], [66, -7, -6], [26, 3, 3], [34, 4, -16], [20, -20, -30], [16, 10, 42], [27, -25, -26], [32, 17, 22], [-12, -18, -36], [-46, 31, 21], [-18, 4, 20], [2, -4, 18], [12, 12, -20], [10, 12, -24], [-34, -18, 22], [-50, -14, -23], [-32, -16, -2], [-16, -12, 18], [-31, 10, 4], [7, 21, -38], [-4, -1, -1], [3, 0, -23], [-31, 11, 4], [-18, 24, -26], [-7, -18, -41], [21, -7, 18], [-40, 18, 1], [-60, 1, -23], [-52, 14, 24], [-42, -8, -16], [-16, 34, 30], [-29, -24, 25], [5, -26, -4], [-10, 2, -8], [-16, 5, 25], [-27, 10, 31], [69, 12, -5], [22, -15, 29], [-41, -10, 12], [50, 4, -6], [-13, 19, 15], [-20, 0, 10], [43, 3, -8], [22, 4, 21], [4, 40, 10], [0, 8, -22], [-20, -13, 13], [-42, -8, -28], [12, 32, -24], [-17, 9, -32], [-25, -30, 19], [-54, 10, 20], [-22, 10, -1], [43, 5, 21], [4, -20, -7], [-22, 26, -4], [17, -39, 14], [-12, 36, 44], [4, -40, -28], [25, -56, -11], [-1, 27, 29], [-52, -5, 4]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_7935_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


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