
// Make newform 2304.4.a.o in Magma, downloaded from the LMFDB on 08 December 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_2304_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_2304_4_a_o();".
// 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_2304_4_a_o();".
// 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_2304_a();"
function MakeCharacter_2304_a()
    N := 2304;
    order := 1;
    char_gens := [1279, 2053, 1793];
    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_2304_a_Hecke( : Kf := Kf)
    return MakeCharacter_2304_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], [0], [22], [0], [0], [-92], [-104], [0], [0], [130], [0], [396], [-472], [0], [0], [-518], [0], [-468], [0], [0], [-1098], [0], [0], [-176], [594], [-598], [0], [0], [1460], [-1328], [0], [0], [2776], [0], [-3514], [0], [-3924], [0], [0], [-4082], [0], [-2860], [0], [-5362], [-1174], [0], [0], [0], [0], [-2684], [7088], [0], [-5310], [0], [8096], [0], [-3406], [0], [1316], [-5792], [0], [9418], [0], [0], [6838], [10274], [0], [12366], [0], [-8964], [-12848], [0], [0], [-6372], [0], [0], [374], [-12564], [15880], [7146], [0], [13412], [0], [4862], [0], [0], [-10120], [16506], [2318], [0], [0], [0], [0], [0], [0], [0], [-14270], [1480], [0], [-24460], [0], [-8626], [0], [-4280], [0], [-3454], [0], [24368], [0], [-17030], [0], [19548], [26464], [0], [0], [14872], [0], [0], [33358], [0], [-22068], [4462], [4054], [0], [0], [-20030], [8404], [0], [0], [-8732], [0], [0], [0], [22516], [27320], [-9650], [-39542], [0], [-41954], [39704], [0], [1850], [0], [0], [-41740], [0], [45468], [-20056], [0], [0], [-29844], [-51808], [0], [0], [0], [0], [0], [-47480], [51946], [-31378], [0], [-15512], [0], [0], [-22936], [0], [0], [-34164], [63810], [-42458], [0], [32220], [0], [-18378], [0], [60736], [0], [40982], [0], [23580], [0], [0], [-13052], [72544], [0], [41350], [-33644], [0], [25434], [0], [-59202], [0], [0], [34430], [0], [-33088], [-55150], [74932], [84064], [0], [84910], [0], [62084], [-85410], [0], [73634], [0], [0], [57776], [0], [7774], [70150], [0], [0], [0], [38630], [0], [99320], [0], [-100418], [32708], [0], [61096], [0], [0], [-41220], [64688], [0], [0], [0], [-107692], [0], [0], [-109408], [0], [0], [-7326], [-59962], [0], [0], [0], [0], [0], [120636], [36032], [0], [0], [0], [0], [0], [-11356], [127760], [0], [-28746], [-108238], [0], [-89260], [0], [66154], [-134026], [0], [0], [-58444], [136188], [-40216], [0], [-15890], [98960], [0], [137462], [-97380], [0], [-126522], [0], [58734], [0], [0], [-141876], [35210], [0], [0], [0], [0], [-118980], [0], [0], [-83358], [-89626], [0], [-58640], [-56210], [0], [-87728], [0], [-105588], [133214], [0], [174938], [0], [0], [121862], [152366], [0], [0], [0], [-103086], [0], [-24284], [0], [-75348], [0], [-185350], [185720], [0], [0], [-164970], [0], [0], [130878], [1040], [0], [176726], [-63230], [0], [186088], [167490], [0], [0], [0], [206518], [164612], [-136994], [0], [0], [0], [0], [-192420], [105008], [-113130], [0], [-14868], [-75064], [-179446], [0], [-34142], [0], [-132572], [0], [0], [-28454], [0], [-225414], [157010], [0], [9324], [197312], [0], [0], [57496], [0], [-86004], [73840], [0], [0], [0], [-175318], [227506], [0], [-186410], [0], [0], [0], [104314], [0], [-72956], [0], [0], [-225182], [-249080], [-260406], [-162338], [-266728], [0], [-222304], [0], [0], [0], [-231676], [0], [0], [244926], [71158], [0], [0], [0], [48618], [0], [273416], [0], [286150], [-278820], [265928], [0], [51656], [-245174], [0], [212996], [-272120], [0], [0], [293618], [146534], [0], [0], [186966], [271282], [0], [0], [83336], [0], [-265954], [314604], [0], [0], [-251962], [-319406], [0], [-200560], [0], [0]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_2304_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_2304_4_a_o();".
// 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_2304_4_a_o(:prec:=1)
    chi := MakeCharacter_2304_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_2304_4_a_o();".
// 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_2304_4_a_o( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_2304_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<5,R![-22, 1]>,<7,R![0, 1]>,<11,R![0, 1]>,<13,R![92, 1]>,<17,R![104, 1]>,<19,R![0, 1]>],Snew);
    return Vf;
end function;