Math cube root

See my Roots Module.

It allows you to easily (and accurately) get all n values for a root
n,
for all number classes.

Instead of: 1000**3**-1 of 1000**(1.0/3) to get only default root
Instead do: 1000.root(3) or 1000.roots(3), for all 3 cube roots

Jabari Zakiya

···

On May 12, 2:53 pm, Rob Biedenharn <R...@AgileConsultingLLC.com> wrote:

On May 12, 2011, at 2:30 PM, Josh Cheek wrote:

> On Thu, May 12, 2011 at 10:26 AM, Colin Bartlett <colin...@googlemail.com > > >wrote:

>> On Thu, May 12, 2011 at 2:54 PM, serialhex <serial...@gmail.com> > >> wrote:
>>> ...
>>> instead of using floats you can try to use rational numbers in ruby:
>>> ruby-1.9.2-p180 :001 > require 'mathn'
>> which also changes this:
>> (-1) ** (1.0 / 3) #=> NaN
>> to:
>> (-1) ** (1.0 / 3) #=> (0.5+0.866025403784439i)
>> so we can also get complex roots if we want them!

> Which we don't here, given that the cube root of -1 isn't imaginary :confused:

ONE of the cube roots of -1 isn't imaginary, but the other two are.
Since (1.0/3) isn't exactly one-third, raising -1 to (1.0/3) isn't
exactly the same as taking the cube root either.

-Rob

Rob Biedenharn
R...@AgileConsultingLLC.com http://AgileConsultingLLC.com/
r...@GaslightSoftware.com http://GaslightSoftware.com/

spiffy!!!
hex

···

On Thu, May 12, 2011 at 4:25 PM, jzakiya <jzakiya@gmail.com> wrote:

See my Roots Module.
roots.rb · GitHub