
// Make newform 1350.5.d.b in Magma, downloaded from the LMFDB on 13 October 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_1350_d();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_1350_d_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_1350_5_d_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_1350_5_d_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 := [9, 0, -4, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0], [0, -2, 0, 2], [-30, 0, 15, 0], [0, 70, 0, -10]];
    Rf_basisdens := [1, 3, 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_1350_d();"
function MakeCharacter_1350_d()
    N := 1350;
    order := 2;
    char_gens := [1001, 1027];
    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_1350_d_Hecke();"
function MakeCharacter_1350_d_Hecke( : Kf := false)
    N := 1350;
    order := 2;
    char_gens := [1001, 1027];
    char_values := [[-1, 0, 0, 0], [1, 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 := 5;
    raw_aps := [[0, 1, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [-20, 0, 0, 0], [0, -27, -1, 0], [43, 0, 0, 1], [0, -3, -9, 0], [56, 0, 0, 2], [0, 24, -11, 0], [0, 276, 17, 0], [845, 0, 0, 7], [-50, 0, 0, -20], [0, -264, -2, 0], [283, 0, 0, -26], [0, 354, -7, 0], [0, -216, -58, 0], [0, 312, -18, 0], [-202, 0, 0, 34], [-302, 0, 0, 0], [0, -114, 88, 0], [-2804, 0, 0, -2], [-1177, 0, 0, 83], [0, -1554, 142, 0], [0, 762, 128, 0], [-2942, 0, 0, -74], [0, -2382, -39, 0], [-6146, 0, 0, 16], [0, 2922, -360, 0], [-6742, 0, 0, -22], [0, -3903, -279, 0], [-7994, 0, 0, 162], [0, -783, 469, 0], [0, 156, 54, 0], [-9352, 0, 0, -268], [0, -8928, 215, 0], [9959, 0, 0, 61], [9061, 0, 0, 301], [-18599, 0, 0, 212], [0, 1512, -742, 0], [0, -13488, -520, 0], [0, 3348, -58, 0], [-4252, 0, 0, -290], [0, -21126, -88, 0], [-21368, 0, 0, 464], [0, 4434, 1420, 0], [-49843, 0, 0, -169], [-30814, 0, 0, -376], [-23456, 0, 0, -646], [0, -5826, 16, 0], [65582, 0, 0, 88], [0, -7404, 2578, 0], [0, 2100, 1372, 0], [-30661, 0, 0, 670], [0, -24909, -1585, 0], [0, 12945, -441, 0], [0, -31320, -158, 0], [0, -2976, -2875, 0], [-6646, 0, 0, 428], [-51626, 0, 0, -484], [0, -26988, -354, 0], [19774, 0, 0, -244], [0, -53682, 116, 0], [-119117, 0, 0, -300], [0, -10686, 2526, 0], [64618, 0, 0, 362], [0, 5952, 122, 0], [-103444, 0, 0, -382], [97750, 0, 0, -856], [0, 54372, 2, 0], [87356, 0, 0, 92], [0, -38553, 3105, 0], [0, 23658, 2226, 0], [-55268, 0, 0, 870], [-84587, 0, 0, -1553], [87692, 0, 0, 796], [0, -40800, -4169, 0], [0, -21942, -4389, 0], [-57443, 0, 0, 1595], [0, -28470, -2978, 0], [158255, 0, 0, -1250], [0, -4023, 2035, 0], [-27790, 0, 0, -2068], [0, -52812, -270, 0], [97786, 0, 0, -38], [13526, 0, 0, -3240], [0, -43692, 1978, 0], [0, 101256, -2520, 0], [-101186, 0, 0, 2376], [0, 28164, -8062, 0], [-74186, 0, 0, 1936], [0, 11940, -6190, 0], [0, -70218, 3162, 0], [-196784, 0, 0, -1688], [0, 19896, 10706, 0], [230990, 0, 0, 1296], [0, 81498, -3391, 0], [0, -56802, -4055, 0], [0, -61932, 5798, 0], [11179, 0, 0, 512], [-363388, 0, 0, 810], [-362477, 0, 0, 1306], [0, 27978, 10334, 0], [0, -61980, -10604, 0], [0, -79824, 8356, 0], [-74098, 0, 0, 1788], [-347444, 0, 0, -3124], [0, -44886, -8570, 0], [0, 149577, 2521, 0], [0, -47022, 11616, 0], [-276511, 0, 0, -1612], [126406, 0, 0, -56], [-283775, 0, 0, -2051], [0, -130419, -131, 0], [-407110, 0, 0, -554], [-334210, 0, 0, 364], [0, 158928, 7116, 0], [-338459, 0, 0, -3432], [0, -150444, -10310, 0], [0, 143358, -38, 0], [0, -182004, -5786, 0], [23858, 0, 0, 4250], [-226118, 0, 0, -1628], [0, 47184, 7676, 0], [0, 276522, -426, 0], [125720, 0, 0, 2646], [0, 21066, -16677, 0], [-1054, 0, 0, 3254], [0, 226428, -7858, 0], [-252890, 0, 0, -4158], [-145994, 0, 0, 5016], [-202552, 0, 0, 4854], [0, -21516, 4121, 0], [-477343, 0, 0, -1807], [-304793, 0, 0, 1835], [0, 205662, 2570, 0], [-592711, 0, 0, -3460], [0, 333270, 6472, 0], [-239645, 0, 0, 5360], [0, -90630, 17580, 0], [0, 289914, 1634, 0], [182048, 0, 0, -2690], [0, 87084, 12638, 0], [-646112, 0, 0, 2800], [0, 133122, 6840, 0], [338720, 0, 0, -3856], [0, 9882, -19748, 0], [481537, 0, 0, -3783], [0, -25344, -23594, 0], [-176950, 0, 0, -9982], [0, 480978, -461, 0], [-96047, 0, 0, 7389], [0, -27216, 16098, 0], [47914, 0, 0, 7132], [0, 64278, 10199, 0], [482605, 0, 0, -6074], [0, 38244, -24538, 0], [269885, 0, 0, -6987], [0, -312732, 12882, 0], [72220, 0, 0, 1944], [0, 125478, -29561, 0], [0, -282582, 25042, 0], [0, 349737, -20193, 0], [-621872, 0, 0, -1538], [0, 78015, 19923, 0], [0, -38793, 459, 0], [0, -200100, 8789, 0], [-81595, 0, 0, -3539], [-397097, 0, 0, 2583], [743993, 0, 0, 3568], [0, -168606, 19778, 0], [0, -470121, -19859, 0], [-584734, 0, 0, 3438], [0, 66594, -8774, 0], [988000, 0, 0, -108], [-711457, 0, 0, 8885], [0, -297528, -24916, 0], [933914, 0, 0, -6482], [0, -54192, -26498, 0], [-812996, 0, 0, -12698], [1050656, 0, 0, 9236], [553300, 0, 0, 8780], [0, -182628, -35658, 0], [1350877, 0, 0, -7611], [0, -87453, -23351, 0], [0, 13332, 29826, 0], [0, -108432, 15690, 0], [1428001, 0, 0, -9021], [426949, 0, 0, -7126], [1031846, 0, 0, 8132], [0, -660618, 10852, 0], [43666, 0, 0, 7774], [0, -33816, 49088, 0], [582980, 0, 0, 15876], [0, 43596, 64723, 0], [0, 84792, 19144, 0], [0, -129108, -45814, 0], [-50626, 0, 0, 14660], [2425579, 0, 0, 1741], [0, 138036, -57590, 0], [0, -98100, -8914, 0], [0, -215862, -14863, 0], [1149302, 0, 0, 13280], [607258, 0, 0, -2936], [326162, 0, 0, -16012], [0, 512553, -5807, 0], [0, 310398, -22968, 0], [-1063285, 0, 0, 16283], [0, -356070, -40768, 0], [0, -143700, 74456, 0], [-246160, 0, 0, 13168], [864868, 0, 0, 5252], [0, -393228, 18969, 0], [-496430, 0, 0, 26292], [0, 318012, 16546, 0], [0, -492750, 37998, 0], [475877, 0, 0, -27472], [1239280, 0, 0, 14494], [0, -225384, 71614, 0], [0, 699348, 36827, 0], [0, -896304, 14532, 0], [-205384, 0, 0, -25252], [-2599051, 0, 0, -1881], [0, 354210, 65780, 0], [-631244, 0, 0, 25482], [0, 91932, -24888, 0], [97034, 0, 0, -34414], [0, -226953, -98653, 0], [0, 293346, -77214, 0], [-110216, 0, 0, 5102], [0, -80613, -54501, 0], [-1538666, 0, 0, -6972], [-1786552, 0, 0, -14640], [178985, 0, 0, 9401], [0, -317898, -6164, 0], [2559238, 0, 0, 13348], [0, 391584, -554, 0], [-592975, 0, 0, -8830], [0, -606738, 67640, 0], [0, -216756, -55366, 0], [0, 346482, -20788, 0], [0, -518598, 66352, 0], [2070074, 0, 0, -11676], [-2742464, 0, 0, 3806], [714332, 0, 0, 1890], [0, -284184, -234, 0], [0, -220590, -54578, 0], [1527190, 0, 0, -15176], [0, -999129, 37445, 0], [-2618434, 0, 0, 15106], [0, -735738, -20289, 0], [739597, 0, 0, 11979], [0, -775698, -8026, 0], [0, -47352, 5930, 0], [542870, 0, 0, 44832], [0, -462798, 114, 0], [0, -970935, 59115, 0], [969056, 0, 0, 5284], [523945, 0, 0, 7902], [0, -262620, 28078, 0], [2836312, 0, 0, 648], [292132, 0, 0, -20480], [0, 162180, 75794, 0], [-446032, 0, 0, 20732], [1495471, 0, 0, 8973], [0, -247773, -61565, 0], [-2691172, 0, 0, 20064], [0, -906768, -91282, 0], [0, -1166598, -27302, 0], [-3861437, 0, 0, -14220], [0, 506394, 96268, 0], [924290, 0, 0, 15822], [-3289685, 0, 0, 7144], [1767304, 0, 0, -26988], [-1205185, 0, 0, -39711], [3660436, 0, 0, -12772], [-2608244, 0, 0, -22360], [0, -513288, -77044, 0], [2279684, 0, 0, -3128], [-1900255, 0, 0, -21158], [0, 173289, -10515, 0], [0, -206304, -26853, 0], [904847, 0, 0, 13005], [0, 311550, 117627, 0], [304820, 0, 0, 58740], [3429625, 0, 0, 26754], [0, 47364, -33458, 0], [-469520, 0, 0, -33854], [0, 374652, 104574, 0], [-3454999, 0, 0, 27965], [0, -1414404, -63722, 0], [0, 1028058, -72957, 0], [0, -404082, -57824, 0], [0, 1035039, -40217, 0], [0, -580584, -28110, 0], [5350150, 0, 0, -5232], [0, 889128, -144350, 0], [1599218, 0, 0, 4496], [0, 1523796, 89182, 0], [0, -260445, -943, 0], [-1759970, 0, 0, -50648], [1862668, 0, 0, 26500], [0, -61320, 139978, 0], [-3482785, 0, 0, 14483]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_1350_d_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_1350_5_d_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_1350_5_d_b(:prec:=4)
    chi := MakeCharacter_1350_d();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 5));
    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_1350_5_d_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_1350_5_d_b( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_1350_d();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,5,sign)));
    Vf := Kernel([<7,R![20, 1]>],Snew);
    return Vf;
end function;