# Root Module (code)

**URL:** <https://www.ruby-forum.com/t/root-module-code/189598>\
**Category:** Ruby\
**Created:** [June 3, 2010, 6:58pm UTC](https://www.ruby-forum.com/t/root-module-code/189598 "2010-06-03T18:58:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jzakiya](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/3ec8ea/32.png) [@jzakiya](https://www.ruby-forum.com/u/jzakiya)\
**Post date:** [June 3, 2010, 6:58pm UTC](https://www.ruby-forum.com/t/root-module-code/189598/1 "2010-06-03T18:58:16Z")

</div>

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:

> <https://gist.github.com/jzakiya/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:

.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
