SciRuby

Tools for Scientific Computing in Ruby

NMatrix’s First Beta Release (Belated Announcement)

Almost two months ago, in December, we release our first beta of NMatrix, our linear algebra library for the Ruby language.

Rather than discussing what NMatrix has (which you can find in the readme), I want to take this opportunity to discuss where we’d like it to go in the future. Think of this as our roadmap to 1.0.

External Library Requirements

NMatrix currently has an extremely limited set of Ruby gem dependencies — essentially only packable, which is needed for some of the I/O functionality — but as with other linear algebra libraries, its native library requirements can be problematic.

Specifically, NMatrix requires ATLAS — which is virtually impossible to install on many Macs, and is no longer readily available with Yosemite — and also likes to have LAPACK around. Moreover, some would prefer to use other math libraries with NMatrix.

There are several partial solutions. The clearest is that any components of NMatrix which require external non-standard libraries need to be abstracted into separate gems — such as nmatrix-atlas and nmatrix-io — and that these components should be interchangeable with others. NMatrix then needs to be able to fall back on either native C/C++ or Ruby implementations of certain functionalities.

To this end, a number of simple LAPACK and CBLAS functions have been implemented in NMatrix, with volunteers working on a few others (the list is available in the README). One of our proposed Google Summer of Code 2015 project ideas involves breaking up NMatrix into several gems.

The end result will be a much simpler installation process, and more freedom of choice.

Removal of Unnecessary Features

We thought it would be quite clever to include rational number support in NMatrix, including three types (32-bit, 64-bit, and 128-bit). Unfortunately, these types increase compilation time by about 30% (back-of-the-envelope calculation), and aren’t particularly useful since most matrix operations with rationals as inputs give irrational-valued matrices as their outputs. The inclusion of rational types also complicates the codebase.

Additionally, rationals are computationally problematic; what happens if there is overflow? Ruby handles overflow gracefully in its own rational type, which NMatrix users would still be able to utilize via the :object dtype.

You

The biggest change going forward is that NMatrix development needs to support actual use-cases. In the past, we’ve aimed to flesh out support for sparse storage formats, as well as math operations for the dense storage-type. It is folly to develop features no one wants to use. Future core development, then, will aim to make NMatrix’s current feature set more usable.

That means that future non-core development depends on you. What would you like to see in NMatrix? What would make it more useful for you?

If you want to become involved, now is a good time. We’re getting ready to submit a Google Summer of Code application (our third, I believe), and we’re in need of students — and especially mentors. Please consider joining our mailing list and adding yourself as a mentor on the ideas page.

Thanks so much for your support!

Nyaplot: Interactive Plots Generator With Ruby

Introduction

Three months of GSoC 2014 term was over this week and finally I released my product Nyaplot as a gem. This blog post was written to introduce Nyaplot version 0.1.1.

Features

There are various plotting libraries in the world as ggplot2 from R community and Plotrb and Rubyvis from Ruby. The features of Nyaplot compared with those libraries are interactivity, simplicity, and extensibility.

Interactivity is the main theme of my D3 project in GSoC 2014. You can soon find the aforementioned interactivity by clicking plots with your mouse or trackpad. This feature is also available on browsers bundled with Android or iOS thanks to technologies like SVG and WebGL.

However, the word ‘interactivity’ is not limited to situations like the above. You can explore that for yourself by using Nyaplot in IRuby notebook. Various modules prepared by Nyaplot help you to create plots interactively in the notebook. You can also publish the result quickly by uploading the notebook to your Dropbox storage, a gist or pastebin, or somewhere else. Here is an example which Mauricio Giraldo created and published on gist.

Simplicity is also an important element. Many plotting libraries has MATLAB-like function-based API but Nyaplot does not. Nyaplot is designed in a more Ruby-like object-oriented style, and its plots consist of various objects created from different classes. But Nyaplot has simple shortcut methods and users may avoid the more complex API.

Extension libraries

Nyaplot can be easily and dramatically extended with some JavaScript code. It bundles 3 extension libraries in its gem package: Nyaplot3D for 3D plots, Mapnya for map visualization, and Bionya for circular plots inspired by circos. Their structure is very simple and you can write the extension easily if you have a little experience in JavaScript and Ruby. For example, the Ruby part of Bionya has only about a hundred lines, even though the graphic’s style is far from that of standard plots.

Quick start

