|
| 1 | +!********************************************************************* |
| 2 | +! This file is part of Polylogarithm. |
| 3 | +! |
| 4 | +! Polylogarithm is licenced under the MIT License. |
| 5 | +!********************************************************************* |
| 6 | + |
| 7 | +!********************************************************************* |
| 8 | +!> @brief Clausen function \f$\mathrm{Cl}_2(\theta) = \mathrm{Im}(\mathrm{Li}_2(e^{i\theta}))\f$ |
| 9 | +!> @param x real angle |
| 10 | +!> @return \f$\mathrm{Cl}_2(\theta)\f$ |
| 11 | +!> @author Alexander Voigt |
| 12 | +!> Implemented as economized Padé approximation. |
| 13 | +!********************************************************************* |
| 14 | + |
| 15 | +double precision function dcl2(x) |
| 16 | + implicit none |
| 17 | + double precision :: x, y, z, z2, z4, p, q, p0, p1, h, sgn |
| 18 | + double precision, parameter :: PI = 3.14159265358979324D0 |
| 19 | + double precision, parameter :: PI2 = 2*PI, PIH = PI/2, PI28 = PI*PI/8 |
| 20 | + double precision, parameter :: cp(4) = (/ & |
| 21 | + 2.7951565822419270D-2, & |
| 22 | + -8.8865360514541522D-4, & |
| 23 | + 6.8282348222485902D-6, & |
| 24 | + -7.5276232403566808D-9 /) |
| 25 | + double precision, parameter :: cq(4) = (/ & |
| 26 | + 1.0000000000000000D+0, & |
| 27 | + -3.6904397961160525D-2, & |
| 28 | + 3.7342870576106476D-4, & |
| 29 | + -8.7460760866531179D-7 /) |
| 30 | + double precision, parameter :: cr(6) = (/ & |
| 31 | + 6.4005702446195512D-1, & |
| 32 | + -2.0641655351338783D-1, & |
| 33 | + 2.4175305223497718D-2, & |
| 34 | + -1.2355955287855728D-3, & |
| 35 | + 2.5649833551291124D-5, & |
| 36 | + -1.4783829128773320D-7 /) |
| 37 | + double precision, parameter :: cs(6) = (/ & |
| 38 | + 1.0000000000000000D+0, & |
| 39 | + -2.5299102015666356D-1, & |
| 40 | + 2.2148751048467057D-2, & |
| 41 | + -7.8183920462457496D-4, & |
| 42 | + 9.5432542196310670D-6, & |
| 43 | + -1.8184302880448247D-8 /) |
| 44 | + |
| 45 | + sgn = 1 |
| 46 | + |
| 47 | + if (x .lt. 0) then |
| 48 | + x = -x |
| 49 | + sgn = -1 |
| 50 | + endif |
| 51 | + |
| 52 | + if (x .ge. PI2) then |
| 53 | + x = mod(x, PI2) |
| 54 | + endif |
| 55 | + |
| 56 | + if (x .gt. PI) then |
| 57 | + p0 = 6.28125D0 |
| 58 | + p1 = 0.0019353071795864769253D0 |
| 59 | + x = (p0 - x) + p1 |
| 60 | + sgn = -sgn |
| 61 | + endif |
| 62 | + |
| 63 | + if (x .eq. 0 .or. x .eq. PI) then |
| 64 | + dcl2 = 0 |
| 65 | + return |
| 66 | + endif |
| 67 | + |
| 68 | + if (x .lt. PIH) then |
| 69 | + y = x*x |
| 70 | + z = y - PI28 |
| 71 | + z2 = z*z |
| 72 | + p = cp(1) + z * cp(2) + z2 * (cp(3) + z * cp(4)) |
| 73 | + q = cq(1) + z * cq(2) + z2 * (cq(3) + z * cq(4)) |
| 74 | + h = x*(1 - log(x) + y*p/q/2) |
| 75 | + else |
| 76 | + y = PI - x |
| 77 | + z = y*y - PI28 |
| 78 | + z2 = z*z |
| 79 | + z4 = z2*z2 |
| 80 | + p = cr(1) + z * cr(2) + z2 * (cr(3) + z * cr(4)) + & |
| 81 | + z4 * (cr(5) + z * cr(6)) |
| 82 | + q = cs(1) + z * cs(2) + z2 * (cs(3) + z * cs(4)) + & |
| 83 | + z4 * (cs(5) + z * cs(6)) |
| 84 | + h = y*p/q |
| 85 | + endif |
| 86 | + |
| 87 | + dcl2 = sgn*h |
| 88 | + |
| 89 | +end function dcl2 |
0 commit comments