Function: Difference between revisions
No edit summary |
|||
Line 57: | Line 57: | ||
====<code>scalprod ( [[expression]] ; [[expression]] )</code>==== | ====<code>scalprod ( [[expression]] ; [[expression]] )</code>==== | ||
If both expressions are vectors, evaluates to their [https://en.wikipedia.org/wiki/Dot_product scalar 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. | If both expressions are vectors, evaluates to their [https://en.wikipedia.org/wiki/Dot_product scalar 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. | ||
====<code>hadamard ( [[expression]] ; [[expression]] ; [[expression]] ; [[expression]] )</code>==== | |||
If both first and second expressions are vectors or matrices of equal dimensions, calculates their element-wise product (if the third expression is 0), division (if the third expression is 1) or power (if the third expression is 2). Usually, this function is not used directly. Rather, the [[Operator|operators]] <code>.*</code>, <code>./</code> and <code>.^</code> should be used. The element-wise product is also called the [https://en.wikipedia.org/wiki/Hadamard_product_(matrices) Hadamard product]. | |||
=== Functions for number display === | === Functions for number display === |
Revision as of 19:34, 27 June 2018
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 characteristic 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.
See also Vector and matrix element access.
vecprod ( expression ; expression )
If both expressions are vectors, evaluates to their vector 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 scalar 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.
hadamard ( expression ; expression ; expression ; expression )
If both first and second expressions are vectors or matrices of equal dimensions, calculates their element-wise product (if the third expression is 0), division (if the third expression is 1) or power (if the third expression is 2). Usually, this function is not used directly. Rather, the operators .*
, ./
and .^
should be used. The element-wise product is also called the Hadamard product.
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.
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.
Temperature conversion functions
The following functions are defined in the abbreviated SI units reference file. They take exactly one argument.
kelvintocelsius celsiustokelvin
The following functions are defined in the imperial units reference file. They take exactly one argument.
kelvintofahrenheit fahrenheittokelvin