Table Of Contents

What is it?

I have developed a great affinity for using LISP as an interactive mathematical problem solving tool and general algorithm development environment. This has resulted in the accumulation of a good deal of mathematically oriented LISP code over the years, and sharing that code is what this page is all about. So, if you are a mathematically inclined LISPer looking for a particular mathematical routine, then you may well be in the right place -- assuming you have a high tolerance for ugly/buggy LISP and can forgive my unapologetic, raging case of NIH Syndrome!

How do I use it?

First and foremost, I keep a REPL up and running all the time with this code loaded -- makes for a great alternative to those silly GUI calculator applications! Please note the code really is designed for interactive use inside of a smart REPL. I use SLIME+SBCL inside of GNU Emacs.

*MJRCALC* is in no way a replacement for tools like Maple or Mathematica -- I use them both. Instead of trying to do everything with a single, powerful tool, I find my problem solving efficiency is much higher when I use a suite of specialized tools for tasks each is particularly good at, and this is where *MJRCALC* comes into play. I think of it as a bit of glue allowing me to more effectively weave such tools together. In fact, I frequently have several mathematical tools running in the same Emacs session with *MJRCALC* : Octave, Maxima, GAP, Macaulay2, and R. Speaking of weaving systems together, *MJRCALC* can drive GNUPlot through a pipe for simple, immediate visualization. For more sophisticated, interactive visualization, *MJRCALC* can produce VTK files for tools like VisIt and Paraview -- I really love VisIT. For less immediate visualization needs, *MJRCALC* can also generate files for POV-Ray.

What can all of this LISP code do? That's a hard question to answer directly, so I'll just list some of the things I have used it for over the years:

Desktop calculator replacement. ;)

Development and prototyping of deeply algorithmic and/or mathematical software

Numerical analysis linear algebra integration ODEs PDEs Optimization Root finding

Dynamical systems modeling and simulation (ODEs, PDEs, and algebraic equations) Efficient solutions to Kepler's equation High speed orbital dynamics (modeling the motion of thousands of solar system bodies) High accuracy integration of planetary systems Large scale particle simulation (Galactic dynamics, fungal growth, fountains, ...) Diffusion simulations Mathematical Population dynamics

Symbolic algebra Computational commutative algebra (solving polynomial systems, Grobner basis, etc...) Non-numeric root localization Rational and integer roots and critical points Combined symbolic and numerical algorithms Factorization of polynomials over the integers and prime order fields Symbolic differentiation of LISP forms Analytical solution of differential equations

Combinatorial enumeration and counting algorithms Most of the 12-fold way Several combinatorial functions Generation of combinatorial objects (sets, cross products, permutations, combinations)

Computational group theory Electron orbital mechanics Crystal lattice formation

Probabilistic modeling and simulation (complex systems or statistical tests)

Sophisticated data visualization problems

Project Euler problems

Gallery

Instead of providing a few boring snips of code (for that see the example code in the download section), here are some pretty pictures generated by this code base in conjunction with tools like GNUPlot, VisIt, and POV-Ray.

Support

Please feel free to contact me if you find a bug, have an idea for an improvement, or just want to chat about implementation details. I can't guarantee I'll be able to act on such feedback in a timely fashion, but I do try very hard to eventually read and respond to all of my mail.

Paid support

Sorry, I don't provide paid support for this product. I have previously accepted contracts for very specific enhancement requests; however, my acceptance has been most strongly influenced by just how interesting the project was and not the cash offer.

Contributed Patches

I hate to say it, but contributed patches are difficult to deal with because of the complexity of copyright and IP law. I would rather get a bug report or enhancement request in plain English than a patch file.

About Quality and Consistency

This code base is an organically growing and evolving project dynamically changing as my work and needs evolve. This has a couple implications. First, this code base will always contain various functions in the middle of being re-factored (i.e. broken) or in the process of being implemented. The second implication is that I freely change things as I recognize dumb API decisions and find opportunities to make the code work better. If you plan on including this code in a long term project, then my advice is to fork the code and then be very careful about updates.

Loading and using the Code in your REPL

