
// Make newform 6975.2.a.o in Magma, downloaded from the LMFDB on 17 December 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_6975_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_6975_2_a_o();".
// 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_6975_2_a_o();".
// 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_6975_a();"
function MakeCharacter_6975_a()
    N := 6975;
    order := 1;
    char_gens := [776, 5302, 1801];
    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_6975_a_Hecke( : Kf := Kf)
    return MakeCharacter_6975_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], [0], [-2], [2], [0], [-7], [-8], [-2], [3], [1], [8], [-12], [9], [13], [-6], [-8], [4], [-10], [15], [14], [-9], [4], [7], [-9], [2], [8], [-11], [-5], [18], [17], [7], [9], [-15], [0], [21], [-7], [-16], [4], [18], [14], [-24], [1], [-6], [11], [16], [-4], [-11], [7], [12], [18], [-14], [20], [14], [-18], [12], [9], [-7], [32], [30], [-2], [2], [-20], [-3], [-32], [18], [20], [22], [18], [-5], [10], [-16], [7], [17], [-8], [6], [22], [14], [-14], [-12], [5], [-15], [8], [-6], [-18], [-11], [-29], [4], [30], [17], [-23], [5], [23], [-24], [-17], [-27], [14], [-24], [13], [-29], [-4], [13], [-9], [-6], [4], [-29], [-30], [6], [-29], [-34], [32], [4], [4], [17], [-43], [-2], [1], [-28], [-8], [12], [-23], [10], [49], [-13], [6], [30], [42], [-14], [-42], [-11], [-23], [30], [-8], [22], [-21], [25], [45], [28], [-18], [33], [-28], [-6], [4], [18], [32], [21], [-29], [-12], [25], [38], [-57], [11], [-32], [3], [-12], [-32], [38], [-38], [18], [45], [12], [-6], [-24], [57], [18], [-56], [7], [6], [-38], [27], [12], [14], [56], [7], [10], [18], [-48], [-20], [46], [46], [34], [40], [-1], [-18], [-65], [31], [49], [-48], [10], [-31], [20], [-32], [-60], [30], [12], [-15], [-24], [-11], [12], [12], [-2], [-32], [-42], [-25], [63], [21], [-60], [12], [34], [-52], [-10], [3], [26], [36], [54], [-1], [12], [-54], [-4], [56], [-26], [14], [-4], [-28], [-60], [34], [-12], [24], [23], [-3], [6], [-56], [10], [-42], [-21], [12], [-1], [10], [24], [-20], [-45], [11], [64], [34], [11], [72], [-29], [-56], [49], [-24], [62], [-20], [18], [-33], [18], [63], [43], [77], [-72], [17], [-26], [4], [8], [26], [66], [48], [-12], [74], [-4], [-20], [15], [72], [6], [41], [-33], [-4], [-11], [10], [44], [10], [67], [-10], [24], [-7], [4], [-36], [42], [-69], [-70], [-31], [-52], [-67], [50], [40], [-16], [21], [79], [-6], [-66], [49], [15], [-45], [32], [36], [-31], [59], [-12], [75], [-30], [-49], [-6], [-11], [18], [37], [8], [0], [72], [-30], [38], [3], [25], [50], [14], [-24], [12], [48], [-82], [-46], [8], [-30], [67], [54], [28], [-30], [-70], [-28], [8], [4], [43], [-47], [-56], [3], [-39], [23], [76], [33], [-78], [-85], [66], [50], [-52], [24], [-90], [-67], [42], [47], [60], [68], [39], [51], [-26], [18], [-38], [-57], [10], [80], [84], [56], [70], [56], [14], [-21], [-96], [-10], [22], [-72], [-48], [70], [54], [-6], [3], [89], [61], [90], [-28], [-33], [18], [14], [11], [26], [-28], [-79], [13], [-2], [-63], [-74], [56], [-70], [4], [-5], [20], [-24], [-24], [32], [-1], [50], [73], [-11], [-68], [-16], [-58], [92], [-24], [-77], [73], [-48], [56], [-92], [-48], [8], [22], [-52], [-80], [29], [35], [98], [63], [73], [-11], [-10]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_6975_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_6975_2_a_o();".
// 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_6975_2_a_o(:prec:=1)
    chi := MakeCharacter_6975_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(2999) - 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_6975_2_a_o();".
// 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_6975_2_a_o( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_6975_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<2,R![-1, 1]>,<7,R![2, 1]>,<11,R![-2, 1]>,<13,R![0, 1]>,<17,R![7, 1]>,<29,R![-3, 1]>],Snew);
    return Vf;
end function;