On Sat, Aug 8, 2009 at 18:17, Henning Thielemann <lemming@henning-thielemann.de> wrote:

On Sat, 8 Aug 2009, Paul Sargent wrote:

First post to the cafe, so "Hello everybody!".
Hope this is reasonable subject matter and not too long.

I've been working on some algorithms that involved taking the n-th root of complex numbers.
In my code I've implemented this as raising the complex number ('z') to 1/n using the (**)
operator. Obviously, there are n roots, but I only need one of them so this is fine.

I have written something on that topic:
 http://haskell.org/haskellwiki/Power_function

I think the problem cannot be fully solved, especially not within the Haskell 98 numeric type classes. There is no satisfying implementation of (**) even for Float and Double.

Well, I'm an engineer rather than a mathematician, so I'm not 100% sure I followed everything on that page, but you seem to be saying that nth-root can't be done because we're using floating point, and floating point isn't accurate enough to represent 1/n.

I basically agree with this, which was why I asked about nth-root functions, but for my uses (**) is good enough as long as complex zero works.

(To be honest I'd expect any complex nth-root function to work with the polar form, there-by getting around some of the issues I think you're referring to.)