Root Module (code)

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:

Install process:

Place module file ‘roots.rb’ into ‘lib’ directory of ruby
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:

.root(s) n, opt
.root(s) n, opt
.root(s) n, opt
.root(s) n, opt
.root(s) n, opt

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

Jabari Zakiya