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