
// Make newform 6552.2.a.i in Magma, downloaded from the LMFDB on 21 January 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_6552_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_6552_2_a_i();".
// 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_6552_2_a_i();".
// 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_6552_a();"
function MakeCharacter_6552_a()
    N := 6552;
    order := 1;
    char_gens := [1639, 3277, 5825, 5617, 2017];
    v := [1, 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_6552_a_Hecke( : Kf := Kf)
    return MakeCharacter_6552_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], [-1], [-1], [-1], [1], [3], [-1], [3], [3], [2], [-5], [-10], [5], [-8], [-6], [-6], [9], [8], [-2], [13], [10], [14], [6], [-18], [-10], [11], [-18], [-19], [8], [4], [-7], [-21], [-2], [0], [-15], [-3], [-6], [-23], [-18], [8], [10], [-1], [22], [18], [-3], [15], [-12], [-2], [-26], [-28], [-28], [-26], [-15], [2], [-24], [-2], [18], [16], [-30], [-20], [6], [28], [20], [-14], [-6], [14], [-1], [-12], [-12], [-26], [6], [16], [-14], [-34], [21], [10], [28], [-6], [7], [11], [22], [-26], [-26], [27], [-18], [7], [-20], [21], [29], [-35], [3], [8], [24], [32], [28], [-35], [-3], [-2], [-19], [-36], [-34], [41], [14], [-20], [-26], [6], [-8], [9], [2], [-25], [-3], [37], [-5], [9], [-30], [37], [16], [-23], [0], [20], [-29], [-6], [-39], [40], [6], [6], [-4], [31], [-4], [-26], [-4], [-20], [16], [12], [-25], [29], [-13], [12], [14], [-29], [-4], [54], [23], [17], [-24], [8], [-18], [50], [40], [6], [3], [1], [2], [44], [45], [-34], [34], [-2], [30], [-41], [0], [-13], [0], [5], [-9], [-22], [-26], [8], [54], [-45], [-14], [-24], [-10], [1], [54], [34], [-62], [24], [-1], [43], [48], [14], [-66], [-16], [-18], [18], [-29], [-32], [-7], [-64], [-17], [-20], [-45], [42], [39], [-4], [-18], [-28], [-36], [46], [35], [6], [12], [62], [10], [36], [2], [-15], [18], [29], [48], [-64], [42], [69], [-13], [-48], [51], [-60], [58], [-4], [-62], [-17], [24], [55], [36], [-69], [-16], [-5], [13], [2], [18], [-13], [-32], [-14], [53], [11], [-4], [-12], [-22], [-64], [-10], [23], [74], [36], [18], [20], [-32], [40], [33], [55], [30], [-44], [-34], [-6], [-27], [52], [-52], [44], [-3], [-26], [-72], [28], [17], [-8], [34], [50], [62], [-60], [-34], [-14], [-24], [65], [34], [-54], [2], [77], [55], [-8], [12], [-36], [7], [4], [44], [27], [32], [-37], [4], [-46], [61], [-75], [-9], [31], [18], [28], [10], [-56], [18], [-1], [29], [-30], [-68], [-88], [54], [59], [-74], [-14], [19], [72], [74], [-72], [-62], [-76], [85], [6], [16], [40], [12], [19], [26], [-70], [-8], [-50], [-83], [55], [-14], [-22], [-61], [75], [-31], [-13], [-35], [64], [92], [-32], [-62], [87], [-60], [-26], [-73], [74], [-30], [63], [28], [-26], [76], [67], [-78], [-64], [-20], [0], [66], [-62], [0], [-34], [7], [-17], [60], [42], [-50], [33], [23], [-53], [-64], [-32], [-90], [33], [-89], [81], [36], [-34], [-38], [47], [-67], [-10], [90], [45], [3], [75], [-68], [-66], [-27], [27], [-66], [12], [-75], [-5], [-75], [-50], [22], [-16], [-34], [-36], [14], [-56], [54], [-34], [31], [-71], [20], [-86], [30], [-99], [-56], [62], [103], [18], [39], [-29], [-42], [62], [-69], [42], [27], [53], [-4], [-62], [49], [-48], [-54], [-63], [34], [-12], [-20], [33], [62], [-52], [-6], [39], [60]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_6552_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


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