
// Make newform 7280.2.a.ca in Magma, downloaded from the LMFDB on 19 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_7280_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_7280_2_a_ca();".
// 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_7280_2_a_ca();".
// 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 := [4, 2, -5, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0], [0, 1, 0, 0], [-3, -1, 1, 0], [1, -3, -1, 1]];
    Rf_basisdens := [1, 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_7280_a();"
function MakeCharacter_7280_a()
    N := 7280;
    order := 1;
    char_gens := [911, 5461, 1457, 4161, 561];
    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_7280_a_Hecke(Kf)
    return MakeCharacter_7280_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], [0, 1, 0, 0], [1, 0, 0, 0], [1, 0, 0, 0], [1, 0, 0, -1], [1, 0, 0, 0], [-1, 1, -1, 0], [2, 1, 1, 1], [1, -2, -2, 1], [-1, 1, -2, 1], [4, -1, 2, 2], [-1, 1, 0, -1], [-1, 1, 1, -2], [1, 2, 0, -1], [2, 2, 2, -4], [0, 2, 2, 0], [-2, -3, -6, 0], [0, 0, 2, 0], [3, -3, -1, 2], [3, 0, -2, -1], [2, 2, 4, 0], [3, 5, 1, -4], [2, 2, 4, -2], [-3, -3, -6, 3], [2, -4, -2, 2], [-6, 4, 0, -4], [4, 1, 3, 5], [5, -6, -4, -1], [2, 0, 2, -2], [0, -2, 2, 0], [1, 0, 0, -1], [4, 0, -4, 4], [3, 7, 4, -1], [6, 0, 2, 4], [-2, -8, -2, 6], [-1, -6, -8, 1], [1, 1, -4, 5], [9, 1, 2, -3], [-4, 0, -6, 2], [-1, -5, 0, 3], [-1, 7, 7, -2], [10, -10, 4, 4], [13, -1, 0, -1], [1, -1, 1, -8], [-1, 7, 0, -5], [4, 12, 0, -4], [9, -7, 1, 2], [0, 0, 0, 8], [8, -6, 0, 4], [3, 1, 5, -2], [0, -10, -8, 2], [-1, 2, 4, 5], [-3, -5, -5, 6], [2, 12, 0, -6], [6, 4, 4, -4], [-1, 6, 6, -5], [-12, 2, -4, -10], [7, 10, 2, -5], [2, 0, -6, -2], [-2, -8, -2, 6], [2, -5, 1, -7], [0, -4, 2, 0], [-2, -2, 2, 4], [12, -6, -6, 2], [-7, -7, -8, 1], [16, -12, 0, 2], [21, -6, 4, 7], [14, -4, -4, 0], [3, -8, 0, 5], [5, 1, 10, 3], [-4, -4, 0, 10], [-5, 0, -10, -1], [9, -10, -6, 1], [-2, -16, 0, 4], [-1, -6, 4, -3], [6, 10, 2, 0], [9, -1, -1, -2], [10, 2, -8, 0], [-2, 0, 10, -6], [-14, 8, 0, -4], [2, -8, -4, -2], [18, 0, 0, 0], [-3, -10, 0, -5], [-1, -11, 7, 0], [0, -4, 2, 6], [13, -12, -2, 5], [12, -2, -2, 0], [7, 3, 0, -1], [-13, -1, -2, -7], [-5, 1, 7, -2], [4, -1, 9, -9], [-4, 11, -2, -2], [-3, 9, 2, -3], [14, -20, -4, 2], [-9, 6, -8, -7], [3, 6, 10, -9], [3, 13, 5, -2], [-22, -2, -8, 4], [-1, -6, -14, 3], [6, -12, -2, 6], [5, -14, 4, 7], [19, -5, 9, 14], [8, -3, -1, 13], [-7, 7, 2, -1], [-7, -7, -8, -1], [6, 6, 4, -12], [-12, 10, 0, 0], [12, -6, 14, 0], [-18, 4, 4, 6], [-6, -12, -2, 10], [-6, 1, -4, 2], [-2, 8, -8, 0], [3, -7, -9, 8], [2, 5, 6, -8], [-11, 0, -2, -3], [-17, -1, -2, -7], [-12, -4, -10, -6], [28, 5, 12, 0], [10, -8, -6, -2], [-17, -7, 1, -4], [-3, -5, -13, 6], [4, -10, -4, 2], [2, -8, -8, -4], [-1, -3, 7, -2], [4, 3, 10, 2], [23, 5, 5, -6], [-2, -8, -10, -2], [12, 4, 8, -4], [-22, 11, 0, -2], [18, -8, 2, 2], [-11, 14, 14, -3], [-11, -7, -5, -8], [1, -19, 0, 3], [16, -2, -4, -2], [1, 9, 14, -5], [2, 0, 0, -4], [-26, 18, 10, 2], [-4, 4, 8, 0], [9, -3, 0, -7], [-7, 5, 13, -8], [-11, -14, -2, 9], [-2, 0, 0, 12], [7, 12, 12, -11], [4, -4, -16, 8], [-4, -4, -14, 4], [-15, -2, 14, -3], [10, -14, -10, -6], [-3, 5, 0, 5], [6, -4, 8, -2], [3, -5, -11, 0], [31, -15, -1, 0], [-34, 6, 4, -4], [-17, -8, -12, 5], [26, -3, 8, -2], [-15, 4, 2, -11], [3, 7, 7, -2], [-1, -9, -8, 5], [-3, 17, 10, -5], [19, 9, 15, 4], [-13, 9, 1, 2], [-13, 11, 9, 0], [-12, -2, -6, -4], [3, 11, 2, -1], [-2, -6, -18, -8], [-5, -13, 1, 2], [8, -22, -16, 0], [1, -11, -3, 10], [3, 9, 19, 0], [14, -12, 2, 2], [5, -5, 5, 4], [-3, 4, -8, 11], [21, 1, -2, -9], [18, -4, 0, -2], [0, -4, -12, 2], [14, 2, 6, 12], [-24, -6, 4, -2], [-13, 6, -14, -5], [-22, 4, -8, 8], [-34, -11, -12, 6], [-22, 20, 4, 0], [5, 23, 22, -7], [24, 6, 26, 2], [14, -12, -4, 8], [6, -4, -8, 4], [-26, -4, -4, 6], [-2, -2, 8, 4], [32, -2, 0, -6], [-10, -2, 10, -4], [-8, -10, 4, 14], [-4, 17, 6, -2], [1, -5, 5, 0], [15, 13, 6, 3], [-13, 21, -12, -7], [-25, 21, -3, -6], [-21, 10, -18, -9], [-42, -4, -4, -4], [-12, -10, 2, 12], [16, 14, 30, -4], [-8, -8, -4, 2], [4, 9, -4, 0], [0, 10, -10, 4], [-10, -6, 12, -2], [20, -10, -14, 0], [-4, 24, 16, -6], [-8, 9, 13, 15], [-21, 9, 3, 8], [26, -11, -3, -3], [9, -4, 14, 9], [8, 2, -2, 4], [14, 12, -8, 14], [4, -14, 4, 18], [-30, -10, -6, 6], [-15, 0, 10, 5], [-26, -6, -12, 10], [7, 18, -2, -9], [-33, 11, -6, -15], [-19, -14, -16, 3], [-46, 4, 6, 2], [31, -9, 10, 19], [7, -7, -5, 12], [9, 5, 21, -4], [-14, -17, 7, 3], [-18, -4, 4, 0], [27, 3, 9, -4], [-4, -5, -7, 7], [33, 3, -2, -1], [-23, -3, -20, 5], [-21, -13, -20, -3], [8, 7, -7, 11], [41, -4, 2, 5], [24, 22, 16, -14], [14, 8, 28, -6], [-9, -32, 4, 5], [-15, -19, -18, 7], [8, 3, 17, 11], [24, 6, -6, -2], [-10, 16, -4, 4], [3, -7, -4, -1], [-21, -9, 7, 2], [10, -26, -16, -2], [3, 25, -10, -1], [4, -2, 6, -14], [-14, -17, -8, 6], [-28, 10, -6, -4], [-16, 18, 16, -6], [2, -22, -20, -6], [-48, -8, -6, -2], [-46, -11, -15, 9], [11, -6, -4, 9], [-11, 18, 4, -17], [11, -5, 5, -6], [-9, -11, -19, 18], [24, -12, 8, 0], [-42, -4, -16, 4], [-42, 8, 0, -8], [-13, 4, 14, -1], [1, -3, 1, -8], [-8, 6, -4, -16], [-3, -17, 5, -4], [24, 20, 4, -14], [-43, 6, 4, -9], [49, -6, 2, -3], [21, -11, -6, 3], [-17, 7, -20, -9], [-28, 24, -2, -4], [-4, -30, 0, 8], [-32, 22, -12, -10], [-29, 29, 9, 2], [3, 19, -14, 11], [-34, -8, -6, 10], [36, 2, 12, 6], [29, 15, 17, -2], [-4, -14, -14, -12], [29, -15, -3, 6], [-15, -1, -3, 16], [22, -6, 6, 4], [1, -13, -15, -14], [12, 6, 18, -4], [8, -2, -12, -10], [14, 4, 18, 4], [6, -19, 3, 3], [-13, -18, 14, -9], [0, -9, 12, -12], [34, -8, 16, 12], [26, -14, 0, 2], [9, -17, -9, 8], [-10, 20, 2, 10], [2, -12, -4, -16], [-4, -23, -19, 3], [-48, 16, 4, 2], [-32, 0, 20, -2], [5, -2, -6, 13], [-17, 35, -8, -17], [-22, 21, 1, -15], [4, -14, -14, 4], [16, 18, 30, 0], [20, 4, 14, -2], [-55, -1, 1, 4], [38, -8, 0, -2], [-32, -12, 0, -12], [-7, 27, 21, 8], [-3, -1, -11, -12], [-5, 5, 8, 9], [-21, 26, -10, -1], [37, 1, 21, 2], [-13, -29, -7, 18], [21, -4, 24, 11], [-34, 12, -10, -14], [-39, -2, 6, -7], [20, -2, -8, -2], [6, -11, 7, 15], [-10, -20, 6, 6], [-3, -11, 1, -16], [-3, -4, -20, -1], [9, 11, -2, -11], [-24, -16, 2, 12], [27, -30, -14, 7], [-11, -22, 16, -5], [6, 10, 10, 6], [-15, -5, 23, -6], [-2, 20, 18, 4], [-5, 27, 9, -14], [-26, -10, 8, 4], [-9, 15, 14, -1], [23, 25, 24, -13], [-64, 4, -6, -12], [15, -12, -24, 9], [-6, 2, -12, -2], [-25, 30, -20, -11], [24, -10, 12, -2], [4, -2, -28, 10], [-52, 2, -26, -8], [-14, 8, 2, -4], [-8, 10, 24, -4], [23, 12, -6, 7], [20, -18, -2, 2], [16, -2, 0, -6], [-8, 2, 4, -10], [-5, -1, -22, -11], [-8, -11, 0, 16], [-3, 25, -16, -3], [-20, 14, 24, -2], [-21, 7, -10, 9], [-23, -31, -12, 15], [-14, -4, 4, -8], [-19, 7, 20, -17], [8, 10, 2, -4], [20, 16, 8, -8], [-54, -27, -23, 17], [18, 24, 8, -4], [-32, 3, -14, 14], [-22, -16, -12, -4], [26, 12, 6, -22], [12, -17, 0, -20], [-9, 3, 26, -7], [-25, 35, 12, -1], [-16, -31, -3, 15], [-18, 5, 2, -24], [18, -8, -12, 12], [-5, 5, -18, 11], [7, -3, 8, 15], [14, 18, 30, 2], [33, 18, 32, -9], [15, 6, -4, 21], [22, -25, -20, -2], [30, 16, 10, -6], [-4, 38, 6, -4], [23, 1, 11, 6], [25, -3, -6, 3], [3, 3, -9, -6], [50, -14, 2, 0], [21, -23, 2, 21], [12, 0, 8, 22], [-12, 16, -4, 8], [-14, 8, -28, -4], [-38, 1, 1, -7], [-57, 5, -15, 0], [28, -10, 24, 6], [-4, -8, -4, -2], [-17, 31, 8, 3], [1, 9, -10, -5], [28, 4, 8, 10], [37, 1, -5, -16], [21, -11, 11, 14], [28, -33, 14, 6], [-8, -34, 12, -4], [-9, 4, 28, -3], [11, 1, -21, -8], [20, 8, -4, 12], [-4, 3, 4, 24], [24, -6, -4, 14], [-16, 8, 22, -12], [29, 22, 32, -21], [12, -5, -4, 0], [-11, 12, -6, -7], [40, 14, 12, 6], [-4, 5, -18, -10], [-16, -16, 16, -18], [15, 29, 16, -23], [-8, -6, -4, -26], [13, 3, -5, 30], [26, -16, -12, 20], [13, 3, 14, 1], [28, 12, -16, 18], [33, -17, 7, 6], [14, 6, 8, -22], [13, 1, 27, 18], [18, 8, 4, -20], [-54, -12, -10, 4], [-15, 14, 2, -7], [10, -20, -12, 0], [-6, 28, -6, -2], [-29, 34, 10, -5], [19, 1, 1, 16], [-32, -10, 6, -12], [32, -30, 14, 16], [-21, 38, -8, -3], [17, -18, 14, 5], [-40, -4, -30, 4], [18, 9, -8, -10], [24, -24, -16, 10], [42, -24, 2, 2], [3, -31, 7, 14], [-20, 2, 2, -26], [24, -22, -12, -10], [-30, 30, 16, -8], [-21, 0, -2, -9], [22, -28, -16, 4], [-41, 6, -18, -1], [14, -16, 6, 12]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_7280_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_7280_2_a_ca();".
// 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_7280_2_a_ca(:prec:=4)
    chi := MakeCharacter_7280_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_7280_2_a_ca();".
// 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_7280_2_a_ca( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_7280_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<3,R![4, 2, -5, -1, 1]>,<11,R![-4, -2, 1]>,<17,R![4, 8, -15, 1, 1]>,<19,R![4, 26, -5, -7, 1]>,<23,R![64, 32, -20, -6, 1]>],Snew);
    return Vf;
end function;