
// Make newform 7350.2.a.dl in Magma, downloaded from the LMFDB on 23 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_7350_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_7350_2_a_dl();".
// 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_7350_2_a_dl();".
// 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 := [-2, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rfbasis := [Kf.1^i : i in [0..Degree(Kf)-1]];
    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_7350_a();"
function MakeCharacter_7350_a()
    N := 7350;
    order := 1;
    char_gens := [4901, 1177, 2551];
    v := [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_7350_a_Hecke(Kf)
    return MakeCharacter_7350_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 := [[1, 0], [1, 0], [0, 0], [0, 0], [-2, 3], [0, -4], [-4, 1], [-4, -2], [-6, 2], [4, -1], [-6, -3], [-4, 3], [2, 6], [-2, -5], [-2, 3], [-6, 4], [-6, 2], [-6, -4], [-2, -5], [4, -6], [2, 0], [8, 0], [-8, 2], [2, -2], [-2, 6], [12, 4], [-12, -2], [-4, -4], [2, -4], [-10, 0], [0, -2], [-6, 2], [-8, -4], [-8, 4], [4, 13], [6, 10], [14, -4], [10, 5], [2, -3], [-18, -2], [22, 3], [10, 6], [4, 0], [2, 2], [6, 14], [-10, 3], [-12, -8], [-4, 8], [8, 12], [-2, -10], [-2, -12], [-8, -8], [-4, -11], [4, -12], [20, -1], [-2, 10], [18, -4], [2, 21], [0, 11], [2, -18], [-18, 6], [-10, -8], [-4, 8], [-8, -2], [-22, -6], [14, 8], [-12, 4], [-2, -22], [28, -4], [-2, 18], [8, -17], [-20, -6], [8, 2], [-8, 1], [-8, 6], [-18, -1], [-20, -7], [-18, 8], [-6, 0], [0, 3], [-20, -12], [2, -4], [-12, 18], [-2, 14], [6, -21], [-8, -20], [-2, -6], [6, -6], [2, 0], [20, 4], [-4, -6], [0, -6], [-8, -2], [-10, -5], [4, 2], [6, -1], [0, -12], [2, 26], [-22, -14], [-10, -14], [10, 13], [38, 0], [12, 6], [26, -12], [16, -8], [18, -10], [8, -2], [20, 15], [4, 0], [-36, 3], [-4, 0], [4, 5], [0, -24], [-12, 22], [6, -10], [26, 0], [-26, -2], [18, -19], [-18, 14], [2, 13], [-22, 12], [-2, 20], [2, 30], [12, 14], [20, -12], [4, -15], [26, -10], [-16, 24], [8, 16], [34, 0], [-20, 22], [0, -20], [2, 14], [-16, -7], [-10, -12], [-8, 9], [6, 12], [-44, 4], [14, -10], [26, 6], [16, -4], [-20, 15], [-12, -12], [-44, 6], [22, 8], [0, 6], [18, 16], [-12, -9], [4, -28], [-40, -4], [0, -3], [26, 0], [30, 3], [6, 19], [-10, 19], [28, 12], [6, -26], [50, 4], [-42, 4], [0, -20], [12, -2], [-16, 8], [16, -4], [12, -12], [18, 8], [10, 5], [-30, 14], [34, 16], [12, 20], [50, -2], [-42, -5], [22, 2], [12, -24], [-2, -2], [2, -31], [-14, -20], [-12, -18], [-28, -7], [-16, -4], [-30, -4], [-8, -22], [-26, 2], [8, 11], [-20, -31], [-14, 14], [-6, 4], [-12, 1], [18, 14], [22, -8], [40, 4], [34, -14], [24, -12], [8, 2], [14, -4], [-8, 10], [-4, 15], [12, -20], [20, -3], [-20, 19], [-18, -9], [-8, -17], [-34, 11], [-32, -20], [0, 13], [12, -32], [6, 16], [-18, 3], [-12, 22], [-22, 16], [20, -16], [14, 12], [-2, 24], [44, 8], [16, 10], [-32, -6], [-32, 23], [0, -2], [-18, -6], [-30, 2], [-14, 34], [-42, -22], [-6, -15], [-34, -22], [-4, 14], [16, 22], [-54, -6], [20, -35], [28, 0], [8, 4], [14, 23], [12, -21], [8, 14], [-32, -4], [-26, 24], [28, 28], [-14, -15], [32, 17], [22, 6], [-6, -31], [36, -10], [-20, 4], [48, 10], [-20, -8], [14, 22], [-24, 17], [-8, 0], [8, -8], [2, 10], [12, -4], [-24, -12], [24, 11], [30, -18], [-24, -4], [-12, -7], [-10, 16], [14, -9], [18, -36], [-2, -18], [30, 4], [-6, -30], [24, 4], [-20, -36], [-2, -36], [-16, 28], [-56, -13], [-56, 4], [-8, -19], [-2, -18], [18, -11], [2, -50], [38, 22], [-14, 5], [30, -2], [40, -8], [-2, 42], [-8, 18], [0, 12], [-14, -34], [-12, 20], [46, -6], [38, 23], [8, -16], [-34, -1], [-50, 20], [-34, 10], [-60, 14], [-18, -30], [46, 8], [-14, 37], [10, 12], [-16, -7], [-20, 36], [-34, -4], [54, 10], [52, -19], [40, 4], [-38, -27], [-14, -42], [-60, -8], [-12, -52], [-54, 16], [34, -18], [48, 20], [-32, 2], [-12, 36], [10, -44], [28, -24], [-6, 16], [48, -14], [48, 13], [30, 7], [-36, -29], [-42, -4], [-14, 21], [-16, 48], [-24, 25], [-20, 12], [4, 2], [38, 6], [66, -18], [12, -28], [-34, -8], [0, 4], [-32, 40], [-4, -28], [-36, 9], [0, -12], [-20, 12], [-24, -36], [66, 8], [42, -12], [-6, -34], [-34, -13], [-48, 8], [-40, -18], [-24, -36], [2, 2], [24, 27], [-8, -29], [-4, 22], [16, -23], [-36, 28], [20, 24], [8, -44], [-78, 6], [-26, -9], [-26, 10], [-14, -43], [-4, 2], [30, -24], [52, 4], [2, -10], [-52, 15], [-12, 32], [-58, 10], [-40, 3], [-4, -20], [-4, 64], [58, 12], [-54, 6], [16, 25], [-14, 28], [-46, -22], [-66, -13], [44, 16], [78, -14], [-30, 14], [32, 2], [-34, 20], [50, 29], [24, -32], [2, -22], [16, -1], [-38, 5], [0, 33], [-34, -6], [8, 46], [26, -10], [2, 18], [58, -20], [-2, -24], [-2, 36], [28, 30], [42, 0], [28, 24], [-82, -5], [80, 4], [-30, 16], [30, -1], [-14, -15], [-4, 44], [-66, 20], [-42, 19], [-84, -8], [-16, 46], [-38, -8], [-2, -17], [86, 4], [0, 30], [8, 33], [-2, 52], [-64, 16], [80, 6], [32, -23], [52, 16], [-30, -15], [48, -15], [-82, 2], [-22, -50], [14, -54], [-10, -24], [2, -20], [-44, -12], [52, 30], [10, 38], [-44, -16], [68, -8], [-8, -18], [0, 33], [-54, 1], [-12, -15], [20, -12], [-48, 4], [68, -8], [14, -18], [-10, -4], [64, -26], [50, 14], [-40, 2], [-72, 18], [-48, 35], [-2, -17], [-64, 6], [-26, -21], [6, 0], [-58, 22], [46, 12], [-26, -40], [22, -5], [30, 35], [-32, 22], [-42, -14], [-26, -14], [24, 16], [-36, -5], [56, 36], [-38, 14], [-26, 15], [-48, 43], [14, -56], [-10, -33], [16, 0], [24, 52], [-10, 42], [-50, -32], [-48, 39], [-38, 0], [28, 32], [40, 12], [-20, 4], [-12, 44], [-26, -6], [-14, -15], [-70, 8], [22, 6], [-70, -18], [0, -48], [-52, -32], [-14, 4], [-12, 38], [0, 58], [-96, -6], [24, -12], [-72, -4]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_7350_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_7350_2_a_dl();".
// 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_7350_2_a_dl(:prec:=2)
    chi := MakeCharacter_7350_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(3361) - 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_7350_2_a_dl();".
// 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_7350_2_a_dl( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_7350_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<11,R![-14, 4, 1]>,<13,R![-32, 0, 1]>,<17,R![14, 8, 1]>,<19,R![8, 8, 1]>,<23,R![28, 12, 1]>,<31,R![18, 12, 1]>],Snew);
    return Vf;
end function;