
// Make newform 1176.4.a.g in Magma, downloaded from the LMFDB on 01 November 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_1176_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_1176_4_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_1176_4_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_1176_a();"
function MakeCharacter_1176_a()
    N := 1176;
    order := 1;
    char_gens := [295, 589, 785, 1081];
    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_1176_a_Hecke( : Kf := Kf)
    return MakeCharacter_1176_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 := 4;
    raw_aps := [[0], [-3], [10], [0], [-52], [10], [54], [52], [48], [-186], [-224], [94], [478], [-316], [-256], [-66], [-420], [-342], [668], [-272], [86], [1360], [-188], [366], [-1554], [1690], [-248], [-1620], [-1066], [-1198], [-2528], [-2156], [234], [2396], [-1602], [-1320], [1482], [-2820], [-1768], [-894], [-1996], [-1582], [2456], [-2942], [-3666], [-1224], [-4932], [816], [1316], [2786], [5162], [3320], [-4066], [1116], [-650], [3648], [7058], [-6960], [-5330], [5754], [-3076], [-2982], [1460], [-1496], [9494], [1974], [-5884], [-10030], [972], [4362], [3686], [-11280], [-6496], [13582], [6068], [8736], [2206], [-11974], [12642], [-14170], [-4604], [11998], [712], [10574], [10536], [-7956], [6178], [10330], [-14142], [-1936], [5204], [-8016], [-9112], [17340], [2108], [18872], [1346], [-22674], [-16228], [11846], [-10692], [-2458], [-1196], [-19174], [9892], [11870], [26892], [16790], [3264], [-5162], [27088], [-26178], [28330], [-17956], [6792], [10098], [16292], [31544], [-170], [29220], [10402], [2338], [18330], [4956], [6692], [-33306], [-13218], [6640], [1304], [-8294], [-8420], [22352], [24160], [-35858], [-10770], [36190], [8026], [-9308], [-22734], [21818], [-25252], [-4642], [-19512], [-12484], [-24902], [-14376], [-6878], [9870], [-26660], [33544], [49494], [3798], [-31268], [6184], [-23452], [-16632], [34232], [31958], [40262], [-22830], [46852], [-2934], [-6376], [28476], [19682], [15960], [52592], [-41806], [6098], [-30966], [-31044], [-7702], [-3216], [-25222], [58784], [-47490], [-7196], [-54146], [-41592], [-52454], [-23168], [24948], [-58114], [22158], [8312], [30666], [6438], [8084], [-54758], [-2816], [24430], [32236], [49948], [-46446], [4980], [-20274], [24722], [-17178], [47446], [-47208], [2758], [-38240], [-39150], [5934], [-32228], [-32206], [40848], [72788], [-47430], [57036], [8306], [-15942], [20504], [-4404], [-43368], [38278], [74016], [-70890], [-34512], [-32282], [-41410], [-39208], [-69374], [-10848], [65444], [-78546], [11118], [23240], [31400], [-44804], [-72490], [-95916], [28400], [-22694], [70508], [-51728], [30622], [-24418], [11820], [49576], [33236], [28108], [52984], [-36682], [19302], [58056], [-4448], [-16828], [54772], [-62376], [114502], [122118], [-1808], [-102506], [-17982], [-64860], [67630], [64636], [-124166], [8982], [-33728], [49860], [68354], [81034], [41126], [35924], [96230], [97918], [72612], [-64738], [69530], [12828], [-28442], [-102896], [-15426], [-14312], [-77284], [68806], [-3878], [-9612], [-59904], [-34184], [95000], [-53486], [-120804], [94088], [68594], [-112130], [-104264], [117398], [-159450], [-30396], [-120422], [162060], [37078], [71858], [-6448], [6906], [-68612], [-57164], [108678], [-8042], [-4336], [110340], [-30940], [-100862], [39676], [-7990], [-89952], [38558], [35472], [-54290], [95090], [-160724], [-54240], [65270], [-78364], [-20088], [-39250], [40898], [436], [129034], [-93838], [-32720], [-162758], [5054], [-1156], [38524], [157944], [118814], [-17578], [32614], [186560], [18820], [-11756], [-147460], [36006], [-40938], [-78250], [-125648], [-18418], [-121542], [-143670], [-77048], [149158], [98452], [-166942], [153636], [-11792], [-17686], [52548], [76314], [-102746], [143328], [153518], [-100738], [-73504], [166140], [116466], [39808], [-105282], [-102914], [207688], [-223492], [204980], [-195270], [192978], [-161768], [-33846], [-193692], [460], [-25016], [74654], [-153896], [132902], [18564], [-244632], [215550], [27990], [169094], [-28302], [87066], [-39720], [-65022], [40500], [-210648], [100480], [30354], [192388], [43472], [-222622], [-52022], [-46452], [-132428], [91072], [-94422], [-33968], [244334], [76660], [184910], [227594], [-51870], [-101616], [-219058], [-131702], [-147880], [-15306], [215826], [-183388], [-100380], [-174098], [-92274], [-241908], [134604], [44570], [-190382], [-59384], [-57880], [39894], [297480], [-279546], [-241774], [189192], [-103444], [13830], [121666], [-197260], [119706], [-155796], [-122232]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_1176_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_1176_4_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_1176_4_a_g(:prec:=1)
    chi := MakeCharacter_1176_a();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 4));
    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_1176_4_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_1176_4_a_g( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_1176_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<5,R![-10, 1]>,<11,R![52, 1]>],Snew);
    return Vf;
end function;