The authoritative source for information regarding how to load the code into your LISP is found in the documentation string for the function MJR_META_HELP found in the :MJR_META package (in file lib-meta.lisp ). What follows is a brief, perhaps out of date, account of what you can find documented in lib-meta.lisp .

The ASDF Way

If your LISP has a modern (post v3) version of ASDF installed and you have placed the source for *MJRCALC* into one of the places your ASDF looks for packages, then you can simply do the following:

(load "/full/path/to/where/you/put/*MJRCALC*/sup-lm-asdf.lisp")



Of course you can use the file name, not the full path, if your LISP is in the directory with the *MJRCALC* source. The code in the sup-lm-asdf.lisp file is quite simple. In essence, it runs three functions:

(require :asdf)

(asdf:load-system :mjrcalc)

(mjr_meta::mjr_meta_use-packages :BASE-PATH "/full/path/to/where/you/put/*MJRCALC*/")



The Meta Way

While most users will make use of ASDF, this not a requirement. The :MJR_META package can load the code (and do a whole lot more). If you just want to load everything up and do a use-package on everything, then the following will do the trick:

(load "/full/path/to/where/you/put/*MJRCALC*/lib-meta.lisp")

(mjr_meta::mjr_meta_load-packages :BASE-PATH "/full/path/to/where/you/put/*MJRCALC*/")

(mjr_meta::mjr_meta_use-packages :BASE-PATH "/full/path/to/where/you/put/*MJRCALC*/")



If your LISP is in the directory with the *MJRCALC* code, then you can nix the :base-path argument, and use just the file name in the load call. In fact, if you are in the directory with the *MJRCALC* , then you could simply load up sup-lm-meta.lisp :

(load "sup-lm-meta.lisp")



This last method is most like the load system used by *MJRCALC* before the conversion to ASDF. So if you have some old code looking for an equivalent to the historical load method, this is where to start.

The Hard Way

If you want to load the stuff up yourself then you will need to be careful of code dependencies. In the following graph the prefix of " MJR_ " has been removed. Normal code is blue, and test code is pink. The arrows point in the direction of the dependency (here is a PDF version, and here is one with unit tests).

Interactive Use

All the functions are contained in packages. All package names begin with the string " MJR_ ". Following this standard prefix is a tag describing the category of functionality and an underscore. Immediately after this second underscore, is a descriptive name for the function. For example, " MJR_MAT_NORM " is a matrix function computing a norm while " mjr_nleq_root-newton " is a function for "NonLinear EQuations" which finds roots via Newton's method.

Because of this naming structure, tab completion may be used to great advantage both as a way to save typing effort and a way to discover function names. SLIME shows the function argument names in the Emacs message window after the function name and a space are typed at the REPL prompt, so function arguments are somewhat systematically named across packages and are a bit more verbosely named than is usual for LISP code.

All the functions have a comment string, so you can use LISP's documentation system to learn about them. Most packages have a "help" function, mjr_nleq_help for example, which will dump its own documentation string when evaluated -- this string generally contains a description of the package and some information useful for understanding how to use the package. You can also take a look at the comment at the top of each file. The unit tests, linked in the download section below, can be a great help in understanding what the functions are intended to do. Finally, several examples linked below may be helpful in understanding how to use the library.

Legal Stuff

All materials available from this website is copyright protected © 1990-2015 by Mitch Richling.

This software, *MJRCALC* , is licensed under a BSD-like license. You can find it in the LICENSE.TXT file in the distribution. The content of that file is as follows:

/* -*- Mode:text; Coding:us-ascii-unix; fill-column:132 -*- */ The license for this software is as follows: ======================================================================= Copyright (c) 1994-2015, Mitchell Jay Richling All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions, and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions, and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =======================================================================

Let me say it again... Under no circumstances and under no legal theory, whether in tort, contract, or otherwise, shall Mitch Richling be liable to you or to any other person for any indirect, special, incidental, or consequential damages of any character including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or for any and all other damages or losses.

If you do not agree with these terms, then you must not use the software.

FAQ

I went without a FAQ for *MJRCALC* for a long time. Now that the user community has grown, it seems the time has come to start one up.