Re: [Haskell-cafe] Fractional sqrt

Hi, Thanks for the answers. The best solution would be a general purpose arbitrary precision math library for Haskell. I found two: http://medialab.freaknet.org/bignum/ http://r6.ca/FewDigits/ I think both uses power series and have trigonometric functions too. (I only need sqrt, so probably I will not use them, just the simple Newton alg.) It would be great, if a fast implementation of arbitrary precision real arithmetic Class would be part of the Standard libraries. Because Haskell is so great for numerical computations already (functions, composing functions, higher order f. with typechecking), a good math library would make Matlab obsolete. :) Zoltan Novak ps. Call me Zoltan (that is my first name), just we write it in different order in Hungary. (Names are in hungarian notation here: the type description precedes the actual name)

Hi Zoltán,
I only need sqrt, so probably I will... use... just the simple Newton alg.
It is still not clear to me what type you want to work in. Is it Rational? In that case, you don't need the Newton algorithm. realToFrac . sqrt . realToFrac works fine, as you originally suggested. If that gives too much precision, you can use (`approxRational` epsilon) . sqrt . realToFrac Newton will not work in general for Fractional. It works for Floating, but there you already have the sqrt function. Are you using a type that has a Fractional instance, does not have a Floating instance, and Newton works and is needed? What type is that?
a good math library would make Matlab obsolete. :)
Yes, that would certainly be nice. This has been discussed at length several times on this list in the past. I wonder if there has been any further progress on it. Regards, Yitz

If it's arbitrary precision floating point that you want then sqrt should where it already is, as a member of Floating. (I find "arbitrary precision real" to be an oxymoron, the real numbers are the real numbers, they already have arbitrary precision.) For a real number module, you can use, e.g., David Lester's implementation, http://www.augustsson.net/Darcs/CReal/ -- Lennart On Jan 19, 2007, at 07:13 , Novák Zoltán wrote:
Hi,
Thanks for the answers. The best solution would be a general purpose arbitrary precision math library for Haskell. I found two:
http://medialab.freaknet.org/bignum/ http://r6.ca/FewDigits/
I think both uses power series and have trigonometric functions too. (I only need sqrt, so probably I will not use them, just the simple Newton alg.)
It would be great, if a fast implementation of arbitrary precision real arithmetic Class would be part of the Standard libraries. Because Haskell is so great for numerical computations already (functions, composing functions, higher order f. with typechecking), a good math library would make Matlab obsolete. :) Zoltan Novak
ps. Call me Zoltan (that is my first name), just we write it in different order in Hungary. (Names are in hungarian notation here: the type description precedes the actual name) _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
participants (3)
-
Lennart Augustsson
-
Novák Zoltán
-
Yitzchak Gale