TITLE: Computing partition numbers
QUESTION [7 upvotes]: Today a friend and myself came up with the question of computing partitions of numbers, i.e.: given a number $n$, what is the number $p(n)$ of was of different ways writing $n$ as a sum of non-zero integers (where commuting two terms in the sum counts as a unique way)?
We know of no formulas to do this. I am currently trying to write a bruteforce (computational) approach to the problem, but I wanted to ask you about another more sophisticated way of attacking the problem (still with a computer).
It is well known that 
$$\sum_{n=0}^\infty p(n)x^n = \prod_{k=1}^\infty\frac{1}{1-x^k}$$
The idea we had is to proceed as follows:

$\log\left(\prod_{k=1}^\infty\frac{1}{1-x^k}\right) = -\sum_{k=1}^\infty\log(1-x^k) = -\sum_{k=1}^N\log(1-x^k) + O(x^{N+1})$ where we used the Taylor expansion of $\log$ around $1$ to get the error term.
$\prod_{k=1}^\infty\frac{1}{1-x^k}\approx \exp\left(\sum_{k=1}^N\log(1-x^k)\right) =: F(x)$ with some error term.
Evaluate $F$ for some $x$ close to zero (so that the higher order terms are no longer relevant) and use polyfit (least squares) to get the coefficient of $x^n$, i.e. $p(n)$.

Now my questions are the following:

Would this method (or something similar) work?
What would the error term in point (2.) look like?
How to choose $N$ and the points $x$ where we evaluate $F$ in step (3.) such that the error is less than, say $0.1$ in the end? Notice that the preceding question is closely related to this one.
What would be the complexity of the resulting algorithm?
How are the $p(n)$ computed usually?

Thank you in advance for the help.

REPLY [3 votes]: The answer may not be that what you want. I just thought that this could be an answer seeing your question.
You may know the recurrence relation $nP(n)=\sum\limits_{k=1}^n\sigma(k)P(n-k)$, where $\sigma(k)$ is sum of divisors function. This can easily be derived using generating functions of $P(n)$ and $\sigma(n)$. Also you may use Erdos's method: 
$nP(n)=\sum_{m=1}^n \sum_{k=1}^{n/m}mP(n-km)=\sum_{r=1}^nP(n-r)\sum_{m\mid r}m=\sum_{r=1}^nP(n-r)\sigma(r)$.
Now note that, you are having $n\ \text{linear equations}$ with variables $x_n=P(n)$ and coefficients $\sigma(n)$.
Using Cramer's rule you may find $P(n)=\frac{\det A_n}{\det B_n}$. It can easily be seen that $B_n$ is upper triangular and determinant of $B_n$ is $n!$.
Now, $A_n(i,1)=\sigma(i)$ and $A_n(j,j)=n-j+1\\A_n(i.j)=-\sigma(j-i), \text{if}\ i<j\\A_n(i,j)=0, \text{if}\ i>j$ for $j>1$.
I think computing $\det A_n$ is 'very difficult' but good in the sense $P(n)$ basically depends on prime factorization of $n$. If you wish to play with the determinant you may find some good recurrence relations, involving $\sigma (n)$'s.