The Eigenmath manual and additional support materials are available at eigenmath.org

abs
adj
and
arccos
arccosh
arcsin
arcsinh
arctan
arctanh
arg
besselj
binding
binomial
ceiling
check
choose
circexp
clear
clock
coeff
cofactor
conj
contract
cos
cosh
cross
curl
d
defint
deg
denominator
det
dim
div
do
dot
draw
e
eigen
erf
erfc
eval
exp
expand
expcos
expcosh
expsin
expsinh
exptan
exptanh
factor
factorial
filter
float
floor
for
gcd
hermite
hilbert
i
imag
inner
integral
inv
isprime
j
laguerre
last
lcm
leading
legendre
lisp
log
mag
mod
not
nroots
number
numerator
or
outer
pi
polar
power
prime
print
product
quote
quotient
rank
rationalize
real
rect
roots
run
simplify
sin
sinh
sqrt
status
stop
string
subst
sum
tan
tanh
taylor
test
trace
transpose
tty
unit
zero

abs(x)

Returns the absolute value or vector length of x.

X = (x,y,z)
abs(X)
              1/2
  2    2    2
(x  + y  + z )

adj(m)

Returns the adjunct of matrix m. Adjunct is equal to determinant times inverse.

A = ((a,b),(c,d))
adj(A) == det(A) inv(A)
1

and(a,b,...)

Returns 1 if all arguments are true (nonzero). Returns 0 otherwise.

and(1=1,2=2)
1

arccos(x)

Returns the arc cosine of x.

arccos(1/2)
 1
--- pi
 3

arccosh(x)

Returns the arc hyperbolic cosine of x.

arcsin(x)

Returns the arc sine of x.

arcsin(1/2)
 1
--- pi
 6

arcsinh(x)

Returns the arc hyperbolic sine of x.

arctan(y,x)

Returns the arc tangent of y over x. If x is omitted then x = 1 is used.

arctan(1,0)
 1
--- pi
 2

arctanh(x)

Returns the arc hyperbolic tangent of x.

arg(z)

Returns the angle of complex z.

arg(2 - 3i)
arctan(-3,2)

besselj(x,n)

Returns a solution to the Bessel differential equation.

besselj(x,1/2)
  1/2
 2    sin(x)
-------------
   1/2  1/2
 pi    x

binding(s)

The result of evaluating a symbol can differ from the symbol's binding. For example, the result may be expanded. The binding function returns the actual binding of a symbol.

p = quote((x + 1)^2)
p
     2
p = x  + 2 x + 1
binding(p)
       2
(x + 1)

binomial(n,k)

Returns the coefficient of xk yn-k in (x + y)n.

binomial(52,5)
2598960

Note: binomial and choose are the same function.

ceiling(x)

Returns the smallest integer greater than or equal to x.

ceiling(1/2)
1

check(x)

If x is true (nonzero) then continue in a script, else stop. Expression x can include the relational operators =, ==, <, <=, >, >=. Use the not function to test for inequality.

A = 1
B = 1
check(A=B) -- script stops here if A not equal to B

choose(n,k)

Returns the number of combinations of n items taken k at a time. The following example computes the number of poker hands.

choose(52,5)
2598960

circexp(x)

Returns expression x with circular and hyperbolic functions converted to exponentials.

circexp(cos(x) + i sin(x))
exp(i x)

clear

Clears all symbol definitions.

clock(z)

Returns complex z in polar form with base of negative 1 instead of e.

clock(2 - 3i)
  1/2     arctan(-3,2)/pi
13    (-1)

coeff(p,x,n)

Returns the coefficient of xn in polynomial p.

p = x^3 + 6x^2 + 12x + 8
coeff(p,x,2)
6

cofactor(m,i,j)

Returns a cofactor of matrix m. The cofactor matrix is the transpose of the adjunct of m. This function returns the cofactor component at row i and column j.

A = ((a,b),(c,d))
cofactor(A,1,2) == transpose(adj(A))[1,2]
1

