| Bill Allombert on Fri, 17 Apr 2026 12:03:22 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
| Re: numbpart(n, {a = k}) |
On Fri, Apr 17, 2026 at 08:55:23AM +0200, Ruud H.G. van Tol wrote:
>
> For https://oeis.org/A046682, I created this code:
>
> first(nn) = {
> my( v = Vec( 1 / prod( k=1, nn, 1+(-x)^k, 1+x*O(x^nn) ) ) );
> vector( nn, i, ( numbpart(i-1) + v[i] ) / 2 );
> }
> This takes about a minute to return 10k values.
>
> Is there a faster way to initialize v?
Yes. There is a formula which is missing from the OEIS, you should probably add it:
The generating series is
Phi(-x)/Phi(x^2) + 1/Phi(x))/2
where Phi is the Euler function mentionned in https://en.wikipedia.org/wiki/Dedekind_eta_function
which admits a lacunary series and can be computed in GP using eta().
So the formula in GP is simply:
first2(nn) = Vec(eta(-x+O(x^nn))/eta(x^2+O(x^nn)) + 1/eta(x+O(x^(nn))))/2
? first2(10000);
*** last result computed in 75 ms.
? first2(100000);
*** last result computed in 3,004 ms.
Similarly if you want all numbpart up to n, you should just compute
1/eta(x+O(x^(n+1)))
> Would a variant numbpart(n, {a = k}) be interesting, like Maple has?
> With the optional a-parameter like with partitions(k, {a = k}, {n = k}).
numbpart use Rademacher formula, which is much faster than #partitions(n) but is
only valid for partitions(n,,).
I do not know fast formula for the other cases.
For example pari can compute numbpart(1000000) in 5 ms
How far Maple can go?
Cheers,
Bill.