
// Make newform 1380.2.a.e in Magma, downloaded from the LMFDB on 19 March 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_1380_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_1380_2_a_e();".
// 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_1380_2_a_e();".
// 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_1380_a();"
function MakeCharacter_1380_a()
    N := 1380;
    order := 1;
    char_gens := [691, 461, 277, 1201];
    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_1380_a_Hecke( : Kf := Kf)
    return MakeCharacter_1380_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], [1], [1], [-3], [-2], [-2], [-7], [-6], [1], [-9], [9], [-7], [5], [0], [8], [-11], [9], [0], [-3], [3], [-6], [-8], [5], [0], [-10], [3], [8], [5], [10], [21], [-16], [-12], [-14], [-5], [-4], [-4], [-5], [-14], [-4], [4], [16], [12], [4], [-24], [14], [14], [-23], [-2], [-12], [-16], [16], [21], [26], [-30], [-8], [11], [-3], [31], [26], [10], [-5], [-9], [-30], [0], [-29], [0], [21], [-26], [12], [31], [-28], [36], [7], [34], [-16], [27], [-6], [-28], [-6], [-35], [30], [-14], [-4], [1], [-24], [-12], [-17], [7], [-18], [-10], [21], [0], [-8], [-5], [15], [-33], [10], [38], [4], [14], [-24], [-11], [-5], [30], [8], [-32], [-2], [-36], [-16], [35], [-32], [-14], [-9], [16], [-44], [-18], [-23], [10], [-6], [-6], [6], [16], [-21], [-4], [-44], [-20], [-32], [-43], [23], [-47], [-23], [-32], [10], [-1], [-39], [40], [-54], [-31], [11], [3], [-7], [10], [52], [31], [49], [2], [-30], [54], [-43], [6], [-34], [-16], [12], [38], [37], [-56], [-12], [-57], [46], [-8], [-24], [6], [4], [-24], [-37], [41], [-59], [16], [48], [4], [-36], [9], [42], [-23], [0], [16], [44], [35], [19], [-50], [-46], [-60], [14], [18], [59], [-42], [46], [19], [-55], [-17], [-38], [26], [38], [-27], [-16], [27], [2], [18], [-14], [54], [28], [20], [42], [-10], [-36], [-2], [20], [-46], [21], [-4], [38], [6], [8], [-20], [33], [0], [22], [45], [43], [50], [33], [2], [-49], [-1], [30], [35], [-22], [5], [-28], [15], [-18], [22], [-22], [31], [29], [36], [-28], [-42], [-11], [-5], [21], [-7], [-2], [-66], [-76], [44], [-44], [-6], [-14], [-15], [50], [-42], [19], [-46], [54], [45], [24], [64], [-42], [14], [-41], [-41], [-49], [-25], [12], [-16], [-52], [22], [-21], [64], [-11], [-43], [73], [-10], [-24], [-70], [36], [41], [20], [64], [6], [-40], [40], [12], [10], [3], [-15], [14], [40], [42], [22], [11], [72], [-60], [-8], [-60], [74], [-42], [-61], [10], [23], [-11], [24], [-24], [-20], [8], [82], [-38], [-84], [-64], [-8], [14], [40], [-44], [-1], [-32], [-87], [85], [1], [70], [52], [11], [-62], [6], [45], [-88], [80], [22], [-8], [-41], [-25], [-74], [55], [66], [84], [56], [-82], [-42], [-46], [-59], [38], [6], [-14], [-60], [59], [-13], [-7], [-10], [-82], [27], [-61], [-12], [7], [75], [-24], [62], [22], [-98], [78], [-66], [-31], [9], [-62], [-44], [66], [38], [24], [65], [-76], [-25], [-31], [6], [8], [8], [18], [45], [90], [-51], [56], [22], [94], [-54], [-32], [18], [44], [14], [53], [24], [-43], [-63], [-10], [34], [71], [-4], [42], [53], [-58], [16], [-20], [-47], [-45], [-26], [87], [63], [-25], [43], [87], [50], [20], [28], [-56], [-82], [-4], [-8], [-17], [-78], [64], [-76], [-79], [36], [26], [-86], [-70], [-12], [24], [-8], [-92], [63], [44], [39]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_1380_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_1380_2_a_e();".
// 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_1380_2_a_e(:prec:=1)
    chi := MakeCharacter_1380_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_1380_2_a_e();".
// 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_1380_2_a_e( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_1380_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<7,R![3, 1]>],Snew);
    return Vf;
end function;