module Math.NevilleTheta
    ( theta_c, 
      theta_d,
      theta_n,
      theta_s,
      theta_c', 
      theta_d',
      theta_n',
      theta_s'
    ) where
import Data.Complex           ( Complex(..) )
import Math.EllipticIntegrals ( ellipticF )
import Math.JacobiTheta
    ( jtheta1, jtheta1Dash, jtheta2, jtheta3, jtheta4 )

type Cplx = Complex Double

i_ :: Cplx
i_ :: Cplx
i_ = Double
0.0 forall a. a -> a -> Complex a
:+ Double
1.0

tauFromM :: Cplx -> Cplx
tauFromM :: Cplx -> Cplx
tauFromM Cplx
m = Cplx
i_ forall a. Num a => a -> a -> a
* Cplx -> Cplx -> Cplx
ellipticF (forall a. Floating a => a
piforall a. Fractional a => a -> a -> a
/Cplx
2) (Cplx
1 forall a. Num a => a -> a -> a
- Cplx
m) forall a. Fractional a => a -> a -> a
/ Cplx -> Cplx -> Cplx
ellipticF (forall a. Floating a => a
piforall a. Fractional a => a -> a -> a
/Cplx
2) Cplx
m

nomeFromM :: Cplx -> Cplx
nomeFromM :: Cplx -> Cplx
nomeFromM Cplx
m = forall a. Floating a => a -> a
exp (Cplx
i_ forall a. Num a => a -> a -> a
* forall a. Floating a => a
pi forall a. Num a => a -> a -> a
* Cplx -> Cplx
tauFromM Cplx
m)

-- | Neville theta-c function in terms of the nome.
theta_c :: 
     Cplx -- ^ z
  -> Cplx -- ^ q, the nome
  -> Cplx
theta_c :: Cplx -> Cplx -> Cplx
theta_c Cplx
z Cplx
q = 
  Cplx -> Cplx -> Cplx
jtheta2 Cplx
z' Cplx
q forall a. Fractional a => a -> a -> a
/ Cplx -> Cplx -> Cplx
jtheta2 Cplx
0 Cplx
q
  where
    j3 :: Cplx
j3 = Cplx -> Cplx -> Cplx
jtheta3 Cplx
0 Cplx
q
    z' :: Cplx
z' = Cplx
z forall a. Fractional a => a -> a -> a
/ (Cplx
j3 forall a. Num a => a -> a -> a
* Cplx
j3)

-- | Neville theta-d function in terms of the nome.
theta_d :: 
     Cplx -- ^ z
  -> Cplx -- ^ q, the nome
  -> Cplx
theta_d :: Cplx -> Cplx -> Cplx
theta_d Cplx
z Cplx
q = 
  Cplx -> Cplx -> Cplx
jtheta3 Cplx
z' Cplx
q forall a. Fractional a => a -> a -> a
/ Cplx -> Cplx -> Cplx
jtheta3 Cplx
0 Cplx
q
  where
    j3 :: Cplx
j3 = Cplx -> Cplx -> Cplx
jtheta3 Cplx
0 Cplx
q
    z' :: Cplx
z' = Cplx
z forall a. Fractional a => a -> a -> a
/ (Cplx
j3 forall a. Num a => a -> a -> a
* Cplx
j3)

-- | Neville theta-n function in terms of the nome.
theta_n :: 
     Cplx -- ^ z
  -> Cplx -- ^ q, the nome
  -> Cplx
theta_n :: Cplx -> Cplx -> Cplx
theta_n Cplx
z Cplx
q = 
  Cplx -> Cplx -> Cplx
jtheta4 Cplx
z' Cplx
q forall a. Fractional a => a -> a -> a
/ Cplx -> Cplx -> Cplx
jtheta4 Cplx
0 Cplx
q
  where
    j3 :: Cplx
j3 = Cplx -> Cplx -> Cplx
jtheta3 Cplx
0 Cplx
q
    z' :: Cplx
z' = Cplx
z forall a. Fractional a => a -> a -> a
/ (Cplx
j3 forall a. Num a => a -> a -> a
* Cplx
j3)

-- | Neville theta-d function in terms of the nome.
theta_s :: 
     Cplx -- ^ z
  -> Cplx -- ^ q, the nome
  -> Cplx
theta_s :: Cplx -> Cplx -> Cplx
theta_s Cplx
z Cplx
q = 
  Cplx
j3sq forall a. Num a => a -> a -> a
* Cplx -> Cplx -> Cplx
jtheta1 Cplx
z' Cplx
q forall a. Fractional a => a -> a -> a
/ Cplx -> Cplx -> Cplx
jtheta1Dash Cplx
0 Cplx
q
  where
    j3 :: Cplx
j3 = Cplx -> Cplx -> Cplx
jtheta3 Cplx
0 Cplx
q
    j3sq :: Cplx
j3sq = Cplx
j3 forall a. Num a => a -> a -> a
* Cplx
j3
    z' :: Cplx
z' = Cplx
z forall a. Fractional a => a -> a -> a
/ Cplx
j3sq

-- | Neville theta-c function in terms of the squared modulus.
theta_c' :: 
     Cplx -- ^ z
  -> Cplx -- ^ m, the squared modulus
  -> Cplx
theta_c' :: Cplx -> Cplx -> Cplx
theta_c' Cplx
z Cplx
m = Cplx -> Cplx -> Cplx
theta_c Cplx
z (Cplx -> Cplx
nomeFromM Cplx
m)

-- | Neville theta-d function in terms of the squared modulus.
theta_d' :: 
     Cplx -- ^ z
  -> Cplx -- ^ m, the squared modulus
  -> Cplx
theta_d' :: Cplx -> Cplx -> Cplx
theta_d' Cplx
z Cplx
m = Cplx -> Cplx -> Cplx
theta_d Cplx
z (Cplx -> Cplx
nomeFromM Cplx
m)

-- | Neville theta-n function in terms of the squared modulus.
theta_n' :: 
     Cplx -- ^ z
  -> Cplx -- ^ m, the squared modulus
  -> Cplx
theta_n' :: Cplx -> Cplx -> Cplx
theta_n' Cplx
z Cplx
m = Cplx -> Cplx -> Cplx
theta_n Cplx
z (Cplx -> Cplx
nomeFromM Cplx
m)

-- | Neville theta-s function in terms of the squared modulus.
theta_s' :: 
     Cplx -- ^ z
  -> Cplx -- ^ m, the squared modulus
  -> Cplx
theta_s' :: Cplx -> Cplx -> Cplx
theta_s' Cplx
z Cplx
m = Cplx -> Cplx -> Cplx
theta_s Cplx
z (Cplx -> Cplx
nomeFromM Cplx
m)