
// Make newform 1150.4.b.b in Magma, downloaded from the LMFDB on 15 January 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_1150_b();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_1150_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_1150_4_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_1150_4_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 := [1, 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_1150_b();"
function MakeCharacter_1150_b()
    N := 1150;
    order := 2;
    char_gens := [277, 51];
    v := [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_1150_b_Hecke();"
function MakeCharacter_1150_b_Hecke( : Kf := false)
    N := 1150;
    order := 2;
    char_gens := [277, 51];
    char_values := [[-1, 0], [1, 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 := 4;
    raw_aps := [[0, 2], [0, 7], [0, 0], [0, -20], [6, 0], [0, 47], [0, 132], [-146, 0], [0, 23], [99, 0], [-253, 0], [0, 118], [495, 0], [0, 272], [0, -639], [0, -342], [-240, 0], [-370, 0], [0, -698], [-357, 0], [0, -259], [-542, 0], [0, -1248], [828, 0], [0, -992], [-1542, 0], [0, 32], [0, 834], [1192, 0], [0, -132], [0, -89], [-1797, 0], [0, 1836], [1027, 0], [-2310, 0], [-2149, 0], [0, -1832], [0, 1217], [0, -3048], [0, 774], [1875, 0], [-1606, 0], [2982, 0], [0, 1385], [0, -957], [358, 0], [-5380, 0], [0, 1040], [0, 3744], [-2804, 0], [0, -4869], [2877, 0], [1622, 0], [-4752, 0], [0, 5073], [0, 1314], [-5265, 0], [-2488, 0], [0, -5465], [8940, 0], [0, 842], [0, -4032], [0, 1096], [-4653, 0], [0, 3440], [0, -3066], [1505, 0], [0, 3268], [0, -4164], [2911, 0], [0, 9753], [-3858, 0], [0, -7856], [0, -34], [6064, 0], [0, 11868], [-8616, 0], [0, -3119], [7986, 0], [3475, 0], [-10992, 0], [2012, 0], [-9792, 0], [0, 5786], [-2549, 0], [0, 1311], [14610, 0], [0, -80], [-2343, 0], [0, -3400], [0, 1374], [-4536, 0], [0, 11455], [-10395, 0], [5497, 0], [0, 7158], [-12801, 0], [16788, 0], [0, 19040], [-13339, 0], [0, 22975], [0, 17964], [0, 12636], [10302, 0], [12380, 0], [0, -1913], [0, -16767], [0, -16722], [4200, 0], [-19915, 0], [0, -24044], [0, 3452], [0, 16374], [12760, 0], [29420, 0], [-13692, 0], [0, 27398], [0, 6417], [0, 14583], [9624, 0], [-24586, 0], [0, 14339], [0, -14658], [0, 16797], [8132, 0], [19668, 0], [-18200, 0], [11880, 0], [0, 2554], [0, 6308], [-9557, 0], [0, 19128], [-18448, 0], [0, 5602], [4005, 0], [-41726, 0], [0, 34116], [0, -1652], [0, -12486], [-5490, 0], [-14785, 0], [-12486, 0], [0, -39805], [0, -15024], [-14618, 0], [10152, 0], [0, -22306], [0, -1731], [12649, 0], [0, -16143], [0, -4094], [30396, 0], [0, -21148], [0, -5031], [0, 538], [3078, 0], [-20288, 0], [-28911, 0], [0, -14810], [-2544, 0], [0, 11145], [0, -4386], [0, -56381], [43782, 0], [0, -3714], [0, -4662], [51440, 0], [0, -686], [23302, 0], [0, -22761], [-846, 0], [-30967, 0], [-46992, 0], [0, -34984], [-13709, 0], [22176, 0], [-41227, 0], [33903, 0], [0, 48278], [51256, 0], [0, 56959], [-68532, 0], [0, 35633], [0, -4866], [0, -51894], [1932, 0], [0, -4742], [0, 50558], [75787, 0], [-62496, 0], [0, -56149], [0, 38964], [54050, 0], [-48990, 0], [0, -12330], [0, 17340], [-2446, 0], [0, 53192], [0, -43656], [0, 61737], [-66564, 0], [19712, 0], [0, 54043], [25510, 0], [-68532, 0], [0, -51141], [-17930, 0], [0, -9813], [-56103, 0], [-61831, 0], [0, -29363], [35859, 0], [0, -70912], [0, -1998], [-82680, 0], [-38248, 0], [0, -70739], [7581, 0], [0, 27894], [0, 31011], [-14677, 0], [-24482, 0], [16803, 0], [0, -25252], [0, 84357], [-52931, 0], [0, 55782], [-92937, 0], [0, 33586], [33828, 0], [0, -17782], [3484, 0], [16070, 0], [-36942, 0], [0, -66148], [0, 90288], [31624, 0], [0, 103806], [83541, 0], [106941, 0], [0, 92856], [-103957, 0], [0, -28213], [-101579, 0], [0, 88446], [-78219, 0], [0, -26687], [-47298, 0], [-20534, 0], [0, 39054], [0, 38860], [-70578, 0], [0, 82662], [78928, 0], [0, 52650], [-88845, 0], [51578, 0], [0, 54802], [0, 35271], [0, 115687], [0, -26620], [0, 58548], [19774, 0], [0, 85412], [0, -115278], [-16706, 0], [-93162, 0], [-85860, 0], [0, -27454], [0, 4533], [73193, 0], [0, 40774], [0, -77632], [-41012, 0], [0, 64711], [0, 32207], [0, -131556], [-40010, 0], [61298, 0], [27840, 0], [0, -49755], [78638, 0], [0, 81150], [4190, 0], [0, 22600], [68208, 0], [0, 95402], [0, 65178], [-27008, 0], [25122, 0], [-94326, 0], [0, -115164], [0, -30366], [17922, 0], [0, -122227], [102726, 0], [168500, 0], [0, 110103], [110127, 0], [0, -154757], [0, -160504], [0, -172002], [18700, 0]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_1150_b_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_1150_4_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_1150_4_b_b(:prec:=2)
    chi := MakeCharacter_1150_b();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 4));
    S := BaseChange(S, Kf);
    maxprec := NextPrime(1999) - 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_1150_4_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_1150_4_b_b( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_1150_b();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<3,R![49, 0, 1]>,<7,R![400, 0, 1]>],Snew);
    return Vf;
end function;