From 9b65c6d80fd8896808942786a003e6b0af0d61cf Mon Sep 17 00:00:00 2001 From: Alexander Voigt Date: Sun, 17 Sep 2023 20:28:56 +0200 Subject: [PATCH] extract function --- src/Li2.jl | 61 +++++++++++++++++++++++++++++------------------------- 1 file changed, 33 insertions(+), 28 deletions(-) diff --git a/src/Li2.jl b/src/Li2.jl index 49029bc..08f53e7 100644 --- a/src/Li2.jl +++ b/src/Li2.jl @@ -46,13 +46,44 @@ end # series expansion of Li2(z) for |z| <= 1 and Re(z) <= 0.5 # in terms of u = -log(1-z) -function li2_approx(u::ComplexF32) +function li2_approx(u::ComplexF32)::ComplexF32 B = (-1.0f0/4, 1.0f0/36, -1.0f0/3600, 1.0f0/211680) u2 = u*u u + u2*(B[1] + u*(B[2] + u2*(B[3] + u2*B[4]))) end +# series expansion of Li2(z) for |z| <= 1 and Re(z) <= 0.5 +# in terms of u = -log(1-z) +function li2_approx(u::ComplexF64)::ComplexF64 + B = ( + - 1.0/4, + 1.0/36, + - 1.0/3600, + 1.0/211680, + - 1.0/10886400, + 1.0/526901760, + - 4.0647616451442255e-11, + 8.9216910204564526e-13, + - 1.9939295860721076e-14, + 4.5189800296199182e-16 + ) + + u2 = u*u + u4 = u2*u2 + + u + + u2*(B[1] + + u *(B[2] + + u2*( + B[3] + + u2*B[4] + + u4*(B[5] + u2*B[6]) + + u4*u4*(B[7] + u2*B[8] + u4*(B[9] + u2*B[10])) + ))) +end + + """ reli2(x::Real) @@ -228,31 +259,5 @@ function _li2(z::ComplexF64)::ComplexF64 end end - B = ( - - 1.0/4.0, - 1.0/36.0, - - 1.0/3600.0, - 1.0/211680.0, - - 1.0/10886400.0, - 1.0/526901760.0, - - 4.0647616451442255e-11, - 8.9216910204564526e-13, - - 1.9939295860721076e-14, - 4.5189800296199182e-16 - ) - - u2 = u*u - u4 = u2*u2 - - rest + sgn*( - u + - u2*(B[1] + - u *(B[2] + - u2*( - B[3] + - u2*B[4] + - u4*(B[5] + u2*B[6]) + - u4*u4*(B[7] + u2*B[8] + u4*(B[9] + u2*B[10])) - ))) - ) + rest + sgn*li2_approx(u) end