Evaluates the Riemann Zeta function.

You're viewing an older version of this page (#282). View the current version.

View versions (3)

Interface

#include <codecogs/maths/special/zeta.h>

using namespace Maths::Special;

This component estimates the Riemann Zeta function, which is defined by the series

$$\zeta(p) = \sum_{k=1}^{\infty} \frac{1}{k^p} \qquad p > 1$$
(1)

A graph for various values of the argument is displayed below.

1/maths_special_zeta.png

For integral values of p up to 20, a precomputed value of the function is returned, otherwise the infinite sum is used to approximate the result. In the following example, arguments from the [3, 4] interval are used, with step equal to 0.2, to evaluate the Zeta function.

Example 1

#include <codecogs/maths/special/zeta.h>
#include <iostream>
#include <iomanip>

int main()
{
  std::cout << std::setprecision(10);
  for (double x = 3; x < 5; x += 0.2)
  {
    std::cout << "Zeta(" << x << ") = ";
    std::cout << Maths::Special::zeta(x) << std::endl;
  }
  return 0;
}

Output

Zeta(3) = 1.202056903
Zeta(3.2) = 1.166773371
Zeta(3.4) = 1.138663776
Zeta(3.6) = 1.115989079
Zeta(3.8) = 1.097510576
Zeta(4) = 1.082323234
Zeta(4.2) = 1.069751477
Zeta(4.4) = 1.059281726
Zeta(4.6) = 1.050517383
Zeta(4.8) = 1.043148013

Reference

John Burkardt&#039;s library of statistical C++ routines, http://www.csit.fsu.edu/~burkardt/cpp_src/prob/prob.html

Parameters

p
the power to which the fractions are raised

Returns

An approximation of the Riemann Zeta function with the given parameter.
GPL Licence — free for non commercial use. See Licence details.

Interactive Calculator

p
Result