ref: 0b5ebea7268da216f2cfe734c5ecbf4283c4ce64
parent: c51da4457f664504247f485cbb177e1d851e8cb5
author: Lennart Augustsson <lennart@augustsson.net>
date: Wed Nov 8 11:01:31 EST 2023
Fix sqrt
--- a/lib/Data/Complex.hs
+++ b/lib/Data/Complex.hs
@@ -89,8 +89,8 @@
inf = 1/0
nan = 0/0
-}
---XXX sqrt (0:+0) = 0
- sqrt z@(x:+y) = u :+ (if y < 0 then negate v else v)
+ sqrt z@(x:+y) | x==0 && y==0 = 0
+ | otherwise = u :+ (if y < 0 then negate v else v)
where (u,v) = if x < 0 then (v',u') else (u',v')
v' = abs y / (u'*2)
u' = sqrt ((magnitude z + abs x) / 2)
--
⑨