Polynomials in Ruby
Get Version
0.7.1polynomial
What
Rich-featured single and multiple variables polynomials classes for Ruby.
Installing
sudo gem install polynomial
The basics
Polynomial.new(1, 2) #=> #<Polynomial:0x7f25286cea68 @coefs=[1, 2]>
Demonstration of usage
foo = Polynomial.new(1, 2) #=> #<Polynomial:0x7f25286cea68 @coefs=[1, 2]> foo.to_s #=> "1 + 2*x" foo.plot # open gnuplot window with 'foo' plotted (require EasyPlot gem) bar = Polynomial.new(3) {|n| n+1 } #=> #<Polynomial:0x7f25287461a8 @coefs=[1, 2, 3, 4]> bar.to_s(:power_symbol=>'^') #=> "1 + 2*x + 3*x^2 + 4*x^3" require 'rational' baz = bar.quo(foo) #=> #<Polynomial:0x7f00a1ff0570 @coefs=[Rational(3, 4), Rational(1, 2), Rational(2, 1)]> baz.to_s #=> "(3/4) + (1/2)*x"
How to submit patches
Read the 8 steps for fixing other people’s code and for section 8b: Submit patch to Google Groups, use the Google Group above.
You can fetch the source from:
git clone git@github.com:adrianomitre/Polynomial.git
Build and test instructions
cd polynomial rake test rake install_gem
License
This code is free to use under the terms of the MIT license.
Contact
Comments are welcome. Send an email to Adriano Mitre.
FIXME full name, 18th November 2010
Theme extended from Paul Battley