Bill Allombert on Mon, 22 Apr 2019 23:08:34 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: Help understanding generating functions, (partitioning n into k parts)


On Sat, Apr 20, 2019 at 08:53:35PM -0500, Hans L wrote:
> I have adapted some equations for some small k values which are:
> T(n,1)=1
> T(n,2)=floor(n/2))
> T(n,3)=floor((n^2+6)/12)
> T(n,4)=floor((n^3+3*n^2-9*n*(n%2)+72)/144)
> T(n,5)=floor((n^4+10*(n^3+n^2)-75*n-45*n*(-1)^n+1440)/2880)
> 
> I actually don't know how these equations are determined beyond k=2, but I
> found them from various OEIS pages.  My ultimate goal is to implement such
> a function in C using GMP or FLINT arbitrary precision libraries, but I'm
> using PARI as testing ground for getting the formulas right.
> I use the floor function and add half the denominator for these(as opposed
> to calling round(...), which is how they were originally written), since
> this will translate better into integer division when I write the code for
> GMP.  I'm also slightly skeptical of the rounding in these formula and I'm
> not certain that they will hold true (with error < 1) for any arbitrarily
> large n.  Does the math always work out correctly that way?

If you do the computation using integer or rational arithmetic, I expect
the formulae to hold.

Cheers,
Bill