
// Make newform 3432.2.a.l in Magma, downloaded from the LMFDB on 02 November 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_3432_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_3432_2_a_l();".
// 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_3432_2_a_l();".
// 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 := [-3, 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_3432_a();"
function MakeCharacter_3432_a()
    N := 3432;
    order := 1;
    char_gens := [2575, 1717, 1145, 937, 2641];
    v := [1, 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_3432_a_Hecke( : Kf := Kf)
    return MakeCharacter_3432_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, 0], [-1, 0], [1, 1], [0, 2], [1, 0], [1, 0], [-1, 1], [-2, 0], [6, 0], [-5, 1], [7, 1], [-2, 0], [-4, 4], [5, 1], [2, 2], [-6, 0], [2, -2], [-2, -4], [3, -3], [4, 0], [-4, 0], [-5, -1], [4, -4], [3, -5], [2, -8], [9, -1], [-2, 2], [-6, -6], [-4, 8], [10, 0], [-5, -9], [8, 4], [7, 3], [-1, 11], [6, 2], [2, -8], [6, -10], [3, 5], [4, -8], [-3, -5], [2, 0], [2, -2], [20, -4], [-4, 4], [2, -10], [-2, 10], [15, 3], [9, 3], [4, 2], [-16, -2], [1, 7], [0, 6], [-2, -12], [-8, -4], [8, -2], [-6, 10], [-4, 6], [6, -4], [2, 0], [12, -8], [-7, -3], [18, -2], [-10, 12], [6, -4], [2, 2], [-5, -1], [-17, 1], [4, 18], [6, 6], [-6, -4], [-1, 15], [4, -2], [8, -12], [-8, 2], [-7, -9], [26, -6], [-4, -6], [26, -4], [19, -1], [8, 4], [10, 16], [-22, 0], [0, -12], [10, 8], [-3, 1], [12, 8], [9, -3], [-6, -12], [12, -16], [3, -11], [18, 0], [-12, -10], [5, -17], [-2, -2], [-29, -3], [34, 2], [-3, 9], [-2, -12], [-9, -9], [2, 12], [-19, 1], [-18, -6], [0, -8], [-15, 15], [-25, -1], [-18, -12], [-30, -6], [30, -2], [12, 20], [-26, 0], [-9, -21], [-12, -12], [-7, 1], [-27, -5], [11, 17], [-30, 4], [5, -1], [8, 8], [12, 6], [20, 8], [-20, 14], [20, 6], [-43, -1], [0, 12], [-37, 5], [-39, 3], [20, -14], [24, 0], [22, -10], [-4, -4], [8, 2], [-28, -4], [-20, -8], [-10, -2], [10, -10], [6, 12], [15, -9], [8, 2], [-24, 6], [-3, -13], [-46, 0], [28, 4], [-2, 14], [0, -2], [14, 16], [4, 20], [-2, 12], [3, -23], [-2, 10], [30, -2], [-14, 4], [-14, 8], [-26, -2], [0, -16], [16, -16], [-24, 8], [19, -13], [7, -5], [-28, 6], [-24, 12], [34, 10], [-9, -19], [-44, 6], [-30, -12], [1, 33], [-24, -8], [34, -10], [24, 6], [-12, 16], [8, 2], [-12, -16], [-10, 12], [-8, -20], [22, -12], [26, -2], [4, -2], [0, -18], [3, -13], [-17, 3], [4, -18], [19, 13], [24, 4], [22, 14], [20, -20], [14, -22], [-2, -20], [40, 2], [-11, -5], [6, -4], [8, -20], [34, -2], [16, 0], [10, -14], [9, -7], [-24, -20], [0, 10], [-22, 0], [-38, 16], [4, -36], [32, 4], [-36, 4], [27, 7], [54, -8], [-10, -24], [6, -10], [-36, 10], [-5, -27], [-16, 0], [20, 16], [10, 10], [20, 10], [6, -16], [4, -16], [-12, -4], [28, 6], [32, 18], [-19, 1], [11, -3], [20, 12], [5, 25], [50, -4], [-8, 6], [-9, -21], [29, 15], [-72, 0], [-12, -2], [-12, 22], [-24, -24], [7, 31], [12, 4], [-14, -4], [-35, -11], [10, 0], [-47, -5], [34, 18], [32, 8], [36, -14], [42, 2], [-26, -20], [2, -28], [18, -22], [-59, 9], [12, -32], [4, -6], [34, 10], [20, 4], [1, -5], [26, -2], [20, 6], [-40, -20], [-22, -24], [-16, 16], [-24, 24], [-18, -34], [29, 3], [8, -6], [38, -10], [-2, -20], [-28, 6], [-54, 4], [17, -3], [-32, 0], [-42, -4], [28, 14], [75, 3], [16, 4], [-9, 7], [-15, -15], [-58, -12], [-33, -27], [2, -32], [5, -33], [-4, -26], [-13, 27], [-48, 18], [-13, 25], [40, -4], [16, -16], [64, -8], [-28, 8], [26, -18], [25, 19], [52, -8], [0, -12], [28, -2], [-32, -16], [-30, -24], [-64, 0], [27, 9], [-39, 15], [0, 10], [6, 24], [-6, 38], [52, -18], [2, 0], [33, -21], [54, -2], [22, 12], [-30, 18], [34, 4], [-30, 0], [24, 8], [-19, 37], [30, 4], [46, 2], [62, -12], [26, 28], [10, 24], [-36, 4], [32, -14], [-2, 46], [-51, 5], [3, -31], [12, -24], [-4, 16], [16, -18], [32, -16], [-60, 6], [40, 2], [33, -13], [25, 25], [-14, 32], [-9, -15], [27, 25], [-30, -6], [14, 2], [-5, -3], [-35, -17], [2, 30], [-17, -27], [-4, 12], [54, 20], [-11, 21], [-24, -18], [-40, 14], [2, 30], [2, 0], [28, -20], [24, 14], [-23, -39], [58, -4], [24, -14], [34, 6], [-2, -22], [-39, -3], [-6, 38], [22, 24], [63, -7], [-44, 22], [-50, 20], [4, -14], [-4, 6], [1, 21], [13, 13], [22, -36], [-51, 11], [-34, -30], [-16, 34], [9, 15], [-14, -10], [-10, -4], [19, -27], [68, 12], [-8, 2], [20, -16], [2, 26], [-36, 12], [-22, -24], [-20, 30], [36, 0], [62, -18], [36, -18], [-17, 9], [-47, 21], [-18, 32], [78, -10], [-2, -14], [-32, 24], [13, -17], [-26, 32], [31, 19], [63, -17], [-8, -22], [-12, -8], [-6, -28], [56, -4], [-43, 3], [58, 16], [-52, -2], [-2, -36], [-10, 16], [11, -21], [24, 12], [88, 4], [42, 10], [-50, 8], [38, -24], [-30, 16], [-78, 2], [-54, -10], [18, -48], [-36, -38], [60, 2], [3, -21], [-44, 12], [-55, -15], [-8, 18], [42, 2], [-39, -25], [-68, 12], [18, 40], [-51, -25], [52, 0], [1, 13], [16, 6], [-32, 2], [48, -18], [30, 30], [9, -19], [-58, 14], [-36, -38], [2, 44], [-12, -28], [42, -22], [38, 20], [-19, -39], [-36, 40], [2, 2], [11, 5], [-70, -2]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_3432_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


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