
// Make newform 847.2.b.e in Magma, downloaded from the LMFDB on 19 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_847_b();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_847_b_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_847_2_b_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_847_2_b_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 := [1252, -2032, 2112, 16, -2612, 1800, 1664, -1936, -462, 968, 32, -288, 26, 48, -8, -4, 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], [45100255204451442, -68019234201392832, 22376006410770642, 45804279696326656, -46968185611381616, -17882135837919002, 39948241880711572, 3309641403668932, -15020743812702819, -791857644457854, 3420001305687324, 124186019484892, -426120789560307, -21271288918721, 33412641339072, -1806236810424], [625351269035571198, 1553865884087417224, -2515081103771166870, -999711612316333720, 2794748912367024884, 559753195558809430, -1638942080886189696, -186901941452851238, 559574244918250357, 34344959360432404, -110409382788319495, -3376523454252486, 11075219895323697, 394285081798624, -258387126282021, -118561841142667], [-1445454391303932166, 2123303416347802048, 427019367761917416, -2995782885963161152, 842688297290520002, 1846906049735482844, -913678225587381786, -839981856233667904, 425990905546002689, 243073021746734110, -109588363761678783, -43490965664325910, 15827200815118652, 4032523449595915, -1052658662623185, -147861519361595], [-657582084604824454, 900669272610036840, 1297866861892009338, -2658605579917768088, -654781641764962126, 2569097164393335486, -257422080833817172, -1292414113275723678, 358286836648461350, 355041013077341522, -149976475235078035, -48485068224744562, 30207096081366034, 1259101271762677, -2641187613864247, 335015184264499], [-3431350478782242, 6162494629111028, 9950766815793644, -15944799250036648, -27880380362172282, 32116177816861078, 11950173123349290, -21715539074948568, -4643591183144488, 9007677824243690, 930762133108183, -2069849602607900, -124417974421783, 283299612034374, -8185822681324, -11845355524648], [-16953126444816472, 28223231587510280, -15906229879009536, -12430545418044632, 47139720384856296, -35688154451700508, -40751494583154584, 37335803035848092, 18089878556151433, -16826031129469600, -3714091342323348, 3861654034082500, 283428795844833, -453609661960810, 23807655997484, 11917111215328], [-981825396029938292, 599130875550547332, -1235815225180964784, -2753924372503515628, 3123323012897178608, 2424010582687315882, -2775319981535112788, -1109160008265371288, 1334154943952591089, 302891721614703524, -394724375485896057, -37806769628355878, 67256821086151432, -606290786085145, -5858565368540612, 793929381913919], [41355316935864360, 47000942610281696, -57802642839937912, 23554149694989280, 30814487259973294, -35752779922795052, -18267893574259336, 20631359194590520, 10112854118207502, -6269728099143920, -4041812925203160, 1411845781359376, 864208450258039, -225696122558276, -94322220582592, 27011392152086], [-665557302469533080, 241690618524009152, -967356194834958860, -516066212605296160, 790598965925279948, 965203421611402430, -167587573181230524, -743890408721857828, -102679862645010379, 309113289528073360, 70202500555950795, -79828976495748052, -17511147516168121, 12326969218594081, 1883112160309661, -1041050542786427], [1021745261695028818, -1705583514667140808, 1757957122926958226, -817379137488037320, -2899284516772344726, 1590717249785072770, 2035761231703905550, -1274513591566924010, -792030723087262350, 488542619069434468, 197563567893022495, -115348535984880472, -28525635810104525, 15178169896398695, 2325108353514161, -1137180982991043], [-30791568858, 47341082576, -60722092488, -53956458496, 107312843204, 13487030188, -81131009856, 10209749788, 33880570978, -8477282916, -8222343940, 2710209516, 1098954297, -429812678, -60484224, 27586196], [1440089191177976230, -943713616354830420, 1051063137176443622, 486077504004089848, -1380488957184649542, -60977283517438792, 1497740867080358982, -188471301222042982, -862239054546140538, 90713215492777030, 316475238016347160, -42649308628937256, -62122077139526184, 10337141022496773, 6314718842342630, -1549128975238964], [813898617538197770, -410107163164174620, -218354411962649438, 486865719770756060, -2924922837458881732, -665155168648250026, 3551279443421674138, 344943688319938954, -1966222733092638378, -30913172570058186, 597078317822983527, -38066114907204286, -100304130203271990, 14104831421626899, 7724437466959080, -1747168649395759], [-53446090927838356, 63603018581143996, -53908970791502632, -5003877115303152, 120450959564895102, -20250999264187344, -115953298850201170, 25363499237715320, 55516738907773282, -12261418571569996, -16314115840737316, 3821157528032188, 2686380243178753, -657627068184028, -229996243725450, 65540689755620], [59846398429104566, -85982174975796068, -2263846659510274, 89490152468439968, -82967315362663904, -52157579306454274, 93540366552406226, 6644012212648884, -51675862451587651, 5380772843062716, 16534921958206198, -3246497926276112, -2917945396268176, 725706845851137, 246212044566059, -75710870805340]];
    Rf_basisdens := [1, 28235118674856242, 1044699390969680954, 1044699390969680954, 1044699390969680954, 28235118674856242, 28235118674856242, 1044699390969680954, 28235118674856242, 1044699390969680954, 1044699390969680954, 22992599138, 1044699390969680954, 1044699390969680954, 28235118674856242, 28235118674856242];
    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_847_b();"
