ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 05 Aug 2013 12:36:58 +0200Coefficients of infinite polynomial productshttps://ask.sagemath.org/question/10413/coefficients-of-infinite-polynomial-products/I would first like to ask if there are commands for computing infinite products,
$$eg.\quad g=q \prod_{n=1}^{\infty} (1-q^{8n})(1-q^{16n}).$$
If not, are there commands for finite products then? How do you compute
$$\quad g=q \prod_{n=1}^{N} (1-q^{8n})(1-q^{16n})?$$
Basically, I'm only interested in the coefficients of $g\theta_2$ and $g\theta_4$ where $g$ is as above and $\theta_t=\sum^{\infty}_{-\infty}q^{tn^2}$.
This link to [OEIS](http://oeis.org/A034950) seems to have a code for generating $g\theta_2$ in PARI, I always thought that SAGE is able to call pari, but I'm unable to perform the command on SAGE.
I'll appreciate it if anyone can advise me how best to do this or direct me to any resources, thanks!Mon, 05 Aug 2013 10:29:33 +0200https://ask.sagemath.org/question/10413/coefficients-of-infinite-polynomial-products/Answer by Luca for <p>I would first like to ask if there are commands for computing infinite products, </p>
<p>$$eg.\quad g=q \prod_{n=1}^{\infty} (1-q^{8n})(1-q^{16n}).$$</p>
<p>If not, are there commands for finite products then? How do you compute
$$\quad g=q \prod_{n=1}^{N} (1-q^{8n})(1-q^{16n})?$$</p>
<p>Basically, I'm only interested in the coefficients of $g\theta_2$ and $g\theta_4$ where $g$ is as above and $\theta_t=\sum^{\infty}_{-\infty}q^{tn^2}$. </p>
<p>This link to <a href="http://oeis.org/A034950">OEIS</a> seems to have a code for generating $g\theta_2$ in PARI, I always thought that SAGE is able to call pari, but I'm unable to perform the command on SAGE.</p>
<p>I'll appreciate it if anyone can advise me how best to do this or direct me to any resources, thanks!</p>
https://ask.sagemath.org/question/10413/coefficients-of-infinite-polynomial-products/?answer=15313#post-id-15313For finite products you can use the function `prod()`, like this:
sage: prod(range(1,42))
33452526613163807108170062053440751665152000000000L
What do you mean by "compute K number of times"?
There certainly is not a generic function to compute infinite product, but there might be functions to do what you have in mind. Have a look at the documentation of `eta` and `EtaProduct`, you can use the `?` syntax:
sage: eta?
...
sage: EtaProduct?
unfortunately, `eta` seems to accept only complex arguments.
You can use the function `gp()` to enter Pari code
sage: a = gp("a(n)=local(A); if(n<0, 0, A=x*O(x^n); polcoeff(eta(x^2+A)^5*eta(x^8+A)/(eta(x+A)^2*eta(x^4+A)), n))")
sage: [a(i) for i in range(10)]
[1, 2, 0, 0, 1, -2, 0, 0, -4, -2]
Mon, 05 Aug 2013 11:42:43 +0200https://ask.sagemath.org/question/10413/coefficients-of-infinite-polynomial-products/?answer=15313#post-id-15313Comment by Blackadder for <p>For finite products you can use the function <code>prod()</code>, like this:</p>
<pre><code>sage: prod(range(1,42))
33452526613163807108170062053440751665152000000000L
</code></pre>
<p>What do you mean by "compute K number of times"?</p>
<p>There certainly is not a generic function to compute infinite product, but there might be functions to do what you have in mind. Have a look at the documentation of <code>eta</code> and <code>EtaProduct</code>, you can use the <code>?</code> syntax:</p>
<pre><code>sage: eta?
...
sage: EtaProduct?
</code></pre>
<p>unfortunately, <code>eta</code> seems to accept only complex arguments.</p>
<p>You can use the function <code>gp()</code> to enter Pari code</p>
<pre><code>sage: a = gp("a(n)=local(A); if(n<0, 0, A=x*O(x^n); polcoeff(eta(x^2+A)^5*eta(x^8+A)/(eta(x+A)^2*eta(x^4+A)), n))")
sage: [a(i) for i in range(10)]
[1, 2, 0, 0, 1, -2, 0, 0, -4, -2]
</code></pre>
https://ask.sagemath.org/question/10413/coefficients-of-infinite-polynomial-products/?comment=17188#post-id-17188Hi Luca, thanks for answering. This is what I was looking for. As to your question, I've edited what I meant. Hopefully that would clear up any confusion.Mon, 05 Aug 2013 12:36:58 +0200https://ask.sagemath.org/question/10413/coefficients-of-infinite-polynomial-products/?comment=17188#post-id-17188