sqrt(a/b) should always be equal to sqrt(a)/sqrt(b) since (a/b)^m = a^m/b^m for b != 0. However, I'm unsure of whether it's the best option for ratios because unless both the numerator and the denominator are perfect squares, you're going to end up with a float anyway. This is trading an extra sqrt for precision in the relatively uncommon situation where both numbers are perfect squares.
As for taking square roots involving complex numbers, I've been considering that as well, but I think it might be a bad idea to have it as a part of the normal sqrt function. In the majority of situations, taking the square root of a negative number is a bad thing and probably shouldn't be allowed. An alternative sqrt associated with complex numbers could be appropriate instead. On Jan 3, 10:06 pm, "Mark H." <mark.hoem...@gmail.com> wrote: > On Jan 3, 11:48 am, "Mark Engelberg" <mark.engelb...@gmail.com> wrote: > > > If you give it an exact number (i.e., not a floating point), > > Floating-point numbers are exact -- it's their operations that may not > be. *ducks* > > Seriously, handy code -- many thanks! I should check with someone > whether sqrt(a/b) -> sqrt(a)/sqrt(b) is a fair assumption. Would you > find a sqrt that returns complex numbers for negative inputs (it would > be the appropriate branch of the sqrt function in order to make it > single-valued) useful? > > mfh --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---