conj(z)

Returns the complex conjugate of z.

conj(2 - 3i)
2 + 3 i

contract(a,i,j)

Returns tensor a summed over indices i and j. If i and j are omitted then 1 and 2 are used. The expression contract(m) computes the trace of matrix m.

A = ((a,b),(c,d))
contract(A)
a + d

cos(x)

Returns the cosine of x.

cos(pi/4)
  1
------
  1/2
 2

cosh(x)

Returns the hyperbolic cosine of x.

circexp(cosh(x))
 1             1
--- exp(-x) + --- exp(x)
 2             2

cross(u,v)

Returns the cross product of vectors u and v. It is OK to redefine cross. This is the default definition.

cross(u,v) = (u[2] v[3] - u[3] v[2],
              u[3] v[1] - u[1] v[3],
              u[1] v[2] - u[2] v[1])

curl(u)

Returns the curl of vector u. It is OK to redefine curl. This is the default definition.

curl(u) = (d(u[3],y) - d(u[2],z),
           d(u[1],z) - d(u[3],x),
           d(u[2],x) - d(u[1],y))

d(f,x)

Returns the partial derivative of f with respect to x.

d(x^2,x)
2 x

Argument f can be a tensor of any rank. Argument x can be a vector. When x is a vector the result is the gradient of f.

F = (f(),g(),h())
X = (x,y,z)
d(F,X)
d(f(),x)   d(f(),y)   d(f(),z)

d(g(),x)   d(g(),y)   d(g(),z)

d(h(),x)   d(h(),y)   d(h(),z)

It is OK to use d as a variable name. It will not conflict with function d.

It is OK to redefine d as a different function. The function derivative, a synonym for d, can still be used to obtain a partial derivative.

defint(f,x,a,b)

Returns the definite integral of f with respect to x evaluated from a to b. The argument list can be extended for multiple integrals as shown in the following example.

f = (1 + cos(theta)^2) sin(theta)
defint(f, theta, 0, pi, phi, 0, 2pi) -- integrate over theta then over phi
 16
---- pi
 3

deg(p,x)

Returns the degree of polynomial p(x).

p = (2x + 1)^3
deg(p,x)
3

denominator(x)

Returns the denominator of expression x.

denominator(a/b)
b

det(m)

Returns the determinant of matrix m.

A = ((a,b),(c,d))
det(A)
a d - b c

dim(a,n)

Returns the dimension of the nth index of tensor a. Index numbering starts with 1.

A = ((1,2),(3,4),(5,6))
dim(A,1)
3

div(u)

Returns the divergence of vector u. It is OK to redefine div. This is the default definition.

div(u) = d(u[1],x) + d(u[2],y) + d(u[3],z)

do(a,b,...)

Evaluates each argument from left to right. Returns the result of the final argument.

do(A=1,B=2,A+B)
3

dot(a,b,...)

Returns the dot or matrix product of vectors, matrices, and tensors.

-- solve for X in AX=B
A = ((1,2),(3,4))
B = (5,6)
X = dot(inv(A),B)
X
    -4

X = 
     9
    ---
     2

draw(f,x)

Draws a graph of f(x). Drawing ranges can be set with xrange and yrange.

xrange = (0,1)
yrange = (0,1)
draw(x^2,x)

e

Symbol e is initialized to the natural number e.

e^x
exp(x)

Note: It is OK to clear or redefine e and use the symbol for something else.

eigen(m)

Computes eigenvalues and eigenvectors numerically. Matrix m is required to be both numerical and symmetric. Eigenvectors are returned in Q and eigenvalues are returned in D. Each row of Q is an eigenvector. Each diagonal element of D is an eigenvalue.

A = ((1,2),(2,1))
eigen(A)
dot(transpose(Q),D,Q)
1.0   2.0

2.0   1.0

erf(x)

Error function of x.

erfc(x)

Complementary error function of x.

eval(f,x,a)

Returns f evaluated at x equals a. The argument list can be extended for multiple symbols.

