module Music.Theory.Meter.Barlow_1987 where
import Data.List
import qualified Data.Numbers.Primes as P
import qualified Music.Theory.Math as T
traceShow :: a -> b -> b
traceShow :: forall a b. a -> b -> b
traceShow a
_ b
x = b
x
at1 :: Integral n => [a] -> n -> a
at1 :: forall n a. Integral n => [a] -> n -> a
at1 [a]
x n
i = [a]
x forall n a. Integral n => [a] -> n -> a
`genericIndex` (n
i forall a. Num a => a -> a -> a
- n
1)
at1_bnd_err :: (Num a,Show a,Integral n,Show n,Show m) => m -> [a] -> n -> a
at1_bnd_err :: forall a n m.
(Num a, Show a, Integral n, Show n, Show m) =>
m -> [a] -> n -> a
at1_bnd_err m
m [a]
x n
i =
let n :: n
n = forall i a. Num i => [a] -> i
genericLength [a]
x
in if n
i forall a. Eq a => a -> a -> Bool
== n
0 Bool -> Bool -> Bool
|| n
i forall a. Eq a => a -> a -> Bool
== n
n forall a. Num a => a -> a -> a
+ n
1
then a
1
else if n
i forall a. Ord a => a -> a -> Bool
< n
0 Bool -> Bool -> Bool
|| n
i forall a. Ord a => a -> a -> Bool
> n
n forall a. Num a => a -> a -> a
+ n
1
then forall a. HasCallStack => String -> a
error (forall a. Show a => a -> String
show (String
"at1_bnd_err",m
m,[a]
x,n
i))
else [a]
x forall n a. Integral n => [a] -> n -> a
`genericIndex` (n
i forall a. Num a => a -> a -> a
- n
1)
mod_pos_err :: (Integral a,Show a) => a -> a -> a
mod_pos_err :: forall a. (Integral a, Show a) => a -> a -> a
mod_pos_err a
a a
b =
let r :: a
r = forall a. Integral a => a -> a -> a
mod a
a a
b
in if a
r forall a. Ord a => a -> a -> Bool
< a
0 Bool -> Bool -> Bool
|| a
r forall a. Ord a => a -> a -> Bool
>= a
b
then forall a. HasCallStack => String -> a
error (forall a. Show a => a -> String
show (String
"mod_pos_err",a
a,a
b,a
r))
else a
r
to_r :: Integral n => n -> Double
to_r :: forall n. Integral n => n -> Double
to_r = forall a b. (Integral a, Num b) => a -> b
fromIntegral
div_pos_err :: (Integral a,Show a) => String -> a -> a -> a
div_pos_err :: forall a. (Integral a, Show a) => String -> a -> a -> a
div_pos_err String
m a
i a
j =
if a
i forall a. Ord a => a -> a -> Bool
< a
0 Bool -> Bool -> Bool
|| a
j forall a. Ord a => a -> a -> Bool
< a
0
then forall a. HasCallStack => String -> a
error (forall a. Show a => a -> String
show (String
"div_pos_err",String
m,a
i,a
j))
else forall a b. (RealFrac a, Integral b) => a -> b
truncate (forall n. Integral n => n -> Double
to_r a
i forall a. Fractional a => a -> a -> a
/ forall n. Integral n => n -> Double
to_r a
j)
type Stratification t = [t]
indispensibilities :: (Integral n,Show n) => Stratification n -> [n]
indispensibilities :: forall n.
(Integral n, Show n) =>
Stratification n -> Stratification n
indispensibilities Stratification n
x = forall a b. (a -> b) -> [a] -> [b]
map (forall a. (Integral a, Show a) => Stratification a -> a -> a -> a
lower_psi Stratification n
x (forall i a. Num i => [a] -> i
genericLength Stratification n
x)) [n
1 .. forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
product Stratification n
x]
lower_psi :: (Integral a,Show a) => Stratification a -> a -> a -> a
lower_psi :: forall a. (Integral a, Show a) => Stratification a -> a -> a -> a
lower_psi Stratification a
q a
z a
n =
let s8 :: a -> a
s8 a
r =
let s1 :: a
s1 = forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
product Stratification a
q
s2 :: a
s2 = (a
n forall a. Num a => a -> a -> a
- a
2) forall a. (Integral a, Show a) => a -> a -> a
`mod_pos_err` a
s1
s3 :: a
s3 = let f :: a -> a
f a
k = forall a n m.
(Num a, Show a, Integral n, Show n, Show m) =>
m -> [a] -> n -> a
at1_bnd_err String
"s3" Stratification a
q (a
z forall a. Num a => a -> a -> a
+ a
1 forall a. Num a => a -> a -> a
- a
k)
in forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
product (forall a b. (a -> b) -> [a] -> [b]
map a -> a
f [a
0 .. a
r])
s4 :: a
s4 = a
1 forall a. Num a => a -> a -> a
+ forall a. (Integral a, Show a) => String -> a -> a -> a
div_pos_err String
"s4" a
s2 a
s3
c :: a
c = forall a n m.
(Num a, Show a, Integral n, Show n, Show m) =>
m -> [a] -> n -> a
at1_bnd_err String
"c" Stratification a
q (a
z forall a. Num a => a -> a -> a
- a
r)
s5 :: a
s5 = a
s4 forall a. (Integral a, Show a) => a -> a -> a
`mod_pos_err` a
c
s6 :: a
s6 = forall a. (Integral a, Show a) => a -> a -> a
upper_psi a
c (a
1 forall a. Num a => a -> a -> a
+ a
s5)
s7 :: a
s7 = let f :: a -> a
f = forall a n m.
(Num a, Show a, Integral n, Show n, Show m) =>
m -> [a] -> n -> a
at1_bnd_err String
"s7" Stratification a
q
in forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
product (forall a b. (a -> b) -> [a] -> [b]
map a -> a
f [a
0 .. a
z forall a. Num a => a -> a -> a
- a
r forall a. Num a => a -> a -> a
- a
1])
in forall a b. a -> b -> b
traceShow (String
"lower_psi:s",a
s1,a
s2,a
s3,a
s4,a
s5,a
s6,a
s7) (a
s7 forall a. Num a => a -> a -> a
* a
s6)
in forall a b. a -> b -> b
traceShow (String
"lower_psi",Stratification a
q,a
z,a
n) (forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
sum (forall a b. (a -> b) -> [a] -> [b]
map a -> a
s8 [a
0 .. a
z forall a. Num a => a -> a -> a
- a
1]))
reverse_primes :: Integral n => n -> [n]
reverse_primes :: forall n. Integral n => n -> [n]
reverse_primes n
n = forall a. [a] -> [a]
reverse (forall i a. Integral i => i -> [a] -> [a]
genericTake n
n forall int. Integral int => [int]
P.primes)
prime_stratification :: (Integral n,Show n) => n -> Stratification n
prime_stratification :: forall n. (Integral n, Show n) => n -> Stratification n
prime_stratification =
let go :: [t] -> t -> [t]
go [t]
x t
k =
case [t]
x of
t
p:[t]
x' -> if t
k forall a. Integral a => a -> a -> a
`rem` t
p forall a. Eq a => a -> a -> Bool
== t
0
then t
p forall a. a -> [a] -> [a]
: [t] -> t -> [t]
go [t]
x (forall a. (Integral a, Show a) => String -> a -> a -> a
div_pos_err String
"ps" t
k t
p)
else [t] -> t -> [t]
go [t]
x' t
k
[] -> []
in forall {t}. (Integral t, Show t) => [t] -> t -> [t]
go (forall n. Integral n => n -> [n]
reverse_primes n
14)
upper_psi :: (Integral a,Show a) => a -> a -> a
upper_psi :: forall a. (Integral a, Show a) => a -> a -> a
upper_psi a
p a
n =
if a
p forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`notElem` forall n. Integral n => n -> [n]
reverse_primes a
14
then forall a. HasCallStack => String -> a
error (forall a. Show a => a -> String
show (String
"upper_psi",String
"not prime",a
p,a
n))
else if a
p forall a. Eq a => a -> a -> Bool
== a
2
then a
p forall a. Num a => a -> a -> a
- a
n
else if a
n forall a. Eq a => a -> a -> Bool
== a
p forall a. Num a => a -> a -> a
- a
1
then forall a. (Integral a, Show a) => String -> a -> a -> a
div_pos_err String
"upper_psi" a
p a
4
else let n' :: a
n' = a
n forall a. Num a => a -> a -> a
- forall a. (Integral a, Show a) => String -> a -> a -> a
div_pos_err String
"n'" a
n a
p
s :: Stratification a
s = forall n. (Integral n, Show n) => n -> Stratification n
prime_stratification (a
p forall a. Num a => a -> a -> a
- a
1)
q :: a
q = forall a. (Integral a, Show a) => Stratification a -> a -> a -> a
lower_psi Stratification a
s (forall i a. Num i => [a] -> i
genericLength Stratification a
s) a
n'
q' :: Double
q' = forall n. Integral n => n -> Double
to_r a
q
p' :: Double
p' = forall n. Integral n => n -> Double
to_r a
p
in forall a b. (RealFrac a, Integral b) => a -> b
truncate (Double
q' forall a. Num a => a -> a -> a
+ Double
2 forall a. Num a => a -> a -> a
* forall a. Floating a => a -> a
sqrt ((Double
q' forall a. Num a => a -> a -> a
+ Double
1) forall a. Fractional a => a -> a -> a
/ Double
p'))
thinning_table :: (Integral n,Show n) => Stratification n -> [[Bool]]
thinning_table :: forall n. (Integral n, Show n) => Stratification n -> [[Bool]]
thinning_table Stratification n
s =
let x :: Stratification n
x = forall n.
(Integral n, Show n) =>
Stratification n -> Stratification n
indispensibilities Stratification n
s
n :: n
n = forall i a. Num i => [a] -> i
genericLength Stratification n
x
true :: i -> [Bool]
true i
i = forall i a. Integral i => i -> a -> [a]
genericReplicate i
i Bool
True
false :: i -> [Bool]
false i
i = forall i a. Integral i => i -> a -> [a]
genericReplicate i
i Bool
False
f :: n -> [Bool]
f n
i = forall {i}. Integral i => i -> [Bool]
true (n
i forall a. Num a => a -> a -> a
+ n
1) forall a. [a] -> [a] -> [a]
++ forall {i}. Integral i => i -> [Bool]
false (n
n forall a. Num a => a -> a -> a
- n
i forall a. Num a => a -> a -> a
- n
1)
in forall a. [[a]] -> [[a]]
transpose (forall a b. (a -> b) -> [a] -> [b]
map n -> [Bool]
f Stratification n
x)
thinning_table_pp :: (Integral n,Show n) => Stratification n -> String
thinning_table_pp :: forall n. (Integral n, Show n) => Stratification n -> String
thinning_table_pp Stratification n
s =
let f :: Bool -> Char
f Bool
x = if Bool
x then Char
'*' else Char
'.'
in [String] -> String
unlines (forall a b. (a -> b) -> [a] -> [b]
map (forall a b. (a -> b) -> [a] -> [b]
map Bool -> Char
f) (forall n. (Integral n, Show n) => Stratification n -> [[Bool]]
thinning_table Stratification n
s))
relative_to_length :: (Real a, Fractional b) => [a] -> [b]
relative_to_length :: forall a b. (Real a, Fractional b) => [a] -> [b]
relative_to_length [a]
x =
let n :: Int
n = forall (t :: * -> *) a. Foldable t => t a -> Int
length [a]
x forall a. Num a => a -> a -> a
- Int
1
in forall a b. (a -> b) -> [a] -> [b]
map ((forall a. Fractional a => a -> a -> a
/ forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
n) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (Real a, Fractional b) => a -> b
realToFrac) [a]
x
relative_indispensibilities :: (Integral n,Show n) => Stratification n -> [Double]
relative_indispensibilities :: forall n. (Integral n, Show n) => Stratification n -> [Double]
relative_indispensibilities = forall a b. (Real a, Fractional b) => [a] -> [b]
relative_to_length forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall n.
(Integral n, Show n) =>
Stratification n -> Stratification n
indispensibilities
align_meters :: (t -> [b]) -> t -> t -> [(b,b)]
align_meters :: forall t b. (t -> [b]) -> t -> t -> [(b, b)]
align_meters t -> [b]
f t
s1 t
s2 =
let i1 :: [b]
i1 = t -> [b]
f t
s1
i2 :: [b]
i2 = t -> [b]
f t
s2
n1 :: Int
n1 = forall (t :: * -> *) a. Foldable t => t a -> Int
length [b]
i1
n2 :: Int
n2 = forall (t :: * -> *) a. Foldable t => t a -> Int
length [b]
i2
n :: Int
n = forall a. Integral a => a -> a -> a
lcm Int
n1 Int
n2
i1' :: [b]
i1' = forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat (forall a. Int -> a -> [a]
replicate (Int
n forall a. Integral a => a -> a -> a
`div` Int
n1) [b]
i1)
i2' :: [b]
i2' = forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat (forall a. Int -> a -> [a]
replicate (Int
n forall a. Integral a => a -> a -> a
`div` Int
n2) [b]
i2)
in forall a b. [a] -> [b] -> [(a, b)]
zip [b]
i1' [b]
i2'
type S_MM t = ([t],t)
whole_div :: Integral a => a -> a -> a
whole_div :: forall a. Integral a => a -> a -> a
whole_div a
i a
j =
case a
i forall a. Integral a => a -> a -> (a, a)
`divMod` a
j of
(a
k,a
0) -> a
k
(a, a)
_ -> forall a. HasCallStack => String -> a
error String
"whole_div"
whole_quot :: Integral a => a -> a -> a
whole_quot :: forall a. Integral a => a -> a -> a
whole_quot a
i a
j =
case a
i forall a. Integral a => a -> a -> (a, a)
`quotRem` a
j of
(a
k,a
0) -> a
k
(a, a)
_ -> forall a. HasCallStack => String -> a
error String
"whole_quot"
prolong_stratifications :: (Integral n,Show n) => S_MM n -> S_MM n -> ([n],[n])
prolong_stratifications :: forall n. (Integral n, Show n) => S_MM n -> S_MM n -> ([n], [n])
prolong_stratifications ([n]
s1,n
v1) ([n]
s2,n
v2) =
let t1 :: n
t1 = forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
product [n]
s1 forall a. Num a => a -> a -> a
* n
v1
t2 :: n
t2 = forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
product [n]
s2 forall a. Num a => a -> a -> a
* n
v2
t :: n
t = forall a. Integral a => a -> a -> a
lcm n
t1 n
t2
s1' :: [n]
s1' = [n]
s1 forall a. [a] -> [a] -> [a]
++ forall n. (Integral n, Show n) => n -> Stratification n
prime_stratification (n
t forall a. Integral a => a -> a -> a
`whole_div` n
t1)
s2' :: [n]
s2' = [n]
s2 forall a. [a] -> [a] -> [a]
++ forall n. (Integral n, Show n) => n -> Stratification n
prime_stratification (n
t forall a. Integral a => a -> a -> a
`whole_div` n
t2)
in ([n]
s1',[n]
s2')
align_s_mm :: (Integral n,Show n) => ([n] -> [t]) -> S_MM n -> S_MM n -> [(t,t)]
align_s_mm :: forall n t.
(Integral n, Show n) =>
([n] -> [t]) -> S_MM n -> S_MM n -> [(t, t)]
align_s_mm [n] -> [t]
f ([n]
s1,n
v1) ([n]
s2,n
v2) =
let ([n]
s1',[n]
s2') = forall n. (Integral n, Show n) => S_MM n -> S_MM n -> ([n], [n])
prolong_stratifications ([n]
s1,n
v1) ([n]
s2,n
v2)
in forall t b. (t -> [b]) -> t -> t -> [(b, b)]
align_meters [n] -> [t]
f [n]
s1' [n]
s2'
upper_psi' :: (Integral a,Show a) => a -> a -> a
upper_psi' :: forall a. (Integral a, Show a) => a -> a -> a
upper_psi' a
h a
n =
if a
h forall a. Ord a => a -> a -> Bool
> a
3
then let omega :: a -> a
omega a
x = if a
x forall a. Eq a => a -> a -> Bool
== a
0 then a
0 else a
1
h4 :: a
h4 = forall a. (Integral a, Show a) => String -> a -> a -> a
div_pos_err String
"h4" a
h a
4
n' :: a
n' = a
n forall a. Num a => a -> a -> a
- a
1 forall a. Num a => a -> a -> a
+ forall {a} {a}. (Eq a, Num a, Num a) => a -> a
omega (a
h forall a. Num a => a -> a -> a
- a
n)
p :: Stratification a
p = forall n. (Integral n, Show n) => n -> Stratification n
prime_stratification (a
h forall a. Num a => a -> a -> a
- a
1)
x0 :: a
x0 = forall a. (Integral a, Show a) => Stratification a -> a -> a -> a
lower_psi Stratification a
p (forall i a. Num i => [a] -> i
genericLength Stratification a
p) a
n'
x1 :: a
x1 = a
x0 forall a. Num a => a -> a -> a
+ forall {a} {a}. (Eq a, Num a, Num a) => a -> a
omega (forall a. (Integral a, Show a) => String -> a -> a -> a
div_pos_err String
"z" a
x0 a
h4)
x2 :: a
x2 = forall {a} {a}. (Eq a, Num a, Num a) => a -> a
omega (a
h forall a. Num a => a -> a -> a
- a
n forall a. Num a => a -> a -> a
- a
1)
x3 :: a
x3 = a
x2 forall a. Num a => a -> a -> a
+ a
h4 forall a. Num a => a -> a -> a
* (a
1 forall a. Num a => a -> a -> a
- a
x2)
in forall a b. a -> b -> b
traceShow (String
"upper_psi'",a
h,a
n,a
n',a
x0,a
x1,a
x2,a
x3) (a
x1 forall a. Num a => a -> a -> a
* a
x3)
else (a
h forall a. Num a => a -> a -> a
+ a
n forall a. Num a => a -> a -> a
- a
2) forall a. (Integral a, Show a) => a -> a -> a
`mod_pos_err` a
h
mps_limit :: Floating a => a -> a
mps_limit :: forall a. Floating a => a -> a
mps_limit a
n = forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
sum [a
n forall a. Floating a => a -> a -> a
** a
4 forall a. Fractional a => a -> a -> a
/ a
9
,a
n forall a. Floating a => a -> a -> a
** a
3 forall a. Fractional a => a -> a -> a
/ a
3
,a
13 forall a. Num a => a -> a -> a
* (a
n forall a. Floating a => a -> a -> a
** a
2 ) forall a. Fractional a => a -> a -> a
/ a
36
,a
n forall a. Fractional a => a -> a -> a
/ a
6
,a
1 forall a. Fractional a => a -> a -> a
/ a
36]
mean_square_product :: Fractional n => [(n,n)] -> n
mean_square_product :: forall n. Fractional n => [(n, n)] -> n
mean_square_product [(n, n)]
x =
let f :: (n, n) -> n
f = forall a. Num a => a -> a
T.square forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry forall a. Num a => a -> a -> a
(*)
n :: n
n = forall a b. (Integral a, Num b) => a -> b
fromIntegral (forall (t :: * -> *) a. Foldable t => t a -> Int
length [(n, n)]
x)
in forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
sum (forall a b. (a -> b) -> [a] -> [b]
map (n, n) -> n
f [(n, n)]
x) forall a. Fractional a => a -> a -> a
/ forall a. Num a => a -> a
T.square n
n
metrical_affinity :: (Integral n,Show n) => [n] -> n -> [n] -> n -> Double
metrical_affinity :: forall n. (Integral n, Show n) => [n] -> n -> [n] -> n -> Double
metrical_affinity [n]
s1 n
v1 [n]
s2 n
v2 =
let ([n]
s1',[n]
s2') = forall n. (Integral n, Show n) => S_MM n -> S_MM n -> ([n], [n])
prolong_stratifications ([n]
s1,n
v1) ([n]
s2,n
v2)
i1 :: [Double]
i1 = forall n. (Integral n, Show n) => Stratification n -> [Double]
relative_indispensibilities [n]
s1'
i2 :: [Double]
i2 = forall n. (Integral n, Show n) => Stratification n -> [Double]
relative_indispensibilities [n]
s2'
v :: n
v = forall a. Integral a => a -> a -> a
lcm n
v1 n
v2
i1' :: [Double]
i1' = forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat (forall i a. Integral i => i -> a -> [a]
genericReplicate (n
v forall a. Integral a => a -> a -> a
`div` n
v1) [Double]
i1)
i2' :: [Double]
i2' = forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat (forall i a. Integral i => i -> a -> [a]
genericReplicate (n
v forall a. Integral a => a -> a -> a
`div` n
v2) [Double]
i2)
in forall n. Fractional n => [(n, n)] -> n
mean_square_product (forall a b. [a] -> [b] -> [(a, b)]
zip [Double]
i1' [Double]
i2')
metrical_affinity' :: (Integral t,Show t) => [t] -> t -> [t] -> t -> Double
metrical_affinity' :: forall n. (Integral n, Show n) => [n] -> n -> [n] -> n -> Double
metrical_affinity' [t]
s1 t
v1 [t]
s2 t
v2 =
let ([t]
s1',[t]
s2') = forall n. (Integral n, Show n) => S_MM n -> S_MM n -> ([n], [n])
prolong_stratifications ([t]
s1,t
v1) ([t]
s2,t
v2)
ix :: (Integer -> x) -> Integer -> x
ix :: forall x. (Integer -> x) -> Integer -> x
ix Integer -> x
f Integer
i = case Integer
i of
Integer
1 -> Integer -> x
f Integer
1
Integer
2 -> Integer -> x
f Integer
2
Integer
_ -> forall a. HasCallStack => String -> a
error (forall a. Show a => a -> String
show (String
"ix",Integer
i))
s :: Integer -> [t]
s = forall x. (Integer -> x) -> Integer -> x
ix (forall n a. Integral n => [a] -> n -> a
at1 [[t]
s1,[t]
s2])
v :: Integer -> t
v = forall x. (Integer -> x) -> Integer -> x
ix (forall n a. Integral n => [a] -> n -> a
at1 [t
v1,t
v2])
u :: Integer -> Int
u = forall x. (Integer -> x) -> Integer -> x
ix (forall i a. Num i => [a] -> i
genericLength forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> [t]
s)
s' :: Integer -> [t]
s' = forall x. (Integer -> x) -> Integer -> x
ix (forall n a. Integral n => [a] -> n -> a
at1 [[t]
s1',[t]
s2'])
z :: Integer -> t
z = forall x. (Integer -> x) -> Integer -> x
ix (forall i a. Num i => [a] -> i
genericLength forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> [t]
s')
q :: Integer -> n -> t
q Integer
i n
j = Integer -> [t]
s Integer
i forall n a. Integral n => [a] -> n -> a
`at1` n
j
omega_u :: Integer -> t
omega_u Integer
i = forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
product (forall a b. (a -> b) -> [a] -> [b]
map (forall {n}. Integral n => Integer -> n -> t
q Integer
i) [Int
1::Int .. Integer -> Int
u Integer
i])
omega_z :: p -> t
omega_z p
_ = forall a. Integral a => a -> a -> a
lcm (Integer -> t
v Integer
1 forall a. Num a => a -> a -> a
* Integer -> t
omega_u Integer
1) (Integer -> t
v Integer
2 forall a. Num a => a -> a -> a
* Integer -> t
omega_u Integer
2)
omega_0 :: t
omega_0 = forall a. Integral a => a -> a -> a
lcm (forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
product (Integer -> [t]
s' Integer
1)) (forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
product (Integer -> [t]
s' Integer
2))
x0 :: t -> Integer -> t
x0 t
n Integer
i = forall a. (Integral a, Show a) => Stratification a -> a -> a -> a
lower_psi (Integer -> [t]
s' Integer
i) (Integer -> t
z Integer
i) (t
1 forall a. Num a => a -> a -> a
+ ((t
n forall a. Num a => a -> a -> a
- t
1) forall a. (Integral a, Show a) => a -> a -> a
`mod_pos_err` forall {p}. p -> t
omega_z Integer
i))
x1 :: t -> t
x1 t
n = forall a. Num a => a -> a
T.square (forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
product (forall a b. (a -> b) -> [a] -> [b]
map (t -> Integer -> t
x0 t
n) [Integer
1,Integer
2]))
x2 :: t
x2 = forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
sum (forall a b. (a -> b) -> [a] -> [b]
map t -> t
x1 [t
1 .. t
omega_0])
x3 :: t
x3 = t
18 forall a. Num a => a -> a -> a
* t
x2 forall a. Num a => a -> a -> a
- t
2
x4 :: p -> t
x4 p
i = forall a. Num a => a -> a
T.square (forall {p}. p -> t
omega_z p
i forall a. Num a => a -> a -> a
- t
1)
x5 :: t
x5 = forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
product (forall a b. (a -> b) -> [a] -> [b]
map forall {p}. p -> t
x4 [Integer
1::Integer,Integer
2])
x6 :: t
x6 = t
7 forall a. Num a => a -> a -> a
* t
omega_0 forall a. Num a => a -> a -> a
* t
x5
x7 :: Double
x7 = forall n. Integral n => n -> Double
to_r t
x3 forall a. Fractional a => a -> a -> a
/ forall n. Integral n => n -> Double
to_r t
x6
x8 :: Double
x8 = Double
2 forall a. Num a => a -> a -> a
* forall a. Floating a => a -> a
log Double
x7
x9 :: Double
x9 = forall a. Num a => a -> a
negate (forall a. Fractional a => a -> a
recip Double
x8)
in forall a b. a -> b -> b
traceShow (forall {p}. p -> t
omega_z,t
omega_0,t
x2,t
x3,t
x5,t
x6,Double
x7,Double
x8,Double
x9) Double
x9