# Routines for computing special values of L-functions¶

Compute $$k$$-th Bernoulli number for the primitive quadratic character associated to $$\chi(x) = \left(\frac{d}{x}\right)$$.

EXAMPLES:

Let us create a list of some odd negative fundamental discriminants:

sage: test_set = [d for d in range(-163, -3, 4) if is_fundamental_discriminant(d)]


In general, we have $$B_{1, \chi_d} = -2 h/w$$ for odd negative fundamental discriminants:

sage: all(QuadraticBernoulliNumber(1, d) == -len(BinaryQF_reduced_representatives(d)) for d in test_set)
True


REFERENCES:

Evaluates the exact value of the $$\Gamma$$ function at an integer or half-integer argument.

EXAMPLES:

sage: gamma__exact(4)
6
sage: gamma__exact(3)
2
sage: gamma__exact(2)
1
sage: gamma__exact(1)
1

sage: gamma__exact(1/2)
sqrt(pi)
sage: gamma__exact(3/2)
1/2*sqrt(pi)
sage: gamma__exact(5/2)
3/4*sqrt(pi)
sage: gamma__exact(7/2)
15/8*sqrt(pi)

sage: gamma__exact(-1/2)
-2*sqrt(pi)
sage: gamma__exact(-3/2)
4/3*sqrt(pi)
sage: gamma__exact(-5/2)
-8/15*sqrt(pi)
sage: gamma__exact(-7/2)
16/105*sqrt(pi)


TESTS:

sage: gamma__exact(1/3)
Traceback (most recent call last):
...
TypeError: you must give an integer or half-integer argument


Returns the exact value of a quadratic twist of the Riemann Zeta function by $$\chi_d(x) = \left(\frac{d}{x}\right)$$.

The input $$n$$ must be a critical value.

EXAMPLES:

sage: quadratic_L_function__exact(1, -4)
1/4*pi
5/2


TESTS:

sage: quadratic_L_function__exact(2, -4)
Traceback (most recent call last):
...
TypeError: n must be a critical value (i.e. odd > 0 or even <= 0)


REFERENCES:

Evaluate the Dirichlet L-function (for quadratic character) numerically (in a very naive way).

EXAMPLES:

First, let us test several values for a given character:

sage: RR = RealField(100)
sage: for i in range(5):
...       print "L(" + str(1+2*i) + ", (-4/.)): ", RR(quadratic_L_function__exact(1+2*i, -4)) - quadratic_L_function__numerical(RR(1+2*i),-4, 10000)
L(1, (-4/.)):  0.000049999999500000024999996962707
L(3, (-4/.)):  4.99999970000003...e-13
L(5, (-4/.)):  4.99999922759382...e-21
L(7, (-4/.)):  ...e-29
L(9, (-4/.)):  ...e-29


This procedure fails for negative special values, as the Dirichlet series does not converge here:

sage: quadratic_L_function__numerical(-3,-4, 10000)
Traceback (most recent call last):
...
ValueError: the Dirichlet series does not converge here


Test for several characters that the result agrees with the exact value, to a given accuracy

sage: for d in range(-20,0):  # long time (2s on sage.math 2014)
....:         print "Oops!  We have a problem at d = ", d, "    exact = ", RR(quadratic_L_function__exact(1, d)), "    numerical = ", RR(quadratic_L_function__numerical(1, d))


Returns the exact value of the Riemann Zeta function

The argument must be a critical value, namely either positive even or negative odd.

See for example [Iwasawa], p13, Special value of $$\zeta(2k)$$

EXAMPLES:

Let us test the accuracy for negative special values:

sage: RR = RealField(100)
sage: for i in range(1,10):
...       print "zeta(" + str(1-2*i) + "): ", RR(zeta__exact(1-2*i)) - zeta(RR(1-2*i))
zeta(-1):  0.00000000000000000000000000000
zeta(-3):  0.00000000000000000000000000000
zeta(-5):  0.00000000000000000000000000000
zeta(-7):  0.00000000000000000000000000000
zeta(-9):  0.00000000000000000000000000000
zeta(-11):  0.00000000000000000000000000000
zeta(-13):  0.00000000000000000000000000000
zeta(-15):  0.00000000000000000000000000000
zeta(-17):  0.00000000000000000000000000000


Let us test the accuracy for positive special values:

sage: all(abs(RR(zeta__exact(2*i))-zeta(RR(2*i))) < 10**(-28) for i in range(1,10))
True


TESTS:

sage: zeta__exact(5)
Traceback (most recent call last):
...
TypeError: n must be a critical value (i.e. even > 0 or odd < 0)


REFERENCES:

 [Iwasawa] (1, 2, 3) Iwasawa, Lectures on p-adic L-functions
 [IreRos] Ireland and Rosen, A Classical Introduction to Modern Number Theory
 [WashCyc] Washington, Cyclotomic Fields