
// Make newform 7350.2.a.bs in Magma, downloaded from the LMFDB on 26 September 2025.
// 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_bs();".
// 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_bs();".
// 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 := 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]];
    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], [-4], [4], [3], [-6], [-7], [4], [5], [-2], [-7], [-2], [1], [2], [14], [-12], [-12], [-9], [6], [-17], [-4], [7], [-7], [18], [-7], [-14], [6], [3], [-16], [8], [-15], [-2], [-6], [24], [-4], [8], [0], [6], [2], [-12], [15], [-25], [-20], [-15], [-22], [9], [-22], [-8], [6], [3], [2], [-4], [-2], [27], [10], [-5], [16], [17], [-8], [-12], [20], [-21], [-27], [-18], [-34], [-3], [-32], [18], [-15], [4], [-32], [-12], [20], [-31], [10], [-22], [34], [-29], [26], [16], [-39], [37], [-17], [26], [-13], [-18], [-36], [7], [0], [-1], [-5], [38], [28], [36], [16], [9], [44], [32], [-22], [-30], [-2], [-45], [40], [-2], [42], [13], [-31], [-46], [29], [-4], [-1], [16], [7], [-9], [14], [-32], [-16], [0], [-30], [11], [32], [-22], [24], [12], [14], [7], [-49], [-10], [14], [-1], [-16], [16], [21], [-10], [-18], [22], [-12], [54], [0], [6], [24], [-20], [38], [25], [-2], [-26], [-24], [11], [-38], [35], [-6], [56], [28], [19], [-39], [30], [-6], [-42], [32], [26], [29], [24], [-3], [28], [7], [-16], [29], [-48], [42], [-34], [-16], [-43], [-29], [-17], [-4], [-2], [-16], [20], [12], [58], [-6], [26], [-45], [-18], [38], [30], [25], [-12], [6], [-12], [-34], [32], [-44], [26], [2], [50], [-22], [40], [-16], [55], [-4], [65], [26], [24], [35], [52], [-15], [-8], [47], [-10], [19], [66], [25], [-25], [-31], [18], [-48], [14], [8], [19], [19], [-5], [-42], [46], [29], [29], [-37], [-40], [4], [-28], [-5], [25], [20], [43], [22], [-72], [-4], [43], [54], [-26], [-32], [8], [-3], [27], [-17], [-8], [-6], [15], [8], [6], [3], [-46], [-60], [74], [20], [28], [2], [41], [-36], [-42], [-2], [24], [79], [-40], [-30], [-10], [34], [68], [8], [-18], [-49], [9], [18], [-69], [42], [56], [-49], [-66], [-11], [-67], [63], [80], [-46], [-15], [7], [0], [-16], [-49], [-20], [-42], [-57], [46], [-34], [48], [-28], [66], [-6], [-18], [-35], [30], [-19], [66], [-50], [-29], [2], [40], [-24], [22], [51], [44], [-18], [20], [45], [22], [-82], [-45], [7], [-7], [-72], [-2], [-66], [-16], [9], [-2], [0], [-56], [-87], [-54], [78], [-10], [57], [6], [6], [32], [-38], [9], [-22], [-5], [-14], [-51], [6], [-80], [-38], [-18], [-46], [-8], [0], [-28], [50], [43], [48], [-73], [60], [-87], [21], [6], [57], [28], [-92], [-50], [-39], [-16], [-6], [-46], [28], [-9], [90], [-18], [48], [-15], [60], [-41], [-32], [-84], [-8], [-81], [89], [41], [48], [-6], [24], [78], [86], [15], [-67], [18], [-56], [7], [-41], [-66], [-72], [-38], [-61], [-85], [8], [90], [36], [6], [-94], [-6], [-9], [54], [-24], [63], [-70], [-69], [-60], [-24], [18], [4], [-24], [-10], [57], [14], [-56], [-15], [-53], [-8], [-8], [-40], [36], [-18], [-11], [106], [-50], [-102], [-28], [39], [83], [-12], [-56], [93], [46], [45], [-33], [70], [82], [-23], [18], [45], [90], [-59], [-79], [-41], [86], [57], [14], [-12], [-88], [-59], [78], [-83], [-63], [50], [24], [22], [-20], [35], [-54], [-17], [-34], [-90], [-14], [-3], [3], [2], [-1], [68], [60], [-34], [-21], [-101]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_7350_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_7350_2_a_bs();".
// 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_bs(: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_bs();".
// 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_bs( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_7350_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<11,R![4, 1]>,<13,R![-4, 1]>,<17,R![-3, 1]>,<19,R![6, 1]>,<23,R![7, 1]>,<31,R![-5, 1]>],Snew);
    return Vf;
end function;