
// Make newform 3920.2.a.bx in Magma, downloaded from the LMFDB on 07 December 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_3920_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_3920_2_a_bx();".
// 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_3920_2_a_bx();".
// 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, 0, 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_3920_a();"
function MakeCharacter_3920_a()
    N := 3920;
    order := 1;
    char_gens := [1471, 981, 3137, 3041];
    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_3920_a_Hecke( : Kf := Kf)
    return MakeCharacter_3920_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], [1, 0], [0, 0], [1, -2], [-5, -1], [-5, 1], [-2, -4], [-2, -1], [1, -4], [6, 1], [-2, 1], [-2, -1], [-6, 4], [1, 7], [-8, -3], [2, -1], [-8, -2], [4, -5], [2, 6], [-8, -2], [1, 10], [-8, 0], [0, 12], [-3, 9], [2, -2], [3, 1], [14, -2], [9, 0], [2, 5], [12, -7], [-16, -3], [-4, -12], [-4, 7], [12, 6], [9, -2], [-2, 6], [-6, 11], [1, -1], [-3, 11], [2, 6], [-6, -3], [-11, 4], [0, -4], [-12, 11], [-14, 9], [13, -8], [17, -5], [-5, -9], [-14, 7], [-12, -2], [-17, -2], [-12, -11], [-20, 5], [6, -14], [-10, 0], [4, -9], [12, -12], [-6, 1], [-1, 0], [-23, -3], [13, -1], [5, 1], [-10, -12], [-1, 11], [2, 12], [-2, 2], [-6, 9], [6, -1], [-18, 0], [-5, -5], [0, 8], [7, -9], [8, -6], [-14, 0], [-12, -6], [-1, -10], [-13, 1], [9, 6], [-30, 2], [6, 11], [9, -8], [7, -2], [-6, -20], [20, -3], [10, -18], [21, -2], [-8, 5], [-28, -4], [-12, -18], [-9, -7], [8, -1], [6, -1], [11, 20], [-9, -16], [15, -17], [28, -5], [-18, -8], [16, 10], [-1, -12], [-16, -6], [12, 14], [2, 16], [-12, 14], [-2, 2], [7, -5], [-28, 2], [-5, 9], [-7, -14], [-34, 4], [21, 5], [-30, 8], [14, -19], [-16, -19], [31, -6], [28, -8], [-17, -15], [4, -22], [-38, -8], [15, -4], [20, -10], [-36, -6], [23, 9], [-4, 22], [12, 6], [9, 6], [-19, -16], [20, 3], [-18, 0], [1, -21], [-15, 4], [16, 5], [13, 10], [40, 2], [-8, -19], [-14, 10], [31, -9], [-31, 9], [17, -13], [23, 12], [-4, 11], [45, -2], [-4, 23], [-14, -17], [-10, 9], [4, -13], [2, -20], [18, -2], [-20, 18], [24, 3], [22, 8], [28, -20], [-24, -22], [18, -28], [10, 23], [16, -28], [27, 6], [34, 9], [-5, -9], [4, 0], [8, -17], [-12, 19], [-18, -18], [10, 23], [6, 10], [-1, 29], [-14, 8], [7, -31], [7, 16], [12, 10], [14, 12], [2, 38], [-13, 16], [10, 33], [6, 12], [4, 34], [19, 2], [13, -16], [-6, -8], [28, -6], [-48, 0], [32, 18], [6, 14], [-2, -20], [12, -24], [-16, -7], [-4, -7], [21, -21], [-27, 10], [-8, -30], [-22, -24], [22, 2], [33, 0], [-14, -3], [12, 2], [-11, -29], [15, -2], [-28, 17], [21, -17], [-5, -21], [-24, 18], [-2, 18], [14, 16], [38, 2], [6, -18], [-13, 17], [28, 1], [44, 6], [28, 16], [-24, -8], [-24, -5], [8, 19], [24, 29], [51, -9], [46, 8], [0, -22], [14, 19], [10, 21], [-50, -6], [-22, -11], [-18, 32], [30, -24], [9, -10], [6, -28], [-13, -5], [-38, 4], [-25, 19], [47, 4], [-5, 15], [2, 16], [-8, -6], [-14, 8], [-18, -2], [1, 36], [31, 13], [67, -5], [10, -23], [-4, -6], [-13, 6], [-16, 19], [-4, 12], [-8, -28], [-45, -21], [0, 22], [-35, -3], [18, 12], [-60, -4], [2, 6], [27, -4], [-22, 14], [18, -20], [18, 12], [-32, -29], [28, 0], [-34, -18], [-39, 12], [0, -18], [-6, 32], [-59, 13], [15, 5], [-46, 2], [-2, -3], [-30, -3], [-15, 21], [6, 16], [-32, 5], [29, -18], [-10, 34], [12, -13], [-22, 0], [-22, 25], [16, -29], [-15, -1], [-18, -16], [42, 16], [-39, 11], [-16, 10], [-4, -12], [-9, 24], [46, 22], [-33, 31], [49, 8], [-4, 8], [36, -19], [-15, 3], [11, 22], [10, -38], [-58, 0], [-38, 19], [-6, -9], [-13, -22], [25, 27], [-40, -17], [22, 31], [6, -16], [26, -25], [-52, -7], [57, 7], [24, 14], [-9, -39], [-39, -1], [-18, 19], [-29, 10], [-24, -28], [-1, 36], [-34, 9], [22, 34], [-16, -32], [38, -12], [44, 7], [68, -14], [21, -10], [24, -24], [-6, -6], [30, 0], [-24, 12], [10, -8], [5, -34], [29, -5], [-3, 34], [-78, 4], [4, 31], [-32, -9], [-8, -7], [2, -22], [-30, 9], [-27, 4], [-24, 0], [-52, 23], [20, 27], [16, 26], [-8, 9], [-20, 9], [-21, -7], [14, -10], [11, -27], [-27, -42], [56, 2], [26, -28], [-23, 43], [-14, -45], [-80, -1], [-12, -29], [-27, 0], [-2, 47], [-28, -24], [56, -7], [88, 0], [12, 23], [-9, -53], [-62, -3], [-32, 2], [51, 8], [-9, 9], [9, -2], [40, 6], [-82, 0], [52, -17], [30, 8], [-34, -5], [-20, -22], [-46, -31], [-16, -21], [-35, -12], [-20, 12], [42, 22], [-27, 23], [-34, 38], [15, 20], [31, 24], [-36, -2], [-24, 11], [63, 12], [30, 12], [-34, 14], [16, -50], [-11, -2], [-19, -17], [-36, 39], [-33, 41], [-22, 24], [22, -53], [32, -23], [-22, 3], [30, -5], [51, 29], [-59, -8], [5, 23], [12, 54], [23, 45], [-33, -38], [-21, 21], [-47, 40], [44, 26], [-31, -38], [4, 12], [24, 10], [34, -35], [15, -10], [-16, 36], [-36, 0], [-16, -19], [2, -51], [15, -31], [16, 12], [14, 54], [30, 45], [65, 18], [-8, -20], [72, 16], [-23, -51], [-42, 22], [38, 23], [6, 50], [-26, -33], [-20, 18], [29, -40], [60, 10], [22, 2], [-13, -11], [45, 4], [-62, -20], [-6, 24], [16, -10], [-9, 17], [-3, 35], [36, 13], [-12, -38], [-22, 29], [28, 8]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_3920_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_3920_2_a_bx();".
// 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_3920_2_a_bx(:prec:=2)
    chi := MakeCharacter_3920_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_3920_2_a_bx();".
// 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_3920_2_a_bx( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_3920_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<3,R![-1, -2, 1]>,<11,R![-7, -2, 1]>,<13,R![23, 10, 1]>,<17,R![23, 10, 1]>],Snew);
    return Vf;
end function;