The program implements an interactive math-oriented playground based on Javascript. It runs directly in web browser, either online or offline. The program includes basic implementations of complex numbers, matrices and units. While it could be possible to further extend the capabilities by using available math libraries (Numeric Javascript, Math.js, etc), for any serious task one should consider a more performant system, such as Python with SciPy in Jupyter environment.

To allow immediate evaluation of simple formulas, all common mathematical functions and a number of math and physics constants are directly available. Hence, one can simply enter a formula such as sin(45*deg) and after hitting Ctrl+Enter the calculation result will appear in the Output area. To display multiple results, use the function print. Simple graphs are produced with the command plot.

If a part of the code in the Code area is selected, only the selection gets evaluated, otherwise all of the code is executed.

Basic Math Functions

abs(x) Absolute value.
sqrt(x) Square root.
Exponentiation (\(e^x\)) and general power function (\(a^x\)).
Logarithms. log(x,b) returns \(\log_b x\). Parameter b is optional so that log(x) returns \(\ln x\).
Trigonometric functions.
Inverse trigonometric functions.
Hyperbolic functions.
Select minimum or maximum value. Calculate sum, mean and standard deviation. These functions accept arbitrary number of arguments and each arguments can be an array itself.
Generate random numbers spanning \([0,1)\), \([0,b)\) or \([a,b)\).
Number raised to the specified power.

Math and Physics Constants

Constants with units become available only after calling loadConst(true).

pi, π
Mathematical constants.
deg denotes pi/180 (value of a degree in radians).
N_A Avogadro's number.
k_b Boltzmann constant.
eps_0, ε_0 Electric constant (permittivity of vacuum).
q_e Elementary charge
alpha Fine-structure constant.
G Gravitational constant.
mu_0, μ_0 Magnetic constant (permeability of vacuum).
m_e, m_p, m_n Mass of electron, proton or neutron.
h, hbar, ħ Planck constant. hbar or ħ denotes h/(2*pi).
c Speed of light in vacuum.
g Standard gravity (acceleration of free fall).
sigma, σ Stefan-Boltzmann constant.
R Universal gas law constant.
b Wien displacement law constant.
lb, psi, inch, foot, mile, yd, eV, kph, mph, at Values of some common non-SI units (expressed in the SI base units). These quantities are defined only when calling loadConst().


print(a1,a2,...) Sequentially display all arguments in the Output window.
print.digits The default accuracy (number of digits) used for printing numerical values. Defaults to 6.
print.fix If set (true), numerical values are printed in fixed-point format.
print.lines Sets the number of lines visible in the output window.
print.term A (string) value used to terminate the output. Defaults to "\n" (new line).


Makes a graph (in a new window) of the provided data arrays or functions. Additional settings are specified either as the last parameter opts or by using the following global parameters.
plot.range The default plotting range in the form [start, stop, step].
plot.colors The cycle of default colors (an array).
plot.styles The default styles (a string or an array of strings).
'-' indicates line plot and 'o' indicates scatter plot.

Special Math Functions and Objects

Uniform or Gaussian random numbers.
Polynom(coeff) Returns the function \(f(x)=p_0+p_1x+\ldots+p_nx^n\), where the coefficients \(p_i\) are contained in the array coeff.
Error and Gamma functions.
Solve.linear(A,b) Returns the solution vector \(x\) (array of numbers) for the system of linear equations \(Ax=b\), where \(A\) is square matrix of the coefficients and \(b\) is vector of the constant terms. Gaussian elimination method is used.
Solve.root(f,a,b,ε) Finds a root of the function f with an accuracy better than ε. The root must be located between a and b.
Solve.quad(a,b,c) Returns an array of solutions of the quadratic equation \(ax^2+bx+c=0\). You can send the object directly to print to display the solution.
Solve.diff(f,y0,tmax,dt) Uses the classical 4. order Runga-Kutta method to solve the differential equation \(y'=f(t,y)\). Parameter y0 is the initial state at \(t=0\). The iteration proceeds till tmax with a step of dt. In the case of a system of differential equations y0 must be an array and the function f must also return an array of derivatives. A 2-dimensional array is returned, where the first row contains the values of the independent variable and the following rows contain the respective values of the dependent variables.
Fit.line(x,y) Returns a function representing the line which is the best least-squares fit to the data in the arrays x and y. You can send the object directly to print to display the solution. Properties slope and offset contain the optimized parameters of the line.
Fit.poly(x,y,n) Returns a function representing a polynomial of degee n which is the best least-squares fit to the data in the arrays x and y. You can send the function object directly to print to display the solution. Property coeff of the object contains the array of optimized polynomial coefficients.
Fit.spline(x,y) Returns a function representing a "natural" cubic spline going through the data points in the arrays x and y.
Element-wise arithmetic with arrays. The argument x can be either an array or a number. The procedure is recursively applied to array-type elements.
Returns a sequence of equally spaced values.
Creates an object representing a complex number. The object has methods to perform common mathematical operations with complex numbers (add, sub, mul, div, abs, arg, cc, exp, pow, sqrt, log, sin, cos, tan, etc).
Creates an object representing a matrix. The object has methods to add (add), subtract (sub) and multiply (mul) matrices, to calculate transpose (trans), inverse (inv) and determinant (det), and to extract a submatrix (slice, rows, cols).
Qty(value,unit) Creates an object representing a value value with unit unit. Similarly to complex numbers the object defines a set of mathematical operations and also methods to(unit) and in(unit) for unit conversion.
Returns the \(n\)-th Fourier component of the basic waveforms. n is an integer ≥0. Fourier.series(wave,n) calculates the sum of the first n terms in the Fourier series. Each of these functions returns the waveform as a function of \(\omega t\) (the product of angular frequency and time).

Other Useful Functions and Methods

time() Returns current time in milliseconds.
Check the data type of the argument.
(object).prec(n) Converts the object to string so that any contained numerical value is displayed as a floating-point number with n significant digits. Trailing zeroes are omitted. Numbers ≥107 and ≥10n+1 or <10−3 are displayed in exponential notation.
(object).fixed(n) Converts the object to string so that any contained numerical value is displayed as a fixed-point number with n digits after the decimal point. Trailing zeroes are preserved.
(string).pad(len,c,alignLeft) Pads the string with character c (space by default) so that the length of the resulting string is len.
(array).clone() Makes a shallow copy of the array. Array-type elements are recursively cloned as well.
zip(a1,a2,...) Returns an array, where the nth element is an array composed from the nth elements of the argument arrays.

You can download the program for offline use or to add more features .

The program uses CodeMirror for syntax highlighting and Flot for plotting.