
// Make newform 2200.2.a.t in Magma, downloaded from the LMFDB on 02 September 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_2200_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_2200_2_a_t();".
// 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_2200_2_a_t();".
// 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, -6, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0], [0, 1, 0], [-4, 0, 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_2200_a();"
function MakeCharacter_2200_a()
    N := 2200;
    order := 1;
    char_gens := [551, 1101, 177, 1201];
    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_2200_a_Hecke( : Kf := Kf)
    return MakeCharacter_2200_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], [-1, 1, 0], [0, 0, 0], [-1, 0, 1], [-1, 0, 0], [1, 2, 0], [1, -1, 2], [1, 0, 0], [-2, 1, 0], [4, 0, -1], [-1, 0, 2], [-4, -1, -1], [2, -1, 1], [1, -1, 1], [-4, 3, -1], [3, 4, -1], [8, 3, -1], [-1, 2, -3], [-2, -2, 2], [-5, 5, 1], [11, 0, 1], [5, -3, 0], [-2, -2, 3], [2, -2, 3], [6, -5, -2], [12, -1, 2], [4, -6, -3], [5, -4, 0], [-4, 2, 3], [6, 1, 1], [-11, 1, 0], [6, -5, -2], [4, 2, -1], [3, 2, 2], [-2, 2, -2], [-8, -1, -1], [-2, -8, 4], [1, 0, -5], [-2, -5, 5], [-5, -4, 0], [11, 2, -1], [1, 6, -3], [8, -2, -3], [4, 4, -4], [2, -5, 6], [0, -4, -1], [-8, -5, -1], [4, 3, -1], [2, -2, -5], [3, -3, 0], [3, -2, 1], [-13, -4, -1], [-5, 5, -4], [5, 3, 2], [7, -3, -1], [-8, -3, -3], [-3, -7, -2], [0, -3, 7], [4, 7, 1], [-2, 5, 7], [-5, -5, 0], [-6, 0, -8], [3, -11, -2], [11, -2, 2], [8, 10, 0], [9, -9, -2], [-6, 1, -1], [-2, 0, 4], [23, 0, 1], [-21, -2, 2], [-19, 4, 0], [12, -6, 6], [-6, 3, 0], [2, -13, -1], [-4, -7, -1], [5, -9, 1], [-12, 4, 0], [9, 5, -6], [13, -1, 1], [-20, 9, 1], [-8, -17, 5], [-3, 6, 7], [2, -1, -7], [17, 6, -6], [-11, -9, 2], [-10, 10, -4], [10, -1, 6], [7, 2, 3], [6, -1, 3], [3, -6, 8], [6, -3, 5], [-2, -11, -3], [-19, -2, 0], [9, 2, -6], [17, 8, 1], [4, -10, 0], [-5, 4, 3], [11, 11, -1], [23, 5, -5], [-4, 1, 6], [8, 7, 4], [-9, -12, 6], [-19, -2, -7], [-21, 0, 1], [4, -11, 6], [31, -5, -2], [-13, -5, -4], [0, -11, -5], [11, 7, -4], [-19, -6, 5], [-14, 8, -8], [-21, 1, 0], [27, 3, -5], [-12, -9, -1], [3, -6, -5], [5, -8, -8], [-24, -10, 2], [10, 11, 1], [1, -9, -4], [10, 6, 3], [-28, 3, -1], [18, 1, 3], [-1, -5, -1], [-12, 1, -11], [1, 12, 3], [7, -17, -7], [-4, -4, 8], [26, -1, -3], [18, -10, -1], [-5, -2, 10], [-7, 8, -13], [-3, 6, -1], [16, 10, -7], [-34, -3, -1], [4, 8, 0], [16, -9, -7], [-11, 8, -5], [-22, 1, -5], [5, -3, -4], [18, 18, -6], [24, 7, -5], [29, 9, -1], [28, 0, 4], [19, 15, -9], [31, 9, -4], [15, 12, 1], [-13, -3, -8], [-4, 13, -7], [-20, -14, 0], [11, -4, 4], [3, -5, 13], [-10, -15, 4], [26, -1, 1], [-2, -3, 1], [-34, 6, 2], [8, 10, -6], [4, 0, 12], [5, 0, -6], [10, 10, 6], [28, -3, -1], [34, 3, -5], [-10, 8, -4], [-33, -1, 2], [21, 8, -7], [-6, -7, 9], [-13, 3, 5], [11, -1, 8], [-19, 17, -2], [10, 5, 1], [-28, -8, 2], [2, -5, -14], [-1, 6, -13], [7, 3, 14], [-3, 8, -1], [25, -4, 12], [35, 5, 3], [9, -19, -9], [20, 5, 7], [32, 6, 0], [9, -19, 3], [-5, -17, 3], [7, -10, 7], [8, 7, -9], [14, -4, -4], [36, 13, -7], [18, 9, -5], [-15, -5, -9], [-23, 10, -7], [28, 11, 1], [36, 12, -8], [40, 10, -3], [23, 11, -7], [8, -3, -3], [29, -3, 16], [16, -7, 4], [11, -12, 6], [-2, -10, 16], [-18, 7, -5], [13, -10, -3], [-35, 9, 4], [-2, -21, 0], [13, 16, -9], [3, 1, 0], [-11, 13, 12], [26, 4, 0], [27, -6, 3], [-4, 8, -4], [-5, 8, -6], [-20, 2, 10], [47, -10, -1], [12, 5, 9], [-12, -3, 13], [-21, -4, -7], [8, -16, 6], [0, -3, -9], [-15, 15, -1], [-18, 10, 2], [-5, 1, -6], [-4, 1, -14], [3, 8, -7], [-13, 3, -6], [-16, 21, -3], [-15, 9, -17], [-3, 13, -4], [-6, 5, -13], [-11, 8, 6], [-15, -18, 3], [19, -1, 11], [-32, 8, -8], [-16, -2, -7], [3, 0, -15], [37, -2, -4], [2, -9, 7], [-30, 5, 9], [-7, -7, 6], [-20, -5, 7], [-13, 17, -3], [-28, -29, 12], [-21, 9, 12], [5, 8, -1], [-14, -13, -3], [2, -20, -6], [-31, -13, 7], [16, -3, -13], [-10, 0, -10], [-1, 8, -5], [6, -15, -6], [17, -14, -3], [-46, -2, 3], [-24, 16, -2], [-7, 17, 13], [22, -1, -3], [-39, -9, 7], [23, -4, -8], [2, -13, 8], [-5, 17, 1], [28, -1, -1], [24, 3, 7], [-9, -6, -13], [-2, -20, 0], [-12, -12, 12], [7, 21, 5], [25, 6, 6], [2, 2, 21], [25, 14, 4], [-2, 16, -14], [0, -13, -15], [2, -1, -6], [11, 8, -8], [-30, 3, 3], [10, -10, 0], [-28, -7, -13], [19, 15, 7], [-26, 1, 7], [7, 13, -4], [-19, -12, -6], [4, -16, -8], [19, -1, -10], [39, 2, 3], [20, -11, 5], [21, 23, -12], [-9, -5, -7], [3, -6, 13], [-23, -20, 10], [20, -1, 6], [-3, 21, 11], [14, 8, -9], [-8, 21, 0], [-4, 17, -14], [5, -9, -14], [18, 9, 7], [-6, 3, 7], [-32, 16, -8], [16, 2, 1], [-37, -8, -2], [-16, -7, 0], [-1, 24, 2], [64, 5, -3], [5, -13, 1], [-17, -14, 8], [-18, 19, -7], [-9, 17, -17], [5, -16, 9], [-20, 5, 13], [-5, 19, -2], [2, 15, -21], [6, -2, 12], [7, -18, -7], [36, 14, 3], [-17, -2, 0], [9, -1, -8], [7, -13, 6], [25, -16, -9], [-36, -9, 11], [20, -11, 11], [18, -32, -6], [-16, -6, 2], [0, 18, 0], [12, -20, 10], [-27, 16, 1], [33, -4, -1], [-10, 17, 4], [-12, -35, 7], [1, 12, 0], [-27, 3, 12], [35, 5, 11], [19, 17, -4], [-41, 12, 1], [10, 2, 0], [49, 11, 5], [3, -11, -7], [-26, 23, 5], [-51, 1, -8], [-37, 14, -6], [-5, 17, 9], [6, 0, 4], [18, 10, 4], [0, 6, 12], [11, 30, -15], [-55, -10, 5], [-2, 8, -14], [-21, 12, 12], [8, -1, -7], [-24, 1, -14], [24, -7, 27], [-15, 3, 10], [-41, -5, 2], [40, -3, -9], [-49, 1, -12], [2, -3, -13], [-44, 13, -2], [1, -6, -5], [0, -13, -5], [1, 5, -2], [3, -25, 1], [-56, 5, -11], [-20, -10, 2], [-2, 17, 8], [-44, 5, -17], [25, 17, 7], [10, -11, 18], [8, 1, -13], [21, 18, -10], [36, 0, 9], [-29, 16, 1], [29, -26, -4], [36, 8, -2], [16, -27, 3], [44, 0, 0], [-41, -19, 12], [-16, 12, -4], [-5, -18, -3], [-23, -1, -4], [47, 1, 16], [10, -3, 3], [25, 8, 5], [19, -28, -11], [-48, -2, -2], [-23, -12, 15], [53, 8, 1], [0, 12, 14], [-10, -7, -3], [22, -32, 2], [-27, -13, -18], [-24, 7, -5], [-12, -18, -3], [-56, -19, 4], [46, -2, -14], [-1, 16, -10], [-40, -2, -10], [-52, 3, 4], [16, 0, -4], [-12, 9, -15], [32, -12, -10], [-51, 8, -4], [44, 5, 11], [-9, 19, -14], [48, -6, 4], [40, -9, 19], [10, -29, 2], [15, -1, -7], [4, -27, -10], [-17, -2, 1], [-25, -26, 14], [-7, 10, 2], [62, 7, -5], [34, 24, -10], [-6, 7, 15], [-18, 6, 10], [-16, 8, -14], [19, -19, 8], [15, -24, 6], [12, 33, -5], [-50, 1, 0], [-20, -22, 14], [-20, -1, 11], [-2, 17, 1], [15, 5, 6], [-7, -4, 6], [45, -27, -14], [-8, -9, 23], [-33, 10, -10], [-39, -4, 16], [-11, 36, 2], [67, 1, -3], [8, 8, 16], [-16, -10, -6], [9, -17, -10], [24, 46, -14], [35, -1, 6]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_2200_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_2200_2_a_t();".
// 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_2200_2_a_t(:prec:=3)
    chi := MakeCharacter_2200_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_2200_2_a_t();".
// 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_2200_2_a_t( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_2200_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<3,R![-6, -3, 3, 1]>,<7,R![4, -9, 3, 1]>,<13,R![15, -21, -3, 1]>],Snew);
    return Vf;
end function;