
// Make newform 5400.2.a.m in Magma, downloaded from the LMFDB on 08 December 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_5400_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_5400_2_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_5400_2_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
        Kf := Rationals();
    end if;
    return [Kf!elt[1] : elt in input];
end function;


// To make the character of type GrpDrchElt, type "MakeCharacter_5400_a();"
function MakeCharacter_5400_a()
    N := 5400;
    order := 1;
    char_gens := [1351, 2701, 1001, 2377];
    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_5400_a_Hecke( : Kf := Kf)
    return MakeCharacter_5400_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], [0], [-2], [-1], [-1], [-1], [4], [1], [5], [1], [-6], [0], [-7], [7], [-12], [4], [10], [4], [-12], [-6], [15], [2], [12], [-10], [15], [14], [18], [-4], [3], [6], [9], [22], [-6], [13], [-1], [17], [5], [12], [-10], [4], [-4], [22], [2], [-8], [5], [-22], [16], [24], [-20], [-6], [18], [5], [-21], [27], [-12], [31], [0], [10], [2], [16], [-2], [5], [-8], [-8], [24], [-18], [8], [-16], [-18], [17], [12], [-2], [-19], [16], [-15], [9], [11], [-36], [31], [33], [12], [-8], [-26], [16], [12], [-6], [-28], [18], [-6], [-28], [20], [-4], [12], [20], [9], [-7], [-28], [-1], [34], [37], [-28], [-38], [-32], [22], [-32], [42], [15], [-30], [-35], [-30], [15], [9], [38], [-8], [30], [9], [-12], [-4], [-24], [42], [6], [4], [24], [-10], [-11], [-52], [2], [28], [-42], [12], [51], [3], [1], [6], [7], [-6], [-47], [-36], [0], [-10], [38], [20], [-30], [-20], [-26], [31], [6], [-22], [-21], [53], [-18], [52], [19], [45], [56], [35], [20], [14], [17], [-14], [21], [6], [-53], [-61], [33], [-55], [-39], [-31], [-10], [-59], [10], [-50], [28], [-31], [0], [4], [-50], [-16], [-14], [40], [-24], [1], [-53], [32], [-14], [43], [-35], [38], [-22], [10], [54], [44], [-17], [-20], [-10], [-66], [-21], [-46], [-16], [51], [28], [58], [30], [-63], [-4], [-11], [22], [-18], [20], [-64], [-5], [28], [30], [-46], [-9], [-46], [70], [-9], [34], [44], [-59], [-28], [-60], [-42], [-14], [23], [58], [-32], [-41], [26], [42], [-37], [26], [-60], [-36], [75], [72], [8], [0], [16], [28], [-58], [70], [-34], [-32], [-10], [25], [-62], [-19], [45], [-52], [72], [50], [14], [39], [44], [-33], [30], [-30], [-28], [-22], [-6], [31], [5], [64], [-46], [0], [9], [4], [20], [11], [-66], [-43], [22], [-32], [-8], [-4], [-43], [45], [39], [-39], [17], [40], [-7], [62], [16], [18], [57], [42], [-61], [-12], [-15], [-60], [50], [-42], [80], [-6], [83], [36], [48], [24], [-67], [-58], [30], [-34], [18], [46], [42], [-11], [-23], [-18], [-66], [17], [-7], [55], [-7], [24], [68], [26], [-28], [-8], [45], [-76], [-5], [-39], [4], [-92], [-55], [60], [-34], [58], [-53], [-2], [28], [54], [-40], [-6], [-53], [54], [61], [27], [26], [-55], [4], [5], [22], [20], [-84], [78], [-20], [0], [-31], [10], [20], [-95], [12], [5], [25], [-19], [58], [-52], [44], [69], [-27], [80], [36], [34], [-85], [-27], [-10], [-97], [66], [72], [-59], [81], [76], [88], [-54], [22], [-35], [49], [48], [-63], [6], [43], [40], [-18], [-15], [79], [13], [-54], [-84], [77], [-20], [-56], [-40], [84], [50], [51], [36], [-27], [-76], [33], [90], [-48], [29], [18], [-52], [15], [-34], [-30], [26], [-74], [-46], [90], [-46], [-88], [90], [21], [-75], [62], [37], [59], [-6], [-6], [-72], [48], [26], [-14]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_5400_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_5400_2_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_5400_2_a_m(:prec:=1)
    chi := MakeCharacter_5400_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_5400_2_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_5400_2_a_m( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_5400_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<7,R![2, 1]>,<11,R![1, 1]>,<13,R![1, 1]>,<17,R![1, 1]>],Snew);
    return Vf;
end function;