eval(x + y,x,a,y,b)
a + b

exp(x)

Returns the exponential of x.

exp(i pi)
-1

expand(r,x)

Returns the partial fraction expansion of the ratio of polynomials r in x.

p = (x + 1)^2
q = (x + 2)^2
expand(p/q,x)
     2            1
- ------- + -------------- + 1
   x + 2      2
             x  + 4 x + 4

expcos(z)

Returns the cosine of z in exponential form.

expcos(z)
 1              1
--- exp(i z) + --- exp(-i z)
 2              2

expcosh(z)

Returns the hyperbolic cosine of z in exponential form.

expcosh(z)
 1             1
--- exp(-z) + --- exp(z)
 2             2

expsin(z)

Returns the sine of z in exponential form.

expsin(z)
   1                1
- --- i exp(i z) + --- i exp(-i z)
   2                2

expsinh(z)

Returns the hyperbolic sine of z in exponential form.

expsinh(z)
   1             1
- --- exp(-z) + --- exp(z)
   2             2

exptan(z)

Returns the tangent of z in exponential form.

exptan(z)
       i             i exp(2 i z)
---------------- - ----------------
 exp(2 i z) + 1     exp(2 i z) + 1

exptanh(z)

Returns the hyperbolic tangent of z in exponential form.

exptanh(z)
        1             exp(2 z)
- -------------- + --------------
   exp(2 z) + 1     exp(2 z) + 1

factor(n)

Factors numerical value n and returns the result.

factor(12/35)
  2
 2  3
------
 5 7

If n is a floating point value then a rational approximation of n is factored and returned.

factor(float(pi))
 5 71
------
 113

factor(p,x)

Factors polynomial p of x and returns the result. The argument list can be extended for multivariate polynomials.

p = 2x + x y + y + 2
factor(p,x,y)
(x + 1) (y + 2)

Note: factor returns an unexpanded expression. If the result is assigned to a symbol, evaluating the symbol will expand the result. Use binding to retrieve the unexpanded expression.

q = factor(p,x,y)
binding(q)
(x + 1) (y + 2)

factorial(n)

Returns the factorial of n. The expression n! can also be used.

20!
2432902008176640000

filter(f,a,b,...)

Returns f excluding any terms containing a, b, etc.

p = x^2 + 3x + 2
filter(p,x^2)
3 x + 2

float(x)

Returns expression x with rational numbers and integers converted to floating point values. The symbol pi and the natural number are also converted.

float(212^17)
          39
3.52947 10

floor(x)

Returns the largest integer less than or equal to x.

floor(1/2)
0

for(i,j,k,a,b,...)

For i equals j through k evaluate a, b, etc.

for(k,1,3,A=k,print(A))
A = 1
A = 2
A = 3

Note: The original value of i is restored after for completes. If symbol i is used for index variable i then the imaginary unit is overridden in the scope of for.

gcd(a,b,...)

Returns the greatest common divisor of expressions.

gcd(x,x y)
x

hermite(x,n)

Returns the nth Hermite polynomial in x.

hermite(x,3)
   3
8 x  - 12 x

hilbert(n)

Returns an n by n Hilbert matrix.

hilbert(3)
       1     1
 1    ---   ---
       2     3

 1     1     1
---   ---   ---
 2     3     4

 1     1     1
---   ---   ---
 3     4     5

i

Symbol i is initialized to the imaginary unit (−1)1/2.

exp(i pi)
-1

Note: It is OK to clear or redefine i and use the symbol for something else.

imag(z)

Returns the imaginary part of complex z.

imag(2 - 3i)
-3

inner(a,b,...)

Returns the inner product of tensors.

A = ((a,b),(c,d))
B = (x,y)
inner(A,B)
a x + b y

c x + d y

Note: inner and dot are the same function.

integral(f,x)

Returns the integral of f with respect to x.

integral(x^2,x)
 1   3
--- x
 3

inv(m)

Returns the inverse of matrix m.

