
// Make newform 2200.2.a.p in Magma, downloaded from the LMFDB on 26 July 2026.
// 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_p();".
// 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_p();".
// 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, -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_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], [0, 0], [1, 1], [1, 0], [-3, 4], [2, -5], [-5, -2], [-1, -1], [4, -7], [-5, 6], [1, 2], [-7, 6], [-2, 8], [1, -2], [-3, 1], [-7, 6], [-5, -5], [12, 0], [2, -10], [-11, 1], [-8, -1], [8, -9], [-10, 7], [-11, -1], [-13, 1], [8, -7], [7, -10], [-2, -9], [-7, 2], [4, 3], [-7, 9], [4, -9], [-5, 10], [0, 12], [11, -8], [2, -4], [7, 1], [-3, 6], [-15, -6], [-1, -5], [5, 1], [-4, 13], [-12, -4], [-3, 13], [-14, 1], [-1, 0], [17, -14], [-12, 3], [12, -1], [11, -9], [-23, -1], [2, 3], [8, -17], [-10, -8], [13, -4], [-2, 1], [9, -6], [15, -18], [3, -2], [-12, 25], [14, 4], [22, -3], [1, -8], [2, -14], [-4, -1], [1, -20], [-26, 16], [-3, 1], [3, 18], [-7, 20], [22, -16], [-23, 21], [-7, 12], [27, -4], [14, -8], [28, -8], [18, -11], [-2, -4], [-23, -4], [-15, -4], [9, 7], [-7, -2], [-1, 16], [6, -29], [28, 6], [17, 15], [-21, -3], [-3, -16], [-35, 2], [-31, 6], [3, 12], [19, -10], [1, 14], [35, -9], [22, -10], [25, -3], [4, 2], [10, -12], [25, -25], [7, 7], [5, -4], [-7, -13], [-27, -11], [-15, 31], [-18, 19], [-14, -11], [25, 14], [-14, 33], [9, 7], [6, 24], [-42, 7], [12, -2], [37, -6], [23, -25], [-3, 12], [-18, 12], [-9, 12], [48, 1], [-8, 19], [13, -22], [-5, 22], [-12, -22], [-5, -10], [19, -35], [-40, -4], [-12, 20], [35, -24], [10, -5], [7, 18], [-1, 3], [33, -23], [8, 13], [5, 16], [8, 0], [-33, 14], [27, -35], [3, 2], [30, -9], [-28, 36], [-9, 8], [-28, 40], [0, 24], [-8, 2], [-4, 31], [-7, 3], [6, -9], [-3, -24], [-18, 6], [-45, 12], [36, -16], [-1, -25], [11, -24], [-17, 0], [-4, 32], [-18, -8], [-40, 20], [-43, -10], [8, 12], [-15, -10], [3, 18], [10, 16], [12, 15], [-1, -1], [-15, 30], [36, -8], [-46, 5], [-48, 13], [-45, 12], [-24, 38], [13, -11], [-17, 35], [-32, 19], [-25, 7], [37, -8], [-10, -20], [-12, 12], [15, 28], [2, 26], [-52, 8], [20, -10], [-33, 9], [17, -10], [-30, 24], [-25, 38], [-19, 20], [10, -10], [5, -3], [7, -10], [-20, -20], [8, -11], [-28, -16], [11, -18], [-2, -9], [49, 5], [51, 6], [32, -22], [-21, 30], [-11, 11], [-44, 15], [-23, 23], [27, -13], [32, 3], [20, -9], [22, -32], [3, -5], [12, -8], [29, -8], [-30, 24], [-17, -1], [-11, 16], [-37, -2], [-23, 11], [-52, 22], [-19, 38], [-38, 46], [20, 4], [-50, -11], [-63, 1], [1, -33], [-40, -13], [-11, -8], [-12, -16], [-54, 15], [11, 2], [23, -16], [5, 27], [12, 22], [-16, -20], [-14, -31], [-3, 3], [1, -36], [13, -16], [43, -32], [2, -11], [-13, -36], [22, -26], [3, -21], [-28, 31], [-25, 17], [-45, 12], [-38, 14], [58, -22], [3, -48], [22, -30], [-39, 7], [39, 13], [29, 9], [20, 23], [-8, -30], [-20, 14], [-15, 26], [-14, 42], [51, 0], [-31, 15], [-14, 18], [41, -50], [23, -48], [23, -53], [-6, -12], [0, -36], [-2, 30], [-35, -14], [52, -47], [-21, -26], [-6, -18], [69, -8], [29, -37], [13, 2], [-31, 56], [48, 10], [-49, 20], [16, -2], [-29, 58], [-66, 19], [-7, 22], [-4, -8], [28, 19], [-53, 1], [33, -32], [6, 37], [-12, 8], [-17, 19], [43, 24], [11, -55], [44, -12], [-36, 49], [13, -11], [13, -3], [46, -37], [13, -40], [-29, 34], [16, 4], [-18, 21], [-31, -12], [-27, 41], [15, 30], [-45, 2], [26, -44], [11, 12], [9, -10], [-42, 4], [-13, 1], [27, -6], [-30, 31], [35, -30], [0, -26], [-21, -15], [-12, 3], [19, 8], [18, 1], [22, -33], [-9, -17], [37, -38], [69, -26], [42, 30], [-18, -4], [-10, 46], [-64, 34], [35, -63], [23, 15], [-5, -13], [-11, 10], [33, 16], [-30, -19], [-22, 16], [-12, 47], [-11, 47], [-44, 6], [-18, 48], [42, -30], [11, -24], [32, -21], [71, 2], [6, -42], [50, -56], [-48, -6], [-2, -30], [47, -43], [-43, 27], [54, -38], [43, -20], [3, -2], [53, -55], [23, -24], [-66, 23], [-38, -33], [-41, 8], [22, 35], [-11, 8], [29, -65], [-59, 23], [25, -26], [68, 5], [-16, 32], [-35, 0], [-38, 36], [-57, 41], [-15, -30], [44, 0], [-21, -13], [-23, 10], [-21, 60], [8, 47], [-11, 59], [3, 22], [-40, 6], [37, -2], [4, 40], [44, 15], [-68, -8], [-85, 7], [22, 1], [42, -57], [57, -40], [-29, 51], [49, 21], [-78, 24], [-1, -45], [7, -31], [-36, -18], [65, -10], [-18, 22], [86, -1], [-21, -12], [8, -51], [-75, 15], [-16, -20], [9, -20], [54, -16], [55, 9], [-32, 32], [-13, -10], [16, -58], [-23, 60], [-19, -10], [36, -73], [-6, 42], [-3, -38], [73, 5], [-28, 32], [21, -51], [-61, 19], [9, 12], [-51, 6], [25, -60], [-54, 42], [-71, 4], [28, -48], [-48, 42], [46, -65], [-15, 44], [-41, 72], [-33, 25], [70, 8], [5, -34], [39, 40], [20, -23], [37, 10], [-20, 5], [-23, 54], [39, -86], [-75, 20], [51, -16], [-14, -22], [-28, 12], [-34, 4], [-26, 27], [-90, 0], [-76, -5]];
    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_p();".
// 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_p(:prec:=2)
    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_p();".
// 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_p( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_2200_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<3,R![-1, 1, 1]>,<7,R![1, -3, 1]>,<13,R![-19, 2, 1]>],Snew);
    return Vf;
end function;