Roots Module (code)

J

jzakiya

Module 'Roots' provides two methods 'root' and 'roots' which will
find all the nth roots for all real, and complex , numerical types.

View and download code here:

http://gist.github.com/422636

Install process:
Place module file 'roots.rb' into 'lib' directory of ruby version.
Then from irb session, or a source code file, do:

require 'roots'
#For extended math features also do: require 'mathn'
#Mixin 'Roots' into class Numeric
class Numeric; include Roots end

Can now find nth root(s) of all numerical types:

<floats>.root(s) n, opt
<integer>.root(s) n, opt
<rational>.root(s) n, opt
<complex>.root(s) n, opt
<bigdecimal>.root(s) n, opt

It would be nice for this capability to be considered for Ruby core.

Jabari Zakiya
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,990
Messages
2,570,211
Members
46,796
Latest member
SteveBreed

Latest Threads

Top