
// Make newform 7360.2.a.ce in Magma, downloaded from the LMFDB on 24 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_7360_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_7360_2_a_ce();".
// 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_7360_2_a_ce();".
// 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 := [12, -9, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0], [0, 1, 0], [-7, 1, 1]];
    Rf_basisdens := [1, 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_7360_a();"
function MakeCharacter_7360_a()
    N := 7360;
    order := 1;
    char_gens := [1151, 5061, 4417, 6721];
    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_7360_a_Hecke(Kf)
    return MakeCharacter_7360_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+1)]];
    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], [0, 1, 0], [1, 0, 0], [-1, 1, 1], [2, -1, 2], [1, -1, 1], [-2, -1, 0], [1, -1, -1], [1, 0, 0], [2, -2, 0], [1, 1, -1], [0, 0, -2], [0, -1, -2], [8, 0, 0], [6, -2, 2], [6, 0, 0], [4, 2, 0], [-2, 1, -4], [4, 0, 4], [-4, 1, 0], [-4, 2, -2], [4, -4, 4], [2, 0, -2], [4, 4, -2], [-10, -3, 0], [2, -2, 0], [-10, 1, -2], [2, 6, -2], [5, 1, 1], [-6, 0, 0], [-4, -2, 4], [-2, 4, -2], [-3, -3, -3], [0, -2, 4], [3, 3, 3], [4, -3, 0], [-10, 2, 0], [1, 1, 3], [-12, 4, -4], [8, 3, -2], [-2, -2, -2], [1, -3, -3], [0, -6, 0], [4, -6, -2], [8, -3, -2], [10, -4, -2], [2, 0, -6], [0, 4, 0], [-2, -6, 2], [2, 0, -4], [-8, 6, 2], [4, 4, 4], [-12, 4, -2], [-9, -7, 1], [0, -2, 2], [10, 3, 2], [-10, 2, -4], [-3, -3, -5], [-2, 4, -4], [-2, -2, 4], [14, 4, 2], [6, 0, 0], [4, -9, 4], [-4, 0, 4], [-1, -1, -5], [5, -1, 5], [12, -6, 8], [-3, 5, -3], [8, 1, 0], [-10, 4, 4], [-12, 0, 6], [-26, 0, 2], [8, -4, 0], [0, -2, 6], [-14, 5, 2], [0, 0, 0], [14, -1, -4], [20, -3, 2], [16, 2, -6], [21, -1, -3], [-8, 4, -8], [-7, 5, -3], [-14, 2, 6], [17, 5, 1], [17, -3, -1], [-5, -5, 1], [15, -7, -5], [10, -8, 0], [0, 6, -6], [-30, 0, -2], [4, -6, -4], [-2, 8, -6], [24, -2, 0], [10, -2, 10], [-16, 4, -4], [-17, 1, 1], [18, -6, 0], [6, 4, -4], [2, 0, 6], [-4, -4, 6], [-1, 3, -3], [16, 4, -2], [8, 0, -8], [-2, 4, 4], [14, -1, -2], [-6, 0, 8], [-4, 9, 4], [-12, 2, -2], [-4, -5, 0], [-11, 7, -3], [8, -8, -8], [18, -4, -4], [10, 7, 4], [11, -7, -11], [-8, 2, -8], [-4, -4, -10], [-18, 6, 2], [-6, 4, -10], [-3, -1, -11], [4, 12, -4], [-30, 1, 0], [10, -4, 8], [6, 0, 0], [13, -7, -9], [-14, 2, 2], [-1, 7, -9], [-6, 3, -8], [27, -5, 5], [18, -3, 10], [-14, -8, -4], [-12, 4, -8], [-9, 5, 1], [4, -10, 4], [-12, -16, 2], [9, 3, 9], [6, -4, -12], [8, 0, -2], [20, -10, 4], [-16, 2, -10], [16, 5, 6], [-14, -2, -6], [-2, 12, -4], [-18, 8, 2], [36, 2, 4], [2, 0, 8], [-22, 6, -2], [-25, 9, -13], [-6, 12, 0], [38, 2, -2], [-4, 14, -4], [28, 1, 2], [0, 0, -6], [3, 15, -7], [-8, 16, -8], [-14, -2, 6], [34, 2, 6], [-8, 4, 8], [-18, -4, 4], [9, -7, 9], [-6, 17, -8], [-1, -13, 5], [-6, 9, -12], [4, -14, -4], [26, 5, 2], [3, -5, -1], [-2, 1, -2], [-16, -5, 4], [-18, -4, -4], [-4, 14, -2], [-12, -7, 10], [12, -12, 12], [-22, -6, 8], [22, 6, 2], [30, 1, -8], [-8, 13, -4], [6, -2, -4], [-26, 8, -10], [20, 12, -2], [2, 9, 2], [7, 3, -9], [-28, 2, -12], [14, -3, -2], [-7, -1, 9], [14, -6, 4], [2, -3, -14], [11, 7, 3], [-7, -1, 9], [-4, -4, 4], [16, -9, -2], [-4, 5, 8], [-4, 18, 6], [0, -8, -4], [52, 0, 4], [4, -4, 6], [-30, 8, -2], [-35, 1, -11], [26, -6, 0], [22, -8, 8], [10, -16, 0], [38, 2, 2], [26, 1, 0], [-15, 1, -9], [0, -7, -10], [12, 4, -2], [-8, 16, -8], [10, 4, -8], [2, 16, -2], [8, -1, 8], [7, 13, -5], [22, 6, -2], [6, -14, 4], [-26, 4, 4], [11, 1, 13], [46, -2, 10], [-36, 4, -4], [34, 6, -8], [-8, -2, -16], [2, -4, -16], [1, -13, -9], [2, -16, 8], [26, -2, -8], [38, -4, -6], [12, 1, 2], [-3, 19, 3], [44, -8, 0], [-26, -2, -4], [-29, 3, -1], [-35, 9, 11], [9, 11, -1], [20, -8, 0], [-9, 9, 19], [-38, 11, 2], [12, 12, 4], [-32, 7, -2], [-18, 2, -6], [4, -20, 4], [-6, -2, -8], [22, -2, 16], [-2, -14, -2], [-4, -25, 8], [2, -10, 14], [-14, 16, -6], [30, 8, 2], [-24, -2, -6], [18, -14, 8], [27, -1, 13], [-14, 10, -10], [21, 11, -5], [14, 1, 14], [-14, 3, 2], [-12, 10, 18], [8, -6, 10], [53, -5, 3], [0, 0, 2], [-26, 4, 4], [24, -2, -4], [-6, -5, 0], [-8, 10, 0], [-11, -5, 13], [-6, 0, -16], [6, -1, 14], [26, 4, 6], [-52, -8, -2], [-2, -18, 0], [2, 4, 0], [-2, -9, -2], [6, 21, -12], [-26, -8, 4], [-8, 14, 8], [11, -7, 23], [-18, -2, -12], [32, -4, 16], [3, -13, 15], [20, -16, 12], [-38, 16, -24], [-36, 18, -20], [-12, -9, -12], [-26, -10, 4], [-70, 0, 0], [1, 7, 7], [36, -8, -4], [20, -16, -12], [-14, 5, -6], [10, 20, 4], [-41, -1, 5], [-8, -11, 4], [22, -20, 12], [0, -14, 14], [40, -9, 12], [24, 9, 6], [10, 0, 20], [-44, -6, -4], [44, -6, -2], [-13, -11, -3], [-24, 19, -18], [2, -7, -16], [-6, 2, 14], [-12, -5, 2], [-34, 12, -2], [-72, 5, 0], [-29, 15, 7], [-6, -10, 4], [-4, -2, 4], [8, -8, 12], [-13, 5, -11], [-36, 2, 6], [-32, -13, 0], [27, 11, 11], [34, -6, -10], [32, -13, 6], [-42, -6, -6], [49, -3, 5], [8, -10, 2], [44, 1, -4], [-23, 7, 7], [-6, -2, -8], [38, -4, 14], [19, 7, -11], [-30, -8, -8], [-4, -21, 10], [14, -15, 6], [18, 5, 12], [14, 12, 4], [-10, -2, 10], [10, 15, -4], [-28, 12, -18], [13, -13, 11], [1, -11, 3], [47, -3, 1], [38, 10, 0], [0, 6, 10], [12, 3, 18], [16, 24, 0], [17, -11, -21], [20, -8, -4], [-23, -3, -13], [6, 9, -20], [-18, 16, -4], [20, -11, 2], [-14, -29, 2], [-22, 4, -8], [-6, 3, 12], [24, -12, -6], [30, 14, 2], [22, -12, -16], [-4, -4, -16], [-26, 0, -12], [25, 1, 3], [-2, 16, -14], [6, 2, -8], [-22, 14, -14], [-2, -20, 12], [4, -22, 6], [-26, 3, 6], [10, 0, -12], [34, -14, 16], [36, -6, -12], [-11, -1, 3], [6, 0, 12], [-30, -12, 6], [-4, 2, 18], [50, -16, 8], [-16, 10, 0], [-10, 29, -10], [16, 19, 0], [26, -12, 0], [-24, -7, -2], [-32, -24, 0], [42, -10, 0], [-6, -4, 10], [-8, 14, 20], [-6, -20, -10], [50, -1, 8], [-56, 4, -16], [-45, -7, -1], [-26, -2, -2], [20, -2, 12], [-30, 21, -4], [34, 2, 0], [-32, 4, 18], [10, -9, 8], [18, -9, -12], [-56, 6, 0], [10, 4, -8], [4, 20, -4], [24, 0, 0], [-39, 5, -1], [25, -9, 9], [-74, -4, 2], [19, -11, -11], [2, -12, 0], [-17, -15, -13], [12, -12, 0], [-24, -4, 12], [26, 8, 14], [-7, 5, 1], [54, 0, -14], [36, -16, 22], [-1, -15, -15], [10, 0, -16], [-16, -10, 18], [52, -18, 14], [-36, 8, -4], [-5, -5, -17], [28, 12, -10], [48, -5, 12], [-82, 2, 0], [13, 11, -3], [50, 14, -2], [28, -8, 16], [-4, 6, 6], [-28, -11, -6], [-8, 16, -8], [14, -25, 22], [-31, 21, -15], [2, 8, 8], [15, -5, -7], [10, -2, 14], [-34, 7, 0], [27, -11, 5], [-14, 7, 16], [-42, -22, 8], [30, -14, 2], [46, 22, -2], [-34, -6, -12], [34, -16, -24], [-24, 0, 24], [33, 15, -15], [-24, 6, -4], [32, 15, 4]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_7360_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_7360_2_a_ce();".
// 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_7360_2_a_ce(:prec:=3)
    chi := MakeCharacter_7360_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_7360_2_a_ce();".
// 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_7360_2_a_ce( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_7360_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<3,R![12, -9, -1, 1]>,<7,R![-64, -21, 3, 1]>,<11,R![144, -39, -3, 1]>,<13,R![18, -15, -1, 1]>,<17,R![-18, 7, 7, 1]>],Snew);
    return Vf;
end function;