
// Make newform 245.4.a.m in Magma, downloaded from the LMFDB on 15 March 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_245_a();"
// To make the coeffs of the qexp of the newform in the Hecke field type "qexpCoeffs();"
// To make the newform (type ModFrm), type "MakeNewformModFrm_245_4_a_m();".
// 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_245_4_a_m();".
// 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 := [64, 288, 21, -37, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0, 0], [0, 1, 0, 0, 0], [-4, -21, 0, 1, 0], [-15, 0, 1, 0, 0], [112, 21, -29, -1, 1]];
    Rf_basisdens := [1, 1, 4, 1, 4];
    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_245_a();"
function MakeCharacter_245_a()
    N := 245;
    order := 1;
    char_gens := [197, 101];
    v := [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;

function MakeCharacter_245_a_Hecke( : Kf := Kf)
    return MakeCharacter_245_a();
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, 1, 0, 0, 0], [-2, 0, 1, 0, 0], [-5, 0, 0, 0, 0], [0, 0, 0, 0, 0], [8, 7, -1, 1, 1], [2, -1, -1, -1, -3], [-2, 4, 2, -6, 0], [-6, 9, 3, 1, -3], [40, 7, 0, -9, -3], [31, 31, -1, -13, 3], [82, 10, -12, -8, -4], [-24, -37, 1, -11, 5], [-67, 2, 26, 14, 0], [134, -56, -15, -4, -8], [-88, -33, 9, -15, -9], [64, 7, 15, -13, -3], [138, 46, -10, 8, -4], [379, 41, 1, 1, 3], [218, -66, 59, 26, -12], [158, 62, 10, -32, -4], [-362, 74, 44, 8, -2], [86, -8, -96, -22, -6], [-318, 22, -3, 22, 36], [453, -115, 63, 3, 23], [134, -40, -8, -24, -8], [-139, 163, -73, -17, 11], [12, 264, -95, 42, -14], [198, -110, -73, 86, -12], [937, -77, -49, 11, -35], [-636, 156, -14, 62, -16], [344, -15, 95, 39, 69], [1264, -81, -47, -47, 33], [20, -24, -56, 72, 72], [388, -168, -226, -52, 48], [-871, 249, -147, -119, -53], [102, -136, 182, 26, 38], [718, -217, 125, 97, -27], [1044, 244, 20, -252, -38], [-340, -123, -114, 53, -31], [-648, -621, -19, 113, 5], [1246, 155, -137, -5, 43], [-411, 417, 85, 1, 69], [-716, 560, 74, 44, 136], [1534, -50, 86, -142, -2], [2034, 187, -267, -3, 49], [52, -504, -176, 24, -16], [2218, -207, 263, -119, 37], [2072, -300, 304, 204, 26], [-1024, -404, -168, -272, 122], [-942, 818, -118, -158, 86], [550, 456, 210, 206, -72], [542, 184, -282, -126, -146], [1202, 65, 335, 59, 159], [1406, 71, 423, 175, 23], [1428, -712, 204, 288, 68], [-1116, 108, 617, -186, 74], [1161, 171, 467, 79, -7], [-1122, -438, -202, -140, 52], [-2950, 452, 406, -6, 164], [-606, 71, -415, -139, 25], [1148, -302, -386, 258, -176], [-2952, -955, 311, -201, -33], [330, -116, 589, -264, 34], [-954, 526, -74, 172, -196], [912, 96, 696, 68, -72], [-5306, -744, 474, -94, -92], [3118, 1423, -161, -189, -85], [-2184, 746, 276, -44, -262], [-1622, -1382, -253, 214, -64], [2843, -41, -257, -133, 87], [-396, 796, 6, -222, 172], [506, -1700, 114, 298, -194], [-2500, 847, -706, -253, -179], [-2356, -94, 614, -198, -94], [402, -135, -769, 437, 105], [-2264, 259, -520, -681, 253], [-2626, -1110, 314, 90, -154], [-638, -656, -1596, 380, -136], [-5513, -1226, -246, 158, 346], [-1989, -793, 121, 33, 63], [3308, -697, -387, -363, 133], [47, -289, -669, -169, -187], [1472, -1384, -102, 312, 60], [-1252, -112, -574, -626, -116], [-576, 622, -90, 538, 22], [94, -1262, 163, -294, -70], [-2945, -942, 1478, 578, 24], [4832, -1670, 118, 154, -26], [2226, 932, -916, 736, -124], [7600, 1381, -412, -263, 225], [-10922, -556, 173, 272, 118], [1994, -1778, 684, -40, 324], [-792, 1124, -364, -152, 226], [-4654, -1710, 668, 20, 4], [4740, 664, 1626, -48, 152], [572, 2920, 819, -586, 376], [3159, -157, -1677, -789, 43], [3582, 1295, -1471, -387, 25], [240, -208, -508, -292, -70], [4777, 1147, -813, 491, 115], [10338, 2726, -1133, 438, 428], [-4030, -509, 633, 161, -507], [1058, 1024, 203, -568, -86], [-5634, 291, -1115, -671, -611], [1590, 1542, 266, -936, -420], [1258, 2714, 126, -142, 526], [-3392, 1952, 988, -276, -354], [9720, -2368, 730, -414, 272], [6324, -2610, 1778, 134, 282], [-10282, 844, -880, -452, -356], [-4812, 4437, -1380, -471, -257], [-3846, 2153, 657, 209, 439], [2688, -2278, 2346, 822, 218], [4092, 1479, -281, -811, -859], [-1224, -2088, 1810, 792, -600], [-171, -1438, 94, 94, 564], [4568, -4078, -438, 330, -696], [-16580, -2013, 34, 1207, 101], [-1766, 1863, -1949, 39, 77], [-13882, -1318, -830, -516, 712], [1727, -1259, -3643, -39, -149], [-2396, 2306, -574, -898, -546], [3154, 295, -2065, -933, -587], [2966, 206, -757, -534, -794], [-4472, -2320, 1510, -1588, 92], [2831, 1707, -1733, 1659, 133], [-13057, 1627, 2351, 1111, 123], [484, -3896, 198, 36, 612], [-8652, 1737, 1474, 565, 45], [3726, 1105, -689, 375, 371], [5344, 4631, 455, -299, 329], [1480, 601, -1764, 285, -883], [-3300, -1378, 914, 1082, 1082], [-2566, 3204, -38, -34, 428], [6150, 1563, 1649, -403, -619], [-7858, 2701, -257, 1099, -13], [10794, 3065, -1467, -135, 131], [14670, 2708, -2255, 308, 294], [-19536, -2782, -1458, 626, 394], [5553, -786, 654, 1562, 254], [-3690, -1403, 1261, 865, 1061], [-7586, -1248, 368, -212, 560], [7260, -4324, 1175, -830, 436], [22850, -3616, -1689, -52, -768], [6346, 2148, -1292, 120, 1060], [6824, 1618, 84, -894, -510], [-2748, 4255, -2917, -1297, 57], [-12662, 4820, 2808, 1080, -192], [-9136, 5744, 472, -580, 1168], [9408, 1127, -2422, -1157, 3], [9880, -3963, 3625, 1825, -501], [-1371, -4632, 492, -932, 406], [11416, 2668, 1128, -160, 966], [11736, -6628, 2293, 606, -56], [-5782, -2388, 1179, 276, -140], [-5880, 2170, 1820, -1086, 274], [-1486, -5212, -1908, -90, -326], [6471, 430, 486, -290, -476], [-9924, -866, -2422, 2098, -182], [-14874, 2018, -3134, -1638, 302], [13206, 1420, -1671, 652, -210], [-2824, -1292, 2792, 2724, 272], [13016, 332, -3731, -1426, -916], [-8516, 667, 161, -1819, 1157], [1510, 140, -4128, -2180, -700], [-21236, 2117, -1748, -191, -55], [5590, 2838, 1432, 2800, -352], [-1712, 282, 2832, -1956, -718]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_245_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_245_4_a_m();".
// 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_245_4_a_m(:prec:=5)
    chi := MakeCharacter_245_a();
    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_245_4_a_m();".
// 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_245_4_a_m( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_245_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<2,R![64, 288, 21, -37, -1, 1]>,<3,R![4126, 1731, -462, -76, 8, 1]>],Snew);
    return Vf;
end function;