
// Make newform 3920.2.a.bl in Magma, downloaded from the LMFDB on 17 March 2026.
// 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_bl();".
// 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_bl();".
// 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
        Kf := Rationals();
    end if;
    return [Kf!elt[1] : elt in input];
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], [3], [1], [0], [5], [3], [1], [6], [-6], [-9], [-4], [2], [4], [-10], [-1], [4], [-8], [8], [-12], [-8], [-2], [-13], [-4], [-4], [13], [-6], [19], [6], [-3], [14], [8], [-10], [-12], [-14], [-6], [-5], [2], [10], [3], [1], [12], [20], [-3], [-4], [8], [8], [11], [-5], [-1], [-4], [24], [-1], [26], [30], [-14], [-2], [-18], [0], [6], [11], [-31], [5], [-23], [-18], [7], [-26], [-28], [22], [-10], [-10], [-3], [16], [-17], [-4], [-12], [36], [-31], [-7], [25], [-6], [36], [-19], [9], [-2], [-2], [14], [-9], [16], [-40], [16], [5], [6], [-26], [15], [9], [-3], [14], [-14], [4], [39], [24], [40], [-28], [-30], [12], [-13], [-16], [27], [-15], [-30], [13], [42], [-46], [-10], [-47], [2], [19], [-8], [2], [-31], [32], [4], [27], [-8], [28], [-5], [31], [6], [24], [47], [5], [-36], [19], [-32], [18], [-22], [-45], [31], [33], [9], [14], [-39], [-28], [-50], [28], [2], [10], [-18], [36], [-16], [26], [-32], [36], [8], [-14], [48], [31], [-28], [37], [-32], [-8], [24], [2], [-24], [-42], [-43], [-16], [-11], [-35], [-58], [-56], [46], [-27], [42], [14], [-52], [17], [9], [20], [56], [52], [-12], [38], [10], [12], [30], [-56], [59], [-23], [-48], [-18], [-34], [-25], [40], [36], [51], [-41], [-44], [-15], [35], [46], [-58], [-18], [6], [-30], [61], [-58], [-60], [54], [-64], [36], [-42], [-4], [-1], [-18], [-20], [50], [12], [2], [-42], [26], [-58], [-27], [-6], [71], [38], [5], [25], [43], [4], [4], [18], [32], [9], [7], [75], [8], [32], [-65], [-50], [56], [56], [15], [70], [75], [-6], [-40], [-42], [19], [22], [10], [-18], [36], [-24], [-54], [-7], [-58], [4], [3], [75], [-18], [-22], [-4], [-65], [78], [14], [-39], [-2], [68], [42], [48], [-12], [-11], [36], [-38], [47], [-68], [50], [33], [22], [-77], [19], [-48], [18], [-1], [81], [-74], [-30], [20], [12], [33], [-43], [-32], [68], [66], [72], [-2], [83], [-60], [59], [-15], [-34], [53], [48], [-17], [42], [-26], [0], [-24], [-88], [24], [-45], [-50], [22], [30], [76], [54], [33], [9], [-67], [58], [-8], [-50], [-36], [30], [4], [7], [60], [-16], [36], [-10], [12], [10], [33], [-44], [-21], [-35], [30], [74], [-73], [-38], [-8], [-66], [-35], [78], [68], [-30], [-4], [54], [57], [-40], [-96], [-63], [47], [-39], [18], [42], [58], [42], [-54], [-16], [-56], [-56], [41], [-20], [34], [-55], [-46], [85], [-63], [-32], [-88], [-45], [74], [10], [-88], [93], [-29], [-6], [-57], [-22], [22], [36], [-42], [96], [51], [33], [-5], [52], [97], [-55], [53], [11], [60], [-31], [-56], [28], [-64], [93], [66], [-60], [-60], [2], [-3], [20], [70], [-70], [63], [-12], [-60], [61], [-42], [-42], [68], [14], [56], [9], [12], [-90], [11], [-35], [58], [-54], [-100], [-9], [17], [-32], [-6], [-8], [-64]];
    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_bl();".
// 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_bl(:prec:=1)
    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_bl();".
// 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_bl( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_3920_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<3,R![-3, 1]>,<11,R![-5, 1]>,<13,R![-3, 1]>,<17,R![-1, 1]>],Snew);
    return Vf;
end function;