You can install Nyaplot by simply running gem install nyaplot. After that, find example code from path_to_gems/nyaplot-0.1.1/examples/rb and run some of them using ruby command. These scripts will generate some plots with Nyaplot and export them as html files to current directory.

In addition, I strongly recommend you to install IRuby notebook at the same time. IRuby is a web-based, interactive Ruby environment and is useful for quickly creating plots with Nyaplot. The introduction video embedded at the top of this post was also created on IRuby.

IRuby depends on some software outside of Ruby-ecosystem, so its installation method is a bit complicated. Please read the description in the readme to learn more.

Usage

I already wrote tutorials, so I’d like to limit the role of this paragraph to the introduction of the basic usage. You can skip reading this paragraph and find details in the nbviewer tutorial and documentation.

The minimum code to create a scatter plot is as shown below:

1
2
plot = Nyaplot::Plot.new
sc = plot.add(:scatter, [0,1,2,3,4], [-1,2,-3,4,-5])

Nyaplot::Plot is the base class to create plots and Nyaplot::Plot#add is the method to add diagram to its instance. The first argument is to specify the type of diagram, and the second and third are for data mapped into x and y axes. Plot#add returns an instance of Nyaplot::Diagram and you can change attributes like color and stroke of each diagram component.

For example you can change its color by running the code below.

1
2
color = Nyaplot::Colors.qual
sc.color(color)

Nyaplot::Colors is the simple wrapper for Colorbrewer, and one of its methods Nyaplot::Colors.qual randomly returns colorset suitable for qualitative data.

If you execute this code in IRuby notebook, you can check if you favor the colorset through html-table based interface. See the tutorial to learn more.

Nyaplot::Colors

The plot generated from the code can be exported with two lines below.

1
2
plot.show # show plot on IRuby notebook
plot.export_html # export plot to the current directory as a html file

We cannot explain Nyaplot without Nyaplot::DataFrame. Example code above does not contain the word ‘DataFrame’, but the software internally create an instance of Nyaplot:DataFrame and creates plots based on it.

To create the same scatter plot as above, run the code below.

1
2
df = Nyaplot::DataFrame.new({a: [0,1,2,3,4], b: [-1,2,-3,4,-5]})
plot.add_with_df(df, :scatter, :a, :b)

You may not feel any advantage of using Plot#add_with_df instead of Plot#add, but the former is useful when creating more complicated plots. Have a look at the tutorial to learn more.

Conclusion

My GSoC term has concluded, but that do not mean the end of development. There are still many things to do for improvement of this project. For example Mapnya and Bionya are both experimental implementation, and the functionality of Nyaplot::DataFrame is relatively limited. If you are interested in this project, please fork either or both of the two repositories below and send me pull-requests.

Any form of contribution is welcome.

At last I’d like to express my gratitude to my mentor Pjotr Prins and other members of SciRuby community. I would not have been able to finish my GSoC term without great help from them. Feedback from people outside of the community also helped me a lot. I had a great summer thanks to all people related to this project.

Benchmarks for Integration Gem

The Integration gem now includes quite a few functions from which to choose. To make this choice easier, I have done some benchmarking to see how fast and acuurate each of these functions are. The results of these tests for some randomly chosen functions are given below. The speed test reports shows the user CPU time, system CPU time, the sum of the user and system CPU times, and the elapsed real time to perform 100 iterations of the code. The unit of time is seconds.

For function f(x)= x2+3*x+7 on interval (0,1)

Speed Tests

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
Benchmarking with 100 iterations
                                user     system      total        real
rectangle                  72.040000   0.010000  72.050000 ( 72.058014)
                                user     system      total        real
trapezoid                 105.500000   0.000000 105.500000 (105.489225)
                                user     system      total        real
simpson                     0.020000   0.000000   0.020000 (  0.017601)
                                user     system      total        real
romberg                     0.000000   0.000000   0.000000 (  0.002219)
                                user     system      total        real
adaptive_quadrature         0.010000   0.000000   0.010000 (  0.002757)
                                user     system      total        real
gauss                       0.010000   0.000000   0.010000 (  0.006439)
                                user     system      total        real
gauss_kronrod               0.000000   0.000000   0.000000 (  0.008615)
                                user     system      total        real
simpson3by8                 0.080000   0.000000   0.080000 (  0.074791)
                                user     system      total        real
boole                       0.100000   0.000000   0.100000 (  0.100300)
                                user     system      total        real
