
// Make newform 7350.2.a.cy in Magma, downloaded from the LMFDB on 24 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_cy();".
// 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_cy();".
// 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_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], [1], [0], [0], [6], [-4], [-3], [-4], [3], [-6], [5], [8], [-3], [8], [9], [12], [6], [2], [8], [-9], [14], [-7], [-6], [3], [17], [12], [-13], [6], [-4], [3], [-16], [-18], [-15], [2], [-6], [-16], [14], [8], [0], [-6], [-18], [2], [15], [5], [0], [5], [8], [11], [-18], [-22], [6], [3], [-22], [24], [-18], [-3], [0], [-25], [26], [27], [-22], [-18], [20], [21], [17], [12], [26], [-13], [18], [-28], [15], [-36], [-28], [8], [-10], [21], [0], [2], [-6], [29], [24], [-4], [21], [-7], [-13], [-24], [-3], [2], [36], [-13], [-30], [21], [-25], [-12], [38], [24], [-6], [21], [-34], [-28], [8], [-30], [12], [-15], [20], [2], [18], [-33], [9], [-34], [11], [-34], [-21], [-46], [17], [-39], [-34], [12], [-36], [-30], [-10], [-19], [18], [18], [-34], [-48], [-46], [-27], [-31], [50], [-16], [9], [-16], [-4], [9], [50], [-12], [8], [-18], [-6], [-40], [36], [44], [30], [2], [15], [-28], [6], [14], [21], [2], [15], [14], [24], [38], [-21], [11], [-30], [-34], [12], [-48], [6], [-31], [6], [57], [-48], [-43], [-4], [29], [-12], [42], [-16], [24], [-13], [59], [27], [26], [-42], [-4], [-10], [-28], [42], [14], [54], [45], [18], [38], [-10], [5], [-48], [14], [-12], [26], [18], [-54], [-6], [-58], [-10], [-18], [0], [-36], [-25], [14], [35], [54], [36], [-25], [-18], [15], [38], [17], [-60], [-1], [-36], [-45], [-55], [-31], [42], [-48], [-36], [-22], [11], [69], [-25], [-18], [56], [51], [69], [17], [0], [-16], [38], [5], [15], [-40], [-33], [-22], [18], [-24], [-3], [24], [-34], [32], [38], [63], [-27], [-43], [18], [44], [-15], [-52], [54], [-27], [-34], [60], [24], [20], [-28], [18], [29], [-16], [18], [-58], [56], [21], [-10], [-30], [30], [14], [-42], [2], [2], [-1], [-1], [62], [-31], [-78], [26], [11], [6], [81], [23], [-33], [-70], [-4], [-15], [-43], [30], [-64], [-21], [0], [12], [3], [-36], [-4], [-78], [8], [24], [36], [-52], [5], [-30], [11], [66], [20], [41], [42], [-40], [-24], [2], [-81], [-66], [-78], [50], [-45], [38], [42], [-45], [-37], [3], [2], [-22], [6], [-16], [-51], [62], [20], [-4], [3], [66], [-52], [30], [53], [24], [-34], [18], [-58], [51], [-58], [-55], [26], [9], [-36], [-40], [42], [72], [26], [62], [0], [48], [-70], [-7], [-42], [-67], [-10], [-33], [-21], [-36], [-3], [-72], [-82], [30], [-9], [84], [-4], [14], [42], [-49], [50], [-18], [92], [-45], [0], [-49], [38], [24], [72], [-49], [-39], [-91], [-48], [-6], [-16], [18], [-76], [15], [23], [-58], [74], [63], [-1], [-24], [-72], [-22], [39], [-55], [-28], [-30], [-64], [36], [14], [-66], [71], [6], [24], [-13], [-10], [-99], [80], [24], [2], [54], [-84], [-10], [-13], [6], [24], [-25], [33], [48], [102], [20], [36], [-12], [-79], [-66], [0], [78], [8], [-39], [77], [-102], [-76], [-3], [14], [-15], [47], [-40], [62], [-7], [12], [15], [80], [21], [-1], [39], [104], [33], [26], [-58], [32], [39], [108], [93], [107], [-90], [-16], [18], [50], [75], [-4], [-67], [-54], [20], [14], [-13], [-7], [-42], [-51], [-88], [-40], [96], [81], [-61]];
    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_cy();".
// 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_cy(:prec:=1)
    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_cy();".
// 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_cy( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_7350_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<11,R![-6, 1]>,<13,R![4, 1]>,<17,R![3, 1]>,<19,R![4, 1]>,<23,R![-3, 1]>,<31,R![-5, 1]>],Snew);
    return Vf;
end function;