
// Make newform 6762.2.a.bp 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_bp();".
// 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_bp();".
// 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], [0, 1], [0, 0], [2, 0], [0, 0], [4, 0], [4, -1], [1, 0], [2, 4], [4, 3], [2, 0], [0, -3], [4, 4], [4, -5], [2, -8], [4, -4], [0, -3], [-4, 4], [-10, 4], [0, 7], [-8, -4], [4, 5], [12, -2], [12, 2], [-8, 6], [0, -2], [2, 0], [-8, 0], [10, 4], [-6, 4], [-12, 4], [6, 4], [-4, 6], [0, 0], [-14, -4], [0, -5], [0, -12], [4, 3], [0, -2], [12, -8], [8, -7], [16, -8], [-4, -8], [-6, 8], [0, -2], [16, 8], [12, -1], [-4, 5], [-8, -13], [10, -8], [-2, 12], [-12, 0], [4, -5], [16, 11], [12, 12], [0, 10], [12, 9], [-14, -12], [-10, -4], [4, 1], [8, 9], [20, 6], [-4, -11], [-12, 4], [-10, -12], [-4, 4], [-14, 0], [16, -12], [-16, 2], [16, -5], [-4, -12], [16, 2], [-8, 0], [-6, 8], [8, -8], [8, -8], [0, -12], [-6, -8], [-8, 9], [4, 3], [22, 0], [20, -8], [20, 2], [12, 9], [16, 8], [0, 0], [6, -12], [8, -2], [0, -8], [20, 9], [8, 18], [8, 8], [4, -24], [0, -8], [8, -12], [-8, -6], [4, 2], [12, -19], [6, 4], [-8, 12], [-4, 0], [36, -3], [10, -8], [12, -4], [16, -19], [-20, -14], [0, 5], [16, 8], [0, 13], [28, -5], [16, 0], [-18, 8], [12, -9], [-4, 12], [22, 16], [36, -9], [-12, -3], [2, 32], [20, -4], [-16, 23], [-22, 0], [8, 27], [8, 24], [12, -10], [30, 0], [-2, 16], [20, 9], [8, 26], [0, -13], [-28, 4], [0, 4], [-28, -4], [8, -32], [32, 13], [12, -4], [-8, 15], [28, -5], [0, -7], [-4, -16], [-20, 12], [6, 4], [-30, -12], [22, 16], [24, -4], [0, -4], [-24, -12], [40, -7], [12, -26], [-34, 12], [-18, 12], [4, -24], [8, 0], [-20, -3], [-22, -16], [-20, 20], [0, 36], [-32, -11], [-44, 4], [-16, -5], [4, -20], [-22, 0], [-8, 16], [20, 11], [-6, -28], [-16, 4], [14, 4], [8, 0], [34, -4], [8, 36], [50, -8], [-8, 18], [0, -8], [26, 20], [-4, 7], [-12, -22], [-8, -8], [14, 0], [16, -12], [-40, -1], [2, -12], [28, 5], [6, -32], [-48, 11], [4, -16], [-48, 11], [34, -20], [36, -19], [-10, 8], [28, -19], [-8, -27], [16, -16], [30, 8], [0, 0], [4, -4], [12, 18], [50, -8], [-12, 0], [-12, -32], [-12, -9], [-42, 16], [-12, -7], [32, -20], [-28, -12], [-12, -21], [-16, 8], [-48, -12], [-16, 4], [2, -16], [-20, -26], [4, 32], [-32, -26], [0, -12], [44, -19], [-28, 1], [-52, -4], [-24, 0], [16, 3], [-12, -16], [-10, -24], [26, 16], [-32, 28], [-34, 0], [4, -8], [-4, -32], [-10, 4], [20, 10], [-2, 20], [-24, -22], [16, 12], [-18, -32], [-12, -1], [-36, 4], [-16, -40], [-20, 35], [-48, -2], [-36, 20], [14, 16], [-40, 16], [12, 7], [20, -12], [-52, -4], [-44, 5], [26, -24], [-24, 3], [44, -9], [4, 19], [12, -21], [-44, -20], [60, 0], [26, 8], [-36, 10], [8, -4], [44, -8], [-32, -14], [-8, 0], [32, -24], [36, -3], [-40, 20], [40, 3], [-16, 12], [-4, 36], [-8, 32], [-8, 9], [-24, 29], [20, 31], [4, 24], [12, 30], [52, -12], [-50, 8], [-40, 6], [-14, 8], [-12, -10], [32, 4], [8, -29], [20, -9], [-36, 12], [38, -12], [2, -44], [-28, 7], [-4, -31], [-24, 32], [16, 0], [-40, -17], [36, 22], [10, -28], [22, 32], [52, 8], [4, -47], [-24, 11], [-16, 32], [-4, 43], [12, 0], [28, -7], [-18, -8], [-24, -43], [48, 8], [-8, 28], [-4, 10], [-4, 32], [-36, -18], [0, -8], [20, -16], [8, -28], [12, -52], [-12, -16], [-8, 28], [-48, -21], [20, -24], [14, 48], [-44, 7], [44, -8], [2, 44], [40, 28], [-4, -28], [-36, -2], [20, 22], [10, 36], [-4, 6], [48, -16], [12, -11], [-18, 36], [-24, 22], [40, 16], [-18, 36], [20, 16], [-20, -20], [28, 34], [28, 4], [14, 24], [86, 4], [-2, 0], [4, -7], [-4, -4], [-60, 20], [60, -2], [-22, 32], [-12, -42], [-16, 21], [-8, -52], [-6, 36], [-54, -16], [-40, 0], [28, 40], [32, 0], [-44, -28], [16, -32], [-36, -28], [40, -12], [24, -3], [20, -4], [26, -32], [-6, -20], [-24, -36], [20, -32], [0, -39], [16, 24], [20, 13], [-44, 24], [16, -16], [30, -32], [-8, 23], [0, -24], [-12, -20], [28, 32], [-6, 32], [-72, 8], [0, -52], [26, -36], [20, -40], [-28, -38], [-40, -24], [-12, 40], [-16, 50], [54, -16], [-28, -6], [4, 0], [-44, 32], [4, 6], [32, 11], [16, -39], [-58, 12], [34, -4], [-74, 0], [28, 19], [52, 11], [-42, 4], [0, -36], [4, -28], [64, 16], [-70, -8], [-32, -44], [0, 64], [-36, 10], [12, -36], [30, 36], [-80, 0], [4, 10], [2, -56], [-54, -12], [-56, -26], [44, 0], [-40, -20], [-12, -22], [-8, -56], [4, -29], [36, 24], [-52, -8], [-4, -27], [76, 6], [40, 27], [-50, -24], [-28, -52], [-62, -16], [-42, 20], [48, 18], [-72, 0], [-44, -5], [52, 6], [-8, -36], [6, -40], [32, 11], [-32, 24], [44, -20], [8, -23], [48, 2], [62, 0], [-24, -24], [84, 6], [-68, -27]];
    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_bp();".
// 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_bp(: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_bp();".
// 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_bp( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_6762_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<5,R![-2, 0, 1]>,<11,R![-2, 1]>,<13,R![0, 1]>,<17,R![-4, 1]>],Snew);
    return Vf;
end function;