
// Make newform 800.6.c.j in Magma, downloaded from the LMFDB on 18 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_800_c();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_800_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_800_6_c_j();".
// 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_800_6_c_j();".
// 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 := [7605, 2778, 256, 116, 32, -2, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0, 0, 0], [106320, 8137, -5515, 2174, -275, 7], [25205, -72, 1440, 256, 0, 8], [-212280, -27323, 2645, -6166, 685, -173], [12965, 20544, -680, -112, 200, -16], [1899360, 693051, 89655, 32802, -1825, 1061]];
    Rf_basisdens := [1, 58125, 625, 11625, 625, 19375];
    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_800_c();"
function MakeCharacter_800_c()
    N := 800;
    order := 2;
    char_gens := [351, 101, 577];
    v := [2, 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_800_c_Hecke();"
function MakeCharacter_800_c_Hecke(Kf)
    N := 800;
    order := 2;
    char_gens := [351, 101, 577];
    char_values := [[1, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0], [-1, 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+1)]];
    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 := 6;
    raw_aps := [[0, 0, 0, 0, 0, 0], [0, -2, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0], [0, -1, 0, 1, 0, 1], [-131, 0, 0, 0, 3, 0], [0, 53, 0, 20, 0, 2], [0, 211, 0, -60, 0, -6], [-1072, 0, -25, 0, 1, 0], [0, -1009, 0, -43, 0, -7], [-118, 0, 20, 0, 52, 0], [1061, 0, -135, 0, 42, 0], [0, -2019, 0, 200, 0, -76], [4154, 0, 34, 0, -22, 0], [0, -4460, 0, 221, 0, 14], [0, 6093, 0, 77, 0, -25], [0, 3869, 0, -1140, 0, -114], [-11730, 0, 35, 0, -185, 0], [-7726, 0, 992, 0, -32, 0], [0, -2404, 0, 2345, 0, -82], [29517, 0, 515, 0, -56, 0], [0, -10295, 0, -2340, 0, 150], [30922, 0, -350, 0, 164, 0], [0, -4194, 0, -2923, 0, -376], [-57474, 0, 300, 0, -36, 0], [0, 28155, 0, 1420, 0, 430], [-39946, 0, -220, 0, 4, 0], [0, 14687, 0, 2785, 0, 481], [0, -10170, 0, 237, 0, 288], [99686, 0, 2372, 0, 52, 0], [0, -29817, 0, -7800, 0, -108], [0, -15735, 0, -1287, 0, 1467], [12371, 0, 3920, 0, 1117, 0], [0, -45319, 0, 1360, 0, -2456], [282434, 0, -2585, 0, 143, 0], [71246, 0, 1236, 0, -828, 0], [5365, 0, -4885, 0, -1160, 0], [0, 25225, 0, -520, 0, 620], [0, -115246, 0, -6187, 0, 1532], [0, 80491, 0, -18463, 0, -3475], [0, 117943, 0, 5560, 0, 652], [146370, 0, 10885, 0, 3425, 0], [50862, 0, -16960, 0, 688, 0], [613699, 0, -3845, 0, 1178, 0], [0, -46771, 0, 3900, 0, 4806], [0, 64959, 0, 28100, 0, -1894], [234704, 0, -11670, 0, -1002, 0], [476651, 0, 300, 0, 1737, 0], [0, -335235, 0, 8621, 0, 1943], [0, 284288, 0, 15629, 0, 3482], [-782630, 0, -4680, 0, 72, 0], [0, 89609, 0, 27540, 0, -1374], [93322, 0, -22510, 0, 4084, 0], [-262590, 0, 6858, 0, -3630, 0], [377825, 0, -21640, 0, 1255, 0], [0, 121273, 0, -42600, 0, 2172], [0, -541053, 0, -631, 0, 5525], [313422, 0, -6760, 0, -2696, 0], [-279493, 0, 3675, 0, 8514, 0], [0, 433969, 0, -21240, 0, -2124], [-1418398, 0, 6422, 0, 814, 0], [0, 8716, 0, -58615, 0, -6754], [0, -94329, 0, -47280, 0, -11736], [0, -752856, 0, -25031, 0, -4646], [1032527, 0, 15525, 0, -14796, 0], [0, -364857, 0, -73560, 0, 2052], [0, 124391, 0, -56420, 0, -4586], [-971809, 0, -33290, 0, -15013, 0], [0, 376013, 0, -50520, 0, -9468], [0, 171094, 0, 67849, 0, -3416], [1813442, 0, -320, 0, 176, 0], [0, -1209005, 0, -35000, 0, 7060], [-804464, 0, 23910, 0, -4038, 0], [0, -314679, 0, 9981, 0, 6531], [0, 1311895, 0, -600, 0, 19140], [-192456, 0, 17385, 0, 19623, 0], [0, -1510203, 0, 18469, 0, -9521], [-1170458, 0, -12072, 0, -14856, 0], [0, -780837, 0, -118420, 0, 16382], [-397902, 0, 52480, 0, 6560, 0], [-67898, 0, -15414, 0, -19086, 0], [-3318390, 0, 43145, 0, 14005, 0], [1576114, 0, -28116, 0, -21252, 0], [1854095, 0, 4055, 0, 8530, 0], [0, -3146139, 0, -11180, 0, 7234], [-815776, 0, 51090, 0, -24162, 0], [0, -1173088, 0, -145123, 0, 11738], [-1303642, 0, 74510, 0, -22394, 0], [0, 820317, 0, -83040, 0, 36048], [-469074, 0, -102380, 0, 32756, 0], [0, 737617, 0, -223207, 0, -22141], [0, 2229096, 0, -44031, 0, 33642], [-6767886, 0, -21150, 0, -8772, 0], [0, 137123, 0, 49293, 0, 37821], [3948065, 0, 132520, 0, 22775, 0], [-2579260, 0, 147455, 0, -12875, 0], [0, 1128579, 0, 61297, 0, 25381], [-2068062, 0, 20360, 0, 53464, 0], [-6836646, 0, 9440, 0, -6176, 0], [0, 1434800, 0, 278649, 0, -35934], [-155890, 0, -75220, 0, 34924, 0], [0, -2690976, 0, 117821, 0, -61222], [0, 3965357, 0, -104840, 0, 23308], [0, 2859834, 0, 14025, 0, -43572], [5308470, 0, 46162, 0, 51290, 0], [-7475089, 0, 3230, 0, -4253, 0], [0, 641941, 0, -234160, 0, -55576], [0, 666542, 0, -275195, 0, 74104], [0, -83209, 0, -84160, 0, -37216], [-4653774, 0, 9640, 0, 12902, 0], [-1127870, 0, -80754, 0, -74490, 0], [0, -16087, 0, -120155, 0, 45043], [0, 2508741, 0, -528380, 0, -63686], [0, -3400385, 0, 220060, 0, 48790], [-4424932, 0, -215995, 0, -44729, 0], [-8914071, 0, -32785, 0, 95008, 0], [-5494302, 0, -147814, 0, -8414, 0], [0, 1794494, 0, 399953, 0, 13856], [0, -1361597, 0, -306875, 0, -31667], [0, 693885, 0, -300660, 0, 48750], [-5681866, 0, 373625, 0, -54887, 0], [3058474, 0, 246104, 0, 91768, 0], [0, -2217135, 0, -638260, 0, -35890], [0, 1091643, 0, -459700, 0, 24782], [0, 994284, 0, 163229, 0, -43162], [-386667, 0, 250710, 0, -104379, 0], [6993018, 0, 98620, 0, -51124, 0], [3356530, 0, 43380, 0, 6228, 0], [-2005630, 0, -154430, 0, -96820, 0], [0, 1190579, 0, 224137, 0, -63803], [0, 4637723, 0, -317440, 0, -44128], [-3601274, 0, 164685, 0, 9237, 0], [0, -1207465, 0, -164755, 0, -40783], [5070821, 0, -239655, 0, -45558, 0], [0, -5231435, 0, -310480, 0, 19640], [3603850, 0, 363760, 0, 43376, 0], [-6872970, 0, 102860, 0, 108988, 0], [0, 761809, 0, 124620, 0, 15246], [0, 5778404, 0, -460667, 0, -36050], [0, -1495565, 0, 110740, 0, -210590], [-1398234, 0, 643360, 0, -29920, 0], [106985, 0, 223260, 0, 45915, 0], [-7376270, 0, 33828, 0, -104940, 0], [0, -3490889, 0, -1115, 0, -81599], [0, -7411842, 0, 535465, 0, 16], [8687950, 0, -142288, 0, 127600, 0], [10150134, 0, 211660, 0, -11362, 0], [0, 6094945, 0, -265380, 0, -169290], [0, 552109, 0, -856280, 0, -35804], [14894354, 0, 168255, 0, 6183, 0], [0, 3949281, 0, -321523, 0, 166523], [0, 4760005, 0, -895120, 0, 75320], [-77254, 0, -327178, 0, -205778, 0], [0, -6749022, 0, 465193, 0, -192908], [0, -4144341, 0, -662791, 0, 144029], [0, 7316282, 0, -271959, 0, 89868], [-9186107, 0, -395, 0, 55406, 0], [-613234, 0, -340940, 0, 135902, 0], [-5792970, 0, -198994, 0, 49510, 0], [0, 10069227, 0, -422540, 0, -50222], [10744598, 0, 242600, 0, -57800, 0], [0, -6223208, 0, 52017, 0, -6726], [0, 706691, 0, 1292320, 0, -19376], [0, 6903791, 0, 42013, 0, -121367], [-13319241, 0, -540570, 0, -155757, 0], [0, -7266689, 0, 439540, 0, -19886], [0, 6321583, 0, -468615, 0, 99105], [-4221871, 0, 193265, 0, -10682, 0], [0, -16908881, 0, -706820, 0, 34726]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_800_c_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_800_6_c_j();".
// 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_800_6_c_j(:prec:=6)
    chi := MakeCharacter_800_c();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 6));
    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_800_6_c_j();".
// 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_800_6_c_j( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_800_c();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,6,sign)));
    Vf := Kernel([<3,R![166464, 0, 292144, 0, 1196, 0, 1]>,<11,R![-59934400, -155280, 396, 1]>],Snew);
    return Vf;
end function;