
// Make newform 990.3.b.b in Magma, downloaded from the LMFDB on 25 June 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_990_b();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_990_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_990_3_b_b();".
// 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_990_3_b_b();".
// 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 := [25, 0, -30, 0, 19, 0, -4, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0, 0, 0, 0, 0], [15, 0, -4, 0, 2, 0, 0, 0], [0, 20, 0, -37, 0, 7, 0, -3], [0, 120, 0, -57, 0, 17, 0, -3], [0, -10, 0, 17, 0, -3, 0, 1], [-75, 65, 85, -24, -15, 4, 5, -1], [75, 65, -85, -24, 15, 4, -5, -1], [20, 0, -24, 0, 6, 0, -2, 0]];
    Rf_basisdens := [1, 5, 25, 25, 5, 25, 25, 5];
    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_990_b();"
function MakeCharacter_990_b()
    N := 990;
    order := 2;
    char_gens := [551, 397, 541];
    v := [2, 2, 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;

// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_990_b_Hecke();"
function MakeCharacter_990_b_Hecke( : Kf := false)
    N := 990;
    order := 2;
    char_gens := [551, 397, 541];
    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, -1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 2, 0, 0, -2, 2, -1], [0, 0, 0, -1, 0, 0, -3, 1], [0, 0, -5, 0, 4, 0, 0, 1], [0, 0, 7, 0, 2, 0, 0, 3], [0, 0, 0, 0, -4, 1, -1, -4], [17, 7, 0, -5, 0, 4, 4, 0], [0, 0, -4, 0, -6, -2, 2, 2], [-8, -12, 0, 2, 0, 1, 1, 0], [-6, 4, 0, -4, 0, 0, 0, 0], [0, 0, 23, 0, 5, -8, 8, 4], [0, 0, -2, 0, -4, -8, 8, 5], [-19, 11, 0, -17, 0, 2, 2, 0], [-44, 6, 0, 4, 0, 4, 4, 0], [-10, -14, 0, -10, 0, -4, -4, 0], [0, 0, 3, 0, -3, -10, 10, 16], [3, -3, 0, -15, 0, 10, 10, 0], [32, -28, 0, -4, 0, 2, 2, 0], [0, 0, -15, 0, 0, -24, 24, -5], [0, 0, 26, 0, 18, -9, 9, -8], [0, 0, -42, 0, -24, -2, 2, 5], [46, 22, 0, -8, 0, 18, 18, 0], [-4, -10, 0, 8, 0, 20, 20, 0], [0, 0, 34, 0, -10, 2, -2, 8], [-7, -25, 0, -9, 0, -10, -10, 0], [0, 0, -54, 0, 16, -12, 12, -17], [0, 0, 7, 0, -5, 14, -14, -2], [52, 6, 0, 0, 0, 8, 8, 0], [0, 0, 66, 0, 0, -20, 20, 5], [0, 0, -22, 0, 26, -8, 8, 22], [-102, 12, 0, -4, 0, 0, 0, 0], [0, 0, -102, 0, 22, 8, -8, 20], [0, 0, 31, 0, -1, -2, 2, -46], [0, 0, 20, 0, 0, 16, -16, 14], [-40, -18, 0, -28, 0, 4, 4, 0], [9, -17, 0, -41, 0, 0, 0, 0], [0, 0, 46, 0, 0, 30, -30, 35], [0, 0, 47, 0, 22, 28, -28, 15], [-94, 46, 0, -40, 0, 3, 3, 0], [-38, -10, 0, 16, 0, 26, 26, 0], [0, 60, 0, 34, 0, -15, -15, 0], [0, 0, 131, 0, 24, 20, -20, -19], [0, 0, -11, 0, 18, 12, -12, -47], [-82, 86, 0, 26, 0, 24, 24, 0], [0, 0, -54, 0, 2, 16, -16, 46], [73, -49, 0, -21, 0, 18, 18, 0], [0, 0, -30, 0, -52, 18, -18, -1], [242, 8, 0, -24, 0, -4, -4, 0], [0, 0, 85, 0, 34, -36, 36, 5], [0, 0, 118, 0, -50, -13, 13, 8], [0, 0, -71, 0, 55, -4, 4, 16], [228, -20, 0, 36, 0, 18, 18, 0], [-8, 42, 0, -88, 0, -8, -8, 0], [0, 0, 98, 0, -20, -4, 4, -67], [0, 12, 0, -24, 0, 10, 10, 0], [0, 0, 136, 0, -36, 56, -56, 30], [0, 0, -71, 0, -36, 56, -56, -1], [0, 0, -83, 0, 71, 52, -52, 68], [0, 0, -82, 0, -8, 14, -14, 5], [0, 0, -91, 0, -34, 28, -28, -35], [0, 0, 62, 0, 28, -16, 16, -11], [-188, 56, 0, 0, 0, -42, -42, 0], [-178, -104, 0, 100, 0, -44, -44, 0], [198, -48, 0, -16, 0, -36, -36, 0], [212, -4, 0, -78, 0, 5, 5, 0], [0, 0, 27, 0, -80, 8, -8, 29], [0, 0, 18, 0, 0, 26, -26, -41], [0, 0, 114, 0, -20, -38, 38, -78], [68, 118, 0, -12, 0, -56, -56, 0], [0, 0, 206, 0, -58, -11, 11, -20], [89, 143, 0, -5, 0, -10, -10, 0], [0, 0, -183, 0, 26, 0, 0, 41], [-86, 22, 0, -86, 0, 36, 36, 0], [-355, 3, 0, -69, 0, -16, -16, 0], [40, -132, 0, 24, 0, 46, 46, 0], [-290, -84, 0, 28, 0, -36, -36, 0], [-26, -78, 0, -48, 0, 6, 6, 0], [0, 0, 151, 0, -45, 52, -52, -18], [118, -22, 0, -96, 0, -71, -71, 0], [132, 114, 0, 72, 0, -36, -36, 0], [0, 0, 174, 0, 58, -103, 103, 30], [320, -18, 0, 12, 0, 56, 56, 0], [0, 0, 328, 0, 56, 64, -64, -56], [193, 87, 0, -41, 0, 14, 14, 0], [-216, 2, 0, 72, 0, -24, -24, 0], [0, 0, -55, 0, 86, 24, -24, -71], [0, 0, 248, 0, -4, -78, 78, -60], [89, 103, 0, 79, 0, -2, -2, 0], [163, -35, 0, -15, 0, 92, 92, 0], [0, 0, -2, 0, 166, 55, -55, -4], [265, -49, 0, 59, 0, -58, -58, 0], [0, 0, 96, 0, -8, 51, -51, 82], [-366, -130, 0, 14, 0, 6, 6, 0], [0, 0, -174, 0, -100, -32, 32, 23], [54, -8, 0, 120, 0, 0, 0, 0], [-206, -10, 0, 152, 0, 34, 34, 0], [0, 0, 134, 0, -52, -38, 38, 53], [0, 0, 128, 0, 12, -38, 38, -84], [0, 0, -142, 0, -44, 24, -24, -11], [0, 0, 13, 0, -52, -108, 108, -129], [0, 0, 166, 0, 64, 114, -114, 11], [0, 0, 187, 0, -81, 40, -40, -74], [0, 0, -84, 0, -116, -67, 67, 26], [-96, -246, 0, -76, 0, -20, -20, 0], [109, -69, 0, -33, 0, -8, -8, 0], [0, 0, 247, 0, -54, -88, 88, -93], [-178, -106, 0, 92, 0, 53, 53, 0], [0, 0, 19, 0, -63, -140, 140, -12], [0, 0, -258, 0, 156, -96, 96, -131], [0, 0, -205, 0, 22, 64, -64, -109], [98, 12, 0, 28, 0, -112, -112, 0], [-50, 10, 0, -136, 0, 69, 69, 0], [-56, 12, 0, -120, 0, 108, 108, 0], [204, -50, 0, 184, 0, 20, 20, 0], [345, 55, 0, 175, 0, -14, -14, 0], [119, 49, 0, -71, 0, 32, 32, 0], [-136, 114, 0, 252, 0, 52, 52, 0], [0, 0, -414, 0, -82, 56, -56, -40], [16, 200, 0, -8, 0, 34, 34, 0], [0, 0, -247, 0, 34, -40, 40, 53], [0, 0, -195, 0, 104, -204, 204, -145], [-247, -121, 0, 191, 0, -26, -26, 0], [296, -248, 0, 160, 0, 2, 2, 0], [0, 0, 41, 0, 111, -162, 162, -56], [70, -386, 0, 56, 0, 66, 66, 0], [-118, -70, 0, -92, 0, 7, 7, 0], [225, 327, 0, -121, 0, 82, 82, 0], [0, 0, 577, 0, 56, 28, -28, -113], [0, 0, 222, 0, 170, 28, -28, -16], [0, 0, 246, 0, 172, 134, -134, 45], [260, -200, 0, 60, 0, -4, -4, 0], [246, 24, 0, 60, 0, 0, 0, 0], [0, 0, -46, 0, -78, 28, -28, -44], [0, 0, 436, 0, -6, 32, -32, 18], [-160, -246, 0, -80, 0, -12, -12, 0], [0, 0, -178, 0, 148, 60, -60, -67], [18, 288, 0, -56, 0, -96, -96, 0], [0, 0, -156, 0, 154, -88, 88, -102], [0, 0, -408, 0, -184, -95, 95, 122], [0, 0, -127, 0, -289, 78, -78, 32], [331, -211, 0, -295, 0, -2, -2, 0], [0, 0, -330, 0, -84, 10, -10, 13], [-120, 318, 0, 48, 0, 40, 40, 0], [-518, -158, 0, -142, 0, 50, 50, 0], [0, 0, -13, 0, 62, -12, 12, -21], [0, 0, 5, 0, 20, 160, -160, 55], [-126, 382, 0, -20, 0, 45, 45, 0], [369, -41, 0, -109, 0, 52, 52, 0], [0, 0, 613, 0, -142, -24, 24, -79], [-60, 108, 0, -328, 0, 70, 70, 0], [-631, 31, 0, -37, 0, -92, -92, 0], [0, 0, -86, 0, -112, 56, -56, -235], [-715, -13, 0, -277, 0, -14, -14, 0], [764, 320, 0, 2, 0, -73, -73, 0], [0, 0, -364, 0, 84, 52, -52, 24], [-320, 220, 0, -32, 0, 26, 26, 0], [0, 0, -183, 0, 104, -28, 28, -17], [0, 0, 422, 0, 294, 86, -86, 4], [-207, 223, 0, -181, 0, 32, 32, 0], [0, 0, 169, 0, -164, -96, 96, 31], [0, 0, -142, 0, -324, 60, -60, -121], [-72, -88, 0, 294, 0, 125, 125, 0], [-26, -36, 0, 288, 0, 4, 4, 0], [107, -355, 0, -183, 0, -62, -62, 0], [-20, 24, 0, -158, 0, -9, -9, 0], [0, 0, -507, 0, 8, -132, 132, -53]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_990_b_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_990_3_b_b();".
// 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_990_3_b_b(:prec:=8)
    chi := MakeCharacter_990_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_990_3_b_b();".
// 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_990_3_b_b( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_990_b();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,3,sign)));
    Vf := Kernel([<7,R![11182336, 0, 1107328, 0, 31024, 0, 312, 0, 1]>,<23,R![-1209164, 71192, 108, -68, 1]>],Snew);
    return Vf;
end function;