
// Make newform 525.8.a.a in Magma, downloaded from the LMFDB on 05 March 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_525_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_525_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_525_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_525_a();"
function MakeCharacter_525_a()
    N := 525;
    order := 1;
    char_gens := [176, 127, 451];
    v := [1, 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_525_a_Hecke( : Kf := Kf)
    return MakeCharacter_525_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 := [[-18], [27], [0], [-343], [-8016], [1786], [-8358], [-5884], [77700], [155742], [-310000], [433618], [357942], [724492], [-175320], [-132198], [2648628], [835478], [-3486308], [-2872260], [-5951882], [-1680904], [-3577524], [-6254826], [5257054], [15024954], [16006576], [-5301048], [-6463402], [14833302], [-13502360], [12247044], [-12399978], [-5954332], [-31099026], [-14327272], [58107154], [23600428], [-26580144], [70967070], [115061424], [-2260906], [-80713548], [-70793906], [-75347334], [-157565104], [-222118276], [-140214608], [113463204], [-100120090], [372064038], [-95095284], [-286367158], [55342260], [59774898], [123562212], [429280314], [-548961424], [-332835614], [-454456542], [-82184900], [-371449002], [459953332], [-494972784], [-359666018], [-184941774], [1025183636], [-1130727362], [-628828704], [905466662], [113857530], [271653708], [-1350926720], [1097673970], [-431536012], [-529317600], [-12700986], [1940867026], [1293349290], [-827345038], [-1688082468], [1246730318], [1418066916], [-2110644218], [-2436378256], [-2175989328], [-388947870], [3976212790], [3617197890], [-2410215368], [-1759775052], [-4187974344], [3659818696], [-3636136680], [651843356], [787013928], [-608920950], [-1123963122], [-4131649100], [-5152568074], [696991132], [-2889084606], [5014877508], [1911221730], [373937756], [-1915387418], [4104485724], [3091173738], [-9696119508], [2122385354], [-2112116288], [2419374418], [3533701542], [-171721180], [-10289307040], [11060578218], [1751548180], [-304738080], [-1910915286], [2669173368], [-1208890498], [-2653296002], [-9292624074], [-15201816144], [3495199580], [-13475557890], [-13716393346], [15236651568], [-8496613520], [-10298261606], [20192221604], [-12096632100], [-3495656992], [-12741999230], [5660769318], [13974723698], [12624621798], [22978617628], [-578645778], [-9578792262], [-22564822156], [-23352377202], [14843339248], [21866854824], [-16022502754], [-7374745632], [-29986078310], [-30759425382], [-16650808564], [-19856184708], [6359218618], [-13725063306], [-2434646396], [33217132944], [17127742348], [30859203156], [12306110312], [-28445789106], [40862617486], [15262192458], [23285888352], [-29808517698], [7130760160], [-43296924948], [-27744175170], [3012766008], [-26784547936], [24678396442], [797592674], [-21667795818], [-14121930768], [-13379568970], [-26476697460], [31649097286], [6044161208], [-18134023362], [37352266028], [-17704518906], [28924439632], [12463503254], [30330314776], [15748086660], [-63568573934], [-68657889198], [-80915475492], [62555082474], [-11016431606], [12817705708], [56823510650], [74708960928], [-78757582178], [72764154840], [-60856199908], [-91560445614], [54390087984], [55520554626], [8412057410], [-31523063030], [-79628170398], [-78846198672], [-20797957386], [69360894872], [45037782418], [-4908245446], [131870360556], [-3259560354], [101200962008], [147709075008], [50804662938], [-92888041252], [139632516574], [33271588722], [8611610248], [-158083421436], [-29800510560], [-12912503590], [-118224681152], [83848724742], [6571279284], [-90880641750], [-43557916162], [160062416168], [-145913895102], [-40504401056], [42622376460], [-30384711010], [198471123882], [-91679234628], [20164418704], [-44543664792], [-76872205958], [-32674140844], [-202968546736], [-164617785270], [-74901076532], [-47511520896], [109203853802], [169514402586], [35238384264], [35017775928], [-55140264840], [-59813644156], [-83047400024], [-237008951386], [44015701362], [-168246617760], [64947199624], [205327909980], [36864880700], [208942523388], [215921660458], [270101919702], [-179137809108], [-32242809358], [-103294879986], [40153087416], [229410197390], [-98091965204], [162470638566], [79630531198], [177048672184], [-62550597336], [250608511670], [75346668322], [-253917144486], [-122136633172], [-203964935274], [71034393678], [-401929257884], [-178808902830], [-163145546410], [132739880164], [198487697590], [217107067136], [-403382030306], [-330418215488], [-273370054344], [126577330550], [-8672829910], [411336301788], [3564754992], [-193068781744], [273449468280], [144603926270], [220096860052], [-538703160684], [257748875134], [-264929462022], [447302804264], [-111638022354], [-183763139082], [305897016396], [29582685462], [100670499300], [212309896330], [560333767266], [338843187800], [-51085085442], [13649393892], [-542747079476], [121980426862], [-84647651574], [-274868752120], [-294260831760], [650993854460], [633737362318], [174007868064], [-441982391890], [47393573100], [-106561148222], [-150204161376], [62033982630], [-402603765462], [-600619123004], [722615522292], [-673896187006], [781538205012], [239906738556], [-395865089378], [-663032676246], [-376965663148], [-503599301834], [50023380546], [819515805568], [-336328150386], [-182307570406], [361385030036], [-754508111732], [-191411066412], [15728650002], [324624736070], [1008552361050], [383175691568], [-56990930124], [874299706220], [-424205144100], [-316791400426], [396952920498], [-385339255150], [335420568088], [153581277682], [-815166885066], [371858028690], [500494608152], [599657705082], [534124672632], [-1215436110874], [-717482807396], [-542220236112], [-81853420602], [787944711092], [4659203878], [552235178838], [518714385472], [1014273576158], [472790962674], [-1342229191680], [-1238689313508], [474517990902], [-361931666676], [1349856205858], [-933950373642], [-687693290892], [-883199545344], [493803971836], [130719057958], [605044978806], [176824283920], [317023077530], [-320638285248], [-1212643596724], [441696614484], [548638885950], [-689050745464], [-67148708726], [-1288386359532], [-915940894500], [-437130477146], [1107310794870], [231271184278], [-825849913902], [436403237982], [385159113880], [324184962246], [269718429020], [-1868821908504], [-139251559168], [818211621010], [1525259599972], [-649822540584], [1563693042626], [789708064878], [1532914466784], [-1125439159004], [-468670044420], [-334869669914], [-1061508414616], [1248691745022], [-984094411828], [-1212107695722], [1591253310614], [-2084426688378], [784877263960], [-292833919014], [-1123790317950], [1718491068272], [-646877777894], [827972153250], [1414895648908], [637081029036], [968670449830], [259004100978], [1179986661504], [742552652492], [-349216017242], [1351956233226], [-976894980036], [-1975647566384], [2030296186890], [1977932689104], [153350485086], [514256333290], [2371131708564], [-1990738105620], [348884295838], [-669624509106], [882370860696], [-428627006046], [778645486964], [-20150856816]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_525_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_525_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_525_8_a_a(:prec:=1)
    chi := MakeCharacter_525_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_525_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_525_8_a_a( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_525_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,8,sign)));
    Vf := Kernel([<2,R![18, 1]>],Snew);
    return Vf;
end function;