
// Make newform 1840.2.i.a in Magma, downloaded from the LMFDB on 25 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_1840_i();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_1840_i_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_1840_2_i_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_1840_2_i_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 := [784, 0, 2696, 0, 4705, 0, -9200, 0, 7128, 0, -2398, 0, 400, 0, -32, 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, 0, 0, 0, 0, 0, 0, 0], [-188557796, 0, -989294405, 0, 1633121252, 0, -729577504, 0, 151546566, 0, -14917580, 0, 639364, 0, -7141, 0], [5858020, 0, 12535373, 0, 24310636, 0, -29821744, 0, 11582258, 0, -2080516, 0, 173356, 0, -5547, 0], [0, -262952740, 0, -3971651317, 0, 4187604864, 0, -2108936952, 0, 555881878, 0, -79149040, 0, 5706972, 0, -165589], [0, -11846476, 0, -16298863, 0, -235120, 0, -19800248, 0, 10946626, 0, -2331136, 0, 214244, 0, -7343], [1863596, 0, 10040651, 0, -15727740, 0, 9652416, 0, -2840762, 0, 432756, 0, -32540, 0, 971, 0], [-80965164, 0, 20161121, 0, 39042108, 0, -48266192, 0, 19188922, 0, -3520980, 0, 298300, 0, -9687, 0], [-86948092, 0, 55334005, 0, 107683996, 0, -129690636, 0, 47481542, 0, -8072756, 0, 647232, 0, -20175, 0], [0, -37094388, 0, -30384773, 0, 69774352, 0, -60743728, 0, 21553958, 0, -3710656, 0, 302708, 0, -9589], [692456380, 0, 3858584675, 0, -5691404292, 0, 4773358420, 0, -1701925438, 0, 294082508, 0, -24021912, 0, 760831, 0], [0, -189996, 0, -3773569, 0, 4829752, 0, -3009724, 0, 918310, 0, -145224, 0, 11264, 0, -345], [-239476132, 0, -1302558772, 0, 2000680458, 0, -1354547795, 0, 428229415, 0, -69284106, 0, 5459985, 0, -169285, 0], [0, 361303484, 0, 12816032259, 0, -20448941960, 0, 14996450792, 0, -4930874706, 0, 811056936, 0, -64300516, 0, 1996395], [0, 336396572, 0, 265063979, 0, -668515696, 0, 550748136, 0, -189379626, 0, 31894496, 0, -2562948, 0, 80267], [0, 390867284, 0, 290130617, 0, -838029688, 0, 635359128, 0, -206610582, 0, 33591704, 0, -2642028, 0, 81585], [0, -1062631524, 0, -23466355989, 0, 31723436072, 0, -20714457512, 0, 6493543742, 0, -1045043272, 0, 81970636, 0, -2530093]];
    Rf_basisdens := [1, 547177568, 18868192, 1094355136, 37736384, 2088464, 18868192, 18868192, 18868192, 547177568, 425488, 68397196, 1094355136, 37736384, 37736384, 547177568];
    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_1840_i();"
