a Code for the Combination of Indirect and Direct Constraints on High Energy Physics Models Logo
Polylogarithms.cpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2012 HEPfit Collaboration
3 *
4 *
5 * For the licensing terms see doc/COPYING.
6 */
7
8#include <cstdlib>
9#include <stdexcept>
10#include <cmath>
11#include <gsl/gsl_complex.h>
12#include <gsl/gsl_sf.h>
13#include "Polylogarithms.h"
14
15
17{
18}
19
21
22gslpp::complex Polylogarithms::Li2(const double x) const
23{
24 gsl_sf_result re, im;
25 gsl_sf_complex_dilog_xy_e(x, 0.0, &re, &im);
26 return gslpp::complex(re.val, im.val, false);
27}
28
29gslpp::complex Polylogarithms::Li2(const gslpp::complex z) const
30{
31 gsl_sf_result re, im;
32 gsl_sf_complex_dilog_xy_e(z.real(), z.imag(), &re, &im);
33 return gslpp::complex(re.val, im.val, false);
34}
35
36double Polylogarithms::Li3(const double x) const
37{
38 double Li3 = 0.0;
39 if (x < 0.0)
40 Li3 = -gsl_sf_fermi_dirac_2(log(-x));
41 else if (x == 0.0)
42 Li3 = 0.0;
43 else if (x > 0.0 && x < 0.5) {
44 double log_1mx = log(1.0 - x);
45 double lfactorial = 1.0, kfactorial = 1.0;
46 for (int l=0; l<19; l++) {
47 if (l!=0) lfactorial *= (double)l;
48 kfactorial = 1.0;
49 for (int k=0; k<19; k++) {
50 if (k!=0) kfactorial *= (double)k;
51 Li3 += B[l]*B[k]/((double)l+1.0)/((double)l+(double)k+1.0)
52 /lfactorial/kfactorial
53 * pow(-log_1mx, (double)l+(double)k+1.0);
54 }
55 }
56 } else if (x == 0.5) {
57 double log2 = log(2.0);
58 double zeta3 = gsl_sf_zeta_int(3);
59 Li3 = (4.0*pow(log2, 3.0) - 2.0*M_PI*M_PI*log2 + 21.0*zeta3)/24.0;
60 } else if (x > 0.5 && x < 1.0) {
61 double log_x = log(x);
62 double S12 = 0.0, lfactorial = 1.0;
63 for (int l=0; l<19; l++) {
64 if (l!=0) lfactorial *= (double)l;
65 S12 += 0.5 * B[l]/((double)l+2.0)/lfactorial
66 * pow(-log_x, (double)l+2.0);
67 }
68 Li3 = - S12 - log_x*gsl_sf_dilog(1.0-x) - 0.5*log_x*log_x*log(1.0-x)
69 + gsl_sf_zeta_int(2)*log_x + gsl_sf_zeta_int(3);
70 } else if (x == 1.0)
71 Li3 = gsl_sf_zeta_int(3);
72 else
73 throw std::runtime_error("Polylogarithms::Li3(): x is out of range!");
74 return (Li3);
75}
76
77
78
double B[19]
the Bernoulli numbers
double Li3(const double x) const
The trilogarithm .
Polylogarithms()
The default constructor.
gslpp::complex Li2(const double x) const
The dilogarithm with a real argument, .