
// Make newform 7350.2.a.di in Magma, downloaded from the LMFDB on 12 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_di();".
// 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_di();".
// 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 := 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, 0], [-1, 0], [0, 0], [0, 0], [-2, 3], [3, 2], [1, 4], [4, 1], [3, 1], [-5, 4], [3, -3], [-4, -3], [7, 0], [-5, -1], [8, 0], [-3, -4], [-3, -1], [-3, -4], [4, -4], [-2, 0], [4, -3], [2, -3], [-7, -1], [4, -8], [14, 0], [-12, 4], [3, 1], [2, 10], [-4, -8], [8, -3], [18, 2], [0, 2], [-2, -5], [8, 1], [-11, -4], [-6, 11], [16, 2], [1, 7], [10, -6], [-6, -11], [-14, -3], [-4, 12], [-5, -9], [-4, -14], [3, 10], [-2, -12], [21, 5], [-11, 5], [25, -3], [2, 8], [-2, 9], [-8, 8], [-14, 4], [-7, -15], [25, 2], [31, -1], [0, -1], [4, -18], [0, -17], [-4, 0], [-24, -3], [-8, -8], [10, -1], [2, -11], [4, 15], [-7, -8], [-9, -1], [-23, -2], [10, -14], [-13, 6], [-20, 10], [-11, 9], [1, 11], [4, -4], [19, 9], [12, 5], [-8, -20], [3, -22], [6, -21], [-12, 15], [-1, -9], [14, 4], [3, -21], [-10, -4], [15, -15], [-8, -16], [-14, 9], [15, 18], [-8, 0], [-16, 11], [13, 9], [12, 9], [-14, -10], [2, 2], [13, -5], [18, -13], [-6, 9], [1, 2], [-8, -8], [26, 5], [31, -1], [-16, 0], [-9, 21], [-16, -9], [19, -7], [6, -16], [1, -23], [34, 0], [1, -15], [-30, 3], [22, 0], [-14, -8], [0, -9], [18, 10], [-6, -2], [8, 15], [26, -17], [18, 5], [24, 4], [14, 14], [-8, 12], [-29, 10], [-26, -3], [-30, -5], [-2, -18], [19, 0], [14, 7], [10, -27], [1, 19], [-1, 24], [19, 11], [9, -13], [32, 16], [32, -11], [16, 24], [32, 0], [12, 24], [38, 10], [16, -7], [-16, 0], [2, 17], [-32, 6], [6, 15], [-26, -9], [-37, -4], [0, 15], [-21, 10], [-36, 6], [-28, 8], [8, -8], [24, -12], [1, -30], [-15, -3], [-18, 1], [35, -7], [-35, 3], [-12, -19], [-17, 10], [-12, 19], [-24, -8], [-12, 11], [-16, 28], [-20, 7], [12, 24], [-12, 25], [8, -16], [-12, -32], [2, -8], [21, 16], [-2, -29], [-30, -10], [-1, -10], [3, 39], [-5, 8], [-26, 8], [17, 16], [36, 18], [11, 16], [-5, -1], [9, -34], [46, -5], [-7, 11], [-28, -5], [-13, 8], [16, 4], [-6, 4], [6, 29], [-18, 26], [-23, -16], [20, 13], [20, 28], [12, -27], [-22, 4], [-2, -16], [28, 17], [7, -18], [-9, 8], [2, 12], [-4, -8], [-60, -3], [-8, 26], [-17, 11], [5, 10], [0, -17], [-21, -11], [-6, -17], [-27, -9], [-30, -25], [20, -7], [10, 41], [32, -12], [-4, 9], [2, 13], [11, -23], [14, -6], [-16, -4], [0, 29], [12, -30], [-9, -29], [19, -10], [0, 16], [15, -27], [2, -8], [-40, 7], [2, -32], [30, -24], [28, -26], [16, 12], [-44, -14], [2, -14], [6, -39], [16, -4], [16, 28], [4, -21], [-4, -29], [8, 21], [-26, -16], [-14, 24], [42, 13], [42, 2], [-20, 29], [66, -2], [-7, -29], [32, -13], [-15, 38], [20, -21], [-5, -17], [22, -32], [-36, 4], [-48, 0], [-6, -35], [-15, 0], [-51, -11], [6, 8], [-38, 19], [-10, -42], [-12, 15], [-46, -6], [42, 4], [-78, 0], [24, 20], [-20, 33], [-19, 6], [16, 16], [17, 26], [14, 25], [-17, -26], [11, 42], [-3, -31], [-25, -10], [1, -14], [31, 7], [-18, 1], [16, 35], [-4, -12], [-52, -6], [-36, -12], [22, 40], [-33, -32], [35, 15], [-56, -1], [8, -17], [-8, 44], [35, -22], [-20, 4], [-21, -23], [3, -6], [-32, 22], [5, 7], [-4, -48], [-40, -2], [14, 0], [44, -20], [-24, -14], [46, -20], [32, 4], [53, -15], [44, 9], [-27, -35], [30, 23], [-24, -8], [13, -36], [18, 10], [-32, 28], [6, 0], [-53, 20], [-50, 6], [-27, -20], [15, -1], [12, -1], [18, 10], [-51, 8], [48, 1], [16, -6], [5, 45], [30, 40], [-4, -30], [31, -5], [34, -33], [-42, -21], [54, 14], [-52, 2], [-6, -8], [40, -28], [-28, -17], [60, -12], [15, -9], [2, 3], [-24, 0], [-27, -26], [6, -24], [-27, 34], [61, -1], [15, 17], [-7, -9], [12, 12], [8, -8], [51, 0], [-22, 28], [61, 1], [58, -4], [-18, -52], [-26, -27], [8, 20], [-33, 18], [52, 0], [-16, 10], [1, -11], [64, 5], [-24, -15], [-28, -5], [17, 10], [-1, -42], [27, 17], [-16, 5], [43, 6], [22, 19], [49, 19], [-14, -12], [-51, -3], [64, -4], [-28, -2], [8, 4], [-24, 37], [10, -11], [-9, -4], [12, -31], [44, -8], [-1, -14], [-64, -20], [60, 25], [41, 7], [-11, -26], [65, 5], [0, -36], [19, -45], [8, -4], [58, -19], [55, 12], [2, 1], [-34, 24], [64, 0], [-8, -48], [-36, -24], [-40, 21], [4, -20], [-34, -31], [-36, -32], [60, -8], [14, -42], [-13, -14], [48, -4], [-30, -7], [30, -38], [-7, 11], [-20, 38], [11, 1], [31, -8], [12, -36], [80, 6], [5, 40], [-16, -1], [-16, 0], [-11, -38], [-10, 49], [-81, 15], [-24, 27], [-22, 4], [-2, 10], [64, 6], [-2, -9], [-4, 44], [-8, -39], [-41, 27], [-29, 46], [-10, -43], [-13, 47], [47, 9], [-27, -24], [-6, 10], [15, -60], [13, 6], [3, 59], [-17, 19], [82, 3], [-2, 41], [-14, 5], [20, 1], [40, -31], [18, 42], [30, 8], [34, -1], [-19, 3], [26, -6], [15, -36], [-56, -8], [55, 6], [-74, 1], [-20, 50], [-48, 8], [-37, -23], [24, -28], [-44, -40], [-33, 11], [30, -29], [-40, 12], [38, 47], [-46, -18], [6, 37], [19, -20], [29, 39], [-52, 0], [-18, -25], [19, 6], [1, -58], [18, -48], [-2, 24], [-31, -13], [71, 0], [94, 8], [36, -26], [10, -33], [28, -12], [2, 40], [2, -18], [-22, 24], [6, -6], [-5, 49], [-20, -25], [0, -4], [-42, 29], [-18, -18], [-24, 27], [-9, -2]];
    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_di();".
// 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_di(: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_di();".
// 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_di( : 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![1, -6, 1]>,<17,R![-31, -2, 1]>,<19,R![14, -8, 1]>,<23,R![7, -6, 1]>,<31,R![-9, -6, 1]>],Snew);
    return Vf;
end function;