
// Make newform 8208.2.a.bp in Magma, downloaded from the LMFDB on 11 March 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_8208_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_8208_2_a_bp();".
// 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_8208_2_a_bp();".
// 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, -4, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0], [0, 1, 0], [-3, -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_8208_a();"
function MakeCharacter_8208_a()
    N := 8208;
    order := 1;
    char_gens := [7183, 2053, 1217, 6481];
    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_8208_a_Hecke( : Kf := Kf)
    return MakeCharacter_8208_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], [0, 0, 0], [2, -1, 0], [0, 0, 1], [-3, 0, -1], [0, 0, 1], [1, 2, -2], [1, 0, 0], [-4, 3, 0], [-3, -1, -4], [1, 0, 1], [-3, -1, 1], [2, -1, 0], [-4, 5, 2], [-9, 0, 0], [2, 1, 5], [-1, 1, -3], [2, 2, 1], [2, 5, -1], [1, -4, -1], [-1, 2, 2], [-1, -5, -1], [-1, -6, -4], [-1, -4, -3], [-9, 1, -3], [6, 2, 3], [7, -3, -4], [1, 1, 0], [0, 5, 0], [-4, 1, -3], [1, -2, 4], [-6, 7, 1], [-10, 4, 1], [1, 4, 2], [-12, 0, -3], [3, -1, 7], [9, 4, 8], [-13, -1, 0], [-13, 1, -3], [-9, 5, 1], [1, -6, 1], [8, -6, 1], [3, -6, -3], [-2, 0, -3], [2, -7, 4], [1, -5, -6], [-2, -9, -5], [5, 3, 5], [-8, 5, 5], [-4, -5, -6], [13, -6, -5], [5, -5, 7], [-13, 1, 2], [18, -6, -1], [7, -5, 7], [-6, -3, 4], [7, -10, -3], [4, -10, 2], [1, 9, 9], [-17, -2, 4], [8, 6, -2], [-17, -3, 3], [-9, -6, 6], [1, 1, 6], [1, 10, 2], [3, 6, -4], [-11, -1, 4], [-5, 16, 2], [-12, -9, -2], [-18, -5, -1], [2, 3, -6], [-5, -11, 2], [21, -8, -3], [-6, -7, 3], [3, 3, 4], [-14, 0, 2], [3, -15, 3], [2, 12, -8], [-23, 4, 3], [23, -13, -4], [5, -1, -7], [-18, 2, 5], [-17, 2, -9], [13, 3, 10], [1, -2, -4], [8, 7, 15], [-21, 16, 5], [1, -7, 7], [11, -2, 1], [7, 9, -3], [3, 11, 9], [0, 4, -6], [-10, 14, -1], [14, 0, -4], [10, -5, -4], [-1, -11, 6], [-7, 12, -7], [-16, 0, -4], [12, 10, 7], [-12, -1, -8], [-6, -1, 11], [-4, -11, -10], [11, -19, 0], [-2, 2, 5], [-10, 8, -3], [-7, -5, -2], [-23, -3, -3], [7, 2, 2], [5, -2, -8], [-18, -8, -7], [-4, 1, -12], [-22, -2, -2], [11, 3, -4], [-18, 7, 3], [-8, -14, -6], [6, -7, 1], [27, 1, 1], [-24, 6, -6], [2, 3, 5], [-8, 10, -1], [-2, -4, 2], [-7, 3, -13], [11, -18, -3], [-2, 14, -10], [-9, -2, -8], [11, 4, -12], [-20, -5, 6], [-5, -5, 0], [-9, -2, 9], [20, 2, -1], [5, 10, 2], [0, -6, -1], [1, 7, 9], [-12, 5, -12], [15, 17, -5], [-7, 7, 8], [22, -13, -2], [11, -4, 7], [10, 2, -12], [-10, 6, 7], [-15, -5, -12], [3, -12, -9], [19, -5, 1], [4, 0, -5], [0, -19, 15], [-14, 17, 8], [15, 4, 7], [-22, 4, -13], [18, -11, -1], [-13, 20, 2], [-13, 0, 2], [16, 12, 12], [6, -9, -4], [-22, -1, 0], [-21, 5, -16], [12, -17, -7], [-19, 5, 5], [21, 10, 12], [17, 6, -7], [7, -20, -12], [-13, -9, -15], [-22, -3, -6], [8, 0, 9], [-11, 5, -7], [3, -3, 12], [-43, -3, 1], [-15, 20, 15], [-4, 3, -14], [15, 0, 17], [28, 5, 9], [-8, 22, 0], [3, -20, 3], [-13, 0, 7], [-36, -2, -13], [-7, 11, 9], [-15, -8, 2], [13, -14, -15], [-17, 15, -5], [44, -2, 6], [14, 13, -4], [18, -26, -9], [44, 7, -5], [-4, 21, 13], [37, 5, 10], [-5, 5, 6], [-24, -4, -3], [5, -26, 4], [-5, -3, -8], [-9, 20, 2], [-2, -6, -9], [-23, 6, -18], [1, 13, -10], [10, 4, 5], [49, -9, 1], [13, -13, -7], [-5, 18, 14], [-8, -5, -20], [0, -8, -5], [27, 6, -10], [-34, 8, 6], [-28, -16, 7], [-14, 21, 6], [40, 11, -6], [-3, 8, 15], [18, 9, 17], [41, -5, 4], [19, 13, 11], [41, 0, 11], [-35, 13, -6], [11, 9, 11], [6, 1, 11], [-8, -13, -1], [23, -13, -1], [-16, 4, -1], [-30, -12, -5], [-21, -7, 8], [-26, 0, -4], [0, 12, -18], [18, 0, 21], [26, 4, 0], [10, -3, -5], [-7, 9, 4], [-4, 7, -20], [-52, 7, -1], [-14, 25, 10], [14, -18, 15], [-8, 11, -4], [-6, 3, 0], [26, 8, -4], [-8, -13, -11], [19, -1, 10], [28, -22, -11], [-19, 18, 6], [17, -20, 7], [-18, -7, 5], [-3, 8, -14], [16, -11, -3], [52, 3, -2], [2, 10, -14], [0, 18, 8], [25, 8, 4], [9, 21, -3], [9, -4, -7], [1, -26, -16], [36, -16, -6], [-3, 5, 19], [13, 4, -13], [22, -9, -2], [5, 18, 9], [22, 13, -12], [25, -5, 11], [31, 10, 3], [16, 13, 15], [-9, -12, -5], [41, 7, 0], [52, -7, -6], [-9, -8, -12], [47, 6, 12], [-25, -11, 0], [40, 11, 12], [-37, 8, 3], [-4, 14, 4], [24, -1, -9], [-4, -23, -10], [-13, 13, 7], [-24, 3, 5], [-25, 15, 6], [26, 15, 4], [0, -25, -22], [-12, 31, 17], [26, -11, 21], [-10, 0, -17], [12, -20, -12], [-14, 2, -19], [12, -15, -10], [-18, 11, -10], [-13, -5, -16], [9, 12, -1], [3, 18, -22], [38, 10, -6], [6, 3, -14], [-22, 27, 1], [-1, 13, -11], [34, 6, -4], [6, -21, 24], [18, 15, 0], [-41, 7, -12], [-16, 7, 0], [-30, 4, -3], [-12, -26, -7], [28, 12, 13], [7, 14, 12], [1, 3, 19], [2, -14, -13], [17, 3, 1], [-48, -3, -7], [0, 17, 14], [-17, -3, -14], [39, -21, -6], [15, -14, 20], [-3, -4, 14], [0, -21, -15], [-21, -7, 9], [34, -6, 23], [-36, -18, 1], [41, 16, -3], [10, -1, -5], [-20, 21, 2], [29, 4, -8], [-2, 3, 25], [-20, -2, 5], [-23, 1, 9], [39, -19, 0], [-10, 0, -10], [5, 4, -11], [-19, 9, -5], [20, -35, -2], [-50, 28, 13], [12, -7, 13], [10, 22, 1], [8, 8, -8], [31, -12, 13], [24, 1, 27], [-25, -6, -1], [-41, -7, 5], [-21, 27, -2], [-16, 14, 20], [-34, -3, -2], [53, -14, -6], [2, -18, 14], [9, -11, -6], [19, 29, -18], [10, -9, -4], [9, 6, 1], [34, -1, -1], [14, -4, 19], [-37, 3, -3], [34, 6, 19], [5, -4, -15], [21, -2, -8], [2, -4, -2], [4, 6, 4], [8, 16, 9], [6, -23, 18], [-8, -12, -17], [-2, -21, -23], [3, -21, -12], [-42, -16, 15], [-16, -5, 25], [6, -5, -10], [1, 12, 19], [-43, 27, 11], [36, 9, 1], [-15, -18, -12], [-51, 13, -10], [-21, 27, -11], [5, -23, -5], [-16, 18, 13], [6, 27, 2], [-32, -22, 16], [2, -9, 12], [-33, -6, -25], [-44, 2, -4], [6, 30, 18], [35, -12, 6], [2, 18, -9], [-39, 20, -8], [-21, -29, 11], [49, 5, 19], [56, -1, 14], [-7, -21, 3], [-56, 7, -13], [-30, -6, -2], [-10, 10, 3], [-32, 24, -15], [-49, -12, -23], [18, -13, 11], [-36, 16, 15], [15, -12, 6], [-39, -13, -34], [44, 25, -10], [19, -13, -22], [-30, -25, 2], [-36, 9, 2], [-12, -20, -28], [9, -11, 5], [-5, 25, -2], [-7, 3, -26], [-22, 23, -10], [5, -29, -8], [-4, 8, 18], [-11, -1, 13], [10, -20, 21], [45, -11, -4], [-65, -9, -7], [-52, -8, -7], [-3, 31, 5], [-4, -11, 10], [-30, -6, -25], [-3, 8, 22], [6, -18, -7], [7, -8, -27], [-30, -23, -17], [35, -23, -8], [-33, -6, -7], [-28, 14, -12], [-8, 2, -23], [45, -27, 7], [-10, 16, 4], [-5, 4, 20], [10, -42, -14], [0, -4, -2], [-22, 19, -25], [-11, 33, 18], [47, -16, 7], [83, 7, -5], [25, 27, 4], [2, 15, -20], [35, -1, 33], [-11, -33, 13], [-16, 22, -1], [-26, 7, 6], [44, 0, 27], [-54, 0, 15], [-12, -30, -26], [-34, 28, -11], [7, 9, 19], [18, -18, 21], [4, 16, 7], [18, -48, -6]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_8208_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


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