I would like use Python to verify the following identities:

  • $ \frac{1}{1-z} = 1 + z + z^2 + z^3 + \dots $

  • $ \frac{1}{1-z - z^2} = 1 + z + 2z^2 + 3z^3 + \dots $

  • $ q \prod_{n \geq 1} (1 - q^n)^{24} = q - 24 q^2 + 252 q^3 + \dots$

The last one could be evaluated by checking the poly1d class in numpy.

Python doesn't seem to have a Laurent series or rational functions capability for the first two examples.

Perhaps there are numerical methods for generating these coefficients very quickly. I am not sure what a good data type for storing series with potentially negative exponents.

Another possibility might be to manipulate generators.

  • $\begingroup$ Do you mean that you want to verify the above equalities for any values of $z$ and $q$ or for specific values? $\endgroup$
    – Dominique
    Dec 28, 2013 at 0:00
  • $\begingroup$ try the web site Wolfram alpha. use the series command. very easy. $\endgroup$
    – Nasser
    Dec 28, 2013 at 6:38

1 Answer 1


I think you are looking for capabilities not available in Python itself nor Numpy, but that are available in SymPy. Sympy is a computer algebra package developed in Python. You can try it "live" in its on-line shell. Documentation on series development can be found here.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.