
// Make newform 234.4.a.m in Magma, downloaded from the LMFDB on 13 December 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_234_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_234_4_a_m();".
// 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_234_4_a_m();".
// 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
        poly := [-22, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0], [0, 2]];
    Rf_basisdens := [1, 1];
    Rf_basisnums := ChangeUniverse([[z : z in elt] : elt in Rf_num], Kf);
    Rfbasis := [Rf_basisnums[i]/Rf_basisdens[i] : i in [1..Degree(Kf)]];
    inp_vec := Vector(Rfbasis)*ChangeRing(Transpose(Matrix([[elt : elt in row] : row in input])),Kf);
    return Eltseq(inp_vec);
end function;


// To make the character of type GrpDrchElt, type "MakeCharacter_234_a();"
function MakeCharacter_234_a()
    N := 234;
    order := 1;
    char_gens := [209, 145];
    v := [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_234_a_Hecke( : Kf := Kf)
    return MakeCharacter_234_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 := [[2, 0], [0, 0], [4, 1], [6, 1], [22, -5], [13, 0], [28, 4], [30, -11], [84, -12], [108, 12], [-58, 21], [-54, -32], [232, 7], [-216, 22], [154, 7], [208, -2], [74, -43], [-426, -44], [-190, -21], [-430, -25], [-202, 48], [-364, -96], [-546, 75], [-896, 13], [342, 76], [176, -124], [-108, 130], [-828, -60], [702, 4], [-636, 126], [208, -178], [308, 104], [64, 175], [-2060, -16], [-1260, -57], [-2582, 47], [290, 108], [1538, -21], [-1494, -141], [1744, 28], [1416, 186], [1718, -84], [3416, -130], [2298, -128], [1884, 69], [1488, 286], [-2504, -64], [1094, -267], [-566, 481], [-1722, -260], [3000, -150], [-4230, -81], [4566, 52], [5036, -94], [-3048, 150], [-5948, -170], [788, 536], [1118, 621], [3978, 256], [6344, 191], [-700, 378], [-5804, 211], [-7530, -155], [-732, -660], [3118, -4], [-5004, 153], [-454, 291], [-2222, -196], [-2544, -684], [-3854, -28], [-1208, -605], [7770, 291], [-4776, 124], [-350, 1352], [-9890, 317], [-12714, 117], [6812, 830], [2314, -16], [-1992, 837], [-394, 1188], [-12124, -112], [4782, -416], [5030, 869], [1882, -16], [5772, 106], [9004, 244], [2952, -1155], [-1850, 572], [1572, -1059], [1686, 1213], [11068, 598], [1198, 1369], [11766, -155], [14868, -42], [-9422, 371], [-1348, -430], [1308, -1155], [18356, -46], [540, 1048], [6734, 1476], [-5836, 120], [-1380, -2169], [-2152, -694], [240, -666], [11820, 1222], [-4310, 1820], [206, -841], [-10056, -687], [7692, -426], [-3970, 60], [17768, 576], [-6054, -272], [-4512, 1947], [1478, -2619], [13762, -61], [-1820, 928], [3746, -1449], [6648, 2016], [-19052, 1000], [-4344, -972], [-10062, -464], [11694, 484], [9208, 2194], [-10370, -737], [-9990, 859], [17204, 710], [-12386, 1952], [-6876, 1032], [14912, 870], [4614, -1628], [4518, 1813], [4146, -45], [36500, 102], [-974, -2620], [16280, -1873], [-31822, 72], [-18492, 639], [-24714, -383], [10052, -3106], [10972, -2618], [-5258, -2683], [540, 3387], [2420, -2370], [11294, 2675], [-4206, -908], [-13538, 3529], [-30054, -1088], [12072, 930], [-3096, 1228], [-2482, -1075], [-4638, -3212], [976, -4478], [-6156, -158], [27072, 1290], [11508, -1898], [16376, -1882], [30260, -1368], [3800, 875], [-13486, 840], [50356, 547], [11218, -2759], [4296, 1926], [7110, 409], [9472, -992], [10704, -867], [-21882, -2091], [18064, -88], [-17106, -1928]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_234_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_234_4_a_m();".
// 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_234_4_a_m(:prec:=2)
    chi := MakeCharacter_234_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(997) - 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_234_4_a_m();".
// 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_234_4_a_m( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_234_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<5,R![-72, -8, 1]>,<7,R![-52, -12, 1]>],Snew);
    return Vf;
end function;