
// Make newform 2352.2.a.g in Magma, downloaded from the LMFDB on 24 June 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_2352_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_2352_2_a_g();".
// 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_2352_2_a_g();".
// 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_2352_a();"
function MakeCharacter_2352_a()
    N := 2352;
    order := 1;
    char_gens := [1471, 1765, 785, 2257];
    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_2352_a_Hecke( : Kf := Kf)
    return MakeCharacter_2352_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], [-1], [-1], [0], [-3], [4], [0], [4], [-8], [-3], [5], [8], [8], [-6], [-10], [9], [5], [-10], [-6], [-10], [2], [-11], [-7], [-18], [-17], [-2], [0], [11], [-10], [-8], [7], [-15], [-14], [22], [18], [5], [-4], [-8], [2], [2], [-12], [0], [16], [-27], [-26], [-12], [-6], [-1], [-21], [-12], [-24], [0], [23], [-11], [14], [14], [1], [17], [8], [6], [18], [-19], [16], [0], [9], [13], [-4], [-15], [20], [2], [8], [-6], [7], [16], [16], [-2], [26], [28], [-8], [7], [0], [-6], [12], [-2], [9], [1], [4], [-17], [30], [16], [28], [-6], [-37], [9], [-10], [12], [-39], [-18], [12], [34], [8], [15], [-39], [12], [-22], [-33], [-45], [0], [42], [-13], [-13], [8], [-30], [-6], [11], [-22], [-46], [50], [15], [-24], [38], [29], [19], [-17], [0], [5], [6], [34], [-47], [14], [-10], [-34], [27], [-10], [-12], [37], [-26], [22], [3], [-16], [-2], [-39], [-32], [41], [-4], [24], [14], [14], [14], [-22], [-32], [-54], [-40], [48], [16], [-6], [16], [42], [19], [-13], [48], [-38], [-3], [-25], [-22], [-44], [-15], [-26], [15], [-21], [19], [-18], [-4], [-27], [11], [-4], [46], [-45], [24], [-6], [37], [51], [-26], [14], [-26], [31], [-26], [-42], [59], [20], [-31], [-21], [-52], [58], [-7], [18], [-26], [-66], [62], [22], [-1], [-64], [-42], [-38], [-16], [69], [-24], [-21], [56], [34], [-62], [11], [-35], [-61], [-28], [18], [-1], [56], [-42], [-2], [8], [64], [58], [-31], [-33], [64], [26], [-28], [9], [-12], [-6], [8], [-51], [30], [2], [60], [-13], [-21], [68], [16], [-60], [-16], [-17], [50], [36], [-12], [-19], [36], [16], [64], [26], [-78], [-6], [18], [49], [21], [-30], [28], [1], [-67], [-40], [-15], [54], [-76], [2], [70], [-5], [60], [-20], [-29], [-48], [10], [-59], [51], [-43], [56], [-29], [-40], [54], [32], [22], [17], [-36], [-36], [-50], [8], [79], [-45], [-53], [84], [10], [-53], [12], [-20], [4], [3], [-56], [-86], [60], [62], [6], [11], [59], [-39], [-10], [-14], [9], [38], [-6], [-26], [-30], [78], [20], [0], [32], [38], [-51], [48], [-51], [-8], [-64], [34], [-19], [56], [-24], [-5], [50], [62], [38], [15], [-54], [51], [72], [40], [82], [44], [52], [-2], [81], [47], [14], [36], [-75], [-81], [13], [-9], [-10], [14], [30], [45], [68], [27], [-42], [-93], [-50], [-6], [-42], [-43], [12], [34], [90], [-24], [54], [20], [32], [-53], [22], [-16], [57], [51], [-80], [-46], [-43], [-8], [-88], [-56], [-20], [-21], [-22], [46], [-6], [6], [8], [36], [78], [14], [8], [28], [28], [12], [-71], [42], [33], [-46], [58], [-89], [-5], [-30], [40], [-21], [4], [24], [76], [-54], [65], [-25], [54], [-38], [14], [-63], [-41], [-33], [23], [-82], [-86], [-63], [12], [-32], [72], [-18], [-49], [54], [-58], [17], [10], [78], [-69], [48], [-30], [-52]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_2352_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


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