Clone wiki

symja_android_library / Functions

Table of contents

Getting Started


An identifier is a user-choosen or built-in name for a variable, function or constant. Only the identifiers which consists of only one character are case sensitive. For all other identifiers the input parser doesn't distinguish between lower and upper case characters.

For example: the upper-case identifiers D, E, I, N are different from the identifiers d, e, i, n, thereas the functions like Factorial() or Integrate() can alternatively be entered as factorial() or integrate().

On output all built-in functions are starting with an upper case character (Sin(), Cos(), Expand(), Inverse(), etc). Built-in constants are also starting with an upper case letter Degree, E, I, Pi, etc). If you type SIN(x) or sin(x), Symja assumes you always mean the same built-in Sin(x) function. User-defined functions and variables typically start with a "$" character and are converted to lower case output (i.e. the input $foo(x*y), $Foo(x*y), $FOO(x*y) are all converted to $foo(x*y) in the output).


Symja has an evaluation engine for mathematical expressions. The common arithmetic operations are:

  • + addition
  • - subtraction
  • * scalar multiplication
  • / division
  • ^ exponentiation
  • . matrix multiplication

A semicolon operator ; is used to separate multiple expressions. The following example shows two expressions separated by the ";" operator, only the result for the second expression will be returned back after evaluation:


gives 42.


A string is a representation of text as a sequence of characters. Strings must be surrounded by double quotes. An example string:

  "...Hello world..." 

Expression types

TypeDescriptionInput Example
Integerinteger numbers 42
Rationalrational numbers 13/17
Complexcomplex numbers 2+I*(1/3)
Realdouble values 0.5
Complex Realcomplex double values 0.5-I*0.25
Evaluation Precedencecontrol precedence with (...) (a+b)*c
Listscomma separated list of elements which are sourrounded by { ... } {a, b, c, d}
Vectorsvectors are like list, but cannot contain sublists { ... } {1, 2, 3, 4}
Matricesa matrix contains the rows as sublists { {1, 2}, {3, 4} }
Predefined Functionspredefined function names start with an upper case character and the arguments are surrounded by ( ... ) Sin(0), PrimeQ(13)
Predefined Constantspredefined constant names start with an upper case character Degree, E, Pi, False, True, ...
Userdefined variablesidentifiers which you would like to assign a value start with a '$' character $a=42
Userdefined rulesidentifiers which you would like to assign a rule start with a '$' character $f(x_,y_):={x,y}
Pattern Symbolspatterns end with a preceding '_' and could have a constraint $f(x_IntegerQ):={x}
Stringscharacter strings are enclosed by double quote characters "Hello World"
Slotsa # character followed by an optional number # or #2
Pure Functionspure functions can be expressed with the & operator (#^3)&[x] gives x^3
Parts of an expression expression[ [index] ] {a, b, c, d}[ [2] ] gives b


Find simplest form of:


Calculate the numerical value of:

N(24/60) or 24.0/60.0

Calculate sine in radians:


Calculate sine in degrees:


Simplify an expression:


Factor an integer number:


Derivative of a function:

D(Sin(x^3), x)

Integrate a function:

Integrate(x^2, x)

Factor a polynomial:


Factor a polynomial modulo an integer:

Factor(5+x^12, Modulus->7)

Expand a polynomial:


Inverse of a matrix:


Determinant of a matrix:


Solve a polynomial equation for x:

Solve(a*x + b == 0, x)

Math functions

System functions

String functions


Boolean values



Other values

Numerical constants