
// Make newform 2200.2.a.u 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_u();".
// 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_u();".
// 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 := [6, -7, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0], [0, 1, 0], [-5, 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], [0, -1, 0], [0, 0, 0], [-1, 0, -1], [1, 0, 0], [-1, 0, 0], [2, -1, 0], [3, -2, 0], [-3, -1, 0], [4, -2, -1], [-1, 0, -2], [3, -1, 1], [1, 1, -1], [-2, -3, 1], [-1, 3, 1], [-1, -2, -3], [1, -3, -1], [-1, 2, 1], [4, 2, 2], [6, -1, 1], [7, 0, 3], [4, -1, -2], [-8, 4, 1], [10, 0, -1], [3, 1, -2], [3, -1, 0], [-4, -4, -1], [1, -2, -4], [6, 0, -1], [3, 5, -1], [0, 5, 2], [13, -1, 4], [0, 4, -3], [3, 0, 6], [8, 2, -2], [-1, 5, -3], [-2, 0, -4], [-7, 6, 1], [-1, 7, 1], [3, -2, 0], [-9, 0, -1], [1, -8, 1], [0, 4, -3], [12, 4, 0], [-5, -3, 0], [-2, 6, -5], [-5, -3, -3], [-9, 7, 1], [-12, 0, 1], [4, -7, 4], [1, 2, -1], [9, 4, 3], [-2, 7, -2], [0, 7, -2], [-2, 1, 5], [-1, -11, 1], [-2, 1, -2], [-3, 7, 1], [1, 3, 5], [3, -5, 1], [-16, -1, -2], [18, -4, 0], [-2, 1, 4], [13, 2, 2], [-2, 2, 0], [-20, 5, 2], [-7, -1, -1], [10, 0, 0], [-13, 0, -1], [15, -8, -2], [7, 4, 0], [-18, 2, 2], [-21, 1, -4], [-1, -9, 3], [3, -1, -1], [22, -5, -1], [-4, -12, 4], [-2, -1, -2], [10, -7, -7], [-7, -1, 3], [17, -7, 1], [-27, 4, 3], [5, -3, 3], [9, -6, -6], [-14, 1, 4], [20, 6, 0], [-15, 3, 6], [1, 2, -7], [-3, 13, -3], [-17, -2, -4], [-1, 9, 7], [-1, -1, 3], [-15, 10, 4], [-7, 0, -6], [-21, -2, 1], [-14, 6, 8], [-3, 6, 3], [16, 1, -1], [-6, -1, -9], [9, 5, -4], [13, -11, 2], [-17, -6, 2], [15, -6, -1], [17, -8, -7], [-27, 1, -4], [18, -3, 6], [-2, -3, 0], [-1, 9, -5], [10, 7, 0], [-3, -6, -3], [10, 12, -4], [-26, 9, 6], [8, -9, -3], [-11, 9, 7], [-9, -12, 7], [5, 4, 0], [10, 6, -6], [-23, -5, 3], [16, 5, 8], [8, 4, 3], [17, -7, -1], [-11, 5, 7], [-16, 1, 3], [21, -3, 11], [-5, 14, 7], [4, -1, 7], [-20, 4, 0], [-5, -3, 1], [-6, 8, -7], [5, 12, -2], [23, 4, -1], [-1, 6, 5], [-20, 0, 1], [7, -3, 9], [32, 4, -4], [-9, -3, 3], [25, -10, 1], [-23, 5, -5], [-22, -5, 0], [4, 2, 6], [3, 5, 5], [-16, 5, 1], [0, 8, 8], [12, 5, -1], [-28, -3, 0], [1, -10, 5], [-10, -3, -14], [11, -11, 5], [46, 2, 0], [33, 0, 4], [16, -3, -7], [15, 5, -8], [-11, -5, 7], [5, 1, 1], [20, -6, -6], [-18, 2, 2], [8, -12, 0], [-11, 0, 6], [40, 2, -2], [1, 11, -7], [5, -1, 1], [6, -8, 0], [16, -13, -12], [7, 14, -7], [-5, -11, -5], [24, -5, -9], [-6, -1, 4], [-12, -11, 4], [27, 11, -1], [-32, 0, 2], [-15, 15, 0], [-5, 0, -13], [28, 5, 0], [-3, 16, 5], [33, -8, -8], [-22, 19, 11], [16, -7, 9], [27, -5, 3], [-18, -6, 8], [-8, -7, 5], [-16, -5, 9], [-1, 14, 7], [-29, -1, -11], [14, 12, 4], [1, -7, -9], [1, -1, -9], [10, -11, 3], [-37, -8, -1], [-9, 13, 11], [28, 4, 8], [20, -8, 3], [-24, -3, 1], [3, 15, 9], [14, -15, 4], [-5, -9, -10], [-11, -16, 2], [-8, 10, -12], [-7, 3, 9], [-17, 2, -13], [0, 1, -6], [41, -5, -6], [-21, -12, -1], [-8, 7, -8], [8, -1, -6], [14, 4, -12], [-7, -8, 13], [4, -12, -4], [11, 6, 10], [-6, 2, -14], [-25, 4, 7], [19, 1, 9], [15, -1, 17], [15, -10, -1], [36, -12, -2], [1, 11, -7], [6, 1, 3], [-28, -6, -2], [18, -13, -12], [-21, -1, -2], [-37, 2, -5], [12, -7, -8], [17, -1, 15], [16, 7, -5], [6, 23, -8], [1, -7, -9], [-13, 22, 2], [47, 4, 1], [8, 5, 7], [-40, -4, 0], [26, -12, 9], [7, -18, 3], [9, 12, 4], [-23, -7, -7], [3, -13, 11], [38, -9, -6], [41, -9, -5], [-30, 3, -19], [21, 5, -6], [-20, 5, 4], [-17, -10, -5], [-11, -1, -1], [-30, 12, 2], [-22, -9, -7], [-1, 23, 3], [-38, 8, -2], [17, -8, 7], [-3, -1, 2], [21, 0, -3], [4, -4, -9], [8, 12, -6], [-8, -17, -3], [-7, 5, 15], [2, 3, -3], [-29, -8, 8], [15, 17, -6], [-2, -7, -17], [-19, -11, -1], [-51, 3, 3], [13, 12, -7], [22, 8, 4], [24, 0, 4], [-26, 3, 9], [9, -12, 2], [12, 12, 3], [-59, -2, 0], [-30, 12, 10], [-15, 17, -3], [-3, 15, -2], [11, 2, 12], [23, -1, -1], [-16, 22, 0], [-15, -7, -7], [20, 3, -7], [-9, 11, 5], [6, 9, 10], [-29, -4, 6], [28, -16, -8], [-16, -11, 12], [-25, 14, 11], [37, -13, -5], [-10, 3, 6], [-56, 13, 9], [9, -2, 11], [23, 6, 2], [-7, 21, -8], [48, -1, 7], [8, -10, -19], [-13, -5, 6], [-7, 9, 6], [26, 17, 0], [-15, 7, 3], [-3, -9, 9], [-8, 4, -16], [-42, 16, 1], [43, -10, -2], [5, -19, 6], [-21, -12, 2], [25, -3, 15], [6, 11, -5], [-43, 0, 0], [23, -1, 17], [6, 19, 11], [-21, 12, -3], [-3, -19, -1], [26, -5, 2], [33, -9, 1], [8, 10, 20], [-41, 12, 5], [-40, -4, 3], [17, 12, 0], [10, -25, 6], [-2, 3, 6], [3, 16, 3], [-29, 3, -11], [-41, 1, -5], [26, -12, -6], [-42, -18, 2], [-26, -2, 4], [32, -4, 10], [-41, 12, -7], [15, 0, -17], [21, 3, -4], [-43, 3, -3], [11, -16, 0], [18, -1, -10], [-2, 19, -9], [28, -11, 12], [-13, 6, 3], [12, 6, 0], [-2, 5, 9], [-2, -3, 3], [25, -1, 11], [4, -25, 2], [-15, 16, 2], [-30, 9, -5], [14, -24, -8], [-24, 10, -4], [10, -18, 4], [3, 4, 1], [43, 6, 3], [10, -16, 6], [5, -28, 0], [-21, 5, -13], [-31, 1, 2], [37, -15, -3], [-70, 5, 4], [82, 3, -2], [-47, 5, 1], [2, -9, 10], [-17, 17, -19], [57, 5, -8], [7, -12, -3], [13, 5, 7], [24, -19, -8], [-20, -9, -5], [3, -3, -3], [-14, 10, 14], [-13, 21, 10], [-25, 21, 11], [-40, 9, 5], [-27, 15, -12], [-23, -13, 5], [-23, 2, -10], [-8, -14, 5], [3, 6, 7], [37, 10, 4], [24, 20, -2], [-49, 5, -17], [4, 8, 16], [12, -3, 12], [-4, 0, -8], [53, 6, 7], [-6, 13, -14], [78, 7, -2], [11, 1, 5], [43, -6, 9], [-23, -12, -7], [62, -2, -2], [-13, 4, 3], [13, -24, -13], [12, 4, 2], [-37, -3, 3], [-6, 8, 2], [46, 15, -4], [-41, -19, 1], [-12, 4, 19], [9, -11, 20], [-16, 6, -14], [-1, 14, -2], [50, -2, 14], [-17, 19, -8], [24, 0, 0], [19, -25, -7], [-56, -12, -2], [-11, 0, -4], [-5, -3, 7], [40, 9, -8], [-30, 10, -12], [-19, -3, 3], [9, -21, 0], [16, -9, 11], [-21, 15, 6], [5, -6, -9], [-25, 22, 18], [41, -8, 18], [-11, -27, -7], [14, 36, -6], [-55, -3, 1], [52, -6, 10], [-8, -8, -22], [62, -7, -10], [59, 10, 2], [41, 13, -7], [3, 21, -14], [10, 14, 6], [-15, -7, -5], [19, -17, -17], [-28, -5, 10], [43, 8, 14], [48, -19, 0], [-27, -3, -9], [-3, 8, 2], [55, -16, 4], [27, 6, 10], [-30, 13, 7], [12, 0, -4], [-38, 10, -10], [18, -11, 20], [22, -2, -18], [0, 1, 12]];
    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_u();".
// 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_u(: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_u();".
// 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_u( : 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, -7, 1, 1]>,<7,R![-32, -11, 3, 1]>,<13,R![1, 1]>],Snew);
    return Vf;
end function;