Variables and Expressions

See Also: Calculator  Nonlinear Equations Solver  Differential Equations Solver


Expression Structure

The following objects compose a valid Polymath math expression:

Expression Objects Description Examples
Number A number can be represented in decimal notation or engineering notation. Engineering notation can be used to indicate powers of 10 using 'e' or 'E' for example, 0.123e-5 is the same as 0.123*10^(-5).
Note that only the period "." is used as the decimal delimiter symbol and comma nor spaces must not be used to indicate digits grouping.
1.0, 2300, 5E-7, 1.23E+9, 34.0046

Invalid Polymath numbers:
5,000.00
12,9
12 000 000
Variable name Variable names must begin with an alphabetical character and can contain alphabetic and numeric characters or underscore “_”. Variable names are case-sensitive, i.e. 't' and 'T' are two different variables. Special characters such as $, &, #, @ etc. are not allowed. x1, x2, A12, T, tm4eee, VH2O, PmmHg, KL_1
Arithmetic operator Returns the arithmetic operations of the binary components.
For example '2+3' returns 5
The '^' symbol is used for exponentiation. The +, -, *, / symbols are used for addition, subtraction, multiplication, and division respectively. The precedence of operators is ^, (* or /), (+ or -) which is invoked working from left to right in an expression.
+, -, *, /, ^

(1 + 2 * 3 ^ 2 ^ 3 / 2 - 4)  is equivalent to

(1 + (2 * (((3 ^ 2) ^ 3) / 2)) - 4)

Function name Various mathematical function names are available.
Examples: sin, cos, exp,  ...
The full list of available Polymath functions is presented below.
12+sin(4)
exp( 5*9+log(8))
Condition operator

These operators return "1" if the condition met, and "0" if the condition does not meet.
Examples: The expression '3>6' returns 0. The expression '4>=4'
returns 1.

>, <, >=, <=, ==

Boolean operator

The Boolean operators return "1" if the condition is met, and "0" if the condition is not met.
Example: The expression '(2>3) or (1>0)' returns 1. The expression '1 and 0' returns 0.

And, Or

If-Then-Else There are three case-insensitive keywords which compose the if-then-else expression structure.
The three keywords are: If, Then, Else.
If (2>5) Then (sin(12)+4) Else (sin(12)+8)

if(2>5)then(sin(12)+4)else(sin(12)+8)

Parenthesis Open Parenthesis: (
Close Parenthesis: )
x+(3-2)

A special 'if' statement is available, with the following syntax:

if (condition) then (expression1) else (expression2)

The parentheses are optional.
The condition may include the following operators: and, or (Boolean operators), > (greater than), < (less than), >= (greater than or equal), <= (less than or equal), == (equals).
The expressions may be any formula, including another 'if' statement.

For example:

A = if (x>0) then (log(x)) else(0)

b = if (T<minT) then (minT) else (if (T>maxT) then (maxT) else (T))

Vol_h1 = if (a>5 and c<2) then 1.12 else 7.89

Available Functions

A number of standard functions are available for use in the various programs. The arguments of the functions must be enclosed in parentheses. The arguments may be themselves expressions or other functions. The nesting of functions is allowed.

Function Name Description
abs ( )  absolute value
arccos ( )  trigonometric inverse cosine with result in radians
arccosec ( )  trigonometric inverse cosecant with result in radians
arccosech ( )  inverse hyperbolic cosecant
arcsech () inverse hyperbolic secant
arccosh ( )  inverse hyperbolic cosine
arccotan ( )  trigonometric inverse cotangent with result in radians
arccotanh ( )  inverse hyperbolic cotangent
arcsec ( )  trigonometric inverse secant with result in radians
arcsin ( )  trigonometric inverse sine with result in radians
arcsinh ( )  inverse hyperbolic sine
arctan ( )  trigonometric inverse tangent with result in radians
arctanh ( )  inverse hyperbolic tangent
cbrt ( )  cubic root
cos ( )  trigonometric cosine with argument in radians
cosec ( )  trigonometric cosecant with argument in radians
cosech ( )  hyperbolic cosecant
cosh ( )  hyperbolic cosine
cotan ( )  trigonometric cotangent with argument in radians
coth ( )  hyperbolic cotangent
exp ( )  exponential (e^x )
erf ( )  error function 
exp10 ( )  exponential of 10 (10^x )
exp2 ( )  exponential of 2 (2^x )
fact ( N )  factorial of integer part of number N (this only operates on a number)
frac ( )  fractional part
int ( )  integer part
ln ( )  natural logarithm to the base e
log ( )  logarithm to the base 10
psi ( )  psi function 
rand ( ) 

Returns a random number between 0-1.
A parameter such as 1 or 2 should be provided to this function.

round ( )  rounded value
sec ( )  trigonometric secant with argument in radians
sech ( )  hyperbolic secant
sign ( )  returns + 1 or 0 or -1
sin ( )  trigonometric sine with argument in radians
sinh ( )  hyperbolic sine
sqrt ( )  square root
tan ( )  trigonometric tangent with argument in radians
tanh ( )  hyperbolic tangent

All function names must be given in lower-case letters. The trigonometric functions require that their arguments be given in radians. Conversely, the inverse trigonometric functions give their results in radians.

You should note that the functions require that their arguments be enclosed in parentheses, but that the arguments do not have to be simple numbers. You may have a complicated expression as the argument for a function, and you may even nest the functions, using one function (or an expression including one or more functions) as the argument for another.