open_trapezoid            181.470000   0.050000 181.520000 (181.572745)
                                user     system      total        real
milne                       0.060000   0.000000   0.060000 (  0.058677)
                                user     system      total        real
qng                         0.000000   0.000000   0.000000 (  0.003788)
                                user     system      total        real
qag                         0.010000   0.000000   0.010000 (  0.010407)

Accuracy Tests

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+---------------------+-------------------+-------------------+------------------------+-------------------+
|       Method        |      Result       |   Actual Result   |         Error          |     Accuracy      |
+---------------------+-------------------+-------------------+------------------------+-------------------+
| rectangle           | 8.833333324123249 | 8.833333333333334 | 9.210085138988688e-09  | 99.99999989573489 |
| trapezoid           | 8.83333334502252  | 8.833333333333334 | 1.1689186507624072e-08 | 99.99999986766959 |
| simpson             | 8.833333333333332 | 8.833333333333334 | 1.7763568394002505e-15 | 99.99999999999997 |
| romberg             | 9.0               | 8.833333333333334 | 0.16666666666666607    | 98.11320754716982 |
| adaptive_quadrature | 8.833333333333334 | 8.833333333333334 | 0.0                    | 100.0             |
| gauss               | 8.750000000006125 | 8.833333333333334 | 0.08333333332720905    | 99.05660377365425 |
| gauss_kronrod       | 8.75              | 8.833333333333334 | 0.08333333333333393    | 99.0566037735849  |
| simpson3by8         | 8.833333333333336 | 8.833333333333334 | 1.7763568394002505e-15 | 99.99999999999997 |
| boole               | 8.833333333333336 | 8.833333333333334 | 1.7763568394002505e-15 | 99.99999999999997 |
| open_trapezoid      | 8.833333325264693 | 8.833333333333334 | 8.068640866554233e-09  | 99.9999999086569  |
| milne               | 8.833333333333334 | 8.833333333333334 | 0.0                    | 100.0             |
| qng                 | 8.833333333333334 | 8.833333333333334 | 0.0                    | 100.0             |
| qag                 | 8.833333333333336 | 8.833333333333334 | 1.7763568394002505e-15 | 99.99999999999997 |
+---------------------+-------------------+-------------------+------------------------+-------------------+

For function f(x) = x5+7*x2+2*cos(x) on interval (0,1)

Speed Tests

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
Benchmarking with 100 iterations
                                user     system      total        real
rectangle                 534.790000   0.510000 535.300000 (538.238675)
                                user     system      total        real
trapezoid                 835.950000   0.540000 836.490000 (839.233313)
                                user     system      total        real
simpson                     0.650000   0.000000   0.650000 (  0.652694)
                                user     system      total        real
romberg                     0.010000   0.000000   0.010000 (  0.002073)
                                user     system      total        real
adaptive_quadrature         0.170000   0.000000   0.170000 (  0.167520)
                                user     system      total        real
gauss                       0.000000   0.000000   0.000000 (  0.007621)
                                user     system      total        real
gauss_kronrod               0.020000   0.000000   0.020000 (  0.010610)
                                user     system      total        real
simpson3by8                 0.820000   0.000000   0.820000 (  0.831039)
                                user     system      total        real
boole                       0.120000   0.000000   0.120000 (  0.119929)
                                user     system      total        real
open_trapezoid            1019.100000   0.150000 1019.250000 (1020.034828)
                                user     system      total        real
milne                       0.980000   0.000000   0.980000 (  0.970671)
                                user     system      total        real
qng                         0.000000   0.000000   0.000000 (  0.008263)
                                user     system      total        real
qag                         0.020000   0.000000   0.020000 (  0.020050)

