ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sun, 28 Jul 2013 11:04:56 -0500Hadamard product for the Riemann zeta functionhttp://ask.sagemath.org/question/10390/hadamard-product-for-the-riemann-zeta-function/What is the best way to compute numerically with Sage the product
over the first n nontrivial zeros of the Riemann zeta function?
<pre><code>p(s,n) = product((1-s/rho(k))*exp(s/rho(k)) for k in (1..n))</code></pre>
where zeta(rho(k)) == 0 and Im(rho(k)) != 0.
Wikipedia advises: "To ensure convergence the product should be
taken over 'matching pairs' of zeroes, i.e. the factors for a
pair of zeroes of the form rho(k) and 1-rho(k) should be combined."
[Hadamard product on MathWorld](http://mathworld.wolfram.com/HadamardProduct.html)
Fri, 26 Jul 2013 06:42:03 -0500http://ask.sagemath.org/question/10390/hadamard-product-for-the-riemann-zeta-function/Answer by slelievre for <p>What is the best way to compute numerically with Sage the product
over the first n nontrivial zeros of the Riemann zeta function?</p>
<p></p><pre><code>p(s,n) = product((1-s/rho(k))*exp(s/rho(k)) for k in (1..n))</code></pre><p></p>
<p>where zeta(rho(k)) == 0 and Im(rho(k)) != 0. </p>
<p>Wikipedia advises: "To ensure convergence the product should be
taken over 'matching pairs' of zeroes, i.e. the factors for a
pair of zeroes of the form rho(k) and 1-rho(k) should be combined."</p>
<p><a href="http://mathworld.wolfram.com/HadamardProduct.html">Hadamard product on MathWorld</a></p>
http://ask.sagemath.org/question/10390/hadamard-product-for-the-riemann-zeta-function/?answer=15279#post-id-15279First you need to install Odlyzko's database of zeta zeros. In a terminal, type:
$ sage -i database_odlyzko_zeta
The command
sage: zeta_zeros()
will then give you a list of the *imaginary parts* of the first 100,000 non trivial zeros of zeta. Note that as usual, the list is indexed from 0.
The [information page](http://www.sagemath.org/doc/reference/databases/sage/databases/odlyzko.html)
about this package also warns:
*Note that only the first 9 digits after the decimal come from the database. Subsequent digits are the result of the inherent imprecision of a binary representation of decimal numbers.*
So you should have that in mind and check how this affects precision in your product.
Then you can do the following:
sage: def rho(k):
....: return CC(0.5,zeta_zeros()[k])
....:
sage: def a(x):
....: return (CC(1.,0.)-x)*exp(x)
....:
sage: def p(s,n):
....: return prod(a(s/rho(k))*a(s/(CC(1.,0.)-rho(k))) for k in (0..n))
....:
sage: p(0.5,2)
1.00221605640651
sage: p(0.5,20)
1.00403653183532
sage: p(0.5,200)
1.00527298745769
sage: p(0.5,2000)
1.00567828272459
If you plan to use large values of `n`, you might want to use Cython to speed up computation, but you should probably first check what precision the computations really give you.
Sat, 27 Jul 2013 06:31:18 -0500http://ask.sagemath.org/question/10390/hadamard-product-for-the-riemann-zeta-function/?answer=15279#post-id-15279Comment by petropolis for <p>First you need to install Odlyzko's database of zeta zeros. In a terminal, type:</p>
<pre><code>$ sage -i database_odlyzko_zeta
</code></pre>
<p>The command</p>
<pre><code>sage: zeta_zeros()
</code></pre>
<p>will then give you a list of the <em>imaginary parts</em> of the first 100,000 non trivial zeros of zeta. Note that as usual, the list is indexed from 0.</p>
<p>The <a href="http://www.sagemath.org/doc/reference/databases/sage/databases/odlyzko.html">information page</a>
about this package also warns:
<em>Note that only the first 9 digits after the decimal come from the database. Subsequent digits are the result of the inherent imprecision of a binary representation of decimal numbers.</em>
So you should have that in mind and check how this affects precision in your product.</p>
<p>Then you can do the following:</p>
<pre><code>sage: def rho(k):
....: return CC(0.5,zeta_zeros()[k])
....:
sage: def a(x):
....: return (CC(1.,0.)-x)*exp(x)
....:
sage: def p(s,n):
....: return prod(a(s/rho(k))*a(s/(CC(1.,0.)-rho(k))) for k in (0..n))
....:
sage: p(0.5,2)
1.00221605640651
sage: p(0.5,20)
1.00403653183532
sage: p(0.5,200)
1.00527298745769
sage: p(0.5,2000)
1.00567828272459
</code></pre>
<p>If you plan to use large values of <code>n</code>, you might want to use Cython to speed up computation, but you should probably first check what precision the computations really give you.</p>
http://ask.sagemath.org/question/10390/hadamard-product-for-the-riemann-zeta-function/?comment=17232#post-id-17232Nice. Thanks!Sat, 27 Jul 2013 08:12:01 -0500http://ask.sagemath.org/question/10390/hadamard-product-for-the-riemann-zeta-function/?comment=17232#post-id-17232Comment by slelievre for <p>First you need to install Odlyzko's database of zeta zeros. In a terminal, type:</p>
<pre><code>$ sage -i database_odlyzko_zeta
</code></pre>
<p>The command</p>
<pre><code>sage: zeta_zeros()
</code></pre>
<p>will then give you a list of the <em>imaginary parts</em> of the first 100,000 non trivial zeros of zeta. Note that as usual, the list is indexed from 0.</p>
<p>The <a href="http://www.sagemath.org/doc/reference/databases/sage/databases/odlyzko.html">information page</a>
about this package also warns:
<em>Note that only the first 9 digits after the decimal come from the database. Subsequent digits are the result of the inherent imprecision of a binary representation of decimal numbers.</em>
So you should have that in mind and check how this affects precision in your product.</p>
<p>Then you can do the following:</p>
<pre><code>sage: def rho(k):
....: return CC(0.5,zeta_zeros()[k])
....:
sage: def a(x):
....: return (CC(1.,0.)-x)*exp(x)
....:
sage: def p(s,n):
....: return prod(a(s/rho(k))*a(s/(CC(1.,0.)-rho(k))) for k in (0..n))
....:
sage: p(0.5,2)
1.00221605640651
sage: p(0.5,20)
1.00403653183532
sage: p(0.5,200)
1.00527298745769
sage: p(0.5,2000)
1.00567828272459
</code></pre>
<p>If you plan to use large values of <code>n</code>, you might want to use Cython to speed up computation, but you should probably first check what precision the computations really give you.</p>
http://ask.sagemath.org/question/10390/hadamard-product-for-the-riemann-zeta-function/?comment=17225#post-id-17225If you need more precision but not too high `n`, [Odlyzko's tables](http://www.dtc.umn.edu/~odlyzko/zeta_tables/index.html)
include one of imaginary parts of the first 100 zeros of
the Riemann zeta function, accurate to over 1000 decimal places.Sun, 28 Jul 2013 11:04:56 -0500http://ask.sagemath.org/question/10390/hadamard-product-for-the-riemann-zeta-function/?comment=17225#post-id-17225