Pragmatic Mathematical Service

The pessimist complains about the wind; the optimist expects it to change; the realist adjusts the sails.
William Arthur Ward

Latest Release

Version 0.0.10


These are the handful of Javascript functions—over 500 to be a bit more exact plus over 180 mathematical and physical constants—that accumulated over the years. Most of them came into existence while in need to do calculations that would be to complicated and partly even impossible to do per pedes with the single help of pen&paper and a sliding rule. That shall not be an excuse for the unholy mess but at least an explanation.

It is not a single monolithic library but separate functions to grab what you need and throw the rest into a corner where the sun rarely shines.

Future plans

About 100 functions still sit on the workbench and await their insertion. The most frequent hindrance is an unknown license associated with a dead email address. These functions would need a complete reimplementation. Another, much smaller part is simply illegible but in such a way that a complete reimplementation would be simpler than a cleanup. A very small part is just too computing intensive to be useful in a Javascript implementation and will most probably published at the very end.

The short term plan is a port of the rest of the statistical tests of Octave; the Bessel and Weber functions from the C-Lib (libmath) which are very urgent but my implementation gives wrong answers sometimes.

The long term plan is to implement the rest of the workbench cover (hopefully done at the end of 2008/start of 2009 if I live that long) and leave it there and add nothing more but bugfixes. And paid-for features of course. And functions I like to see in that packet but do not know that yet. And algorithms people want who send me an extraordinary and tasty cooking recipe. And …

The file Frontend should be the same as the one of the same name in the packet but it is not guaranteed. Please download the package at the download page by exchanging "http" with "https" at the front of the URL. For example "" should be changed to "". The SSL certificate of Sourceforge is attached to the name "", you (hopefully) may get a warning that "" does not belong to the certificate.


The whole package is licensed GPL but most of the individual functions are also under a license which is legally equivalent to the old X-license. See the FAQ for a list and the license.


Javascript is an interpreted language, only partially standardized and interpreted by many different interpreters. It is therefore not guaranteed that the code will be interpreted and translated into machine code correctly and do what it has been told to do. Furthermore: not all functions are thoroughly tested and some algorithms might be of sovereign impreciseness or are even plain wrong. Most of the functions lack input sanitizing, too.

Short Overview

The functions can be sorted loosely into the following groups. See the documentation or the source for the details


Several prototypes for the Array object. From push() and pop() (lacking in some older IEs), forEach() and others introduced by Mozilla/Firefox, some functions to walk over the entries and do something with them to ports of some functions from John Walkers "ent"(e.g. monteCarloPi())


Several functions regarding several discrete and continuous distributions. I ported most of them from Octave (octave/2.1.35/m/statistics/distributions/*) to replace my own writ with something elegant and legible.


Only one function yet: to calculate the capacitance of a cylinder capacitor, a coax cable.


The obligatory calculations with triangles of different kind on the plane and on the sphere. Some calculations for gardeners to build regular polygons. Several helpers to get volume and area of cones, spheres, toruses, and circles and parts of them, a plane Lamé curve and volume of a rotational Lamé curve.


The functions ripped out of a form to calculate a heat store (for solar energy in this case, but it is universal). The full form.


Basic interest calculation. Not very interesting.


Besides several helpers and constants it offers a function to factor an integer (shamelessly stolen from GNU's factor), greatest common divisor, least common multiple, gamma–, beta–, error function, digamma, Pochhammer (raising factorial), factorial, Bernoulli numbers, Chebychev (integers only), factorial, double factorial, hyper factorial, Bessel, Weber, Rieman's and Hurzitz' Zeta and much more.


Basic Matrix operations for small complex matrices (up to 10x10, depending on the power of the machine), addition, multiplication, determinant, transform, adjoint and inverse. These work with arrays and are implemented as prototypes of the Array Matrix object. Some matrix decompositions including the Eigen- and Singular-Value-decompositions for real matrices are included which allow basic linear algebra for smaller matrices (up to about 100x100 depending on your patience and the machines power and memory).


Several means to get means like arithmetic–, geometric–, harmonic–, power mean, mode and median.


A function that proves empirically (so no real proof in the mathematical sense) that the very next element of every arithmetical series given numerical (in a comma separated row like in many so called "Intelligence Tests") is 42.

"1,2,3,4,5,6, what is the next number? Yes, Christoph!"
"Oh no, it's obviously 7, isn't it?"
"No, it isn't, it's obviously 42! With some simple matrix operation you can easily see that the generating formula is simply 0.04861x6 - 1.02083x5 + 8.50694x4 - 35.72916x3 + 78.94x2 - 84.75x + 35. If you replace x with 7 what do you get? Hu? 42, yes!"


Mechanic (Newtonian and relativistic) and more.


Some functions to do very basic plotting, including two examples to test them. There are several very elaborated plotting libraries for Javascript which should be used instead for anything more than the most basic.


Includes what you need. Not more, but also not less.

Statistical tests

Statistical tests like student's test, Fisher exact (2x2), chi2 or ANOVA. Descriptive functions like variance, standard deviation and more. See also "Distributions".


It seems as if my Sourceforge email address (and a lot of others, too) had been used as a From address in SPAM and is thus listed in some of the more stupid blacklists. Please use the email address listed in the AUTHOR file in the download package instead. If you don't want to download the package you can guess what the capital X in means.