Algebrite is a simple, comprehensible and extensible Javascript library for symbolic computation.

Why Algebrite

lightweight: made to be simple to comprehend and extend, it only depends on BigInteger.js by Peter Olson.

made to be simple to comprehend and extend, it only depends on BigInteger.js by Peter Olson. self-contained: doesn't need connection to servers or another "backend" CAS

doesn't need connection to servers or another "backend" CAS a library: beyond use as an interactive tool, Algebrite can be embedded in your applications and extended with custom functions.

beyond use as an interactive tool, Algebrite can be embedded in your applications and extended with custom functions. free: MIT-Licenced

Features

Algebrite is...

...these are just some of the features. For an organic view please check the function reference.

Usage via API or custom scripting language

Algebrite comes with its own scripting language, but all functions are also exposed as API for standard JS integration. See function reference for API description.

# internal scripting language x+x

// standard javascript via API Algebrite.run('x + x');

Arbitrary-precision arithmetic

100! # gets long after 50000!

factor(100!)

Fractions

13579/99999 + 13580/100000 numerator(1/a+1/b) denominator(1/(x-1)/(x-2)) rationalize(a/b+b/a)

Complex quantities: rectangular and polar

A=1+i B=sqrt(2)*exp(i*pi/8) A-B rect

Simplification

simplify(cos(x)^2 + sin(x)^2) simplify(a*b+a*c) simplify(n!/(n+1)!)

Expansion

(x-1)*(x-2)^3

Substitution

subst( u, exp(x), 2*exp(x) )

Symbolic and numeric roots

... symbolic solutions of simple polynomials:

roots(3 x + 12 + y = 24) # first degree (in x) roots(a*x^2+b*x+c) # second degree

... symbolic solutions of higher-degree polynomials or special polynomials:

roots(x^4 + x^3 + x^2 + x + 1) # third and fourth degree are solved too roots(m*x^9 + n) # roots of special polynomials roots((x^4+x^3)*(x^4*x^2)) # roots of factorable polynomials ...give it a few seconds

... numeric solutions for even higher-degree irreducible polynomials:

nroots(x^16+x^15+2)

Units of measurement

velocity=17000*"mile"/"hr" time=8*"min"/(60*"min"/"hr") velocity/time

Matrices, tensors

# shows A^−1 = adj A/ det A. (see that the last result is a zero matrix) A=[[a,b],[c,d]] inv(A) adj(A) det(A) inv(A)-adj(A)/det(A)

... tensors:

# Define a tensor function F=[x+2y,3x+4y] # now the gradient d(F,[x,y])

tensors (unlike matrices) can have more than 2 dimensions:

# Zero tensor with three dimensions zerotensor = zero(2,3,2) # get an element zerotensor[1,2,2]

Derivatives and gradients

d(x^2) # gradients are derivatives on vectors r=sqrt(x^2+y^2) d(r,[x,y])

integral(x^2) integral(x*y,x,y)

... computing integrals:

defint(x^2,y,0,sqrt(1-x^2),x,-1,1) ...give it a few seconds

... calculating them in the exponential domain:

f=sin(t)^4-2*cos(t/2)^3*sin(t) f=circexp(f) defint(f,t,0,2*pi) ...give it a few seconds

Credits and links

Algebrite is an adaptation of a delightful gem of CAS named EigenMath by George Weigt. Most of his manual applies to Algebrite. See the function reference (adapted from the one compiled by George Weigt for the EigenMath project) for a quick view. Also you might want to check another fork of EigenMath: SMIB by Philippe Billet.

Another CAS of similar nature is SymPy, made in Python.

Other Javascript CAS are:

The sandbox is based on simple-console by Isaiah Odhner (and for older versions, jquery.terminal by Jakub Jankiewicz). The "pentakis dodecahedron" logo is by Felix Koutchinski.