
// Make newform 8325.2.a.bi in Magma, downloaded from the LMFDB on 13 January 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_8325_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_8325_2_a_bi();".
// 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_8325_2_a_bi();".
// 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 := [-3, -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_8325_a();"
function MakeCharacter_8325_a()
    N := 8325;
    order := 1;
    char_gens := [3701, 7327, 5626];
    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_8325_a_Hecke( : Kf := Kf)
    return MakeCharacter_8325_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, -1], [0, 0], [0, 0], [3, 0], [-1, -1], [5, 0], [-4, 3], [4, -3], [1, 2], [2, 3], [-1, 4], [-1, 0], [11, 0], [6, -1], [3, -4], [0, -4], [-1, 5], [-1, -4], [-2, 5], [-2, -5], [9, -1], [-5, -1], [5, 1], [-7, 4], [5, 2], [6, -3], [-5, 0], [8, -2], [-10, 3], [13, 1], [11, 3], [3, -6], [-10, 1], [0, 5], [3, -4], [1, -6], [11, -4], [0, -2], [8, -5], [-11, -4], [9, 4], [-13, 3], [-8, 4], [4, -12], [-5, 8], [-17, 6], [17, -3], [15, -8], [8, 8], [2, -2], [19, -4], [13, -12], [13, -3], [-12, 9], [2, 1], [14, -7], [11, 2], [-28, 2], [-4, 4], [8, -17], [0, -3], [-15, -6], [27, -4], [6, 0], [4, -9], [18, -2], [6, 9], [-11, -2], [-12, 2], [2, -13], [-7, -8], [-13, -2], [-2, 17], [2, 3], [16, -3], [-11, 5], [4, -4], [-5, -14], [14, -2], [4, 7], [10, 4], [19, 0], [0, 6], [-2, -5], [6, 4], [21, -12], [-15, 7], [-24, -4], [-9, -6], [30, 0], [9, 13], [-21, 0], [-9, 7], [-25, 0], [-8, 12], [-12, -8], [20, 8], [0, -13], [-7, 3], [-15, 0], [-14, 22], [3, -3], [-36, 3], [-14, 17], [-15, 14], [-22, 11], [27, -6], [19, 0], [-15, -10], [2, 0], [11, -18], [-4, 18], [9, -21], [-4, -6], [5, -7], [19, 8], [1, -1], [10, 4], [-12, -8], [-15, 22], [-11, 0], [26, 7], [-30, -3], [-2, -10], [-29, -6], [-20, -8], [-6, 16], [-1, 4], [-18, 7], [13, 12], [-12, 25], [11, 15], [-25, 5], [-10, 15], [23, 7], [2, -3], [-18, 24], [-29, -5], [-25, 8], [-17, 1], [8, 19], [9, 6], [14, -22], [-3, -4], [14, -8], [-9, 2], [-6, -6], [3, 8], [6, 16], [9, 13], [39, -9], [-18, -17], [31, -6], [33, -12], [0, 6], [-23, -6], [18, -14], [-16, 0], [22, -19], [3, 17], [22, 2], [-4, -18], [13, 3], [-5, 14], [-25, 9], [-36, 15], [-41, -5], [33, 3], [43, 4], [-3, 16], [-1, -14], [21, -29], [-12, 9], [-17, 23], [-23, -15], [-25, 22], [-6, -18], [21, -24], [6, 4], [5, 20], [12, 1], [9, -1], [-25, 12], [8, 8], [30, -9], [18, -11], [14, 1], [32, -3], [-5, 31], [37, -18], [23, 9], [4, 10], [3, 9], [-36, 22], [-3, 9], [-2, 12], [18, 1], [4, -7], [-38, 17], [-15, 1], [-13, -5], [6, 18], [-29, 2], [-46, -4], [15, -6], [-54, 6], [-50, -2], [52, 1], [-3, -6], [-17, 4], [-17, 24], [27, 5], [-8, -16], [-19, 33], [0, -3], [36, -22], [10, 22], [-33, -6], [-12, -2], [9, 12], [-28, -1], [49, -8], [9, 3], [-3, -28], [28, -15], [-5, -11], [-23, 8], [20, -27], [6, 11], [42, 6], [-38, 14], [-5, -9], [-21, 11], [-29, -6], [-19, 14], [11, 16], [14, 19], [39, -20], [30, -21], [1, 8], [-2, -4], [-35, -16], [4, 16], [67, -7], [-15, -6], [-38, 0], [-11, -9], [-18, 1], [-35, 1], [33, 14], [-17, 1], [-30, 13], [0, -12], [61, -10], [-67, 2], [-36, -9], [-28, 11], [3, 7], [6, -9], [29, -19], [6, 20], [15, -20], [49, 1], [19, -16], [-27, -9], [4, 6], [-36, 4], [15, 17], [-1, -4], [-56, -2], [-33, 23], [-7, 6], [-37, -16], [-36, 0], [0, -15], [-10, 26], [3, -12], [-38, -4], [16, 2], [-38, 8], [21, -20], [9, -20], [-53, -6], [-39, 9], [-35, 32], [35, -14], [-25, -9], [-15, 33], [60, -19], [-38, 29], [27, 2], [49, -9], [-49, 13], [0, -3], [34, -18], [35, -14], [-17, -20], [-15, 6], [27, 12], [-28, -4], [-37, 19], [-12, 29], [5, 2], [-62, 2], [67, 6], [62, -19], [29, 13], [-22, 3], [8, -2], [-5, 8], [29, -35], [-15, 24], [-36, -6], [16, 30], [-16, -1], [64, -3], [2, 16], [-33, -6], [23, 13], [-3, -27], [-31, -24], [42, -38], [21, -8], [53, -15], [17, 1], [11, 8], [-23, 28], [-40, 6], [-42, 0], [-26, 13], [-44, 14], [42, -13], [-14, -2], [21, 7], [31, 1], [-26, 6], [82, -5], [5, 17], [33, -40], [-6, -33], [-41, 10], [24, -23], [42, -33], [-41, -22], [-42, 11], [36, -12], [-22, 6], [51, -1], [72, -3], [-9, 13], [41, -23], [-40, 40], [-31, -6], [-24, 2], [19, 11], [-48, 9], [-15, -4], [10, 2], [28, -46], [-17, 7], [-52, 15], [9, -11], [28, 11], [38, -16], [24, -11], [81, -7], [54, -3], [-33, 3], [-27, -4], [75, 3], [-23, -7], [-39, -4], [-42, -21], [-37, -2], [-19, -27], [-35, 15], [12, -30], [1, 6], [-6, 18], [30, 20], [41, 6], [12, -18], [-35, 10], [-52, 29], [-61, -8], [66, -4], [-30, 44], [55, -12], [-43, -8], [10, 29], [-66, -3], [-12, -16], [-30, 25], [-9, -14], [0, 7], [37, 18], [38, -21], [54, -15], [-7, 2], [73, 2], [-87, -2], [7, 26], [11, -33], [-75, -8], [-15, -4], [-10, 20], [-27, -32], [-90, 5], [23, -29], [18, 3], [-11, -4], [27, -12], [-33, 29], [-41, -10], [68, -16], [0, -14], [65, -15], [21, 8], [-9, 30], [78, -11], [18, -28], [49, 16], [27, 3], [15, 10], [43, -12], [-16, -36], [11, 20], [39, 18], [6, -7], [15, -8]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_8325_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


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