jacobi-theta 0.2.0.0 → 0.2.1.0
raw patch · 4 files changed
+94/−8 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Math.JacobiTheta: jtheta1Dash0 :: Complex Double -> Complex Double
+ Math.JacobiTheta: jthetaAB :: Complex Double -> Complex Double -> Complex Double -> Complex Double -> Complex Double
Files
- CHANGELOG.md +7/−0
- jacobi-theta.cabal +1/−1
- src/Math/JacobiTheta.hs +67/−5
- tests/Main.hs +19/−2
CHANGELOG.md view
@@ -1,3 +1,10 @@+## 0.2.1.0 - 2023-10-18 + +- Jacobi theta function with characteristics. + +- Derivative at 0 of the first Jacobi theta function. + + ## 0.2.0.0 - 2023-10-16 New, better implementation of the Jacobi theta functions.
jacobi-theta.cabal view
@@ -1,5 +1,5 @@ name: jacobi-theta -version: 0.2.0.0 +version: 0.2.1.0 synopsis: Jacobi Theta Functions description: Evaluation of the Jacobi theta functions. homepage: https://github.com/stla/jacobi-theta#readme
src/Math/JacobiTheta.hs view
@@ -1,9 +1,23 @@+{-| +Module : Math.JacobiTheta +Description : Jacobi theta functions. +Copyright : (c) Stéphane Laurent, 2023 +License : BSD3 +Maintainer : laurent_step@outlook.fr + +Provides the four usual Jacobi theta functions, the Jacobi theta function +with characteristics, the derivative of the first Jacobi theta function, +as well as a function for the derivative at @0@ only of the first Jacobi +theta function. +-} module Math.JacobiTheta ( jtheta1, jtheta2, jtheta3, jtheta4, + jthetaAB, + jtheta1Dash0, jtheta1Dash ) where @@ -112,7 +126,7 @@ ljtheta1 :: Cplx -> Cplx -> Cplx ljtheta1 z tau = ljtheta2 (z - 0.5) tau --- | First Jacobi theta function +-- | First Jacobi theta function. jtheta1 :: Complex Double -- ^ z -> Complex Double -- ^ q, the nome @@ -125,7 +139,7 @@ ljtheta2 z tau = funM z tau + dologtheta3 (z + 0.5 * tau) tau 0 1000 --- | Second Jacobi theta function +-- | Second Jacobi theta function. jtheta2 :: Complex Double -- ^ z -> Complex Double -- ^ q, the nome @@ -134,7 +148,7 @@ where tau = getTauFromQ q --- | Third Jacobi theta function +-- | Third Jacobi theta function. jtheta3 :: Complex Double -- ^ z -> Complex Double -- ^ q, the nome @@ -143,7 +157,7 @@ where tau = getTauFromQ q --- | Fourth Jacobi theta function +-- | Fourth Jacobi theta function. jtheta4 :: Complex Double -- ^ z -> Complex Double -- ^ q, the nome @@ -152,7 +166,55 @@ where tau = getTauFromQ q --- | Derivative of the first Jacobi theta function +-- | Jacobi theta function with characteristics. This is a family of functions, +-- containing the first Jacobi theta function (@a=b=0.5@), the second Jacobi +-- theta function (@a=0.5, b=0@), the third Jacobi theta function (@a=b=0@) +-- and the fourth Jacobi theta function (@a=0, b=0.5@). The examples given +-- below show the periodicity-like properties of these functions: +-- +-- >>> import Data.Complex +-- >>> a = 2 :+ 0.3 +-- >>> b = 1 :+ (-0.6) +-- >>> z = 0.1 :+ 0.4 +-- >>> tau = 0.2 :+ 0.3 +-- >>> im = 0 :+ 1 +-- >>> q = exp(im * pi * tau) +-- >>> jab = jthetaAB a b z q +-- >>> jthetaAB a b (z + pi) q +-- (-5.285746223832433e-3) :+ 0.1674462628348814 +-- +-- >>> jab * exp(2 * im * pi * a) +-- (-5.285746223831987e-3) :+ 0.16744626283488154 +-- +-- >>> jtheta_ab a b (z + pi*tau) q +-- 0.10389127606987271 :+ 0.10155646232306936 +-- +-- >>> jab * exp(-im * (pi*tau + 2*z + 2*pi*b)) +-- 0.10389127606987278 :+ 0.10155646232306961 +jthetaAB :: + Complex Double -- ^ characteristic a + -> Complex Double -- ^ characteristic b + -> Complex Double -- ^ z + -> Complex Double -- ^ q, the nome + -> Complex Double +jthetaAB a b z q = c * jtheta3 (alpha + beta) q + where + tau = getTauFromQ q + alpha = pi * a * tau + beta = z + pi * b + c = exp(i_ * a * (alpha + 2*beta)) + +-- | Derivative at 0 of the first Jacobi theta function. This is much more +-- efficient than evaluating @jtheta1Dash@ at @0@. +jtheta1Dash0 :: + Complex Double -- ^ q, the nome + -> Complex Double +jtheta1Dash0 q = + -2 * i_ * jab * jab * jab + where + jab = jthetaAB (1/6) 0.5 0 (q*q*q) + +-- | Derivative of the first Jacobi theta function. jtheta1Dash :: Complex Double -- ^ z -> Complex Double -- ^ q, the nome
tests/Main.hs view
@@ -2,7 +2,7 @@ import Approx ( approx ) import Data.Complex ( Complex(..) ) import Math.JacobiTheta - ( jtheta1, jtheta2, jtheta3, jtheta4, jtheta1Dash ) + ( jtheta1, jtheta2, jtheta3, jtheta4, jtheta1Dash, jtheta1Dash0, jthetaAB ) import Test.Tasty (defaultMain, testGroup) import Test.Tasty.HUnit (assertEqual, testCase) @@ -90,6 +90,23 @@ expected = 27.746815969548447 :+ 31.241216782108797 assertEqual "" (approx 10 obtained) - (approx 10 expected) + (approx 10 expected), + + testCase "jtheta1Dash at 0" $ do + let q''' = 0.556 :+ 0.283 + expected = jtheta1Dash0 q''' + obtained = jtheta1Dash 0 q''' + assertEqual "" + (approx 10 obtained) + (approx 10 expected), + + testCase "A formula involving some jthetaAB at z=0" $ do + let q''' = 0.556 :+ 0.283 + expected = (jthetaAB (1/6) 0.5 0 q''')**3 + obtained = + (jthetaAB (1/6) (1/6) 0 q''')**3 + (jthetaAB (1/6) (5/6) 0 q''')**3 + assertEqual "" + (approx 10 obtained) + (approx 10 expected) ]