ruby_integrator --------------- I. Introduction This software provides an example for how to do numerical integration with ruby and its math library. It is coded to be a functional example and is not necessarily designed for speed although it works well enough. I wrote these classes to help learn the Ruby language. Although I've checked my math against a couple of calculators and a few on-line applets, this software comes with no guarantee and may contain bugs. A particularly good illustration of the estimation techniques used herein is located at: http://www.math.ucla.edu/~ronmiech/Java_Applets/Riemann/index.html II. Usage There are two ways to use the estimator classes. One is to initialize them through a constructor, for example: require 'right_integral_estimator' r = RightIntegralEstimator.new(0, "pi", 100, Function.new("x","sin(x)")) print "Right: " + r.calculate.to_s + "\n" The other is to instantiate the class and then set it up by having the class interact on the user's terminal. This is achieved by doing: require 'right_integral_estimator' r = RightIntegralEstimator.new r.interact print r.inspect + "\n" # completely optional print "Right: " + r.calculate.to_s + "\n" If using the latter method, an example interaction may look like: Please enter a function in terms of the variable x on the line below. For example: (pi*(sin(x^2)))^2 You may use the constants e and pi in your function. Enter f(x) (type q to quit): sin(x^2) Enter start bound (type q to quit): 0 Enter stop bound (type q to quit): 2*pi Enter number of sub-intervals (type q to quit): 100 Shall I show evaluations (y/n) (type q to quit): n Using: a: 0.0 b: 6.28318530717959 n: 100 function: f(x) = sin(x**2) Right: 0.672010534481375 III. Copyright Information ruby_integrator is freely distributable Copyright (C) 2005 Jordan Husney ruby_integrator may be used by public or private entities for any purpose. ruby_integrator may be distributed in source or binary form. If changes are made to ruby_integrator the author will accept patches via e-mail to Jordan Husney but this is not required.