Accuracy Tests

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+---------------------+--------------------+--------------------+------------------------+-------------------+
|       Method        |       Result       |   Actual Result    |         Error          |     Accuracy      |
+---------------------+--------------------+--------------------+------------------------+-------------------+
| rectangle           | 4.182941950501391  | 4.1829419696157935 | 1.9114402505238104e-08 | 99.99999954303927 |
| trapezoid           | 4.182941993679488  | 4.1829419696157935 | 2.406369414842402e-08  | 99.99999942471844 |
| simpson             | 4.182941969798875  | 4.1829419696157935 | 1.8308110583120651e-10 | 99.99999999562314 |
| romberg             | 5.54030230586814   | 4.1829419696157935 | 1.3573603362523468     | 67.5501035847021  |
| adaptive_quadrature | 4.182941969702552  | 4.1829419696157935 | 8.675815621472793e-11  | 99.9999999979259  |
| gauss               | 3.5364151237832213 | 4.1829419696157935 | 0.6465268458325721     | 84.54372901826423 |
| gauss_kronrod       | 3.5364151237807455 | 4.1829419696157935 | 0.6465268458350479     | 84.54372901820506 |
| simpson3by8         | 4.182941969676288  | 4.1829419696157935 | 6.049472034419523e-11  | 99.99999999855378 |
| boole               | 4.182941969615793  | 4.1829419696157935 | 8.881784197001252e-16  | 99.99999999999997 |
| open_trapezoid      | 4.182941952971977  | 4.1829419696157935 | 1.6643816103112385e-08 | 99.99999960210263 |
| milne               | 4.18294196954598   | 4.1829419696157935 | 6.981348832368894e-11  | 99.99999999833099 |
| qng                 | 4.182941969615793  | 4.1829419696157935 | 8.881784197001252e-16  | 99.99999999999997 |
| qag                 | 4.1829419696157935 | 4.1829419696157935 | 0.0                    | 100.0             |
+---------------------+--------------------+--------------------+------------------------+-------------------+

If you are keen to test any function of your choice you can pull from my Integration gem fork and change the files in the benchmark folder. For both the files, accuracy.rb and speed.rb, change the line func = lambda{|x| f(x)} with f(x) as your desired function. In case you want to perform accuracy benchmarks, make sure that you know the exact result of the integration operation before hand and assign this value to the variable actual_result Feel free to comment if you face any problem running the benchmarks with your desired functions.

The Nyaplot Internal Event Handler

Nyaplot multi-pane example

Introduction

Last week I implemented the multiple panes interactivity to the front-end of Nyaplot. You can see the demo on this notebook.

Skip over single pane demo, and have a look at the paragraph ‘Multiple panes demo’ at the bottom. In this example, the histogram and bar chart are created individually, and then thrown into one instance of Nyaplot::Frame. After running frame.show, both of the diagrams appear in one out-put box on the notebook. When you click the histogram, bar chart refrects that and change its height.

In this article I will explain about the event handler of Nyaplot, which allows for interactivity among panes.

The Trick

The trick is actually hidden in Nyaplot::DataFrame. In this example, both of the two diagrams are generated from columns in one DataFrame. When Nyaplot receives a column object (instance of Nyaplot::Series, defined here), it internally find its source data frame and remembers its location.

Consequently, Nyaplot can find that histogram and bar chart are sharing their data source, and allows them to interact with each other.

Nyaplot::DataFrame Example

Implementation

Before explaining the event handler, I want to outline Nyaplot’s diagram rendering procedure. In the back-end JavaScript library, diagrams, such as histograms, fetch column data from data frames and generate their SVG DOM nodes dynamically (source code).

The key is a data frame written in JavaScript. After mouse events coming from a filter (such as the gray box on the plot area) are handled, the histogram registers its filter function to the data frame and instructs all diagrams to update their SVG DOM objects. The bar chart updates its SVG from data filtered by the new function.

As you can see, Nyaplot’s inner workings are fairly simple; and these workings are common to all diagrams supported by Nyaplot. So not only the histogram and bar chart, but other diagrams as well, can behave interactively (e.g., histogram, bar, and Venn example).

Conclusion

Despite, or perhaps because of, the relative simplicity of the structure, the event handler functions well. The actual interactivity in Nyaplot is based on the data frame object, both in the Ruby front-end and the JavaScript back-end. As a result, handling events in DataFrame is both natural and efficient for Nyaplot.

Additional Information

Nyaplot and its back-end library Nyaplotjs are being developed on GitHub.

If you are interesed, feel free to try it and raise issues or send pull-requests.

Usage: Integration Gem Improvements

Numerical Integration

Integration is the process of finding the summation of the value of a function at small intervals, when the width of the intervals is infinitesimally small. As there is no such thing as “infinitesimally small interval”, there are several other methods which help us to approximate the values of integrals.

Numerical integration is one such technique which helps us to estimate the value of the definite integral of a function over an interval. Numerical integration is based on the principle of evaluating the values of a function at specific points in the interval and then taking the product of those values with a corresponding weight, which is a standard constant specific to the method being used.

Integration Gem

