
// Make newform 3234.2.a.y in Magma, downloaded from the LMFDB on 14 January 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_3234_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_3234_2_a_y();".
// 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_3234_2_a_y();".
// 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 := [-2, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rfbasis := [Kf.1^i : i in [0..Degree(Kf)-1]];
    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_3234_a();"
function MakeCharacter_3234_a()
    N := 3234;
    order := 1;
    char_gens := [1079, 199, 2059];
    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_3234_a_Hecke( : Kf := Kf)
    return MakeCharacter_3234_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 := [[-1, 0], [-1, 0], [0, 0], [0, 0], [1, 0], [0, -1], [4, 0], [4, -1], [2, -4], [0, 4], [4, 5], [-2, -4], [4, -4], [-10, 0], [0, 1], [2, 4], [4, -2], [0, 1], [0, 8], [8, -4], [4, 0], [-4, -4], [-8, 5], [4, 1], [0, -9], [4, 3], [4, -7], [6, -8], [-10, 0], [0, 4], [-4, 8], [8, 3], [2, 8], [12, 7], [-4, -12], [4, 4], [0, 2], [0, -4], [8, -2], [12, 5], [8, 4], [-16, 4], [6, 12], [2, -4], [10, -8], [12, 1], [6, -8], [4, -11], [8, -11], [0, -4], [18, 4], [20, 4], [4, 8], [12, -2], [-4, 9], [8, -4], [0, -16], [24, 2], [4, 0], [-2, 12], [20, 3], [4, 5], [12, 9], [16, -3], [-8, 3], [6, 8], [12, -12], [-6, 8], [-2, 0], [24, 1], [-4, 7], [-4, 0], [-4, 19], [-14, 16], [-12, 4], [8, 11], [-10, -16], [-8, -14], [-6, 0], [-4, 6], [-12, -20], [2, 12], [16, 0], [16, -15], [16, -14], [0, -20], [16, 4], [14, -4], [28, -7], [-16, 8], [-4, 24], [16, -12], [-6, -4], [20, 0], [12, 16], [8, 6], [-8, 24], [-20, -9], [-36, -3], [14, 16], [4, 4], [-2, -24], [-24, -1], [-18, -8], [12, -20], [-32, -3], [12, 6], [-12, 8], [-16, 12], [-12, -18], [-8, -8], [12, 0], [20, 4], [4, 8], [-2, -28], [-20, -20], [-44, 2], [8, -7], [-10, 16], [-14, 8], [-8, 12], [14, -4], [-20, -1], [-20, 20], [-4, -6], [-30, 8], [-22, -16], [16, 1], [-4, 25], [-40, -3], [12, 4], [12, 12], [10, -12], [-18, -8], [-28, -10], [20, -14], [0, 10], [-20, 13], [-48, 2], [2, -12], [28, 19], [20, 12], [-14, 28], [28, 0], [8, -8], [0, -9], [-40, 9], [-12, 2], [4, -30], [10, -28], [42, -8], [-12, 7], [-4, 16], [24, 20], [0, 24], [2, -28], [-8, -16], [-28, 5], [-28, 16], [-28, -21], [-36, -8], [-26, 0], [16, -20], [-4, -36], [32, 4], [0, -29], [32, -8], [0, -7], [34, 12], [-32, 4], [-6, 16], [24, -10], [4, 40], [-22, -4], [12, 25], [28, 25], [-4, -4], [10, 12], [16, 14], [-24, 15], [-24, 0], [-16, -3], [22, 0], [20, -26], [0, 20], [-24, 28], [6, -16], [-44, -4], [14, -20], [8, 10], [40, -7], [-26, -24], [-8, 0], [-8, -6], [-28, -8], [4, -9], [26, -8], [6, -12], [20, 12], [-16, 6], [-44, -4], [32, -10], [-8, -14], [36, -8], [-44, -4], [-8, -32], [12, 27], [-4, -24], [-38, 4], [4, 32], [-2, 48], [16, 6], [-24, -24], [20, -26], [0, 14], [-64, -3], [4, 4], [12, 34], [-8, -20], [10, 0], [32, 0], [40, 14], [52, -12], [-24, 8], [48, -11], [-34, -24], [20, -35], [0, 20], [48, -10], [6, 24], [42, 4], [20, -5], [16, -32], [42, 16], [-36, -20], [40, 6], [48, -1], [-60, 4], [-16, -12], [48, 17], [4, 40], [12, 1], [4, 15], [-50, 4], [-60, -2], [48, 14], [12, -1], [28, 22], [4, 36], [-12, -36], [54, -8], [-28, -12], [-40, -20], [24, -37], [4, 39], [42, 8], [-58, 12], [4, 39], [48, 12], [20, 24], [0, 4], [-52, 8], [-16, -31], [16, 29], [-20, -13], [36, -6], [-22, -4], [-20, -1], [-36, -20], [-4, 12], [48, 18], [-16, 44], [-8, 35], [32, 32], [-12, -36], [-12, 13], [4, -24], [6, -24], [-38, 20], [8, -49], [-32, -8], [16, 16], [32, -16], [0, -7], [12, -21], [-78, 4], [4, 24], [16, -12], [60, -15], [44, -6], [-38, 28], [4, -44], [50, 16], [-40, 17], [60, -16], [-28, 17], [12, -13], [-40, 24], [-8, -1], [20, -17], [-28, 2], [-38, -8], [-16, 4], [24, 16], [-36, -20], [-54, -16], [-16, 40], [-24, 20], [-40, 12], [12, -40], [0, -44], [-26, 0], [-14, -20], [-28, -20], [-36, 0], [-12, -48], [-4, 14], [4, -20], [-48, -3], [-22, 20], [28, -17], [24, 0], [-20, 45], [-34, 20], [-14, 36], [-48, 29], [8, -60], [-36, 12], [12, 24], [22, 0], [22, 40], [50, 4], [-16, 6], [32, 15], [-84, -4], [-52, 24], [42, -4], [-36, -34], [24, -47], [8, -24], [-10, 40], [-44, -12], [52, 7], [-6, 28], [-14, -40], [20, 8], [-16, -44], [-8, -12], [24, -8], [-32, -14], [-36, -11], [-8, 24], [-14, 24], [-8, 24], [-16, 24], [-4, 42], [-72, 3], [-24, 25], [26, -32], [24, 20], [48, 0], [28, -22], [40, -12], [-44, -24], [44, -12], [20, -32], [44, 7], [0, -40], [-14, 36], [-12, -44], [-12, 24], [4, 36], [-38, -40], [-40, 32], [2, -20], [44, -12], [0, -32], [-20, -26], [-12, -40], [60, -4], [24, 6], [46, 24], [-40, -20], [-42, -32], [-20, 35], [-48, -9], [-74, 4], [0, 40], [-94, 0], [-32, 27], [12, 56], [-32, -18], [-12, -12], [-20, -30], [72, -4], [-18, 52], [8, -44], [4, -9], [-28, 8], [-10, -32], [-32, -15], [6, 0], [68, 16], [44, 17], [-20, -35], [8, 10], [-22, -8], [-30, -12], [-20, 48], [-60, 16], [-28, 8], [-32, 36], [36, 32], [-28, 12], [30, -12], [0, -26], [40, -4], [28, 7], [-12, 61], [-24, -12], [-18, -8], [-16, 29], [-32, 4], [24, -45], [-40, -41], [64, 30], [-4, 16], [2, 4], [4, -52], [-16, 40]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_3234_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


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