
// Make newform 2205.2.a.bg in Magma, downloaded from the LMFDB on 15 June 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_2205_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_2205_2_a_bg();".
// 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_2205_2_a_bg();".
// 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, -4, -6, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0], [0, 1, 0, 0], [-3, -1, 1, 0], [0, -4, -1, 1]];
    Rf_basisdens := [1, 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_2205_a();"
function MakeCharacter_2205_a()
    N := 2205;
    order := 1;
    char_gens := [1226, 442, 1081];
    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_2205_a_Hecke( : Kf := Kf)
    return MakeCharacter_2205_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 := [[-1, -1, 0, 1], [0, 0, 0, 0], [1, 0, 0, 0], [0, 0, 0, 0], [-2, 0, -2, 0], [0, 0, 2, -2], [-2, 2, 2, -2], [-2, 2, 0, 1], [0, -2, -2, 1], [-2, 4, 0, 0], [-2, -2, 0, -1], [2, -4, 0, 2], [0, 2, 2, 0], [-2, -2, 2, 0], [-2, 0, 0, -6], [-2, 0, 2, -1], [-4, -4, 0, 6], [-8, 0, 0, 1], [0, -4, -4, 6], [2, 4, 2, -2], [0, 4, -2, -2], [0, -2, -2, 8], [-10, 0, 0, -2], [2, 0, 0, 2], [0, -4, -2, 8], [4, -2, -2, 4], [4, 4, 0, -2], [0, 2, -2, -1], [2, 0, 0, 4], [-6, 0, 6, -9], [-10, 2, -2, -2], [-6, 2, -6, -4], [-2, 0, -6, -1], [-6, 2, -4, 1], [-6, -4, 4, 0], [0, 10, -2, -8], [-4, 0, 2, -6], [2, 2, 6, -6], [-4, -4, -4, 8], [-6, -6, -2, 10], [6, -8, -2, 6], [-8, 4, 0, 7], [2, 4, 2, 4], [12, -6, -6, 2], [-2, 4, -2, 7], [-6, -2, -4, -1], [4, 4, 0, 4], [-12, -4, 4, 2], [-8, 0, 4, 0], [-12, 0, 0, -5], [-14, 0, -6, 3], [2, -8, 6, 4], [-8, -12, 0, 9], [-4, 0, -4, 6], [2, 0, 4, 0], [0, 2, 6, -7], [0, 2, -6, -2], [-6, -6, -4, 11], [-8, 6, 2, 0], [-10, -4, 4, -8], [-4, 4, 8, -2], [-6, -4, 0, -4], [-4, 0, 0, -8], [14, -6, 2, -4], [12, -8, -6, -2], [2, -4, -2, 11], [4, 4, 0, -8], [12, -2, -2, -10], [-8, -6, -6, 1], [-4, -12, 4, 3], [2, -12, 4, 4], [2, 0, -2, -4], [0, 12, 4, -6], [-2, 8, 0, 8], [-8, -2, 2, 8], [-2, -4, 0, -6], [6, 0, 4, -14], [12, -4, -2, -4], [10, 8, 0, 2], [16, 4, -4, 11], [-4, 4, 4, -4], [4, 0, -8, -4], [2, 4, 2, -14], [4, 4, 2, -10], [2, -2, 0, 17], [16, -2, 6, 3], [-18, -12, -8, 20], [10, 0, 4, 18], [10, 4, -4, -10], [-10, 14, 2, -10], [-4, -4, 8, -8], [-6, 10, 2, -4], [-14, 6, 2, -8], [10, 8, 2, -18], [-12, -6, 6, 4], [6, 0, 12, -10], [0, -2, 6, 14], [4, 10, 2, -18], [-4, 4, -4, -10], [4, -4, -12, 12], [-4, 0, 0, -10], [10, 8, 6, -15], [2, 4, 8, 10], [6, -8, -8, 18], [-4, 0, 16, -12], [28, -4, 10, 6], [-14, 8, 4, 2], [-10, -4, -12, 4], [6, -4, 6, 8], [-12, 4, 0, 1], [0, 4, 16, -6], [-16, -2, 2, -8], [-10, -4, 6, -13], [2, -6, 8, -1], [-12, -2, 6, 8], [14, -8, 4, 12], [-4, 8, 4, -4], [-8, 8, -8, -16], [2, 4, -2, -3], [30, 0, 6, -6], [0, 16, 0, -15], [14, 0, -4, -14], [6, 8, -12, 4], [12, 6, 6, -19], [-10, -10, -8, 25], [6, 8, -8, -12], [-20, 0, 8, -8], [-8, 4, -16, 2], [-20, -16, 0, 8], [0, 0, -10, -10], [-4, 16, 0, 0], [12, 6, -6, 5], [-4, -8, 4, 4], [-8, 2, 2, -14], [-14, -8, 0, 10], [12, -4, 0, -15], [-10, 10, -10, 6], [-12, -4, -12, -2], [-6, 2, -2, -6], [-6, 0, -4, -10], [-10, -2, 0, -7], [-6, 8, 0, -14], [-26, 2, -2, -2], [12, -10, -6, 19], [4, 0, -12, -7], [-2, -10, -14, 22], [4, 8, -10, 12], [10, 10, 6, -22], [2, 22, 12, -15], [-4, 6, 14, -17], [20, 2, 6, 4], [-6, -8, 0, 8], [-4, -4, -4, 4], [6, 4, -4, 18], [0, -4, -4, 12], [10, -16, -2, 8], [8, 12, 8, -4], [14, 12, 4, 2], [4, 0, -2, -4], [14, 8, 8, -16], [-8, 10, 2, -3], [-14, 8, -10, -17], [4, 12, -4, 6], [2, -10, -6, -2], [-18, 4, -2, 23], [24, -4, 0, 12], [32, 4, -8, 0], [20, -20, -10, 0], [-2, -8, 0, -8], [-18, -8, 4, -8], [6, 16, 22, -20], [0, -16, 4, 17], [22, 4, -10, 6], [22, 12, 4, -16], [14, -14, 0, -1], [20, 6, -2, 6], [8, 2, -14, 12], [6, 8, 12, 10], [-12, 24, 0, -8], [-28, 12, 0, 1], [-4, 16, 8, -14], [2, -2, -6, 26], [2, -8, 8, -20], [-18, -10, 6, 2], [-8, 2, -18, -3], [20, 2, -6, 16], [-2, -4, 16, -2], [-40, 4, 0, -2], [-8, -12, 12, -12], [-4, 24, 12, -14], [32, 4, -2, 12], [4, -6, 6, 9], [16, -10, -6, -12], [-2, -16, -16, 30], [-20, 10, 10, -21], [-2, 20, -4, -4], [24, 12, -4, 12], [6, 4, 20, -8], [22, 4, 8, -4], [28, 20, 4, -16], [10, -12, -8, 22], [-6, 6, 4, -5], [32, 4, -2, -16], [12, 0, -12, 3], [-26, 6, -6, 14], [6, -18, -6, 22], [34, 6, -12, 15], [-28, 2, -2, 1], [-26, 4, 4, 2], [-22, 22, 8, -9], [24, 14, 2, -12], [12, 6, -2, -10], [24, 12, -12, 4], [-2, 4, 12, 2], [-34, -10, -6, 10], [8, -16, -12, 19], [-2, 6, -6, -12], [18, -12, -4, 0], [20, 14, 10, -23], [-2, -4, 18, -21], [12, -8, -16, 16], [10, -6, -16, 29], [-34, -12, 4, 6], [20, -8, 0, -16], [4, -16, 8, -16], [-12, 8, 0, -16], [34, 20, 8, -28], [2, -20, -6, 30], [32, 4, 4, -2], [30, 0, -10, 6], [-20, 18, 2, -6], [-2, 2, -4, -17], [36, -10, 10, 8], [-30, 20, -4, 2], [-12, -24, -16, 24], [0, -12, -16, 12], [-32, -12, -12, 27], [-22, 0, 18, -13], [2, -4, -2, 6], [12, 12, 0, -18], [4, -14, -10, 1], [10, 18, 12, -39], [-12, -16, 16, -8], [-6, -8, -24, 12], [-10, -10, 2, -2], [-22, -10, 10, 2], [-8, 32, -12, -20], [-20, -4, -20, 4], [-8, 18, 10, -32], [-16, 6, 14, 1], [10, -4, 8, -6], [-18, 8, 0, -24], [28, -6, 10, 5], [-4, 0, -8, -19], [-10, 2, -2, 30], [10, -12, -10, -24], [-24, 16, -8, -12], [-16, -4, 4, -22], [2, 6, 10, -14], [-20, 8, 14, -14], [10, 2, 14, -18], [-32, 10, 26, -23], [-4, -16, 0, 1], [36, -4, 14, 14], [-30, -4, -4, 28], [-6, 2, 16, -21], [6, -16, -24, 26], [4, 2, 10, 18], [0, 8, -8, 10], [14, 4, 10, 7], [24, 0, -12, 15], [50, 10, -2, -8], [0, -8, -18, 32], [32, -12, -16, 12], [8, 8, 10, -20], [0, 0, 4, -12], [-12, -14, -18, 9], [-16, -8, -8, 24], [24, -4, 12, -8], [-4, -4, -16, 18], [-4, -16, -4, 16], [-8, -14, -6, -8], [-20, 8, -4, -8], [0, -16, 4, 19], [0, -28, 0, 18], [-26, -4, -10, 0], [14, 0, 12, -2], [26, 12, -2, -21], [30, 6, 4, 1], [6, 16, 8, 14], [34, 8, -8, 14], [2, -8, -16, 14], [-10, -4, 14, -17], [-24, -8, -8, 28], [-10, -20, -4, 32], [26, 4, 12, -2], [10, 14, -8, 13], [-2, 36, 4, -12], [8, -12, 16, 14], [0, -4, 16, -2], [20, 12, -14, 36], [26, 8, -10, 23], [8, 8, 0, -44], [16, 18, 10, -31], [12, 16, 8, -20], [12, 18, 2, 2], [-8, -22, 6, -1], [0, 12, -28, 3], [26, 12, 10, -34], [20, 2, 2, -6], [32, -28, -16, 0], [-26, -8, -16, -4], [26, 8, 8, 2], [-16, 8, 16, 8], [-24, -2, 6, 9], [-24, -12, 16, -11], [2, -26, 6, 24], [22, 28, 22, -30], [16, -24, 2, -4], [-6, 20, -8, 14], [-6, -2, -12, 5], [-10, -32, -12, 30], [10, -32, 0, 10], [0, -8, 16, 0], [-34, -12, -18, 25], [44, 0, 4, 15], [16, -20, -20, 16], [-28, -4, 16, -38], [4, -10, 6, 35], [6, 28, 14, -27], [-48, -4, 4, 20], [38, 0, -6, 5], [-10, -18, -8, 19], [10, -8, -20, 26], [-20, -6, 10, 20], [6, 8, 12, -10], [-32, -20, 4, 0], [-38, 8, -12, -12], [44, 16, -12, 1], [16, -16, -24, 36], [-22, -32, 0, 28], [54, -8, -2, 5], [-16, -26, -34, 38], [-16, 2, -10, 0], [10, 12, -2, 5], [-26, 4, -6, -2], [40, -28, -4, 5], [-12, 4, -12, 4], [-48, 16, -12, -6], [-6, -16, 20, -16], [-30, -18, 24, -21], [0, -34, 2, 0], [-2, -8, 8, -14], [8, -8, -4, 32], [4, 4, 4, -32], [6, -28, -4, 36], [-20, -16, 4, -14], [-42, 10, 10, -24], [18, 16, -10, -13], [-8, 6, -6, 19], [-30, 20, -4, -12], [12, -30, -6, 20], [48, 2, 14, -11], [14, -4, 18, 2], [-64, 12, -4, -2], [-18, 16, 4, 22], [-22, -20, 4, 12], [4, 4, -4, -18], [8, -12, 4, 0], [-6, -12, -2, -38], [14, -6, -12, -33], [-44, -2, -14, 17], [-26, 20, 12, -4], [14, -26, 12, 29], [-20, -10, -14, -16], [-42, 10, 18, -20], [10, 12, 26, -2], [20, -8, 18, -14], [40, -18, -10, 22], [-48, 0, -14, 6], [24, 10, -6, -36], [-6, -4, -2, 1], [18, 10, 22, 4], [-42, -20, -2, 17], [-10, 22, 12, -9], [26, 24, 4, -18], [8, 28, 0, -8], [16, -16, -14, 34], [-8, -8, -16, -6], [-2, 0, 16, -26], [-8, -28, 4, -4], [-30, -22, 10, -6], [-2, -8, -18, 54], [-16, 8, 0, 8], [46, 0, 2, -2], [-44, 18, -6, -26], [-6, 14, -4, -17], [-2, -24, -48, 36], [-32, 4, 12, -32], [34, -8, -24, 24], [-4, -4, -16, 17], [18, -20, -18, 21], [16, -12, 20, -10], [2, 30, -6, -46], [-26, -24, 8, -12], [-10, 2, 12, -15], [-36, -2, -38, 0], [-6, 4, 8, 32], [-24, 24, 4, -24], [-32, 24, -4, -22], [-12, 24, -14, 4], [46, -20, 6, 9], [16, -2, -10, 51], [-16, 32, 12, -28], [30, 8, 24, -24], [16, -2, -26, 30], [-30, -20, 2, 16], [-44, -16, -4, 36], [26, 10, 2, 22], [14, 12, 12, -26], [38, 24, 4, -26], [44, -20, -6, -8], [-28, -22, -18, 23], [-2, 18, 22, 6], [-36, 16, -18, -18], [-10, 28, 8, 12], [-24, -26, 2, 9], [-26, -12, 16, -6], [-2, 6, -16, 5], [-2, 18, -2, 2]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_2205_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_2205_2_a_bg();".
// 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_2205_2_a_bg(:prec:=4)
    chi := MakeCharacter_2205_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_2205_2_a_bg();".
// 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_2205_2_a_bg( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_2205_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<2,R![-7, -12, 0, 4, 1]>,<11,R![-224, -160, -8, 8, 1]>,<13,R![16, -64, -32, 0, 1]>,<17,R![128, -128, -16, 8, 1]>],Snew);
    return Vf;
end function;