The Integration gem is now equipped with a host of additional algorithms for approximating the integral of a function ranging from the simple ones like Simpson’s method to the more complex ones like Gauss–Kronrod and Adaptive Quadrature method.

Example

Let us say you need to find out the integral of a function 5*x**2 -7*Math.cos(x) over the interval (0,1). We can solve this using the following snippet using the Integration gem:

1
2
Integration.integrate(0,1,{:method=>:simpson}) {|x| 5*x**2 -7*Math.cos(x)}
# => -4.223630227110514

We see that the actual value of this integral is -4.2236302269886088799000849584, which is pretty close to the value estimated by the integration gem. Instead of {:method=>:simpson} in the above code, you can use any one of these implemented methods:

1
rectangle,:trapezoid,:simpson, :adaptive_quadrature , :gauss, :romberg, :monte_carlo, :gauss_kronrod, :simpson3by8, :boole, :open_trapezoid, :milne

Each of these algorithms gives similar results — except if the function has rapid changes in the interval of integration, as is the nature of numerical integration.

The Progress of the GSoC D3/Visualization Project

This week is the half-way point of this year’s Google Summer of Code. Let me report the progress during the term.

Example Nyaplot chart of a spiral

Progress on the front-end library

I am developing Nyaplot as the front-end library for my work.

One topic on Nyaplot is API design. That is a difficult problem since each plotting library has very different methods for creating plots. For example, matplotlib and Bokeh are both written in Python, but their demo code is written in very different styles. After discussing with my mentor, I decided to implement the function-based API.

As an exmaple of that API, here is a minimal working example for generating bar charts with Nyaplot:

1
2
3
4
require 'nyaplot'
plot = Nyaplot::Plot.new
plot.add(:bar, ['nya1', 'nya2', 'nya3'],[10,20,30])
plot.show

If you want to change options (e.g., color or title), put the return value of Nyaplot::Plot.add into a variable and call its methods.

1
2
bar = plot.add(:bar, ['nya1', 'nya2', 'nya3'],[10,20,30])
bar.title("the number of cats") # name the bar chart

IRuby integration

Interaction with IRuby is a priority for Nyaplot. IRuby is a web-based Ruby lab notebook-like environment, based on IPython, which is also useful for fast prototyping.

The image at the top of this blog post is a hyperbolic spiral which I generated with Nyaplot in IRuby. Have a look at the notebook on nbviewer, an IRuby and IPython notebook hosting services.

Progress on the back-end library

Nyaplot uses Nyaplotjs as its back-end library. I spent a lot of time working to implement interactivity among multiple panes to Nyaplotjs. See an example here.

Three-pane interactivity screenshot

The input data source is a TSV file of 2,044 lines. Multiple-pane interactivity is especially important when visualizing such a large dataset.

Have a look at the radio buttons beside the Venn diagram. The left three panels decide which set to put into each of three circles (VENN1, VENN2, VENN3). The right panel decides which data in each area (overlapping area, non-overlapping area, and all) to use in the other two panes.

The gray box on the histogram decides the range of PNR values. If you select the range 0.3 to 0.7 with it, the right bar chart will reflect that and show how many of the selected data are in that range.

Nyaplotjs provides this interactivity using an event handler connected to a dataframe object. That allows us to handle unidirectional update method (e.g., histogram updates bar chart, but bar chart does not update histogram).

Conclusion

I finished the first half term of Google Summer of Code 2014, but I still have a lot of things to do. I would like to continue to add interactivity to both the front-end and back-end libraries.

I am developing those two libraries in separate repositories on GitHub. If you are interested, feel free to raise issues or send pull-requests, even during the GSoC term.

Updates: Minimization and Integration

Minimization

The Minimization gem now supports the following unidimensional function minimizations provided by GSL. The supported methods include the pure Ruby implementations of:

  1. Newton–Raphson
  2. Golden Section
  3. Brent
  4. Quad Golden

Of these, the Golden Section, Brent, and Quad Golden are also available via Minimization’s GSL interface (and are thus faster). Everything is organized in such a way that the faster C code (i.e., GSL) will be executed when GSL is available, but that otherwise the Ruby implementation will be used. I still have to beautify the code and add documentation.

Integration

The Integration gem has been transitioned from Hoe to Bundler. For Gauss–Kronrod Quadrature, I have hard-coded the values of nodes and weights (for 15, 21, 31, 41, and 61 points) — which were already hardcoded in the case of the Gauss quadrature.

