
// Make newform 2268.2.a.c in Magma, downloaded from the LMFDB on 25 September 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_2268_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_2268_2_a_c();".
// 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_2268_2_a_c();".
// 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
        Kf := Rationals();
    end if;
    return [Kf!elt[1] : elt in input];
end function;


// To make the character of type GrpDrchElt, type "MakeCharacter_2268_a();"
function MakeCharacter_2268_a()
    N := 2268;
    order := 1;
    char_gens := [1135, 1541, 325];
    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_2268_a_Hecke( : Kf := Kf)
    return MakeCharacter_2268_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], [3], [-4], [-6], [-4], [0], [-6], [2], [-7], [12], [-7], [6], [-3], [6], [2], [-13], [-9], [8], [-1], [0], [-12], [-4], [12], [-4], [-15], [-10], [9], [-19], [6], [-9], [-4], [9], [-7], [-4], [11], [-12], [-6], [12], [2], [27], [14], [21], [-10], [-25], [-10], [24], [8], [-18], [3], [26], [-6], [0], [-21], [-24], [14], [11], [-9], [26], [-6], [-34], [-30], [26], [-18], [20], [5], [-9], [-10], [24], [33], [-4], [-1], [11], [-12], [-30], [26], [3], [32], [0], [-37], [24], [-4], [26], [24], [21], [11], [-30], [-1], [-12], [42], [-13], [-36], [-4], [24], [-6], [-42], [-34], [11], [-7], [33], [-18], [27], [32], [38], [-18], [42], [-33], [32], [-22], [5], [6], [26], [-16], [15], [-40], [-12], [3], [-27], [20], [29], [-42], [39], [-34], [15], [41], [-42], [-46], [20], [-19], [51], [41], [-22], [-30], [8], [-6], [44], [12], [-15], [20], [33], [-16], [39], [-40], [12], [-22], [18], [-4], [-21], [5], [-48], [-31], [0], [17], [24], [29], [6], [20], [12], [-24], [-6], [-40], [-54], [54], [30], [-7], [-46], [-25], [0], [-36], [-58], [36], [-19], [-40], [-12], [-4], [3], [-64], [-34], [17], [-30], [-31], [12], [9], [60], [-49], [26], [5], [-66], [14], [-33], [-16], [-6], [-12], [-6], [53], [-31], [0], [-30], [30], [26], [-34], [-16], [6], [18], [-28], [15], [-15], [-4], [29], [-30], [-52], [24], [6], [62], [5], [60], [51], [-9], [-31], [-4], [-6], [-25], [66], [-58], [54], [0], [-28], [33], [-58], [2], [-28], [-39], [-10], [-66], [-10], [-54], [15], [-6], [-12], [8], [56], [-49], [-18], [-54], [-70], [-30], [-31], [-48], [-13], [12], [-12], [26], [-42], [60], [-43], [-22], [60], [-52], [-7], [27], [-40], [56], [-6], [14], [69], [78], [68], [-45], [68], [29], [-4], [59], [-58], [50], [-15], [-49], [-13], [48], [54], [29], [-12], [-10], [-46], [-39], [-34], [-75], [44], [6], [81], [18], [-9], [12], [35], [30], [-10], [-42], [30], [62], [56], [42], [29], [21], [68], [-55], [-51], [38], [-84], [-58], [-78], [-45], [-18], [29], [9], [32], [-72], [-21], [-34], [-42], [14], [-46], [0], [-40], [42], [56], [-43], [-10], [-33], [6], [-1], [-33], [-10], [-18], [83], [36], [14], [-30], [26], [-88], [26], [75], [-6], [53], [-81], [-60], [56], [-28], [90], [90], [-4], [-1], [18], [-46], [-58], [72], [90], [66], [21], [-27], [-22], [30], [21], [-24], [-70], [-46], [36], [56], [62], [-15], [-52], [48], [-39], [26], [-70], [30], [-87], [-100], [-6], [14], [-60], [-63], [83], [-27], [74], [90], [-1], [-58], [-76], [-12], [-43], [-24], [21], [-46], [-27], [53], [-70], [-30], [-79], [75], [-22], [21], [-67], [-48], [-54], [14], [-22], [66], [-76], [-36], [44], [-78], [-51], [-52], [41], [42], [-24], [-106], [-42], [90], [87], [-58], [-27], [48], [-16], [54], [60], [-69], [38], [-36]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_2268_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_2268_2_a_c();".
// 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_2268_2_a_c(:prec:=1)
    chi := MakeCharacter_2268_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_2268_2_a_c();".
// 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_2268_2_a_c( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_2268_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<5,R![0, 1]>,<11,R![-3, 1]>],Snew);
    return Vf;
end function;