
// Make newform 450.4.f.d in Magma, downloaded from the LMFDB on 14 March 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_450_f();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_450_f_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_450_4_f_d();".
// 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_450_4_f_d();".
// 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, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 1, 0, -1, 0, 0], [0, 1, 0, -1, 0, -1, 0, 0], [0, 5, 0, 0, 0, 5, 0, 0], [0, 0, 0, -5, 0, 0, 0, 10], [-5, 0, 10, 0, 10, 0, -5, 0], [5, 0, 10, 0, -10, 0, -5, 0]];
    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_450_f();"
function MakeCharacter_450_f()
    N := 450;
    order := 4;
    char_gens := [101, 127];
    v := [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_450_f_Hecke();"
function MakeCharacter_450_f_Hecke( : Kf := false)
    N := 450;
    order := 4;
    char_gens := [101, 127];
    char_values := [[-1, 0, 0, 0, 0, 0, 0, 0], [0, 1, 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 := 4;
    raw_aps := [[0, 0, -1, -1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [-6, -6, 0, 0, 1, 0, 0, 0], [0, 0, 0, -3, 0, 0, 0, 0], [-24, 24, 0, 0, 0, -3, 0, 0], [0, 0, -6, -6, 0, 0, 0, -3], [0, -37, 0, 0, -6, -6, 0, 0], [0, 0, 24, -24, 0, 0, 9, 0], [0, 0, 111, 0, 0, 0, -6, -6], [19, 0, 0, 0, -18, 18, 0, 0], [84, 84, 0, 0, 14, 0, 0, 0], [0, 0, 0, -42, 0, 0, 18, -18], [-270, 270, 0, 0, 0, -11, 0, 0], [0, 0, 90, 90, 0, 0, 0, -27], [0, 0, 246, -246, 0, 0, -12, 0], [0, 0, 33, 0, 0, 0, -6, -6], [125, 0, 0, 0, -60, 60, 0, 0], [102, 102, 0, 0, 39, 0, 0, 0], [0, 0, 0, -186, 0, 0, 42, -42], [-492, 492, 0, 0, 0, 58, 0, 0], [0, 298, 0, 0, -60, -60, 0, 0], [0, 0, 222, -222, 0, 0, -51, 0], [0, 0, -282, 0, 0, 0, -48, -48], [24, 24, 0, 0, -37, 0, 0, 0], [0, 0, 0, -894, 0, 0, -18, 18], [-336, 336, 0, 0, 0, 86, 0, 0], [0, 0, -90, -90, 0, 0, 0, -54], [0, 487, 0, 0, -36, -36, 0, 0], [0, 0, -108, 108, 0, 0, -114, 0], [-252, -252, 0, 0, 144, 0, 0, 0], [0, 0, 0, -600, 0, 0, -6, 6], [0, 0, -96, -96, 0, 0, 0, -57], [0, -946, 0, 0, 96, 96, 0, 0], [0, 0, -135, 0, 0, 0, 120, 120], [-593, 0, 0, 0, 114, -114, 0, 0], [252, 252, 0, 0, 133, 0, 0, 0], [1662, -1662, 0, 0, 0, -69, 0, 0], [0, 0, 546, 546, 0, 0, 0, -174], [0, 0, -1014, 1014, 0, 0, -15, 0], [0, 0, 2397, 0, 0, 0, -42, -42], [583, 0, 0, 0, 216, -216, 0, 0], [0, 0, 0, 141, 0, 0, -156, 156], [2292, -2292, 0, 0, 0, 199, 0, 0], [0, 0, -552, -552, 0, 0, 0, -105], [0, -2765, 0, 0, 126, 126, 0, 0], [2261, 0, 0, 0, 198, -198, 0, 0], [1278, -1278, 0, 0, 0, -403, 0, 0], [0, 0, -1722, -1722, 0, 0, 0, -96], [0, 611, 0, 0, 36, 36, 0, 0], [0, 0, 378, -378, 0, 0, -174, 0], [0, 0, 1332, 0, 0, 0, 210, 210], [-3643, 0, 0, 0, 288, -288, 0, 0], [0, 0, 0, -774, 0, 0, -192, 192], [0, 0, 2064, 2064, 0, 0, 0, 168], [0, 0, -918, 918, 0, 0, 270, 0], [0, 0, -4791, 0, 0, 0, -90, -90], [170, 0, 0, 0, -48, 48, 0, 0], [-792, -792, 0, 0, -817, 0, 0, 0], [0, 0, 0, 1701, 0, 0, 42, -42], [-1206, 1206, 0, 0, 0, 119, 0, 0], [0, 0, -672, 672, 0, 0, -327, 0], [2430, 2430, 0, 0, 151, 0, 0, 0], [0, 0, 0, 1311, 0, 0, 354, -354], [132, -132, 0, 0, 0, 399, 0, 0], [0, 0, -372, -372, 0, 0, 0, 546], [-6634, 0, 0, 0, -408, 408, 0, 0], [2868, 2868, 0, 0, -291, 0, 0, 0], [0, 0, 4626, 4626, 0, 0, 0, -45], [0, 5984, 0, 0, -120, -120, 0, 0], [0, 0, 3258, -3258, 0, 0, -507, 0], [0, 0, 2568, 0, 0, 0, -426, -426], [-174, -174, 0, 0, -705, 0, 0, 0], [-6000, 6000, 0, 0, 0, 377, 0, 0], [0, -8215, 0, 0, -306, -306, 0, 0], [0, 0, 3324, -3324, 0, 0, 594, 0], [0, 0, -4860, 0, 0, 0, -402, -402], [-216, -216, 0, 0, -169, 0, 0, 0], [0, 0, 0, 1476, 0, 0, 654, -654], [0, 1811, 0, 0, -468, -468, 0, 0], [0, 0, 2322, 0, 0, 0, 498, 498], [-4580, 0, 0, 0, -492, 492, 0, 0], [0, 0, 0, 9417, 0, 0, -216, 216], [-4716, 4716, 0, 0, 0, -115, 0, 0], [0, -233, 0, 0, -522, -522, 0, 0], [0, 0, 2784, -2784, 0, 0, 990, 0], [0, 0, 456, 0, 0, 0, -612, -612], [3240, 3240, 0, 0, -1296, 0, 0, 0], [0, 0, 0, -4308, 0, 0, -246, 246], [1812, -1812, 0, 0, 0, -1076, 0, 0], [0, 0, -3252, -3252, 0, 0, 0, -903], [0, 0, 9249, 0, 0, 0, -366, -366], [4854, 4854, 0, 0, 399, 0, 0, 0], [0, 0, 0, 1218, 0, 0, 600, -600], [0, -5057, 0, 0, -90, -90, 0, 0], [0, 0, -2874, 2874, 0, 0, 1248, 0], [0, 0, -927, 0, 0, 0, 912, 912], [0, 0, 0, 891, 0, 0, -690, 690], [1398, -1398, 0, 0, 0, -1225, 0, 0], [-613, 0, 0, 0, 264, -264, 0, 0], [-1056, -1056, 0, 0, 706, 0, 0, 0], [0, 0, -4248, -4248, 0, 0, 0, 807], [0, 0, -8424, 8424, 0, 0, 309, 0], [0, 0, -12513, 0, 0, 0, -186, -186], [-4537, 0, 0, 0, 1002, -1002, 0, 0], [-7968, -7968, 0, 0, -361, 0, 0, 0], [0, 0, 606, 606, 0, 0, 0, -912], [0, 0, -786, 786, 0, 0, -1716, 0], [0, 0, 3558, 0, 0, 0, 1248, 1248], [8083, 0, 0, 0, 1260, -1260, 0, 0], [1488, 1488, 0, 0, -544, 0, 0, 0], [15936, -15936, 0, 0, 0, 230, 0, 0], [0, 0, 9534, 9534, 0, 0, 0, 18], [0, 11467, 0, 0, 42, 42, 0, 0], [-10735, 0, 0, 0, 846, -846, 0, 0], [0, 0, 0, -1752, 0, 0, -504, 504], [10116, -10116, 0, 0, 0, 1080, 0, 0], [0, 0, -10596, -10596, 0, 0, 0, 186], [0, 0, -5496, 5496, 0, 0, -1515, 0], [0, 0, 10782, 0, 0, 0, -390, -390], [9532, 0, 0, 0, 1488, -1488, 0, 0], [5340, -5340, 0, 0, 0, 3082, 0, 0], [0, 0, -8730, -8730, 0, 0, 0, -447], [0, 0, 3612, -3612, 0, 0, -468, 0], [28240, 0, 0, 0, 324, -324, 0, 0], [0, 0, 0, -10875, 0, 0, -450, 450], [0, 1061, 0, 0, 12, 12, 0, 0], [0, 0, -219, 0, 0, 0, -1164, -1164], [-8082, -8082, 0, 0, 691, 0, 0, 0], [-12888, 12888, 0, 0, 0, 990, 0, 0], [0, -18358, 0, 0, 828, 828, 0, 0], [0, 0, 1620, -1620, 0, 0, 492, 0], [-9062, 0, 0, 0, -240, 240, 0, 0], [8220, 8220, 0, 0, 1243, 0, 0, 0], [0, 0, 0, -24546, 0, 0, 204, -204], [0, 23875, 0, 0, 36, 36, 0, 0], [0, 0, 5982, -5982, 0, 0, -336, 0], [12810, 12810, 0, 0, -125, 0, 0, 0], [0, 0, 7260, 7260, 0, 0, 0, -1134], [0, 0, 4044, 0, 0, 0, 6, 6], [16075, 0, 0, 0, -522, 522, 0, 0], [0, 0, 0, 4269, 0, 0, 384, -384], [-4026, 4026, 0, 0, 0, -1455, 0, 0], [0, 0, -4182, -4182, 0, 0, 0, -2976], [0, -19666, 0, 0, -984, -984, 0, 0], [0, 0, 357, 0, 0, 0, 48, 48], [11532, -11532, 0, 0, 0, 3165, 0, 0], [0, 0, -1572, -1572, 0, 0, 0, -396], [0, -16424, 0, 0, -492, -492, 0, 0], [0, 0, 3396, -3396, 0, 0, 1692, 0], [-7620, -7620, 0, 0, -1313, 0, 0, 0], [0, 0, 0, 5568, 0, 0, 456, -456], [-24522, 24522, 0, 0, 0, -865, 0, 0], [0, 0, 17274, 17274, 0, 0, 0, -1227], [11928, 11928, 0, 0, 2660, 0, 0, 0], [0, 0, 0, -4443, 0, 0, 1038, -1038], [0, 5525, 0, 0, -2358, -2358, 0, 0], [0, 0, 13917, 0, 0, 0, -990, -990], [20388, 20388, 0, 0, 199, 0, 0, 0], [0, 0, 0, 5661, 0, 0, 600, -600], [0, 0, -16692, -16692, 0, 0, 0, -321], [0, 0, 5616, -5616, 0, 0, -90, 0], [8040, 8040, 0, 0, -3136, 0, 0, 0], [0, 0, 0, -18831, 0, 0, 726, -726], [0, 0, -6912, -6912, 0, 0, 0, 1575], [0, 0, 11148, -11148, 0, 0, 696, 0], [-27037, 0, 0, 0, -510, 510, 0, 0], [-33264, -33264, 0, 0, -450, 0, 0, 0]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_450_f_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_450_4_f_d();".
// 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_450_4_f_d(:prec:=8)
    chi := MakeCharacter_450_f();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 4));
    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_450_4_f_d();".
// 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_450_4_f_d( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_450_f();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<7,R![9, -72, 288, 24, 1]>],Snew);
    return Vf;
end function;