On May 12, 2:53=A0pm, 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.c=
om
> > >wrote:
>
> >> On Thu, May 12, 2011 at 2:54 PM, serialhex <serial... / gmail.com> =A0
> >> 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) #=3D> NaN
> >> to:
> >> (-1) ** (1.0 / 3) #=3D> (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 :/
>
> ONE of the cube roots of -1 isn't imaginary, but the other two are. =A0
> Since (1.0/3) isn't exactly one-third, raising -1 to (1.0/3) isn't =A0
> exactly the same as taking the cube root either.
>
> -Rob
>
> Rob Biedenharn =A0 =A0 =A0 =A0 =A0
> R... / AgileConsultingLLC.com =A0http://AgileConsultingLLC.com/
> r... / GaslightSoftware.com =A0 =A0 =A0 =A0 =A0 =A0http://GaslightSoftware.=
com/

See my Roots Module.
https://gist.github.com/422636

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