
// Make newform 15.4.e.a in Magma, downloaded from the LMFDB on 02 September 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_15_e();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_15_e_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_15_4_e_a();".
// 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_15_4_e_a();".
// 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 := [1600, 0, 0, 0, 209, 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, 1, 0, 0, 0, 0, 0, 0], [0, 0, -249, 0, 0, 0, -1, 0], [0, 0, 0, 249, 0, 0, 0, 1], [-4520, -3620, -1561, 0, -40, -20, -9, 0], [4520, -3620, -1561, 0, 40, -20, -9, 0], [0, -7240, 0, -2557, 0, -40, 0, -13], [0, 7240, 0, -2557, 0, 40, 0, -13]];
    Rf_basisdens := [1, 1, 680, 680, 1360, 1360, 2720, 2720];
    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_15_e();"
function MakeCharacter_15_e()
    N := 15;
    order := 4;
    char_gens := [11, 7];
    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_15_e_Hecke();"
function MakeCharacter_15_e_Hecke( : Kf := false)
    N := 15;
    order := 4;
    char_gens := [11, 7];
    char_values := [[-1, 0, 0, 0, 0, 0, 0, 0], [0, 0, -1, 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, 0, -1, 0, 0, 0, 0], [-1, 0, -1, 0, 0, 1, 0, 0], [0, -2, 0, 1, 0, 0, -2, 1], [-1, 0, 1, 0, 4, 0, -2, 2], [0, -7, 0, -7, 0, 0, 2, 0], [8, 0, 8, 0, 0, 2, -1, 1], [0, 0, 0, 20, 0, 0, 7, 7], [0, 0, -12, 0, -6, -6, 6, -6], [0, 14, 0, 0, 0, 0, 9, -9], [0, -3, 0, 3, 0, 0, 0, 22], [62, 0, 0, 0, -30, 30, 0, 0], [-146, 0, 146, 0, -6, 0, 3, -3], [0, 32, 0, 32, 0, 0, -52, 0], [78, 0, 78, 0, 0, -38, 19, -19], [0, 0, 0, 2, 0, 0, 21, 21], [0, -130, 0, 0, 0, 0, 1, -1], [0, 39, 0, -39, 0, 0, 0, -136], [2, 0, 0, 0, 0, 0, 0, 0], [84, 0, -84, 0, 134, 0, -67, 67], [0, 116, 0, 116, 0, 0, 74, 0], [-317, 0, -317, 0, 0, 12, -6, 6], [0, 0, 298, 0, -56, -56, 56, -56], [0, 86, 0, 0, 0, 0, -7, 7], [0, 276, 0, -276, 0, 0, 0, 126], [179, 0, -179, 0, -236, 0, 118, -118], [0, -265, 0, -265, 0, 0, -160, 0], [-847, 0, -847, 0, 0, -28, 14, -14], [0, 0, 0, 446, 0, 0, -11, -11], [0, 0, 258, 0, 294, 294, -294, 294], [0, 152, 0, 0, 0, 0, -15, 15], [-191, 0, 191, 0, -96, 0, 48, -48], [0, 149, 0, 149, 0, 0, 386, 0], [0, 0, 0, -412, 0, 0, 3, 3], [0, 0, 1328, 0, -226, -226, 226, -226], [0, -585, 0, 585, 0, 0, 0, 290], [512, 0, 0, 0, 420, -420, 0, 0], [-1536, 0, 1536, 0, -106, 0, 53, -53], [-1172, 0, -1172, 0, 0, 582, -291, 291], [0, 0, 0, -310, 0, 0, 437, 437], [0, -136, 0, 0, 0, 0, -331, 331], [0, 387, 0, -387, 0, 0, 0, -288], [1202, 0, 0, 0, -180, 180, 0, 0], [0, -448, 0, -448, 0, 0, -22, 0], [-127, 0, -127, 0, 0, -808, 404, -404], [0, 0, 0, 542, 0, 0, -389, -389], [0, 0, 888, 0, -126, -126, 126, -126], [1232, 0, 0, 0, -240, 240, 0, 0], [1743, 0, 1743, 0, 0, 352, -176, 176], [0, 0, 0, -1036, 0, 0, -435, -435], [0, 0, 878, 0, 494, 494, -494, 494], [0, 536, 0, 0, 0, 0, 433, -433], [0, -174, 0, 174, 0, 0, 0, -424], [-2428, 0, 0, 0, -690, 690, 0, 0], [0, -445, 0, -445, 0, 0, -430, 0], [0, 0, 0, 356, 0, 0, -1, -1], [0, 482, 0, 0, 0, 0, -775, 775], [0, 363, 0, -363, 0, 0, 0, -462], [-1408, 0, 0, 0, 300, -300, 0, 0], [1634, 0, -1634, 0, -1046, 0, 523, -523], [0, -166, 0, -166, 0, 0, -724, 0], [-3172, 0, -3172, 0, 0, -298, 149, -149], [0, 458, 0, 0, 0, 0, 837, -837], [2554, 0, -2554, 0, 234, 0, -117, 117], [0, 1388, 0, 1388, 0, 0, -118, 0], [3873, 0, 3873, 0, 0, 712, -356, 356], [0, 0, 0, -40, 0, 0, 507, 507], [-8848, 0, 0, 0, 120, -120, 0, 0], [-201, 0, 201, 0, 764, 0, -382, 382], [0, 0, 0, 1292, 0, 0, -1099, -1099], [0, 0, -5942, 0, 514, 514, -514, 514], [0, -2380, 0, 0, 0, 0, 581, -581], [0, -1536, 0, 1536, 0, 0, 0, 2064], [6389, 0, -6389, 0, 64, 0, -32, 32], [-1612, 0, -1612, 0, 0, 1682, -841, 841], [0, 0, 2328, 0, 774, 774, -774, 774], [0, -2374, 0, 0, 0, 0, -747, 747], [0, 1881, 0, -1881, 0, 0, 0, 1306], [-5066, 0, 5066, 0, -1206, 0, 603, -603], [0, 770, 0, 770, 0, 0, 680, 0], [0, 0, 2528, 0, -1156, -1156, 1156, -1156], [0, 2103, 0, -2103, 0, 0, 0, -472], [1862, 0, 0, 0, 1740, -1740, 0, 0], [0, -1966, 0, -1966, 0, 0, 1826, 0], [5023, 0, 5023, 0, 0, 132, -66, 66], [0, 0, -8432, 0, 34, 34, -34, 34], [0, 2348, 0, 0, 0, 0, 137, -137], [0, -720, 0, 720, 0, 0, 0, -2670], [-2071, 0, 2071, 0, 1384, 0, -692, 692], [0, 1853, 0, 1853, 0, 0, 2192, 0], [-67, 0, -67, 0, 0, 452, -226, 226], [0, 0, 0, -2890, 0, 0, -323, -323], [0, 2142, 0, -2142, 0, 0, 0, -8], [-2711, 0, 2711, 0, -1296, 0, 648, -648], [0, 2117, 0, 2117, 0, 0, -1462, 0], [0, 0, 788, 0, 1634, 1634, -1634, 1634], [0, -2050, 0, 0, 0, 0, 901, -901], [0, -2031, 0, 2031, 0, 0, 0, 1094], [0, -2434, 0, -2434, 0, 0, -3976, 0], [2008, 0, 2008, 0, 0, -1338, 669, -669], [5942, 0, 0, 0, 1320, -1320, 0, 0], [4334, 0, -4334, 0, -2606, 0, 1303, -1303], [0, 0, 0, -1114, 0, 0, -1661, -1661], [0, 152, 0, 0, 0, 0, 1965, -1965], [0, -1332, 0, 1332, 0, 0, 0, -1382], [-8128, 0, 0, 0, 480, -480, 0, 0], [-1811, 0, 1811, 0, 3984, 0, -1992, 1992], [0, 0, 0, 1238, 0, 0, -1167, -1167], [0, 6488, 0, 0, 0, 0, 517, -517], [0, -3240, 0, 3240, 0, 0, 0, 2960], [1862, 0, 0, 0, -2760, 2760, 0, 0], [10299, 0, -10299, 0, -796, 0, 398, -398], [-1502, 0, -1502, 0, 0, 2862, -1431, 1431], [0, 0, 0, -1960, 0, 0, 2447, 2447], [0, 0, 8848, 0, -1946, -1946, 1946, -1946], [-19438, 0, 0, 0, -1290, 1290, 0, 0], [0, -3208, 0, -3208, 0, 0, 788, 0], [-5032, 0, -5032, 0, 0, -1978, 989, -989], [0, 0, 0, 6542, 0, 0, 1681, 1681], [0, -5440, 0, 0, 0, 0, -3819, 3819], [0, -681, 0, 681, 0, 0, 0, -3056], [10922, 0, 0, 0, 1680, -1680, 0, 0], [-2787, 0, -2787, 0, 0, -6968, 3484, -3484], [0, 0, 0, -1276, 0, 0, 2175, 2175], [0, 86, 0, 0, 0, 0, -2627, 2627], [-8188, 0, 0, 0, 1380, -1380, 0, 0], [0, -5335, 0, -5335, 0, 0, -940, 0], [0, 0, 19438, 0, 1414, 1414, -1414, 1414], [0, -192, 0, 192, 0, 0, 0, 3408], [4109, 0, -4109, 0, 4504, 0, -2252, 2252], [4478, 0, 4478, 0, 0, 3902, -1951, 1951], [0, 0, -9552, 0, 4014, 4014, -4014, 4014], [0, -322, 0, 0, 0, 0, -963, 963], [6722, 0, 0, 0, 750, -750, 0, 0], [-14726, 0, 14726, 0, -1446, 0, 723, -723], [0, 3458, 0, 3458, 0, 0, -3088, 0], [0, 0, -17482, 0, -1246, -1246, 1246, -1246], [0, -4036, 0, 0, 0, 0, 2329, -2329], [-3036, 0, 3036, 0, -5746, 0, 2873, -2873], [0, 0, 0, -508, 0, 0, -2989, -2989], [0, 6954, 0, -6954, 0, 0, 0, 1254], [24932, 0, 0, 0, -60, 60, 0, 0], [0, 1181, 0, 1181, 0, 0, 5084, 0], [7943, 0, 7943, 0, 0, -2248, 1124, -1124], [0, 0, 0, 7604, 0, 0, 4585, 4585], [0, 0, 3018, 0, 2934, 2934, -2934, 2934], [0, 996, 0, -996, 0, 0, 0, -5504], [-17682, 0, -17682, 0, 0, 5782, -2891, 2891], [0, 0, 0, 2276, 0, 0, 2739, 2739], [0, 0, 3608, 0, -2026, -2026, 2026, -2026], [0, -5098, 0, 0, 0, 0, -2075, 2075], [-3876, 0, 3876, 0, 5294, 0, -2647, 2647], [0, 8474, 0, 8474, 0, 0, -2164, 0], [5908, 0, 5908, 0, 0, 6822, -3411, 3411], [0, 0, 0, -6082, 0, 0, -5167, -5167], [-9946, 0, 9946, 0, 4234, 0, -2117, 2117], [0, -7042, 0, -7042, 0, 0, 2762, 0], [0, 0, -18222, 0, -3936, -3936, 3936, -3936], [0, -3228, 0, 3228, 0, 0, 0, 322], [-15821, 0, 15821, 0, -5556, 0, 2778, -2778], [0, -673, 0, -673, 0, 0, 1328, 0], [0, 0, 0, -4828, 0, 0, -579, -579], [0, 4340, 0, 0, 0, 0, 1921, -1921], [21459, 0, -21459, 0, 2684, 0, -1342, 1342], [0, -3979, 0, -3979, 0, 0, 1994, 0], [0, 0, 0, 9704, 0, 0, 3395, 3395], [0, 6086, 0, 0, 0, 0, -1507, 1507], [1352, 0, 0, 0, 3180, -3180, 0, 0], [-10816, 0, 10816, 0, -10106, 0, 5053, -5053]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_15_e_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_15_4_e_a();".
// 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_15_4_e_a(:prec:=8)
    chi := MakeCharacter_15_e();
    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_15_4_e_a();".
// 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_15_4_e_a( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_15_e();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([],Snew);
    return Vf;
end function;