A = ((1,2),(3,4))
inv(A)
 -2       1


  3        1
 ---    - ---
  2        2

isprime(n)

Returns 1 if n is a prime number. Returns zero otherwise.

isprime(2^31 - 1)
1

j

Set j=sqrt(-1) to use j for the imaginary unit instead of i.

j = sqrt(-1)
1/sqrt(-1)
-j

laguerre(x,n,m)

Returns the nth associated Laguerre polynomial in x of order m. If m is omitted then zero is used.

laguerre(x,3)
   1   3    3   2
- --- x  + --- x  - 3 x + 1
   6        2

last

The result of the previous calculation is stored in last.

212^17
3529471145760275132301897342055866171392
last^(1/17)
212

Note: Symbol last is an implied argument when a function has no argument list.

212^17
3529471145760275132301897342055866171392
float
          39
3.52947 10

lcm(a,b,...)

Returns the least common multiple of expressions.

lcm(x,x y)
x y

leading(p,x)

Returns the leading coefficient of polynomial p(x).

leading(3x^2 + 1,x)
3

legendre(x,n,m)

Returns the nth associated Legendre polynomial in x of order m. If m is omitted then zero is used.

legendre(x,3)
 5   3    3
--- x  - --- x
 2        2

lisp(x)

Evaluates expression x and returns the result as a string in prefix notation. Useful for debugging scripts.

lisp(x^2 + 1)
(+ (^ x 2) 1)

log(x)

Returns the natural logarithm of x.

log(x^y)
y log(x)

mag(z)

Returns the magnitude of complex z. Mag treats undefined symbols as real while abs does not.

mag(x + i y)
         1/2
  2    2
(x  + y )

mod(a,b)

Returns the remainder of a divided by b.

mod(10,7)
3

not(x)

Returns 0 if x is true (nonzero). Returns 1 otherwise.

not(1=1)
0

nroots(p,x)

Returns all roots, both real and complex, of polynomial p(x). The roots are computed numerically. The coefficients of p can be real or complex.

number(x)

Returns 1 if x is a rational or floating point number. Returns 0 otherwise.

number(1/2)
1

numerator(x)

Returns the numerator of expression x.

numerator(a/b)
a

or(a,b,...)

Returns 1 if at least one argument is true (nonzero). Returns 0 otherwise.

or(1=1,2=2)
1

outer(a,b,...)

Returns the outer product of tensors. Also known as the tensor product.

A = (a,b,c)
B = (x,y,z)
outer(A,B)
a x   a y   a z

b x   b y   b z

c x   c y   c z

pi

Symbol for π.

exp(i pi)
-1

polar(z)

Returns complex z in polar form.

polar(x - i y)
         1/2
  2    2
(x  + y )    exp(i arctan(-y,x))

power

Use ^ to raise something to a power. Use parentheses for negative powers.

x^(-2)
 1
----
  2
 x

prime(n)

Returns the nth prime number. The domain of n is 1 to 10000.

prime(100)
541

print(a,b,...)

Evaluate expressions and print the results. Useful for printing from inside a for loop.

for(j,1,3,print(j))
j = 1
j = 2
j = 3

product(i,j,k,f)

For i equals j through k evaluate f. Returns the product of all f.

product(j,1,3,x + j)
 3      2
x  + 6 x  + 11 x + 6

Note: The original value of i is restored after product completes. If symbol i is used for index variable i then the imaginary unit is overridden in the scope of product.

quote(x)

Returns expression x without evaluating it first.

quote((x + 1)^2)
       2
(x + 1)

quotient(p,q,x)

Returns the quotient of polynomial p(x) over q(x).

p = x^2 + 1
q = x + 3
quotient(p,q,x)
x - 3

rank(a)

Returns the number of indices that tensor a has.

A = ((a,b),(c,d))
rank(A)
2

rationalize(x)

Returns expression x with everything over a common denominator.

rationalize(1/a + 1/b + 1/2)
 2 a + a b + 2 b
