
// Make newform 750.4.c.e in Magma, downloaded from the LMFDB on 03 June 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_750_c();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_750_c_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_750_4_c_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_750_4_c_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 := [309136, 0, 54684, 0, 3541, 0, 99, 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, -643480, 0, -76675, 0, -2909, 0, -35], [-27800, 0, -4413, 0, -211, 0, -3, 0], [0, -4562310, 0, -609385, 0, -25659, 0, -335], [219344, 0, 28335, 0, 1165, 0, 15, 0], [0, -44212, 0, -5667, 0, -233, 0, -3], [13894, 0, 1841, 0, 77, 0, 1, 0], [0, -25041872, 0, -3227527, 0, -132457, 0, -1703]];
    Rf_basisdens := [1, 36696, 66, 18348, 132, 132, 6, 36696];
    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_750_c();"
function MakeCharacter_750_c()
    N := 750;
    order := 2;
    char_gens := [251, 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_750_c_Hecke();"
function MakeCharacter_750_c_Hecke(Kf)
    N := 750;
    order := 2;
    char_gens := [251, 127];
    char_values := [[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 := true, 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, -2, 0, 0, 0, 0, 0, 0], [0, -3, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, -1, 0, -1], [-5, 0, -4, 0, -3, 0, -1, 0], [0, -32, 0, 3, 0, 2, 0, -5], [0, 9, 0, 10, 0, -3, 0, 3], [17, 0, 3, 0, -1, 0, -6, 0], [0, -25, 0, 9, 0, -9, 0, 12], [24, 0, -2, 0, -14, 0, 2, 0], [13, 0, 15, 0, -16, 0, 3, 0], [0, 239, 0, -13, 0, -5, 0, 1], [-20, 0, -3, 0, -29, 0, -17, 0], [0, -218, 0, -18, 0, -4, 0, 16], [0, 9, 0, -41, 0, 12, 0, -12], [0, -210, 0, -33, 0, -21, 0, -36], [158, 0, 5, 0, -71, 0, -9, 0], [153, 0, 30, 0, -20, 0, 3, 0], [0, 382, 0, 46, 0, -10, 0, -22], [-484, 0, 2, 0, 4, 0, 54, 0], [0, -438, 0, -60, 0, 36, 0, -18], [263, 0, 18, 0, 58, 0, 51, 0], [0, -517, 0, -78, 0, 36, 0, 27], [383, 0, -12, 0, 53, 0, -19, 0], [0, 226, 0, -54, 0, 38, 0, 76], [-384, 0, 8, 0, -106, 0, -14, 0], [0, -510, 0, 41, 0, -30, 0, 5], [0, 419, 0, -68, 0, -21, 0, 93], [-643, 0, 21, 0, -86, 0, -15, 0], [0, 245, 0, -40, 0, -60, 0, 9], [0, 1006, 0, -100, 0, 14, 0, -126], [233, 0, -44, 0, -3, 0, -83, 0], [0, -220, 0, -28, 0, 18, 0, -192], [-780, 0, 21, 0, -7, 0, -120, 0], [670, 0, 168, 0, -44, 0, 28, 0], [1523, 0, 84, 0, -120, 0, -75, 0], [0, 754, 0, 108, 0, -82, 0, 4], [0, -18, 0, -132, 0, 72, 0, -6], [0, 1238, 0, 49, 0, -33, 0, -36], [0, -885, 0, 149, 0, -99, 0, 63], [14, 0, -37, 0, -89, 0, -63, 0], [2661, 0, 36, 0, 362, 0, 81, 0], [-540, 0, 194, 0, -196, 0, 112, 0], [0, -444, 0, -226, 0, -126, 0, -28], [0, -2707, 0, -172, 0, -87, 0, -21], [-1489, 0, -189, 0, -482, 0, -141, 0], [1157, 0, -42, 0, -155, 0, -78, 0], [0, -1740, 0, 484, 0, -78, 0, -8], [0, 439, 0, -562, 0, -153, 0, 141], [-2319, 0, -99, 0, 294, 0, 159, 0], [0, 1172, 0, -208, 0, 42, 0, -252], [-96, 0, 98, 0, -556, 0, 148, 0], [-838, 0, -351, 0, 151, 0, 12, 0], [806, 0, -10, 0, -680, 0, -30, 0], [0, -1969, 0, 162, 0, 120, 0, -111], [0, 2068, 0, -33, 0, 0, 0, -192], [1374, 0, -32, 0, -476, 0, -172, 0], [-2267, 0, 135, 0, -820, 0, 369, 0], [0, -728, 0, 407, 0, -16, 0, 303], [255, 0, 404, 0, -457, 0, 193, 0], [0, 110, 0, 62, 0, -20, 0, 70], [0, 1081, 0, 613, 0, -255, 0, -144], [0, -3660, 0, -154, 0, 384, 0, -22], [-5358, 0, 106, 0, -200, 0, -238, 0], [0, 4658, 0, 682, 0, 178, 0, -48], [0, -728, 0, 753, 0, 18, 0, 303], [5321, 0, -336, 0, 430, 0, -261, 0], [0, -774, 0, 760, 0, -84, 0, -524], [0, -1353, 0, 312, 0, 354, 0, 3], [-731, 0, 3, 0, -140, 0, 339, 0], [0, 2077, 0, -254, 0, -15, 0, 633], [-1622, 0, 140, 0, -1044, 0, 524, 0], [0, -4426, 0, 876, 0, -110, 0, 218], [0, 1631, 0, 735, 0, 457, 0, -139], [-1917, 0, 12, 0, 623, 0, -27, 0], [0, -3426, 0, 325, 0, -78, 0, 486], [4620, 0, -394, 0, 986, 0, -152, 0], [0, -327, 0, 547, 0, -267, 0, 319], [5788, 0, 61, 0, 689, 0, 357, 0], [-3551, 0, -609, 0, -527, 0, -576, 0], [7828, 0, 332, 0, 888, 0, 524, 0], [2369, 0, 480, 0, -164, 0, 21, 0], [166, 0, -638, 0, -1282, 0, 102, 0], [0, 862, 0, -76, 0, -184, 0, 312], [4594, 0, -228, 0, 334, 0, -246, 0], [0, -5239, 0, 904, 0, 216, 0, 75], [1910, 0, 153, 0, -1825, 0, -199, 0], [0, -10432, 0, -460, 0, 70, 0, 124], [-4868, 0, -346, 0, 1758, 0, 38, 0], [0, 2430, 0, 556, 0, -1236, 0, 550], [0, 4849, 0, -72, 0, 570, 0, 33], [2628, 0, -454, 0, 686, 0, 154, 0], [0, 396, 0, -1051, 0, -378, 0, 755], [-6766, 0, 83, 0, -41, 0, -387, 0], [-3482, 0, 564, 0, -1511, 0, 690, 0], [0, -1994, 0, -2039, 0, 114, 0, 15], [-7462, 0, 58, 0, -834, 0, -14, 0], [-1693, 0, 1318, 0, 15, 0, 349, 0], [0, 1412, 0, 568, 0, 106, 0, 432], [-2091, 0, 483, 0, 1412, 0, -807, 0], [0, 3210, 0, -730, 0, 1218, 0, -526], [0, 52, 0, -1245, 0, -258, 0, -771], [0, -9399, 0, -1452, 0, 441, 0, -381], [-1709, 0, 166, 0, 2741, 0, -375, 0], [-7552, 0, -549, 0, 25, 0, -417, 0], [0, 3722, 0, 1562, 0, -440, 0, 868], [0, 9987, 0, -654, 0, 207, 0, -663], [0, -4037, 0, 970, 0, -210, 0, 1227], [8214, 0, -1098, 0, -1998, 0, 582, 0], [6874, 0, -357, 0, -347, 0, 852, 0], [0, -8107, 0, -2759, 0, -227, 0, -93], [0, -9230, 0, -1279, 0, 884, 0, -453], [0, -5727, 0, -52, 0, -459, 0, 921], [-2208, 0, 531, 0, 843, 0, 384, 0], [-1484, 0, 846, 0, 906, 0, 1506, 0], [-5676, 0, -1007, 0, 607, 0, 743, 0], [0, 3764, 0, 1044, 0, 154, 0, -220], [0, 7903, 0, -2083, 0, -573, 0, 531], [0, -6193, 0, -1349, 0, -348, 0, 72], [-4797, 0, -644, 0, -2813, 0, -1381, 0], [-14079, 0, -711, 0, 1122, 0, 291, 0], [0, -4222, 0, 1484, 0, -1310, 0, 826], [0, 8636, 0, 199, 0, -285, 0, 54], [0, -2069, 0, 56, 0, -1209, 0, -477], [-14445, 0, 381, 0, -28, 0, -1335, 0], [12566, 0, -988, 0, 298, 0, -1272, 0], [2779, 0, -1224, 0, -388, 0, 15, 0], [3836, 0, -296, 0, 2724, 0, -1286, 0], [0, -3677, 0, 3053, 0, 611, 0, -1215], [0, -2408, 0, -1495, 0, -826, 0, 789], [11333, 0, -600, 0, -2877, 0, 816, 0], [0, -722, 0, 2521, 0, 570, 0, -753], [-5647, 0, 1956, 0, -404, 0, 495, 0], [0, -11296, 0, 1655, 0, 664, 0, -125], [4048, 0, 493, 0, 3989, 0, -627, 0], [12332, 0, 612, 0, 1415, 0, 1350, 0], [0, 4481, 0, -2974, 0, 894, 0, -1299], [0, -5218, 0, -2264, 0, -350, 0, -432], [0, -10600, 0, -2693, 0, -888, 0, -984], [-12751, 0, 1800, 0, 1859, 0, 431, 0], [-19636, 0, 96, 0, -3205, 0, -72, 0], [5102, 0, -348, 0, -388, 0, -802, 0], [0, 387, 0, 247, 0, 495, 0, -1271], [0, 9977, 0, 2444, 0, -618, 0, 909], [16699, 0, 168, 0, 1454, 0, -1461, 0], [-6478, 0, 2110, 0, -390, 0, 58, 0], [0, 17761, 0, 2625, 0, -1249, 0, -53], [0, 7537, 0, -2236, 0, 900, 0, 1209], [5908, 0, -1335, 0, -3253, 0, 321, 0], [0, 231, 0, -3491, 0, -789, 0, 1539], [0, 7452, 0, 4197, 0, 1116, 0, -807], [11320, 0, -1225, 0, -1731, 0, -583, 0], [0, 12910, 0, 284, 0, -934, 0, -246], [0, -262, 0, -681, 0, 1173, 0, -276], [0, -23636, 0, 2354, 0, -1504, 0, 1206], [3716, 0, -1532, 0, -828, 0, -1562, 0], [-11875, 0, -1383, 0, -2158, 0, -375, 0], [-13021, 0, -978, 0, 653, 0, -1099, 0], [0, 12162, 0, -4010, 0, -738, 0, 1270], [14968, 0, 680, 0, 2190, 0, 2960, 0], [0, 4125, 0, -2504, 0, 993, 0, 765], [0, -10163, 0, -22, 0, 1197, 0, 399], [0, 14194, 0, 1579, 0, 1976, 0, 2015], [25201, 0, 1828, 0, 3311, 0, 2769, 0], [0, 8549, 0, 1780, 0, 1305, 0, 477], [0, 11515, 0, 833, 0, 204, 0, 1416], [1383, 0, -942, 0, -3714, 0, 2031, 0], [0, 8977, 0, 4221, 0, 1439, 0, 823]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_750_c_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_750_4_c_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_750_4_c_e(:prec:=8)
    chi := MakeCharacter_750_c();
    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_750_4_c_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_750_4_c_e( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_750_c();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<7,R![63425296, 0, 46995576, 0, 579161, 0, 1491, 0, 1]>],Snew);
    return Vf;
end function;