Additionally, I added basic methods like Simpson’s Three-Eighths Method, Milne’s Method, Boole’s Quadrature and Open Trapezoid.

This week, I will be reviewing a pull request which aims to change the structure of the whole Integration gem.

After that I plan to implement more adaptive methods and incorporate the non-adaptive methods under a single Newton–Cotes function.

Lastly, I am brainstorming designs for symbolic integration using JScience and JRuby.

Progress on Minimization Methods

Current Progress on Minimization Gem

In the first half of the summer, I plan to introduce some new numerical minimization methods to SciRuby’s Minimization gem. As per my proposal, I began by implementing the Powell’s multidimensional minimization method. Powell’s method has a better convergence in most cases than the Nelder–Mead algorithm, and is also a multidimensional minimization method which doesn’t use any derivative of the function.

I started by studying SciPy and Apache Commons library’s Powell’s optimizer. I decided to base my implementation on the method from the Apache Commons Mathematics Library. Powell’s method requires a line minimum searching algorithm, for which I used Brent minimizer (already available in SciRuby).

Having finished with Powell’s method, I am now working on the Fletcher–Reeves minimization method — a gradient method which uses the first derivative of the integrating function.

Introduction: Minimization and Integration (Lahiru)

Editor’s Note: We have two students working on numerical minimization and integration this summer, Rajat and Lahiru. Rajat’s introductory post appeared two weeks ago.

Introduction

I’m Lahiru Lasandun and I’m an undergraduate of University of Moratuwa, Sri Lanka. I’ve been selected for Google Summer of Code 2014 for SciRuby’s Minimization and Integration projects.

I was working with SciRuby about a month before GSOC started and did some tests on how to enhance the performance of these numerical computations. My first idea was to use multi-threading. With the instuctions and guidance of mentors, I tested more methods such as Erlang multi-processing, the AKKA package of multi-threading, and finally OpenCL. The final decision was to use OpenCL to enhance computation power of these mathematical computations with the support of multi-cores and GPUs.

Minimization Gem

After GSOC started, I began working on SciRuby’s Minimization gem. I proposed multidimensional minimization methods for the Minimization gem, which already had plenty of unidimensional minimization methods. I chose two non-gradient and two gradient minimization methods as well as simulated annealing.

Integration Gem

For Integration, I proposed to replicate some unidimensional integration methods from the GNU Scientific Library, GSL. Additionally, I proposed to add OpenCL support to enhance performance of integration methods.

Current Progress

Currently, I am working on Nelder–Mead multidimensional minimization method which is a non-gradient method, including working on the relevant test cases.

Introduction to the Minimization and Integration Project (Rajat)

Editor’s Note: We have two students working on numerical minimization and integration this summer, Rajat and Lahiru. Lahiru will be writing a separate post about his work.

Introduction to the Minimization and Integration Project

Hi. My name is Rajat Kapoor and I have been selected to work with SciRuby for Google Summer of Code 2014.

Minimization and Integration are two of the many available gems in the SciRuby suite. My project this year aims to improve these gems to replicate the functionality provided by GNU’s GSL. I will be trying to implement all the minimization and integration algorithms present in GSL in pure Ruby, with improvements as needed, so that these functions are easily accesible to all Ruby users, while the users which have GSL already installed will have an advantage in terms of speedy computations.

What Minimization and Integration actually mean

Minimization refers to the process of finding out the minimum of a mathematical function whose values might depend on multiple variables. Unidimensional minimization restricts these problems to functions of one single variable. Integration is the same as the very widely used concept in calculus which basically boils down to finding the summation of the value of a function at small intervals, when the width of the intervals in infinitesimally small. I can bet that you knowingly or unknowingly use both these things on a daily basis.

The plan

The project can be broken into two major parts: Minimization and Integration, as these are two seperate gems.

The Minimization gem can be broken in two parts: unidimensional (or univariate) and multidimensional (multivariate). With respect to coding, these two can again be broken down into sub-parts: pure Ruby implementations and GSL support. The Integration gem will include the pure Ruby implementations as well as GSL support. Along with this, some support for symbolic integration will be added for JRuby users by way of the JScience library.

Progress

The pure Ruby implementations of the unidimensional minimization part are almost finished. I am also working on the GSL support for the same along with it. I plan to finish up any unidimensional minimization work by the end of this week and start the work with multidimensional minimization methods.

Keep watching this blog for more updates regarding my project.