[Haskell-cafe] convergence of functions of Complex variables

William Lee Irwin III wli at holomorphy.com
Wed Dec 15 05:07:10 EST 2004


This does not work as expected on Complex numbers due to some odd
typechecking hassles apparently associated with abs. How do I get this
to typecheck for both real (e.g. Double) and Complex arguments?

\begin{code}
module Jacobi (sn, cn, dn, sd, cd, nd, cs, ds, ns, sc, dc, nc) where

scd x k | abs k < 1e-14 = (sin x, cos x, 1)
	| otherwise = ((1+m)*s/(1+m*s^2), c*d/(1+m*s^2),
						(1 - m*s^2)/(1+m*s^2))
	where
		k' = cos $ asin k
		m = -tanh(log(k')/2)
		(s, c, d) = scd (x/(1+m)) m

sn x k = let (s,_,_) = scd x k in s
cn x k = let (_,c,_) = scd x k in c
dn x k = let (_,_,d) = scd x k in d
sd x k = (sn x k)/(dn x k)
cd x k = (cn x k)/(dn x k)
nd x k = 1/(dn x k)
cs x k = (cn x k)/(sn x k)
ds x k = (dn x k)/(sn x k)
ns x k = 1/(sn x k)
sc x k = (sn x k)/(cn x k)
dc x k = (dn x k)/(cn x k)
nc x k = 1/(cn x k)
\end{code}


More information about the Haskell-Cafe mailing list