
// Make newform 2250.2.a.e in Magma, downloaded from the LMFDB on 16 September 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_2250_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_2250_2_a_e();".
// 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_2250_2_a_e();".
// 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_2250_a();"
function MakeCharacter_2250_a()
    N := 2250;
    order := 1;
    char_gens := [1001, 127];
    v := [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_2250_a_Hecke( : Kf := Kf)
    return MakeCharacter_2250_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, 0], [0, 0], [0, 0], [0, 1], [1, -1], [3, -3], [-2, -2], [4, -3], [-3, 3], [4, 2], [0, 4], [-4, 9], [10, 1], [2, -6], [-1, 1], [-6, -1], [10, -5], [-6, 6], [0, 6], [6, 4], [8, -8], [6, -12], [10, -8], [15, -5], [6, -6], [-4, 14], [-3, 9], [-2, 8], [0, 10], [2, -2], [4, -12], [-7, -5], [8, 8], [7, -9], [6, -12], [14, 6], [-6, 8], [0, 8], [6, -3], [14, -1], [-14, 13], [18, -12], [12, -8], [-8, -6], [-2, 8], [0, 10], [-8, 15], [24, 0], [22, -10], [-2, -6], [12, -12], [-4, 8], [-9, -3], [-16, 8], [-16, -4], [14, -1], [6, -12], [18, -12], [-11, 3], [3, -5], [24, -10], [-19, 5], [22, 2], [-12, 0], [6, 6], [3, 3], [0, 4], [-10, 16], [10, -26], [-12, 24], [-12, 6], [-2, 4], [12, 12], [20, -17], [-3, 21], [-34, 5], [-14, -2], [8, -15], [2, 7], [-16, -3], [-16, -8], [12, -10], [-22, -10], [10, -12], [-2, -6], [0, 22], [-14, 23], [-24, 24], [-32, 10], [-12, 32], [-14, 2], [-12, -6], [-13, 7], [6, -21], [-15, -15], [5, -13], [-22, 14], [23, -25], [32, 4], [38, -12], [12, -18], [-11, 1], [2, 8], [19, 7], [-12, 23], [-30, 6], [22, 10], [-14, -20], [-30, 30], [-23, 15], [4, -27], [-23, -1], [-12, 28], [-15, 5], [-8, -10], [-10, -19], [-12, -8], [2, -5], [-15, -3], [13, 19], [-6, -14], [-24, -4], [6, -3], [20, -8], [-8, 0], [24, -2], [-4, -2], [18, -16], [20, -39], [-27, 7], [20, 15], [-3, 3], [-34, 22], [-15, 11], [2, -13], [-25, -15], [2, 8], [-18, 12], [2, -5], [-3, 21], [29, -39], [12, -8], [0, 13], [-18, 30], [-18, 36], [10, -10], [12, 9], [2, -10], [-12, -21], [6, 5], [-17, -15], [18, 15], [36, -4], [-38, -5], [2, -18], [26, -16], [-16, 22], [15, -25], [-16, 18], [-6, 18], [20, -16], [-54, 10], [9, -7], [15, 21], [-12, -12], [-9, 25], [42, 0], [24, 3], [34, -28], [-46, 19], [25, -25], [20, 24], [-2, 40], [-18, -16], [-20, 0], [26, 8], [8, -27], [-42, 0], [15, 23], [36, -12], [13, -15], [-16, 8], [30, 8], [-44, 32], [-18, 43], [-24, -12], [-20, -9], [22, 14], [21, -37], [8, -10], [42, -6], [24, -16], [51, 7], [-36, 28], [32, -20], [26, -50], [-19, 27], [8, -33], [-28, -10], [-12, -24], [-14, -22], [-2, 18], [47, -3], [-20, 5], [18, -51], [-30, 24], [6, 8], [-30, 42], [-18, 36], [7, -45], [-12, 0], [-50, 26], [-8, 9], [-32, 8], [42, -24], [-13, -15], [-4, -11], [30, -24], [20, -16], [33, -59], [-18, 10], [-8, 36], [17, -19], [-52, 7], [-36, 36], [30, -30], [-24, -10], [0, -10], [-53, 27], [18, 25], [-36, 15], [-9, 23], [-30, 14], [-22, -5], [32, -6], [30, -1], [-23, -9], [18, -9], [34, 7], [18, 0], [-26, 14], [-13, -5], [-4, 1], [18, -6], [60, 2], [10, -10], [-25, -9], [17, 7], [-51, -3], [0, -8], [-39, 19], [-2, 5], [39, 21], [3, 9], [34, 19], [-68, 16], [34, -54], [-18, 42], [-70, 4], [6, -6], [-49, -9], [4, -4], [0, 20], [30, -12], [56, 2], [-27, 49], [-14, 8], [14, -7], [6, 6], [26, 25], [-32, 8], [-16, 48], [10, -42], [44, -18], [28, 30], [-12, 17], [-16, -4], [-8, -4], [-36, 21], [-58, -13], [39, -71], [42, -40], [-16, -4], [-50, 24], [22, -18], [-22, 40], [-36, 10], [-10, 29], [24, -18], [-43, 41], [-48, -8], [-12, 28], [24, -26], [-60, -4], [-19, 31], [-18, 6], [22, -10], [-63, 33], [-31, 47], [58, 0], [-2, 32], [-31, 1], [-32, -6], [58, -14], [-72, 13], [58, -10], [-30, -16], [38, -36], [68, -26], [71, 1], [-49, 5], [16, 8], [3, -45], [58, -28], [18, 3], [-10, -20], [-28, -4], [42, -18], [-4, 16], [-22, 29], [-44, 27], [32, -18], [-6, 18], [55, 3], [-14, 20], [-24, -33], [-16, 7], [62, -36], [34, -59], [-17, 31], [-8, -40], [-18, -35], [-24, -32], [6, 50], [-40, 24], [36, 2], [-66, 12], [28, -44], [-24, -3], [-4, -41], [24, 15], [-50, 34], [-50, -10], [18, 18], [71, -25], [-9, 33], [-36, 6], [18, 40], [-16, -22], [-3, -35], [-48, 0], [-46, 28], [72, -38], [5, -27], [-42, 24], [18, -14], [-70, -10], [-21, 33], [60, 14], [-38, 53], [38, -20], [54, 13], [-18, 15], [68, -16], [-14, 54], [6, -24], [90, 4], [-72, 7], [38, -12], [-2, -25], [4, 32], [5, -53], [50, 10], [-2, -42], [49, 3], [14, 37], [18, -60], [8, 52], [-6, 7], [20, 16], [36, -56], [-6, 54], [35, -9], [-26, -4], [44, -53], [6, -35], [42, 0], [21, -1], [-66, 20], [-54, -3], [68, 19], [6, 60], [-81, 17], [28, -30], [-26, 68], [24, 20], [-18, -24], [-14, -47], [41, -3], [2, 2], [0, -20], [-38, 58], [-51, -7], [-70, 44], [72, 6], [24, 36], [-39, 19], [3, 35], [68, -18], [-62, -11], [10, 18], [3, 3], [20, -58], [44, 16], [-2, -40], [22, 32], [16, -2], [-75, 1], [-36, 6], [38, -29], [60, -10], [16, -61], [74, -19], [-27, -1], [16, -54], [94, 1], [48, -34], [78, -11], [-24, 17], [42, 16]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_2250_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_2250_2_a_e();".
// 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_2250_2_a_e(:prec:=2)
    chi := MakeCharacter_2250_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_2250_2_a_e();".
// 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_2250_2_a_e( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_2250_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<7,R![-1, -1, 1]>,<11,R![-1, -1, 1]>,<17,R![4, 6, 1]>],Snew);
    return Vf;
end function;