Wrapper around Ruby Math module; Has additional methods.
http://rubygems.org/gems/mathematics
--------------
mathematics.rb
--------------
IMPORTANT NOTE:
--------------
This program introduces/relies on "Prior Knowledge"
in the domain of mathematics, and avoids
computation where unnecessary.
Also, resorting to computation sometimes doesn't yield
perfect results as known/anticipated. Example:
(environment: ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.4.0])
$ ruby -e "puts Math.sin(Math::PI) # I expect 0"
1.2246467991473532e-16
Under the hood of "Prior Knowledge" style/paradigm of programming,
some characteristic functions can manifest as "Intelligent Functions".
The intelligent function can rely on proven, tested, established
knowledge bases/answers; retrieving the result(s) can be on one or
more of these lines ...
. from cache (in-memory/local/remote/distributed)
. via delegation
. via rpc/rest/*cloud calls
.. depending on the need/nature of the "intelligent function" in the
domain space, and the prior knowledge of the complexity vis-a-vis
the path to take (not resorting to any call based on judgement,
distills down to a normal function,
which is a subset of the intelligent function).
gem install mathematics
require 'mathematics'
Mathematics.add(1,2)
Mathematics.sum(1,2,3)
Mathematics.total(1,2,3,4)
Mathematics.average(1,2,3)
Mathematics.avg(1,2,3,4)
Mathematics.mean(1,2,3,4,5)
Mathematics.sin(0)
Mathematics.cos(0)
Mathematics.sin(Math::PI/2)
Mathematics.cos(Math::PI/2)
Feel free to provide comments