
// Make newform 315.5.e.e in Magma, downloaded from the LMFDB on 15 April 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_315_e();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_315_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_315_5_e_e();".
// 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_315_5_e_e();".
// 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 := [4177936, 0, 190880, 0, 7113, 0, 110, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0, 0, 0, 0, 0], [188720, 0, 12513, 0, 125, 0, 2, 0], [47852, 0, -4064, 0, -125, 0, -2, 0], [0, -1118204, 0, -141325, 0, -2166, 0, -25], [0, 6052420, 0, 141325, 0, 2166, 0, 25], [517664, 0, 22497, 0, 436, 0, 3, 0], [-13776560, 26249794, -913449, 330432, -9125, 783, -146, -113], [-13776560, 11977428, -913449, 782451, -9125, 16867, -146, 154]];
    Rf_basisdens := [1, 16898, 8449, 4934216, 4934216, 1988, 2467108, 2467108];
    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_315_e();"
function MakeCharacter_315_e()
    N := 315;
    order := 2;
    char_gens := [281, 127, 136];
    v := [2, 1, 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_315_e_Hecke();"
function MakeCharacter_315_e_Hecke( : Kf := false)
    N := 315;
    order := 2;
    char_gens := [281, 127, 136];
    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 := 5;
    raw_aps := [[0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, -1, 0, 0, 0, 0, 0, -1], [0, 0, 0, -5, 0, 0, 1, -1], [44, 0, 6, 0, 0, 0, 0, 0], [0, -3, 0, -28, 0, 0, 0, -6], [0, -2, 0, 100, 0, 0, 0, -4], [0, -17, 0, 0, 0, -2, 0, 0], [0, -5, 0, 5, 94, 0, -10, 0], [6, 0, 4, 0, 0, 0, 0, 0], [0, -20, 0, 0, 0, 8, 0, 0], [0, 10, 0, -10, 134, 0, 20, 0], [0, 36, 0, 0, 0, -2, 0, 0], [0, -25, 0, 25, 56, 0, -50, 0], [0, 3, 0, 209, 0, 0, 0, 6], [0, 6, 0, -6, -90, 0, 12, 0], [0, 61, 0, 0, 0, 26, 0, 0], [0, -35, 0, 0, 0, 36, 0, 0], [0, -5, 0, 5, -716, 0, -10, 0], [2344, 0, -184, 0, 0, 0, 0, 0], [0, 112, 0, -956, 0, 0, 0, 224], [-976, 0, -204, 0, 0, 0, 0, 0], [0, 6, 0, -109, 0, 0, 0, 12], [0, -258, 0, 0, 0, -60, 0, 0], [0, 138, 0, 2060, 0, 0, 0, 276], [0, -309, 0, 0, 0, 2, 0, 0], [0, -289, 0, -1089, 0, 0, 0, -578], [0, 19, 0, -19, -220, 0, 38, 0], [-1496, 0, -574, 0, 0, 0, 0, 0], [0, 10, 0, -10, 1294, 0, 20, 0], [0, 135, 0, -135, 2994, 0, 270, 0], [0, 831, 0, 0, 0, -26, 0, 0], [0, 124, 0, -124, 2100, 0, 248, 0], [0, -305, 0, 0, 0, -106, 0, 0], [-11704, 0, -906, 0, 0, 0, 0, 0], [25616, 0, 534, 0, 0, 0, 0, 0], [0, 477, 0, 2528, 0, 0, 0, 954], [0, 29, 0, -29, -4820, 0, 58, 0], [0, -225, 0, 10223, 0, 0, 0, -450], [0, 245, 0, 10704, 0, 0, 0, 490], [1372, 0, -3130, 0, 0, 0, 0, 0], [0, -1853, 0, 0, 0, -158, 0, 0], [25128, 0, 2620, 0, 0, 0, 0, 0], [0, -410, 0, 410, 4966, 0, -820, 0], [0, -430, 0, 430, -1814, 0, -860, 0], [0, -1426, 0, 0, 0, -172, 0, 0], [-7348, 0, -1770, 0, 0, 0, 0, 0], [0, 21, 0, 7175, 0, 0, 0, 42], [0, -1110, 0, -4219, 0, 0, 0, -2220], [0, -1081, 0, 0, 0, -54, 0, 0], [0, 320, 0, -320, -1316, 0, 640, 0], [48192, 0, -2090, 0, 0, 0, 0, 0], [0, 1610, 0, 0, 0, 34, 0, 0], [0, 1511, 0, 0, 0, -658, 0, 0], [0, -294, 0, -27016, 0, 0, 0, -588], [0, -645, 0, 645, -8636, 0, -1290, 0], [0, 3211, 0, 0, 0, 40, 0, 0], [0, 412, 0, 0, 0, -464, 0, 0], [0, 746, 0, -746, -7570, 0, 1492, 0], [-16576, 0, -3654, 0, 0, 0, 0, 0], [0, -132, 0, -14755, 0, 0, 0, -264], [0, 575, 0, 5040, 0, 0, 0, 1150], [0, 226, 0, -31901, 0, 0, 0, 452], [0, -1086, 0, 0, 0, -68, 0, 0], [0, -976, 0, 12960, 0, 0, 0, -1952], [0, 430, 0, -430, 1086, 0, 860, 0], [40316, 0, -6246, 0, 0, 0, 0, 0], [0, -114, 0, 114, -16510, 0, -228, 0], [0, 1275, 0, -1275, -14524, 0, 2550, 0], [0, -6393, 0, 0, 0, -166, 0, 0], [0, -2038, 0, -22464, 0, 0, 0, -4076], [51776, 0, 3594, 0, 0, 0, 0, 0], [0, -2349, 0, 34841, 0, 0, 0, -4698], [0, 1410, 0, -1410, -15634, 0, 2820, 0], [101644, 0, 5666, 0, 0, 0, 0, 0], [0, -1911, 0, -7897, 0, 0, 0, -3822], [-146824, 0, 10314, 0, 0, 0, 0, 0], [0, 3141, 0, 47252, 0, 0, 0, 6282], [50394, 0, -9494, 0, 0, 0, 0, 0], [0, 6820, 0, 0, 0, -814, 0, 0], [0, -2851, 0, 0, 0, 426, 0, 0], [-111304, 0, -1086, 0, 0, 0, 0, 0], [-102272, 0, -11890, 0, 0, 0, 0, 0], [0, 942, 0, -28684, 0, 0, 0, 1884], [0, -4506, 0, 0, 0, 932, 0, 0], [0, -1579, 0, 1579, 16580, 0, -3158, 0], [259616, 0, 4254, 0, 0, 0, 0, 0], [0, 1810, 0, -1810, 13254, 0, 3620, 0], [0, -7681, 0, 0, 0, 202, 0, 0], [0, 1899, 0, -1899, -26380, 0, 3798, 0], [0, 3022, 0, 8251, 0, 0, 0, 6044], [0, -560, 0, 0, 0, -1608, 0, 0], [0, -605, 0, 605, -32146, 0, -1210, 0], [25484, 0, 6066, 0, 0, 0, 0, 0], [133508, 0, -3510, 0, 0, 0, 0, 0], [0, -549, 0, -59713, 0, 0, 0, -1098], [0, 11035, 0, 0, 0, 914, 0, 0], [0, -574, 0, 0, 0, -3220, 0, 0], [0, -4130, 0, 14341, 0, 0, 0, -8260], [-31574, 0, -24496, 0, 0, 0, 0, 0], [0, 165, 0, -165, 19204, 0, 330, 0], [0, -1410, 0, 1410, 58266, 0, -2820, 0], [0, 4566, 0, 95525, 0, 0, 0, 9132], [222056, 0, -4056, 0, 0, 0, 0, 0], [217436, 0, -26946, 0, 0, 0, 0, 0], [0, 2662, 0, 73432, 0, 0, 0, 5324], [0, 8648, 0, -41829, 0, 0, 0, 17296], [0, -11718, 0, -8032, 0, 0, 0, -23436], [-236584, 0, 11184, 0, 0, 0, 0, 0], [0, 30112, 0, 0, 0, 534, 0, 0], [0, -10303, 0, -25617, 0, 0, 0, -20606], [0, -830, 0, 830, 86906, 0, -1660, 0], [0, -5430, 0, 5430, 5666, 0, -10860, 0], [0, -2905, 0, 0, 0, -1418, 0, 0], [-214064, 0, -12256, 0, 0, 0, 0, 0], [16824, 0, -20324, 0, 0, 0, 0, 0], [0, 10608, 0, 18677, 0, 0, 0, 21216], [0, 3825, 0, 177737, 0, 0, 0, 7650], [0, 666, 0, -666, 101330, 0, 1332, 0], [59492, 0, -10710, 0, 0, 0, 0, 0], [0, 17289, 0, 0, 0, -3956, 0, 0], [0, -6196, 0, 6196, -18880, 0, -12392, 0], [0, -7671, 0, -7348, 0, 0, 0, -15342], [0, 2385, 0, -2385, -12096, 0, 4770, 0], [0, 6717, 0, 0, 0, 818, 0, 0], [58648, 0, -38770, 0, 0, 0, 0, 0], [-260442, 0, -37100, 0, 0, 0, 0, 0], [0, -31356, 0, 0, 0, 2376, 0, 0], [0, 6771, 0, 12983, 0, 0, 0, 13542], [0, 9647, 0, 18336, 0, 0, 0, 19294], [7004, 0, -22494, 0, 0, 0, 0, 0], [0, 651, 0, -651, -40810, 0, 1302, 0], [-95688, 0, 6790, 0, 0, 0, 0, 0], [0, 4030, 0, -4030, 148154, 0, 8060, 0], [0, -266, 0, 0, 0, 6932, 0, 0], [0, 35792, 0, 0, 0, 1536, 0, 0], [0, 5401, 0, 23068, 0, 0, 0, 10802], [0, -6720, 0, 14891, 0, 0, 0, -13440], [0, 5181, 0, -4, 0, 0, 0, 10362], [92986, 0, 20414, 0, 0, 0, 0, 0], [0, -32369, 0, 0, 0, 1918, 0, 0], [-238552, 0, 49650, 0, 0, 0, 0, 0], [0, 7585, 0, -7585, -19064, 0, 15170, 0], [0, 10175, 0, -10175, 9376, 0, 20350, 0], [0, 20847, 0, 0, 0, 2052, 0, 0], [0, -23734, 0, 0, 0, -2492, 0, 0], [0, 809, 0, -237492, 0, 0, 0, 1618], [0, -5280, 0, 85640, 0, 0, 0, -10560], [0, 8241, 0, 0, 0, -6422, 0, 0], [0, 5755, 0, -5755, 74804, 0, 11510, 0], [0, -554, 0, 554, -158030, 0, -1108, 0], [0, 60834, 0, 0, 0, -810, 0, 0], [0, -9885, 0, 9885, 11796, 0, -19770, 0], [0, 23687, 0, 75447, 0, 0, 0, 47374], [0, 1491, 0, -1491, -49100, 0, 2982, 0], [384704, 0, -16734, 0, 0, 0, 0, 0], [-555976, 0, -23064, 0, 0, 0, 0, 0], [0, 18434, 0, 0, 0, 2950, 0, 0], [0, -1820, 0, 402076, 0, 0, 0, -3640], [0, 50535, 0, 0, 0, -854, 0, 0], [0, 7919, 0, -7919, -62560, 0, 15838, 0], [0, 660, 0, -660, -6276, 0, 1320, 0], [0, -3189, 0, 3189, -101410, 0, -6378, 0], [0, -5605, 0, 0, 0, -6202, 0, 0], [0, 3140, 0, -3140, -115104, 0, 6280, 0], [0, -28443, 0, 62105, 0, 0, 0, -56886], [1135336, 0, -9436, 0, 0, 0, 0, 0], [0, 12053, 0, -66300, 0, 0, 0, 24106]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_315_e_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_315_5_e_e();".
// 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_315_5_e_e(:prec:=8)
    chi := MakeCharacter_315_e();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 5));
    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_315_5_e_e();".
// 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_315_5_e_e( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_315_e();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,5,sign)));
    Vf := Kernel([<2,R![1194, 0, 75, 0, 1]>,<13,R![145926400, 0, -52250, 0, 1]>],Snew);
    return Vf;
end function;