diff --git a/crates/ekore/src/harmonics/cache.rs b/crates/ekore/src/harmonics/cache.rs index 89ae8f3e0..6d88b46cf 100644 --- a/crates/ekore/src/harmonics/cache.rs +++ b/crates/ekore/src/harmonics/cache.rs @@ -38,6 +38,10 @@ pub enum K { Sm2e, /// $S_{-2}(N)$ odd moments Sm2o, + /// $S_{-3}(N)$ even moments + Sm3e, + /// $S_{-3}(N)$ odd moments + Sm3o, /// $S_{-2,1}(N)$ even moments Sm21e, /// $S_{-2,1}(N)$ odd moments @@ -90,6 +94,8 @@ impl Cache { K::Sm1o => w1::Sm1o(self.get(K::S1), self.get(K::S1mh)), K::Sm2e => w2::Sm2e(self.get(K::S2), self.get(K::S2h)), K::Sm2o => w2::Sm2o(self.get(K::S2), self.get(K::S2mh)), + K::Sm3e => w3::Sm3e(self.get(K::S3), self.get(K::S3h)), + K::Sm3o => w3::Sm3o(self.get(K::S3), self.get(K::S3mh)), K::Sm21e => w3::Sm21e(self.n, self.get(K::S1), self.get(K::Sm1e)), K::Sm21o => w3::Sm21o(self.n, self.get(K::S1), self.get(K::Sm1o)), }; diff --git a/crates/ekore/src/harmonics/w3.rs b/crates/ekore/src/harmonics/w3.rs index 2987db7ff..cbcb5df59 100644 --- a/crates/ekore/src/harmonics/w3.rs +++ b/crates/ekore/src/harmonics/w3.rs @@ -1,5 +1,6 @@ //! Harmonic sums of weight 3. use num::complex::Complex; +use num::traits::Pow; use std::f64::consts::LN_2; use crate::constants::{ZETA2, ZETA3}; @@ -14,6 +15,16 @@ pub fn S3(N: Complex) -> Complex { 0.5 * cern_polygamma(N + 1.0, 2) + ZETA3 } +/// Analytic continuation of harmonic sum $S_{-3}(N)$ for even moments. +pub fn Sm3e(hS3: Complex, hS3h: Complex) -> Complex { + 1. / (2_f64).pow(2) * hS3h - hS3 +} + +/// Analytic continuation of harmonic sum $S_{-3}(N)$ for odd moments. +pub fn Sm3o(hS3: Complex, hS3mh: Complex) -> Complex { + 1. / (2_f64).pow(2) * hS3mh - hS3 +} + /// Analytic continuation of harmonic sum $S_{-2,1}(N)$ for even moments. pub fn Sm21e(N: Complex, hS1: Complex, hSm1: Complex) -> Complex { let eta = 1.;