function MakeCharacter_1840_i()
    N := 1840;
    order := 2;
    char_gens := [1151, 1381, 737, 1201];
    v := [1, 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_1840_i_Hecke();"
function MakeCharacter_1840_i_Hecke(Kf)
    N := 1840;
    order := 2;
    char_gens := [1151, 1381, 737, 1201];
    char_values := [[-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [-1, 0, 0, 0, 0, 0, 0, 0, 0, 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+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 := 2;
    raw_aps := [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -2, 0, 1, 0, 0, 0], [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 1, 0, 0, 1], [0, -1, 0, 1, 0, 0, 0, 0, 0, 1, -1, 0, 1, 0, 0, 0], [5, 0, -1, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0], [0, 0, -1, 0, 0, 0, 1, -1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, -2, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, -1, 0], [0, -1, 0, 0, 0, -5, 0, 0, 0, -1, 0, -1, 0, 0, 0, 0], [0, 0, 0, 0, -2, 0, 0, 0, -1, 0, 0, 0, 0, 0, -1, 0], [0, 0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 2, 0, 0, 0, 0], [12, 0, -1, 0, 0, 0, -8, -3, 0, 0, 0, 0, 0, 0, 0, 0], [-14, 0, -5, 0, 0, 0, 4, 3, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, -12, 0, 0, 0, 0, 0, 0, 9, 0, -11, 0, 0, -1], [0, 0, 0, 14, 0, 0, 0, 0, 0, 0, -14, 0, 2, 0, 0, 0], [0, -5, 0, 0, 0, -17, 0, 0, 0, -13, 0, -5, 0, 0, 0, 0], [0, 0, 0, 0, 6, 0, 0, 0, 4, 0, 0, 0, 0, 2, -4, 0], [0, 3, 0, 0, 0, 14, 0, 0, 0, -7, 0, 0, 0, 0, 0, 0], [17, 0, -5, 0, 0, 0, 9, -4, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 7, 0, -16, 0, 0, 0], [-8, 0, 1, 0, 0, 0, -2, 9, 0, 0, 0, 0, 0, 0, 0, 0], [-25, 0, -5, 0, 0, 0, -7, -6, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -14, 0, 10, 0, 0, 0], [-10, 0, -1, 0, 0, 0, -1, -7, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, -1, 0, 0, 0, 0, 0, 0, -13, 0, -2, 0, 0, -6], [0, 1, 0, 0, 0, 12, 0, 0, 0, 3, 0, -6, 0, 0, 0, 0], [35, 0, -3, 0, 0, 0, 5, -2, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 7, 0, 0, 0, -15, 0, 0, 0, 0, -3, -7, 0], [0, -2, 0, 0, 0, 11, 0, 0, 0, 3, 0, -4, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, -13, 0, 0, 1], [0, -11, 0, 0, 0, 9, 0, 0, 0, 3, 0, 1, 0, 0, 0, 0], [-1, 0, 11, 0, 0, 0, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 14, 0, 3, 0, 0, 2], [0, 0, 0, -6, 0, 0, 0, 0, 0, 0, 26, 0, -2, 0, 0, -6], [6, 0, 14, 0, 0, 0, 3, 2, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 15, 0, 0, 0, 0, 0, 0, -12, 0, -7, 0, 0, -5], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -2, 0, 0, 0, 0, 8], [0, 0, 0, 0, 10, 0, 0, 0, -16, 0, 0, 0, 0, -8, 0, 0], [0, 0, 0, 0, -2, 0, 0, 0, -6, 0, 0, 0, 0, 6, 0, 0], [0, -8, 0, 0, 0, 9, 0, 0, 0, -2, 0, -1, 0, 0, 0, 0], [0, -18, 0, 0, 0, -21, 0, 0, 0, -9, 0, 3, 0, 0, 0, 0], [0, 0, 0, -5, 0, 0, 0, 0, 0, 0, 20, 0, -1, 0, 0, 3], [0, 14, 0, 0, 0, -1, 0, 0, 0, -4, 0, 1, 0, 0, 0, 0], [0, -19, 0, 0, 0, -28, 0, 0, 0, 3, 0, 6, 0, 0, 0, 0], [4, 0, -7, 0, 0, 0, -6, -3, 0, 0, 0, 0, 0, 0, 0, 0], [22, 0, 0, 0, 0, 0, 2, -4, 0, 0, 0, 0, 0, 0, 0, 0], [0, -17, 0, 0, 0, -10, 0, 0, 0, -6, 0, -5, 0, 0, 0, 0], [0, 9, 0, 0, 0, 12, 0, 0, 0, 3, 0, 2, 0, 0, 0, 0], [0, 0, 0, 22, 0, 0, 0, 0, 0, 0, -23, 0, 13, 0, 0, 1], [0, 0, 0, -2, 0, 0, 0, 0, 0, 0, 14, 0, 9, 0, 0, 4], [0, 0, 0, -11, 0, 0, 0, 0, 0, 0, -4, 0, -2, 0, 0, -1], [0, 0, 0, 0, -10, 0, 0, 0, 22, 0, 0, 0, 0, 2, -8, 0], [0, 0, 0, 0, 12, 0, 0, 0, -28, 0, 0, 0, 0, -2, 6, 0], [0, 0, 0, 11, 0, 0, 0, 0, 0, 0, -1, 0, -10, 0, 0, 0], [0, 0, 0, 0, 2, 0, 0, 0, -12, 0, 0, 0, 0, -4, -6, 0], [-16, 0, 0, 0, 0, 0, -2, 6, 0, 0, 0, 0, 0, 0, 0, 0], [0, 12, 0, 0, 0, -7, 0, 0, 0, 12, 0, -7, 0, 0, 0, 0], [0, 0, 0, 0, 8, 0, 0, 0, -23, 0, 0, 0, 0, -16, 3, 0], [0, 0, 0, 8, 0, 0, 0, 0, 0, 0, -4, 0, -8, 0, 0, 2], [11, 0, -4, 0, 0, 0, -1, -6, 0, 0, 0, 0, 0, 0, 0, 0], [10, 0, 13, 0, 0, 0, -2, 3, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, -21, 0, 0, 0, 0, 0, 0, 16, 0, 4, 0, 0, 3], [0, 0, 0, -15, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, -7], [13, 0, -2, 0, 0, 0, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, -8, 0, 0, 0, 43, 0, 0, 0, 0, 11, -5, 0], [8, 0, 14, 0, 0, 0, -2, -2, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -2, 0, -7, 0, 0, -6], [0, 0, 0, 0, -8, 0, 0, 0, 25, 0, 0, 0, 0, -8, -1, 0], [0, 0, 0, 0, -6, 0, 0, 0, 6, 0, 0, 0, 0, -4, 10, 0], [0, 0, 0, -1, 0, 0, 0, 0, 0, 0, -28, 0, -3, 0, 0, -1], [-47, 0, 2, 0, 0, 0, -7, 0, 0, 0, 0, 0, 0, 0, 0, 0], [23, 0, 7, 0, 0, 0, 1, -2, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, -23, 0, 0, 0, 0, 0, 0, 2, 0, -3, 0, 0, -1], [0, 0, 0, 0, 3, 0, 0, 0, -16, 0, 0, 0, 0, 6, -8, 0], [0, 0, 0, 8, 0, 0, 0, 0, 0, 0, -30, 0, 20, 0, 0, 4], [-22, 0, -5, 0, 0, 0, 2, -5, 0, 0, 0, 0, 0, 0, 0, 0], [0, -17, 0, 0, 0, -18, 0, 0, 0, 1, 0, -2, 0, 0, 0, 0], [0, 16, 0, 0, 0, 18, 0, 0, 0, 17, 0, 2, 0, 0, 0, 0], [-15, 0, 4, 0, 0, 0, -5, 9, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, -12, 0, 0, 0, 4, 0, 0, 0, 0, 8, -2, 0], [0, 0, 0, 20, 0, 0, 0, 0, 0, 0, -19, 0, 7, 0, 0, 3], [0, 13, 0, 0, 0, 4, 0, 0, 0, 9, 0, 6, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 10, 0, -6, 0, 0, 4], [0, 0, 0, 4, 0, 0, 0, 0, 0, 0, -16, 0, -7, 0, 0, -6], [0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0], [0, -10, 0, 0, 0, 8, 0, 0, 0, 1, 0, -7, 0, 0, 0, 0], [0, -11, 0, 0, 0, -23, 0, 0, 0, -10, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 4, 0, 0, 0, -31, 0, 0, 0, 0, -11, 3, 0], [0, 0, 0, 0, 4, 0, 0, 0, -16, 0, 0, 0, 0, -10, 4, 0], [0, 8, 0, 0, 0, -10, 0, 0, 0, 5, 0, 4, 0, 0, 0, 0], [-11, 0, 8, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 2, 0, 0, 0, -12, 0, 0, 0, 0, -6, 0, 0], [0, 0, 0, 7, 0, 0, 0, 0, 0, 0, -12, 0, -1, 0, 0, 1], [38, 0, -6, 0, 0, 0, -2, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, -18, 0, 0, 0, 0, 0, 0, 19, 0, -5, 0, 0, -1], [1, 0, 11, 0, 0, 0, -16, 2, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 6, 0, 0, 0, 13, 0, 0, 0, 0, -4, 1, 0], [0, 0, 0, -6, 0, 0, 0, 0, 0, 0, -8, 0, -12, 0, 0, 0], [-9, 0, 3, 0, 0, 0, -12, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0, 0, 8, 0, 5, 0, 0, 0, 0], [0, -5, 0, 0, 0, -6, 0, 0, 0, 16, 0, 6, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 4, 0, 0, 0, 0, -6, -6, 0], [0, 0, 0, 0, -6, 0, 0, 0, 27, 0, 0, 0, 0, 5, -7, 0], [0, 0, 0, 10, 0, 0, 0, 0, 0, 0, -18, 0, 0, 0, 0, 2]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_1840_i_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_1840_2_i_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_1840_2_i_a(:prec:=16)
    chi := MakeCharacter_1840_i();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 2));
    S := BaseChange(S, Kf);
    maxprec := NextPrime(1999) - 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_1840_2_i_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_1840_2_i_a( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_1840_i();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<3,R![100, 0, 283, 0, 128, 0, 20, 0, 1]>],Snew);
    return Vf;
end function;