
// Make newform 70.8.a.a in Magma, downloaded from the LMFDB on 01 November 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_70_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_70_8_a_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_70_8_a_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
        Kf := Rationals();
    end if;
    return [Kf!elt[1] : elt in input];
end function;


// To make the character of type GrpDrchElt, type "MakeCharacter_70_a();"
function MakeCharacter_70_a()
    N := 70;
    order := 1;
    char_gens := [57, 31];
    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_70_a_Hecke(Kf)
    return MakeCharacter_70_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 := 8;
    raw_aps := [[8], [-93], [125], [343], [-2167], [-1661], [-35771], [20222], [-42130], [-111789], [-269504], [532774], [158056], [-521874], [-939733], [-408384], [-522172], [350080], [-3931176], [1194016], [998350], [-2120709], [-1746708], [-10077740], [-6238295], [4633050], [-9644905], [5682014], [24254401], [-3523438], [18031596], [15917730], [-24611932], [55834502], [23147898], [-73501477], [-70092430], [-28855530], [47076871], [80910553], [25415492], [19628072], [-60641891], [72555220], [-49966668], [45265916], [170783927], [144305463], [152288511], [-93134216], [28747832], [143827207], [418176510], [91400210], [-208667030], [-7310898], [-404584374], [132166872], [-156747694], [-84538093], [430617353], [49892613], [478054649], [-756686618], [471868195], [-711190826], [407293180], [918485666], [-1438010718], [-770969818], [962807865], [-1261498624], [-15843101], [-107114188], [-1889295692], [-866602260], [-965943051], [234950641], [-1925462847], [-1048805990], [-1961981832], [2197354825], [31556049], [-1024472178], [2866988954], [2689266262], [1764675455], [-3017508404], [-2124004352], [657270896], [3605167373], [45257922], [604176858], [-864288717], [-3181500707], [-3091564207], [-678826982], [-2114148486], [1764641276], [4762655843], [509834080], [-3254695072], [5202842844], [-2202754998], [4090295236], [5608092839], [2905972872], [4700185671], [2545687921], [-1916667142], [-8459605383], [-7932476806], [-3774358594], [3487109338], [-3448063503], [3815877090], [10269222715], [4084971968], [10015463962], [-308150539], [6468194840], [-5928905716], [8566626555], [1141897696], [2277659836], [-4904928465], [3691474003], [-13899867990], [-13835244912], [19163230455], [-6127433895], [-2042450688], [-1167530261], [-2278816192], [7990075966], [-19556523518], [-759460789], [5824496063], [11118372585], [19874628449], [-11089822326], [-21855511171], [19483440832], [-16155833118], [25931240384], [24316315206], [-15677915870], [-8890226090], [-19271098444], [30170999436], [-16252608694], [-23928077616], [27843290644], [13705714928], [8768878038], [-43114093584], [5249508799], [-11086408552], [-3002444583], [-6586762536], [18603457476], [5054531484], [4721014498], [-5913651276], [-841284474], [24374089489], [-28961350160], [-33607337659], [13818157757], [-25912747602], [-21231683992], [-37925712298], [52549908445], [-5951894242], [13973629862], [-47917256932], [-18638319883], [-44250679083], [-16959333700], [12981664536], [30711398956], [7023172748], [25184739238], [-52200207974], [-24710231908], [-14488386806], [-50845554860], [33880060835], [54854239481], [-89150688080], [-22108357762], [-50716606970], [-96286312877], [-99379716436], [-50843303844], [-57369581337], [-31447423585], [-81494524520], [48391768101], [-40049598513], [10578153534], [5997493878], [11943774374], [-43705679058], [-80559963134], [-10258341883], [81150560994], [43869670044], [-65589465370], [48232228368], [-100712487512], [49182366090], [31538817832], [-93861064041], [-40346667666], [15766522156], [-72673409938], [-168355564880], [99068740114], [-36722337742], [-94544834254], [61553008974], [166310551965], [-150605524334], [92442233911], [191759625166], [101344158217], [-52479532071], [-160083484121], [102200534052], [-5319590372], [-120800053006], [96852612072], [106313300049], [-54464223913], [100288236703], [-70656578444], [193815595048], [-34626533269], [-25254494078], [-163512704160], [21305508112], [-203441359557], [67937297750], [-57392648129], [-30191750854], [99528433304], [-99910766658], [167521020871], [263091843246], [-145266817478], [193584715398], [64642553472], [-122799725056], [-165539500422], [168501614973], [59597395958], [-169555982196], [-74155899045], [-3263322289], [-237618696626], [116533982894], [-11134757696], [316324400191], [-340730930770], [64308911994], [-263626511211], [321587005278], [-89182451224], [-50850303822], [-211512482084], [-134511682064], [400710969057], [122846623284], [-443447298630], [7113650003], [-115798172620], [-99639171670], [299646701737], [-399238708210], [339684395319], [-151562546725], [-2589254384], [-29693389346], [-343777600225], [153061259913], [413015433254], [2641291282], [-156286034816], [51298489920], [-36465414835], [-381971421379], [271235045764], [209751688056], [242015944314], [-241575756892], [216228368306], [-245062260381], [-38228161924], [-561162638141], [-366711424579], [424307985554], [-180271729795], [-60234046088], [-146055889837], [113540770718], [-143669509266], [297972868440], [-89665755432], [548982804740], [-718612944432], [-247789049057], [419212791342], [52054677510], [-659320005354], [691886581812], [253338768414], [-41902039783], [548299743709], [-33453695355], [-340902508526], [-540118704588], [-499834561206], [609821062480], [-733764170690], [113207653912], [546713154067], [463129629036], [585313988124], [721611904704], [294900227862], [-200492644680], [-402675670834], [-584895474007], [209316716972], [384509886987], [-30774680663], [-100541894418], [1102623630890], [137951253283], [-422048475746], [350577932852], [-40292863046], [123457849045], [-178235236918], [909585564596], [789059259942], [349258891492], [-658293567446], [-473051034799], [-548874860564], [-214126714304], [-336698766731], [611716140907], [-57371901123], [30676894114], [-1208635961070], [782413688830], [514082984394], [1035945276158], [1070422505544], [-282201928100], [575745860076], [606914755477], [576804986412], [-1001155976438], [-1237454348207], [-843439812198], [-1271937720899], [-661342795099], [582746761200], [645347135548], [-297299540777], [90345635666], [848548547114], [913422296480], [-1681021071931], [-514036977745], [-760769857738], [-389757299877], [-1257923776150], [-1511556050022], [-446632162384], [-1374989396534], [-1243296153724], [-1134068890361], [-1193069290015], [798623596939], [-855841214612], [1786970923029], [1222509862465], [-1155134679323], [373191772495], [-707617514444], [1531444940465], [551659873096], [645314680404], [1260759784228], [-1397532448447], [-277209749718], [1698192105388], [-1191318179240], [729502864366], [-1389130028535], [1848824429988], [1983495957766], [-1317165688914], [2024830299575], [1712536077636], [2087998796060], [-1554971977527], [-2269114152250], [1520915765706], [-1792099381268], [-1518780636270], [1923664463768], [1571530556217], [-1027007787116], [2372415801774], [-1835322487441], [1781668067537], [201860241954], [447564933954], [-1189601202972], [745372482683], [-102175271895], [575581016836], [-2034543415902], [1327709679268], [961665411216]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_70_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_70_8_a_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_70_8_a_a(:prec:=1)
    chi := MakeCharacter_70_a();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 8));
    S := BaseChange(S, Kf);
    maxprec := NextPrime(2999) - 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_70_8_a_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_70_8_a_a( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_70_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,8,sign)));
    Vf := Kernel([<3,R![93, 1]>],Snew);
    return Vf;
end function;