Function

From iMath
Revision as of 19:19, 3 July 2017 by Jrheinlaender (Talk | contribs) (Created page with "iMath has built-in functions and user-defined functions. User-defined functions are created with FUNCTION and FUNCDEF. Function arguments for multi-valued functions ar...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

iMath has built-in functions and user-defined functions. User-defined functions are created with FUNCTION and FUNCDEF. Function arguments for multi-valued functions are separated by semicolon ;.

Most functions will try to immediately evaluate themselves. If this is not possible, then the function will remain in the expression where it has been used. In that case it can be evaluated later with the simplification expand.

Built-in trigonometric functions

The following trigonometric functions are known to iMath. They all take exactly one argument.

  • cos cosh arcsin arccos
  • sin sinh arsinh arcosh
  • tan tanh arctan artanh
  • cot coth arccot arcoth
  • sec arcsec sech arsech
  • csc arcsc csch arcsch

Built-in algebraic functions

These functions take exactly one argument.

  • square sqrt abs fact (factorial)

Built-in exponential and logarithm functions

These functions take exactly one argument.

  • exp ln log (logarithm to basis 10)

=== Built-in complex-valued functions These functions take exactly one argument.

  • re im conjugate

Built-in other functions

These functions take exactly two numbers as arguments.

  • max(x; y) min(x; y)

This function linearly interpolates between two points given as pairs of (x,y)-values in the first four arguments. The fifth argument is the x-value for which the corresponding y-value should be interpolated.

  • interpol(x1; y1; x2; y2; x)

Built-in functions for vectors and matrices

vmin ( expression )

If the expression contains a vector or matrix of which all elements are numbers, evaluates to the smallest element.

vmax ( expression )

If the expression contains a vector or matrix of which all elements are numbers, evaluates to the greatest element.

transpose ( expression )

If the expression contains a vector or matrix, evaluates to the transposed vector or matrix.

det ( expression )

If the expression contains a matrix, evaluates to the determinant of the matrix.

charpoly ( expression )

If the expression contains a matrix, evaluates to the polynomial of the matrix.

mindex ( expression ; expression ; expression )

If the first expression contains a vector or matrix, evaluates to the element at the given row (second expression) and column (third expression). If the row is a wildcard, a whole column will be returned as a vector. If the column is a wildcard, a whole row will be returned.

====vecprod ( expression ; expression ) If both expressions are vectors, evaluates to their product. The vector product can only be calculated with two row or column vectors of three components each. Any other dimensions will produce an error.

====scalprod ( expression ; expression ) If both expressions are vectors, evaluates to their product. The vector product can only be calculated from a column and a row vector of equal length. Any other dimensions will leave the function unchanged.

Functions for number display

round ( expression ; expression )

Immediately evaluates to a number rounded to the given number of decimal places, if possible.

ceil ( expression ; expression )

Immediately evaluates to a number rounded up to the given number of decimal places, if possible.

floor ( expression ; expression )

Immediately evaluates to a number rounded down to the given number of decimal places, if possible.

Functions for sums and products

sum ( expression ; expression ; expression )

Sums the third expression from the lower bound given by the first expression to the upper bound given by the second expression. This function is created by SUM FROM ... TO if immediate evaluation is not possible

Functions for conditional evaluation

ifelse ( condition ; expression ; expression )

If the condition can be evaluated to a boolean value, evaluates to the first expression if the condition is true, otherwise to the second expression.