RIMElib logo

RIMElib Homepage


RIMElib - the RuntIme Mathematical Equation Library

RIMElib (the RuntIme Mathematical Equation Library) is a library intended for parsing, evaluating, differentiating and integrating arbitrary (text based) equations. This can be useful in situations where a program must deal with equations that will not be known until runtime (for example, a graphing program, or SVMheavy).

The following code is an example of the use of RIMElib:

#include "rime.h"
#include <iostream>

int main()
{
    MA_node equation;
    MA_node eqn_deriv;
    double x;

    std::cout << "f(x) = ";

    try
    {
        std::cin >> equation;
    }

    catch ( int x )
    {
        std::cerr << "Error " << x << " during equation input operation.\n";

        return 1;
    }

    try
    {
        eqn_deriv = equation.diff(1,1);
    }

    catch ( int x )
    {
        std::cerr << "Error " << x << " during differentiation.\n";

        return 1;
    }

    std::cout << "f'(x) = " << eqn_deriv << "\n";

    std::cout << "x = ";
    std::cin >> x;

    std::cout << "f(" << x << ") = " << equation(x) << "\n";
    std::cout << "f'(" << x << ") = " << eqn_deriv(x) << "\n";

    return 0;
}

Typical compilation (djgpp, assuming both rime.h and librime.a are in the same directory as the above code (which is saved under the name testweb.cc)) is:

gxx -W -Wall testweb.cc -L. -lrime -lgsl -o testweb.exe

An example of usage is:

E:\code\rimelib\tests>testweb
f(x) = sin(x^2)
f'(x) = #18: ((2*x)*cos((x^2)))

x = 3.2
f(3.2) = -0.727878
f'(3.2) = -4.38852

E:\code\rimelib\tests>_

where the #18: preceeding the derivative gives the length of the string "((2*x)*cos((x^2)))" (the derivative of sin(x^2) ). For a more advanced example, see the file test.cc which comes with the code. If preferred, a C interface is also provided for the library (erime.h is the header file in this case). RIMElib itself is written entirely in C, so if required the C++ wrapper may be removed completely. Note that RIMElib requires that the GNU Scientific Library to work (the gsl "special functions" are used by RIMElib).

RIMElib is written by Alistair Shilton (a p s h at ee dot unimelb dot edu dot au), and is released under the GPL licence. Click here to download.


Older Versions


RIMElib source version 0.4.
RIMElib pre-compiled (DJGPP) library 0.4.
RIMElib pre-compiled test program (DJGPP) 0.4.


For DJGPP Users - A Pre-compiled Version of the GSL Library

RIMElib requires the GNU Scientific Library. However, unless major changes have happened in the most recent release of GSL, installing GSL for DJGPP is a rather painful operation involving much script editing and some rather crude hacks. This is not intended to be a putdown for gsl (which, ime, installs painlessly under linux) - it's just that, despite the minor miracles performed by the good people at http://www.delorie.com/djgpp, DOS is still, well, not the best CLI in existence ;). So, to save you much time (and hair), I've decided to make a pre-compiled binaries for DJGPP available for download here.

To install, just dump the contents of the zip to the relevant parts of the djgpp folder. If it doesn't work, sorry, can't help - I've been through the installation process once and have no plans to repeat the experience anytime soon.

Good luck.


Download GSL binary for DJGPP.

RIMElib logo


This page, its contents and style, are the responsibility of the author and do not necessarily represent the views, policies or opinions of The University of Melbourne.

Created : 14th October, 2004

Last Modified : 20th March 2007
Maintained by : Alistair Shilton (a p s h at ee dot unimelb dot edu dot au)
 

Valid HTML 4.01!