
// Make newform 7360.2.a.cb in Magma, downloaded from the LMFDB on 23 December 2025.
// 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_cb();".
// 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_cb();".
// 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, -6, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0], [0, 1, 0], [-4, -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 := 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]];
    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, 0], [-1, 1, -1], [0, -1, 1], [-1, 1, -1], [-1, 1, 2], [1, 0, 0], [-1, 0, -1], [2, -3, -1], [-4, 0, 0], [-2, -3, -2], [-6, 0, -2], [5, 0, 1], [-2, 0, -4], [-2, 2, 2], [-9, 1, -1], [-4, -4, 4], [2, -3, -2], [-5, -4, 1], [0, 0, 0], [4, 4, 2], [-10, 0, -2], [3, -1, 3], [-4, 2, 2], [-5, 1, -1], [-6, -2, -4], [-7, 1, 2], [-10, 0, 0], [7, 4, 5], [3, 2, 3], [-7, 3, 4], [-1, 0, -3], [3, 3, 2], [6, 1, 2], [0, 6, 6], [2, 7, -3], [0, 0, -4], [5, -7, -5], [-5, -4, -5], [-9, 1, 0], [-8, -2, -4], [-1, 8, -3], [4, 5, 4], [4, -4, 2], [4, 4, 6], [-4, -4, 0], [-12, -2, 2], [2, -8, 0], [-19, 0, -1], [17, 2, 3], [10, -4, 2], [5, -9, -6], [-7, -4, 3], [-11, 3, 1], [3, 0, -1], [-7, 11, 4], [-5, 10, -1], [-4, -2, -10], [10, 8, -4], [0, 8, 6], [-15, -1, -5], [1, -2, 3], [11, 1, 4], [1, -3, -4], [-9, -4, 5], [11, 7, -6], [7, 1, 1], [-15, 2, 5], [9, 2, -1], [16, 0, -2], [8, -12, 0], [-4, -10, 0], [9, -5, 5], [10, -4, -2], [-19, -1, 1], [2, 1, -6], [-4, -2, 8], [12, -3, -1], [-6, -8, -2], [-27, -3, 2], [0, -6, 6], [11, -1, 6], [-8, -3, -7], [-14, -3, -5], [-11, 9, 4], [4, 4, 2], [3, 4, 1], [-8, 12, 6], [0, -10, 0], [4, 0, 2], [27, -4, 1], [-9, -12, -1], [15, -2, -7], [17, 9, -8], [3, 4, 3], [8, 4, -6], [-2, -4, 4], [13, 6, 3], [-12, -7, 5], [-2, -12, -6], [-4, 4, -8], [-2, -12, 4], [-5, -7, -9], [-7, 6, 5], [4, -9, -8], [0, -6, -4], [-9, -3, -15], [-4, 5, 7], [0, -8, -4], [8, 12, 10], [-13, -7, -1], [-3, -9, -10], [8, 6, 0], [10, -8, 2], [-32, 10, 2], [-9, -6, 3], [4, -17, 1], [-40, -4, 4], [-23, 13, 1], [15, -2, -1], [38, 0, 4], [6, -1, 5], [10, -2, -4], [3, 7, 6], [3, -1, -1], [7, 13, 12], [17, 9, 5], [0, -4, -2], [13, 6, 3], [7, 9, 10], [-16, -2, -8], [12, -8, 0], [-24, 1, 7], [-2, 16, 8], [-6, 8, -10], [6, 10, -2], [-2, -10, -14], [-11, -15, -1], [5, 4, 9], [2, -12, -4], [-1, 2, 11], [14, 6, 2], [6, 12, -12], [28, 6, 10], [47, -5, 0], [-25, 18, 3], [25, -4, -7], [7, -8, -3], [23, 3, 5], [-16, 8, 8], [-47, -5, 4], [-5, 14, 1], [2, -10, -8], [10, 2, 0], [-22, -8, 10], [-7, 6, -11], [25, 7, 0], [19, 1, 7], [2, 5, 15], [-13, 11, -1], [27, 8, 5], [11, 15, 3], [-1, 5, -4], [17, -3, 1], [-25, 21, 5], [-22, -12, 0], [-14, -2, -6], [-6, -11, -6], [12, 4, 0], [7, 8, -9], [18, -14, -8], [5, -17, -7], [8, -3, -12], [8, -6, 6], [13, 14, -7], [7, 2, -15], [-17, 1, -9], [-11, -1, 12], [7, -8, 5], [7, -17, 3], [14, 11, -13], [-12, -6, 6], [9, -15, -3], [-31, 11, 4], [17, 5, -16], [8, 12, 8], [-24, 1, -4], [-7, -13, -1], [-11, 12, 3], [-24, 16, 0], [-14, 4, 2], [-18, -16, -2], [18, 8, 0], [47, -5, -2], [-6, -22, 8], [-20, -4, -10], [-16, -20, 6], [11, 0, -1], [-17, 9, -5], [-47, -1, -8], [12, -15, 4], [4, 4, 0], [-8, 0, -8], [3, 10, 11], [12, -12, -2], [-2, 21, -6], [-12, 15, 5], [15, 16, -1], [29, -24, -7], [-1, -22, 3], [-3, -7, 0], [32, 2, 6], [0, 4, -12], [-16, -10, -10], [-15, 0, -5], [-9, 18, 3], [-9, -13, 8], [-31, -6, 5], [17, 0, -7], [-24, -4, 14], [-26, 11, 10], [15, 3, 12], [-11, -10, -17], [-27, -8, -3], [43, 13, -8], [32, 9, 5], [-29, 3, -4], [-4, -8, 0], [11, -21, -12], [-7, 9, -3], [6, 20, 2], [19, -5, -7], [34, -6, -8], [-6, 0, -22], [42, 2, 4], [42, -6, 0], [-43, -8, 5], [2, 19, -10], [10, -18, -4], [-1, 10, 3], [19, -30, -13], [41, -20, -5], [4, 6, -14], [-16, -1, -5], [-3, 12, 13], [-19, -7, 8], [19, 3, -1], [23, 7, 15], [34, -2, 10], [-44, -6, -8], [-5, -5, -24], [10, -8, -10], [-2, 20, 4], [-25, 4, 5], [-11, -5, 5], [32, -2, -8], [34, 7, 3], [21, 18, -7], [-55, 7, 1], [38, 8, 0], [6, -12, 10], [44, 6, -6], [22, -4, 4], [19, 9, -9], [-45, 13, 3], [30, -20, 0], [-6, 14, 14], [-32, -7, 3], [-1, 0, -9], [-18, 28, 10], [-3, 1, 6], [-10, -8, 14], [21, 6, 9], [-3, 8, 11], [41, -17, -5], [-44, 6, 6], [-26, 24, 0], [31, 1, 10], [25, 2, -17], [22, -4, -6], [-41, -11, -1], [2, -4, 0], [29, 3, -12], [9, -5, 3], [-2, 20, 12], [-10, 2, -2], [-49, 9, -3], [-23, -11, -5], [14, -16, -4], [22, -6, -6], [-44, 6, -8], [-23, -5, 18], [18, 23, 14], [-39, -3, -7], [-14, -14, 0], [20, 11, 8], [17, 2, -11], [-22, -17, -10], [-3, 13, 22], [2, -10, -16], [-6, -10, 22], [-1, -22, 1], [-15, 11, 2], [13, -24, -13], [-19, -21, -13], [-7, -1, 12], [80, -2, -2], [25, -39, -9], [9, -4, 5], [27, 1, -12], [10, -14, -6], [-6, -21, -22], [-19, -21, 2], [-24, -10, -18], [17, -2, 13], [-12, 31, 7], [0, -4, -10], [6, -7, -6], [11, -21, -9], [11, 7, -9], [-1, 10, -13], [-22, -18, -16], [-27, -11, -3], [24, -16, -4], [37, -15, 0], [-10, 3, -15], [11, 17, 14], [-34, -14, -12], [27, -32, -11], [4, -5, 24], [-21, 26, 13], [-22, -5, 13], [-24, -16, 20], [18, -29, -3], [-15, 37, 13], [2, -8, -16], [-20, 3, 12], [35, -9, 3], [37, -10, 9], [1, 17, 25], [2, -4, 10], [12, -6, -22], [-18, 0, -12], [32, -12, -4], [3, 10, -25], [11, -3, 20], [2, 0, 12], [-32, -6, -6], [5, 0, 17], [33, 18, 5], [-44, -10, 4], [-41, -9, 11], [56, 12, 10], [-16, 14, 6], [26, 18, 2], [-35, 13, 8], [1, 6, 25], [-16, 0, -2], [-20, 2, -24], [7, 6, -29], [-53, 0, -11], [3, -1, 15], [-44, 5, 12], [-39, -18, 21], [14, 13, 26], [28, 16, 4], [24, 2, 26], [5, 10, -15], [-30, 10, -6], [23, -14, -1], [-31, -9, 9], [-20, -4, -12], [6, 13, -3], [-41, -16, 3], [-10, 26, -2], [-1, 15, -5], [30, 6, -12], [-5, -10, -23], [-25, 27, 11], [7, -7, -13], [14, -6, 18], [31, -14, -1], [-30, 24, 2], [-51, 2, 3], [-36, 5, -11], [-7, -11, 0], [46, 16, -4], [75, 1, -6], [36, 16, 26], [19, 11, -20], [59, 6, -11], [16, 4, -16], [42, 4, 4], [11, 15, -26], [-26, -8, 12], [6, 16, -6], [25, 15, 14], [26, 4, -16], [1, 28, 3], [-29, -24, 1], [26, 20, 2], [-17, 29, -4], [-5, 2, -11], [40, 11, -20], [-22, -18, -12], [12, 9, -1], [-24, -18, 10], [-8, 12, -8], [-55, -4, -9], [-18, -15, -18], [24, 0, 12], [-47, -11, 9], [21, 11, -12], [-27, 14, -15], [43, 13, -20], [22, -14, 8], [-35, -3, -23], [-59, 5, 8], [-49, 27, 3], [40, 6, 6], [-6, -2, -12], [-6, 18, 0], [-73, -12, 7], [-35, -14, 9], [-12, -16, 12], [-25, -17, -24], [-35, 12, 3], [-60, 15, 8]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_7360_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_7360_2_a_cb();".
// 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_cb(: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_cb();".
// 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_cb( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_7360_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<3,R![3, -6, 0, 1]>,<7,R![2, -3, -3, 1]>,<11,R![12, -15, 3, 1]>,<13,R![-29, -18, 0, 1]>,<17,R![12, -15, 3, 1]>],Snew);
    return Vf;
end function;