
// Make newform 768.3.b.e in Magma, downloaded from the LMFDB on 26 May 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_768_b();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_768_b_Hecke();"
// To make the coeffs of the qexp of the newform in the Hecke field type "qexpCoeffs();"
// To make the newform (type ModFrm), type "MakeNewformModFrm_768_3_b_e();".
// 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_768_3_b_e();".
// 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 := [1, 0, 0, 0, -1, 0, 0, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, -2, 0, -2, 0, 0], [0, 0, 2, 0, 0, 0, -1, 0], [-2, 0, 0, 0, 4, 0, 0, 0], [0, 0, 0, 0, 0, 0, 2, 0], [0, -2, 0, 2, 0, -2, 0, -4], [0, 4, 0, 4, 0, -4, 0, 0], [0, 4, 0, 4, 0, 4, 0, -8]];
    Rf_basisdens := [1, 1, 1, 1, 1, 1, 1, 1];
    Rf_basisnums := ChangeUniverse([[z : z in elt] : elt in Rf_num], Kf);
    Rfbasis := [Rf_basisnums[i]/Rf_basisdens[i] : i in [1..Degree(Kf)]];
    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_768_b();"
function MakeCharacter_768_b()
    N := 768;
    order := 2;
    char_gens := [511, 517, 257];
    v := [1, 1, 2];
    // 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;

// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_768_b_Hecke();"
function MakeCharacter_768_b_Hecke( : Kf := false)
    N := 768;
    order := 2;
    char_gens := [511, 517, 257];
    char_values := [[-1, 0, 0, 0, 0, 0, 0, 0], [-1, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0]];
    assert UnitGenerators(DirichletGroup(N)) eq char_gens;
    values := ConvertToHeckeField(char_values : pass_field := ISA(Type(Kf), Fld), Kf := Kf); // the value of chi on the gens as elements in the Hecke field
    F := Universe(values);// the Hecke field
    chi := DirichletCharacterFromValuesOnUnitGenerators(DirichletGroup(N,F),values);
    return chi;
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 := 3;
    raw_aps := [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, -1, 0, 0, 0, 0, 0], [0, -1, 0, -1, 1, 0, 0, 0], [0, 2, 0, 0, 1, -1, 0, 0], [-4, 0, 0, 0, 0, 0, 0, 1], [0, 2, 0, -2, 3, 2, 0, 0], [2, 0, 4, 0, 0, 0, 1, -2], [-12, 0, 4, 0, 0, 0, -2, -1], [0, -4, 0, 0, 2, -2, 0, 0], [0, -5, 0, -5, -5, 4, 0, 0], [0, -2, 0, 4, 3, 5, 0, 0], [0, -4, 0, -8, 1, -6, 0, 0], [-10, 0, 20, 0, 0, 0, 5, 2], [-28, 0, 12, 0, 0, 0, 2, 3], [0, 4, 0, -4, -6, 6, 0, 0], [0, 5, 0, -11, -11, -4, 0, 0], [64, 0, -12, 0, 0, 0, -4, 0], [0, 16, 0, -12, -17, -2, 0, 0], [0, 0, 4, 0, 0, 0, -12, 0], [0, -4, 0, -12, -30, -2, 0, 0], [2, 0, 32, 0, 0, 0, -12, -2], [0, -18, 0, -4, -5, -11, 0, 0], [68, 0, 0, 0, 0, 0, -4, 7], [30, 0, 24, 0, 0, 0, -2, -4], [50, 0, -8, 0, 0, 0, 22, 0], [0, 25, 0, -15, 33, 4, 0, 0], [0, 22, 0, -32, 27, 13, 0, 0], [56, 0, 20, 0, 0, 0, 0, -6], [0, 22, 0, -14, 35, -6, 0, 0], [42, 0, -8, 0, 0, 0, -10, 8], [0, -38, 0, 4, 41, -1, 0, 0], [64, 0, 12, 0, 0, 0, 24, 0], [22, 0, -20, 0, 0, 0, 3, -2], [0, 0, -44, 0, 0, 0, 12, -8], [0, 15, 0, 15, -39, 16, 0, 0], [0, -6, 0, 32, 61, 11, 0, 0], [0, -4, 0, 16, -21, 6, 0, 0], [-68, 0, -36, 0, 0, 0, -10, 13], [0, -24, 0, -64, -8, 8, 0, 0], [0, -11, 0, 29, -37, -8, 0, 0], [128, 0, 20, 0, 0, 0, -20, 0], [0, 34, 0, 22, 17, -26, 0, 0], [0, 32, 0, 36, -56, 8, 0, 0], [-18, 0, -96, 0, 0, 0, 20, -2], [0, -47, 0, 33, 37, -12, 0, 0], [0, -2, 0, -56, -1, -23, 0, 0], [-48, 0, -28, 0, 0, 0, 4, -12], [0, 26, 0, 36, 17, -17, 0, 0], [76, 0, -8, 0, 0, 0, -12, -11], [0, -2, 0, 34, -47, -18, 0, 0], [38, 0, -104, 0, 0, 0, -10, -8], [0, -40, 0, -60, -36, 36, 0, 0], [70, 0, -24, 0, 0, 0, -18, -26], [156, 0, 16, 0, 0, 0, 32, 9], [-62, 0, -80, 0, 0, 0, -12, -8], [0, 24, 0, -52, -136, -24, 0, 0], [0, 31, 0, 23, -49, 44, 0, 0], [0, 42, 0, -4, -47, 47, 0, 0], [0, 2, 0, 22, 105, -10, 0, 0], [118, 0, -48, 0, 0, 0, 4, 12], [16, 0, 12, 0, 0, 0, -40, 4], [0, 53, 0, 21, 109, -4, 0, 0], [0, 0, 84, 0, 0, 0, 4, 0], [0, -112, 0, 44, -68, -28, 0, 0], [-142, 0, -32, 0, 0, 0, 28, 2], [0, 19, 0, 27, 111, 4, 0, 0], [-152, 0, -44, 0, 0, 0, -48, 6], [-114, 0, -32, 0, 0, 0, -4, -6], [108, 0, -120, 0, 0, 0, 20, -3], [0, -88, 0, -4, 15, -2, 0, 0], [74, 0, 8, 0, 0, 0, -14, 16], [0, 108, 0, -76, -6, 22, 0, 0], [0, 94, 0, -28, 123, -3, 0, 0], [0, 24, 0, 20, 53, 82, 0, 0], [140, 0, 36, 0, 0, 0, -38, -7], [0, 32, 0, -28, 56, -56, 0, 0], [0, -45, 0, -5, 149, 8, 0, 0], [0, 0, 0, 52, -77, -18, 0, 0], [-46, 0, 140, 0, 0, 0, -45, 10], [14, 0, 88, 0, 0, 0, 46, -16], [220, 0, -248, 0, 0, 0, 4, 17], [0, -6, 0, -98, -103, 6, 0, 0], [0, -148, 0, -4, 30, 18, 0, 0], [66, 0, 48, 0, 0, 0, 4, 44], [0, -26, 0, 32, 91, -3, 0, 0], [-84, 0, 56, 0, 0, 0, -20, -51], [66, 0, 36, 0, 0, 0, 97, 14], [142, 0, -24, 0, 0, 0, 18, -32], [0, -3, 0, -139, -37, -8, 0, 0], [0, -62, 0, -20, -43, -77, 0, 0], [-388, 0, -72, 0, 0, 0, -44, -7], [0, 12, 0, 56, -2, 2, 0, 0], [0, -62, 0, -40, -31, 31, 0, 0], [-248, 0, 172, 0, 0, 0, -36, 6], [80, 0, 140, 0, 0, 0, 40, 20], [0, 76, 0, 36, -14, 94, 0, 0], [0, -185, 0, -25, 51, 44, 0, 0], [158, 0, 196, 0, 0, 0, -23, 22], [316, 0, -284, 0, 0, 0, 10, -11], [0, 62, 0, -134, -49, -38, 0, 0], [-236, 0, -276, 0, 0, 0, 10, -9], [0, 77, 0, 29, -25, 120, 0, 0], [-60, 0, 40, 0, 0, 0, 96, 15], [-58, 0, -76, 0, 0, 0, 93, -38], [312, 0, -36, 0, 0, 0, -12, 66], [-90, 0, 128, 0, 0, 0, -20, -50], [-200, 0, -196, 0, 0, 0, -36, 10], [-374, 0, 152, 0, 0, 0, 14, 24], [0, -60, 0, -40, -42, -134, 0, 0], [26, 0, 304, 0, 0, 0, -32, 26], [0, -38, 0, -4, -103, 63, 0, 0], [0, -200, 0, -28, -27, 82, 0, 0], [-154, 0, -16, 0, 0, 0, 100, 4], [240, 0, 188, 0, 0, 0, -24, 20], [0, 114, 0, -88, -191, -65, 0, 0], [106, 0, 68, 0, 0, 0, -39, -38], [340, 0, 332, 0, 0, 0, -70, 15], [0, 124, 0, 64, 170, -90, 0, 0], [0, -231, 0, -15, -45, -80, 0, 0], [-216, 0, -132, 0, 0, 0, -4, -18], [0, -140, 0, -160, 181, -134, 0, 0], [-270, 0, 160, 0, 0, 0, 48, 60], [0, 75, 0, 139, 225, -120, 0, 0], [116, 0, 256, 0, 0, 0, 76, -21], [-196, 0, 188, 0, 0, 0, -114, -51], [0, 171, 0, -77, 63, 68, 0, 0], [0, 86, 0, 138, -207, -50, 0, 0], [0, -124, 0, 8, 210, 46, 0, 0], [0, 154, 0, -32, -99, -101, 0, 0], [0, 162, 0, 78, -193, 18, 0, 0], [616, 0, -148, 0, 0, 0, -36, -26], [0, -240, 0, 112, 204, 116, 0, 0], [0, -50, 0, 140, -197, -11, 0, 0], [0, -162, 0, 162, 145, 30, 0, 0], [-258, 0, 92, 0, 0, 0, 79, 66], [-274, 0, -112, 0, 0, 0, -64, 22], [0, -11, 0, 29, 545, 60, 0, 0], [-116, 0, -92, 0, 0, 0, -22, -39], [0, -99, 0, 157, 31, -56, 0, 0], [-42, 0, -580, 0, 0, 0, -65, -10], [548, 0, 532, 0, 0, 0, -26, 27], [0, 173, 0, -91, -167, -4, 0, 0], [0, 234, 0, -128, -19, 99, 0, 0], [-696, 0, 20, 0, 0, 0, 32, 6], [0, -106, 0, 82, -69, -6, 0, 0], [0, -108, 0, 116, 174, 82, 0, 0], [0, -196, 0, 40, 101, 154, 0, 0], [550, 0, -540, 0, 0, 0, 81, 50], [140, 0, -20, 0, 0, 0, -130, 41], [0, -128, 0, -164, 216, -136, 0, 0], [0, 48, 0, 68, 335, -130, 0, 0], [-30, 0, 224, 0, 0, 0, 48, 32], [252, 0, 380, 0, 0, 0, -50, 53], [0, -248, 0, -212, 248, -88, 0, 0], [-548, 0, -500, 0, 0, 0, -82, 53], [0, 88, 0, 4, 412, -44, 0, 0], [0, -54, 0, -152, -227, 179, 0, 0], [-1230, 0, -84, 0, 0, 0, -13, 10], [-242, 0, -160, 0, 0, 0, 56, -48], [0, -131, 0, -123, -21, 88, 0, 0], [-224, 0, -12, 0, 0, 0, -20, 104], [-386, 0, 164, 0, 0, 0, -127, -74], [0, 62, 0, 104, 167, 73, 0, 0], [-380, 0, -320, 0, 0, 0, 180, -9], [-302, 0, -564, 0, 0, 0, -85, 42], [0, -200, 0, -132, -272, 112, 0, 0], [0, -34, 0, -92, -501, -43, 0, 0], [0, 40, 0, 68, -175, -110, 0, 0]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_768_b_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_768_3_b_e();".
// 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_768_3_b_e(:prec:=8)
    chi := MakeCharacter_768_b();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 3));
    S := BaseChange(S, Kf);
    maxprec := NextPrime(997) - 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_768_3_b_e();".
// 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_768_3_b_e( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_768_b();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,3,sign)));
    Vf := Kernel([<5,R![16384, 0, 12288, 0, 2048, 0, 96, 0, 1]>,<11,R![-80, 8, 1]>],Snew);
    return Vf;
end function;