function MakeCharacter_847_b()
    N := 847;
    order := 2;
    char_gens := [122, 365];
    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;

// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_847_b_Hecke();"
function MakeCharacter_847_b_Hecke(Kf)
    N := 847;
    order := 2;
    char_gens := [122, 365];
    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]];
    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, -1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9, 0, 9, 0, 0, 5, 0, 0, 0, 0], [-4, 0, 0, 0, 0, 0, -3, 0, 5, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 5, -1, 0, 0, 0, 0, 0, -4, 0, 0, 5, 0, 0], [0, 0, 16, 0, 0, 0, 0, -2, 0, -1, 0, 0, -7, 0, 0, 0], [-1, 0, 0, 0, 0, 0, -10, 0, 3, 0, 0, 10, 0, 0, 0, 0], [0, -18, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, -6, -5], [0, 0, -2, 0, 0, 0, 0, -6, 0, 16, 0, 0, -3, 0, 0, 0], [-19, 0, 0, 0, 0, 0, -8, 0, 5, 0, 0, 12, 0, 0, 0, 0], [0, 0, 0, -5, -7, 0, 0, 0, 0, 0, 10, 0, 0, -3, 0, 0], [2, 0, 0, 0, 0, 0, -3, 0, -1, 0, 0, -2, 0, 0, 0, 0], [0, 0, 13, 0, 0, 0, 0, 2, 0, -7, 0, 0, -5, 0, 0, 0], [0, -7, 0, 0, 0, 15, 0, 0, 0, 0, 0, 0, 0, 0, -3, -4], [0, 9, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 5, 11], [0, 0, 1, 0, 0, 0, 0, 4, 0, -16, 0, 0, -5, 0, 0, 0], [0, 0, 0, -12, 5, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0], [0, 0, 0, -3, -8, 0, 0, 0, 0, 0, 3, 0, 0, -10, 0, 0], [0, 0, 0, 2, -22, 0, 0, 0, 0, 0, -3, 0, 0, -2, 0, 0], [0, 0, 18, 0, 0, 0, 0, -6, 0, -7, 0, 0, -4, 0, 0, 0], [0, 0, 0, -6, 2, 0, 0, 0, 0, 0, -17, 0, 0, -3, 0, 0], [0, 0, 0, -16, -5, 0, 0, 0, 0, 0, 16, 0, 0, -4, 0, 0], [0, 1, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, -2, 5], [0, -17, 0, 0, 0, -7, 0, 0, 0, 0, 0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13, -6], [0, -2, 0, 0, 0, -19, 0, 0, 0, 0, 0, 0, 0, 0, 8, 1], [0, 0, 14, 0, 0, 0, 0, -6, 0, 2, 0, 0, -20, 0, 0, 0], [0, 0, 0, 3, -7, 0, 0, 0, 0, 0, -15, 0, 0, 0, 0, 0], [0, 0, 0, -1, -7, 0, 0, 0, 0, 0, -5, 0, 0, -4, 0, 0], [-4, 0, 0, 0, 0, 0, 8, 0, -2, 0, 0, -20, 0, 0, 0, 0], [14, 0, 0, 0, 0, 0, -2, 0, -15, 0, 0, -4, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0, 8, 0, -11, 0, 0, 7, 0, 0, 0], [0, 0, -19, 0, 0, 0, 0, 4, 0, 4, 0, 0, 1, 0, 0, 0], [0, -2, 0, 0, 0, -3, 0, 0, 0, 0, 0, 0, 0, 0, -13, -2], [0, 0, -23, 0, 0, 0, 0, 2, 0, 28, 0, 0, 11, 0, 0, 0], [0, 10, 0, 0, 0, 19, 0, 0, 0, 0, 0, 0, 0, 0, -3, 0], [0, 0, 0, 1, 22, 0, 0, 0, 0, 0, -6, 0, 0, -6, 0, 0], [0, 0, 7, 0, 0, 0, 0, 8, 0, -1, 0, 0, -5, 0, 0, 0], [0, 0, 0, 2, 17, 0, 0, 0, 0, 0, -10, 0, 0, 0, 0, 0], [16, 0, 0, 0, 0, 0, -8, 0, 4, 0, 0, 14, 0, 0, 0, 0], [0, 0, 0, 14, -2, 0, 0, 0, 0, 0, -21, 0, 0, 3, 0, 0], [0, 9, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, -9, -2], [0, 17, 0, 0, 0, 19, 0, 0, 0, 0, 0, 0, 0, 0, 9, 11], [0, 0, 17, 0, 0, 0, 0, 0, 0, -6, 0, 0, -2, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1, 0, 24, 0, 0, -1, 0, 0, 0], [0, -23, 0, 0, 0, -10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [-15, 0, 0, 0, 0, 0, -12, 0, -7, 0, 0, -8, 0, 0, 0, 0], [0, 0, 0, 0, 9, 0, 0, 0, 0, 0, -5, 0, 0, -3, 0, 0], [0, 9, 0, 0, 0, -22, 0, 0, 0, 0, 0, 0, 0, 0, 17, -2], [-8, 0, 0, 0, 0, 0, 21, 0, -4, 0, 0, -19, 0, 0, 0, 0], [0, 0, -7, 0, 0, 0, 0, 6, 0, -12, 0, 0, -1, 0, 0, 0], [8, 0, 0, 0, 0, 0, -6, 0, 2, 0, 0, 15, 0, 0, 0, 0], [-2, 0, 0, 0, 0, 0, 4, 0, 5, 0, 0, 9, 0, 0, 0, 0], [0, 0, 0, 0, -10, 0, 0, 0, 0, 0, 6, 0, 0, -11, 0, 0], [0, 29, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, -4, -3], [0, 0, -15, 0, 0, 0, 0, -1, 0, 12, 0, 0, -2, 0, 0, 0], [0, 0, -7, 0, 0, 0, 0, 19, 0, -10, 0, 0, 0, 0, 0, 0], [24, 0, 0, 0, 0, 0, 0, 0, -6, 0, 0, -14, 0, 0, 0, 0], [0, 0, 0, -4, -24, 0, 0, 0, 0, 0, -3, 0, 0, 0, 0, 0], [0, 0, 0, 11, 2, 0, 0, 0, 0, 0, -19, 0, 0, -1, 0, 0], [0, 22, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, -4, 14], [9, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, -8, 0, 0, 0, 0], [0, -23, 0, 0, 0, -23, 0, 0, 0, 0, 0, 0, 0, 0, 4, -2], [-10, 0, 0, 0, 0, 0, 7, 0, -3, 0, 0, -15, 0, 0, 0, 0], [0, 0, -1, 0, 0, 0, 0, 13, 0, -1, 0, 0, 23, 0, 0, 0]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_847_b_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_847_2_b_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_847_2_b_e(:prec:=16)
    chi := MakeCharacter_847_b();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 2));
    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_847_2_b_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_847_2_b_e( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_847_b();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<2,R![1, 0, 60, 0, 47, 0, 12, 0, 1]>],Snew);
    return Vf;
end function;