
// Make newform 7350.2.a.cn in Magma, downloaded from the LMFDB on 30 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_cn();".
// 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_cn();".
// 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], [-4], [-5], [4], [-5], [-6], [11], [-8], [-5], [0], [-1], [-12], [2], [-10], [0], [-1], [2], [9], [6], [-11], [-1], [-12], [13], [-2], [4], [-5], [0], [-6], [-23], [-2], [18], [-16], [-14], [-24], [16], [-2], [22], [22], [-25], [-11], [24], [-5], [-16], [21], [18], [14], [-26], [11], [6], [8], [-14], [21], [24], [9], [2], [-29], [-26], [18], [28], [-29], [-1], [-4], [10], [-13], [18], [4], [9], [-20], [-4], [32], [-2], [3], [24], [-34], [-6], [35], [0], [28], [-3], [-9], [-35], [8], [37], [-14], [-20], [-13], [-34], [3], [39], [12], [22], [8], [-2], [3], [-14], [-4], [-8], [-38], [-36], [9], [-44], [-2], [6], [9], [17], [34], [-27], [-34], [-29], [14], [33], [-15], [26], [-28], [-28], [-14], [-14], [-19], [-18], [2], [2], [0], [10], [3], [-33], [30], [0], [33], [-32], [-28], [-17], [14], [-4], [40], [42], [10], [48], [52], [-20], [30], [-26], [9], [20], [58], [10], [-51], [-22], [-39], [-2], [56], [-18], [51], [43], [-34], [-30], [-36], [0], [6], [1], [-6], [33], [16], [37], [4], [-19], [12], [58], [-32], [-40], [35], [-11], [-19], [2], [30], [4], [-6], [4], [-10], [-26], [-38], [-11], [22], [-26], [58], [-43], [-32], [34], [-4], [10], [-34], [18], [6], [-10], [-2], [-30], [-48], [-36], [57], [34], [-51], [-38], [-52], [-39], [-18], [-41], [18], [1], [-36], [31], [-36], [21], [23], [65], [70], [32], [-20], [50], [69], [45], [-41], [10], [16], [37], [-51], [47], [24], [16], [-14], [21], [-9], [-8], [25], [-10], [50], [40], [-53], [-72], [-46], [0], [-10], [-23], [35], [-5], [30], [-68], [-39], [28], [-6], [45], [-62], [-36], [-24], [-52], [-12], [-18], [19], [16], [34], [-22], [-16], [-61], [-30], [-6], [-78], [14], [6], [-34], [34], [-63], [-33], [-30], [79], [58], [74], [43], [2], [-9], [23], [-23], [-10], [-20], [-39], [5], [14], [32], [-3], [64], [20], [11], [60], [-36], [14], [40], [72], [-76], [44], [-53], [-14], [-37], [2], [-28], [-55], [-54], [-72], [-24], [26], [-39], [-10], [-30], [18], [27], [42], [6], [43], [53], [-69], [14], [-54], [42], [16], [-43], [2], [-68], [-12], [27], [-30], [12], [6], [43], [-64], [-10], [-42], [70], [69], [-86], [71], [82], [1], [52], [-8], [-14], [64], [30], [46], [16], [-40], [14], [-71], [-82], [35], [30], [-23], [45], [-20], [-27], [-56], [6], [-14], [15], [-28], [36], [-50], [-2], [-81], [-62], [-26], [-36], [11], [-16], [-95], [-34], [56], [-8], [1], [-1], [27], [-64], [90], [-64], [-46], [-20], [-23], [-73], [26], [34], [-87], [-65], [-56], [56], [62], [-17], [-23], [-36], [-2], [-40], [12], [26], [62], [-41], [-6], [-96], [-19], [-42], [85], [-24], [56], [-66], [-74], [36], [-74], [-45], [-70], [-24], [41], [87], [-16], [-74], [84], [-12], [-12], [-65], [18], [-88], [78], [32], [-33], [19], [82], [4], [-21], [10], [-57], [31], [40], [-66], [-25], [-44], [-57], [8], [-3], [-63], [-49], [104], [-57], [-74], [74], [88], [33], [-20], [91], [-37], [102], [32], [-18], [-66], [-77], [20], [-3], [82], [44], [-102], [83], [89], [-94], [-59], [-80], [56], [72], [-57], [-29]];
    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_cn();".
// 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_cn(: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_cn();".
// 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_cn( : 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![4, 1]>,<17,R![5, 1]>,<19,R![-4, 1]>,<23,R![5, 1]>,<31,R![-11, 1]>],Snew);
    return Vf;
end function;