-----------------
      2 a b

Note: rationalize returns an unexpanded expression. If the result is assigned to a symbol, evaluating the symbol will expand the result. Use binding to retrieve the unexpanded expression.

f = rationalize(1/a + 1/b + 1/2)
binding(f)
 2 a + a b + 2 b
-----------------
      2 a b

real(z)

Returns the real part of complex z.

real(2 - 3i)
2

rect(z)

Returns complex z in rectangular form.

rect(exp(i x))
cos(x) + i sin(x)

roots(p,x)

Returns the values of x such that polynomial p(x) equals zero. The polynomial should be factorable over integers. Returns a vector for multiple roots.

roots(x^2 + 3x + 2,x)
-2

-1

run(file)

Run script file. Useful for importing function libraries.

run("Downloads/EVA.txt")

Note: file must be in the Downloads folder due to security requirements for apps distributed on the Mac App Store.

simplify(x)

Returns expression x in a simpler form.

simplify(sin(x)^2 + cos(x)^2)
1

sin(x)

Returns the sine of x.

sin(pi/4)
  1
------
  1/2
 2

sinh(x)

Returns the hyperbolic sine of x.

circexp(sinh(x))
   1             1
- --- exp(-x) + --- exp(x)
   2             2

sqrt(x)

Returns the square root of x.

sqrt(10!)
     1/2
720 7

status

Prints memory statistics.

status
block_count 1
free_count 99258
gc_count 1
bignum_count 370
string_count 0
tensor_count 5

stop

In a script, it does what it says.

string(x)

Evaluates expression x and returns the result as a string. Useful for testing scripts.

string((x + 1)^2) == "x^2 + 2 x + 1"
1

subst(a,b,c)

Substitutes a for b in c and returns the result.

subst(x,y,y^2)
 2
x

sum(i,j,k,f)

For i equals j through k evaluate f. Returns the sum of all f.

sum(j,1,5,x^j)
 5    4    3    2
x  + x  + x  + x  + x

Note: The original value of i is restored after sum completes. If symbol i is used for index variable i then the imaginary unit is overridden in the scope of sum.

tan(x)

Returns the tangent of x.

simplify(tan(x) - sin(x)/cos(x))
0

tanh(x)

Returns the hyperbolic tangent of x.

circexp(tanh(x))
        1             exp(2 x)
- -------------- + --------------
   exp(2 x) + 1     exp(2 x) + 1

taylor(f,x,n,a)

Returns the Taylor expansion of f(x) near x equals a. If argument a is omitted then zero is used. Argument n is the degree of the expansion.

taylor(sin(x),x,5)
  1    5    1   3
----- x  - --- x  + x
 120        6

test(a,b,c,d,...)

If argument a is true (nonzero) then b is returned, else if c is true then d is returned, etc. If the number of arguments is odd then the final argument is returned if all else fails. Expressions can include the relational operators =, ==, <, <=, >, >=. Use the not function to test for inequality. (The equality operator == is available for contexts in which = is the assignment operator.)

A = 1
B = 1
test(A=B,"yes","no")
yes

trace

Set trace=1 in a script to print the script as it is evaluated. Useful for debugging.

trace = 1

Note: The contract function is used to obtain the trace of a matrix.

transpose(a,i,j)

Returns the transpose of tensor a with respect to indices i and j. If i and j are omitted then 1 and 2 are used. Hence a matrix can be transposed with a single argument.

A = ((a,b),(c,d))
transpose(A)
a   c

b   d

tty

Set tty=1 to print results in a flat format.

tty = 1
(x + 1/2)^2
x^2 + x + 1/4

unit(n)

Returns an n by n identity matrix.

unit(3)
1   0   0

0   1   0

0   0   1

zero(i,j,...)

Returns a null tensor with dimensions i, j, etc. Useful for creating a tensor and then setting the component values.

A = zero(3,3)
for(k,1,3,A[k,k]=k)
A
    1   0   0

A = 0   2   0

    0   0   3