Re: Math functions

2009-01-05 Thread Stuart Sierra
On Jan 3, 2:48 pm, "Mark Engelberg" wrote: > I've noticed that Clojure is missing several math functions that come > standard with most programming languages, especially other > Schemes/Lisps.  Many of these functions are available in java's math > library, but only for doubles. Nice work, Mark.

Re: Math functions

2009-01-05 Thread Mark H.
On Jan 3, 7:46 pm, vogelrn wrote: > 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

Re: Math functions

2009-01-04 Thread vogelrn
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 s

Re: Math functions

2009-01-03 Thread Mark Engelberg
On Sat, Jan 3, 2009 at 7:06 PM, Mark H. wrote: > 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? Ideally I'd also like that, but since complex numbers aren't part of

Re: Math functions

2009-01-03 Thread Mark H.
On Jan 3, 11:48 am, "Mark Engelberg" 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)