1. problem with euphoria's power()
- Posted by daryl_vdb at HOTMAIL.COM Aug 05, 2001
- 419 views
Consider the following line of code: ? power(-8, 1/3) I get the following error: can't raise negative number to non-integer power. Wrong! raising any number to 1/3 gives the cubed root, and anyone with even a little math experience knows that all negative numbers have real cubed roots. Same applies with 1 / <any odd integer>. So, what's the problem Rob? regards, Daryl van den Brink
2. Re: problem with euphoria's power()
- Posted by Rolf Schroeder <r.schr at T-ONLINE.DE> Aug 05, 2001
- 435 views
3. Re: problem with euphoria's power()
- Posted by gertie at ad-tek.net Aug 05, 2001
- 438 views
On 5 Aug 2001, at 20:09, daryl_vdb at HOTMAIL.COM wrote: > > Consider the following line of code: > > ? power(-8, 1/3) > > I get the following error: > > can't raise negative number to non-integer power. > > Wrong! raising any number to 1/3 gives the cubed root, and anyone with even > a little math experience knows that all negative numbers have real cubed > roots. Same applies with 1 / <any odd integer>. So, what's the problem Rob? If we had the log10 function instead of the natural logs function, we could get any root or power by using that function: atom = 10E(0.3 x log(1728)) -- atom = 12 Kat
4. Re: problem with euphoria's power()
- Posted by daryl_vdb at HOTMAIL.COM Aug 06, 2001
- 424 views
>If we had the log10 function instead of the natural logs function, we could >get any root >or power by using that function: > >atom = 10E(0.3 x log(1728)) >-- atom = 12 > >Kat Here's some code I coppied from a math library I wrote a while ago. It lets you get logarighms with any base. (10, 16 and 8 are sped up a little) -- logarithms -- constant log10 = log(10), log16 = log(16), log8 = log(8) global function declog(object x) return log(x) / log10 end function global function hexlog(object x) return log(x) / log16 end function global function octlog(object x) return log(x) / log8 end function global function customlog(object x, object base) return log(x) / log(base) end function regards, Daryl van den Brink