
// Make newform 6762.2.a.bv in Magma, downloaded from the LMFDB on 25 August 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_6762_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_6762_2_a_bv();".
// 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_6762_2_a_bv();".
// 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_6762_a();"
function MakeCharacter_6762_a()
    N := 6762;
    order := 1;
    char_gens := [2255, 3727, 3823];
    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_6762_a_Hecke( : Kf := Kf)
    return MakeCharacter_6762_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], [-1, 1], [0, 0], [2, 0], [1, -2], [1, -3], [-2, 4], [1, 0], [-4, 2], [-2, 0], [-6, 2], [-8, -2], [-6, -4], [9, 0], [-3, -5], [-4, 4], [-2, 0], [5, 7], [-7, -2], [-5, -4], [-10, 0], [10, 2], [4, -2], [-4, -4], [6, -2], [1, -7], [0, 4], [12, 2], [-1, -9], [2, 2], [5, 10], [-9, -1], [-2, -8], [5, -3], [0, 10], [-10, 4], [-4, -4], [5, -14], [4, 8], [-5, 12], [2, 8], [-8, -2], [3, 6], [-10, 2], [-22, 4], [-14, -2], [-4, 6], [6, 12], [-12, -10], [-8, 0], [16, 4], [-10, 2], [6, -8], [14, 6], [8, -8], [-12, 0], [-2, 20], [-3, -20], [-15, -1], [-11, 13], [-5, -1], [0, 10], [-5, 8], [16, -12], [-10, 16], [-26, 6], [0, 0], [-27, 4], [-11, 10], [-12, -10], [10, -12], [-3, -21], [-6, -4], [-9, 7], [-2, -4], [-12, 18], [-3, 4], [-3, 21], [-7, 14], [16, 6], [4, 8], [-16, 8], [-14, 0], [14, -12], [-3, -10], [18, 6], [0, 0], [14, 0], [-12, 16], [16, -4], [20, 10], [4, -26], [-17, 4], [4, -2], [38, 4], [30, -10], [27, -1], [-7, -5], [27, -10], [-6, -20], [-4, -14], [20, -18], [9, 1], [-11, -7], [2, -24], [-13, 10], [-18, 10], [-9, 2], [14, -20], [22, 10], [2, -14], [-29, -5], [37, -5], [-31, -11], [-29, 13], [18, -8], [-16, -4], [2, -24], [2, 18], [-8, 18], [-18, -8], [-33, 9], [-31, -10], [2, 10], [27, 13], [-24, -10], [9, -4], [-42, 0], [0, 6], [0, 32], [-10, -18], [-2, -28], [12, -12], [-16, 4], [22, -8], [-5, -3], [-13, 17], [-13, 19], [-10, 10], [-10, -22], [26, 20], [6, 14], [-20, 16], [19, 2], [8, -12], [-2, 36], [22, 16], [-24, 8], [37, -4], [-29, -8], [-19, -9], [-16, 20], [24, -12], [33, -7], [0, -6], [-11, 9], [-28, -16], [-4, -6], [40, 6], [-23, -8], [-8, -14], [-8, 2], [8, -4], [-11, -25], [26, 18], [-14, -24], [-2, 16], [-18, 30], [-32, 12], [-14, -20], [-25, -8], [-20, 18], [-12, 12], [-22, -4], [16, -14], [28, 18], [10, -6], [21, -27], [12, -34], [8, 18], [-4, -32], [5, 12], [-38, 14], [-8, -20], [3, -5], [7, -8], [10, 4], [35, -12], [31, 20], [18, 0], [-12, 12], [7, 33], [-12, -4], [16, -14], [-3, -15], [4, 14], [50, -12], [-9, -31], [-3, 18], [39, 15], [0, 38], [-7, -16], [-4, 6], [-2, 42], [34, -2], [23, 13], [9, 24], [26, -22], [-42, -4], [-9, 16], [20, -6], [6, 32], [10, 30], [-32, 0], [12, 14], [24, -26], [6, 2], [12, 34], [0, 26], [13, -14], [-65, 5], [-26, 12], [29, 19], [-44, -12], [63, -2], [12, 38], [19, -8], [11, 27], [1, -14], [23, -2], [-23, -27], [-14, 16], [2, -34], [13, -21], [-40, 10], [-60, 4], [60, -6], [9, 2], [16, 0], [22, -16], [24, -10], [30, -12], [-17, -22], [-18, -10], [24, 20], [-10, 42], [28, 4], [22, -12], [4, 28], [42, -10], [7, -15], [20, 28], [-28, 4], [46, -14], [28, 12], [66, 6], [-6, 20], [-28, -10], [-2, 12], [-51, 19], [-66, 6], [-19, 36], [78, -2], [18, -10], [62, 8], [33, 15], [-12, -30], [1, -15], [2, -12], [-9, -48], [2, -24], [20, 8], [-9, -19], [-57, 8], [16, 14], [39, -12], [-11, 16], [32, -20], [-6, 26], [-45, -4], [57, 3], [42, 10], [-8, -6], [46, 10], [24, 0], [28, -8], [1, 47], [-22, 6], [4, -6], [12, 46], [40, 18], [-16, -14], [34, 16], [9, -6], [-31, 13], [-41, -15], [-20, -28], [57, -18], [-42, -10], [-20, -24], [-47, -5], [63, -11], [0, -40], [-5, 3], [22, -28], [-35, -30], [4, 4], [18, -20], [-6, 32], [-12, 0], [-47, -1], [3, 7], [-40, 6], [-2, 24], [-30, 8], [-4, -12], [-40, -32], [56, 16], [54, 0], [-33, 11], [40, 18], [38, -22], [-48, -18], [27, -19], [14, 0], [-6, 8], [-26, -24], [-24, -18], [36, -34], [57, 20], [32, 2], [18, -30], [5, 30], [17, -29], [-1, 24], [28, -40], [0, -46], [43, 2], [58, -20], [-13, 22], [-25, 17], [-38, 16], [26, 16], [-28, -34], [7, 10], [69, 2], [-70, -16], [-60, 10], [36, 2], [2, 44], [-7, 62], [-4, -10], [-11, 15], [18, 14], [-6, 16], [42, 14], [2, -8], [32, -30], [-17, -20], [-46, -34], [-26, 38], [16, 28], [46, 18], [-16, 14], [33, 24], [56, -18], [-14, 4], [18, -6], [4, -36], [12, 0], [29, -50], [4, -6], [-35, -39], [-49, -20], [-44, -4], [8, 6], [78, 12], [19, -45], [-66, -20], [-16, -38], [41, 31], [62, -18], [-6, -38], [59, -25], [-21, -38], [22, 2], [50, -8], [17, 37], [2, 20], [46, 12], [18, 44], [-5, -24], [-50, 8], [-42, 16], [32, -10], [-37, 3], [-35, -25], [11, 17], [-42, 20], [-15, -28], [46, 10], [-46, -8], [-49, 25], [-24, 50], [0, -42], [-46, -22], [-54, -32], [-43, -5], [-56, -32], [41, 42], [-40, -16], [-42, -10], [-23, 25], [42, -22], [88, -10], [1, -20], [-46, 24], [21, 51], [20, -16], [-8, 2], [50, 0], [-12, -44], [19, 48], [-27, -44], [-76, -2], [-54, -20], [-26, 36], [42, 8], [-8, -24]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_6762_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_6762_2_a_bv();".
// 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_6762_2_a_bv(:prec:=2)
    chi := MakeCharacter_6762_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_6762_2_a_bv();".
// 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_6762_2_a_bv( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_6762_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<5,R![-1, 2, 1]>,<11,R![-2, 1]>,<13,R![-7, -2, 1]>,<17,R![-17, -2, 1]>],Snew);
    return Vf;
end function;