Re: numbpart(n, {a = k})
"Ruud H.G. van Tol" <[email protected]> Sun, 19 Apr 2026 14:05:27 +0200
| Newsgroups | gmane.comp.mathematics.pari.user |
|---|---|
| Message-ID | <[email protected]> |
On 2026-04-17 15:14, Ruud H.G. van Tol wrote:
> On 2026-04-17 13:29, Bill Allombert wrote:
>> On Fri, Apr 17, 2026 at 12:03:17PM +0200, Bill Allombert wrote:
>> [...]
>>
>> first3(nn) =
>> {
>> my(E = eta(x+O(x^(nn))), Ei=1/E);
>> Vec(subst(E,x,-x)*subst(Ei+O(x^(nn\2)),x,x^2) + Ei)/2;
>> }
>
> Test:
> ? #first3(10001)
> # 10000
>
> first4(nn) = {
> my(E = eta(x+O(x^(nn))), Ei = 1/E);
> Vec( subst(E, x, -x) * subst( Ei + O(x^( nn\2 + 1 )), x, x^2) + Ei)/2;
> }
>
> Test:
> ? first2(10001) == first4(10001)
> # 1
>
> That is just great, thanks!
I now made it:
first5(nn)= {
my
( x= 'x
, E= eta(x+O(x^(nn)))
, Ei= 1/E
, ps= (subst(E, x, -x) * subst(Ei + O(x^(nn\2 + 1)), x, x^2) + Ei)/2
);
Vec(ps);
}
to hide any x in the environment, as gp-coders can mess of that up.
See https://oeis.org/history/view?seq=A046682&v=9999
for the latest state.
- - - - - - -
Then also mini-fied that to
first6(nn)= {
my
( x= 'x
, E= eta(x + O(x^nn))
, Ei= 1/E
, ps= (subst(E, x, -x) * subst(Ei, x, x^2) + Ei) / 2
);
Vec(ps);
}
Test:
? my(nn=9999); first5(nn) == first6(nn)
% 1
but first6 is less fast than first5.
-- Ruud