function

Ecolego has a list of mathematical functions to use in expressions. A special function is the **time** function, which returns the simulation time.

It is also possible to create custom functions, written in Java. For more information see Creating custom functions.

All listed functions may be used bu using Constant editing tool.

Here follows a short description of functions included in the Expression editing tool.

==== Constant ==== | |

end_time | The simulation end time, as specified in simulation settings. |

eps | the distance from 1.0 to the next larger double precision number, that is EPS=2-52. |

iteration | The current iteration, for probabilistic simulations. |

pi | 4×atan(1) = imag(log(-1)) = 3.1415926535897…. |

start_time | The simulation start time, as specified in simulation settings. |

time | the current simulation time-point. |

==== Trigonometric ==== | |

acos(X) | the arccosine of the elements of X. |

asin(X) | the arcsine of the elements of X. |

atan(X) | the arctangent of the elements of X. |

atan2(Y,X) | the four quadrant arctangent of the real parts of the elements of X and Y. -pi ⇐ ATAN2(Y,X) ⇐ pi. |

cos(X) | the cosine of the elements of X. |

cosh(X) | the hyperbolic cosine of the elements of X. |

sin(X) | the sine of the elements of X. |

sinh(X) | the hyperbolic sine of the elements of X. |

tan(X) | the tangent of the elements of X. |

tanh(X) | the hyperbolic tangent of the elements of X. |

==== Exponential ==== | |

exp(X) | the exponential of the elements of X, e to the X. |

hypot(A,B) | returns SQRT(ABS(A)2+ABS(B)2) carefully computed to avoid underflow and overflow. |

log(X) | the natural logarithm of the elements of X. |

log10(X) | the base 10 logarithm of the elements of X. |

log2(X) | the base 2 logarithm of the elements of X. |

power(X,Y) | the value of the first argument raised to the power of the second argument. Note: you can use the ^ operator in place of the power() function. |

sqrt(X) | the square root of the elements of X. |

==== Rounding and Remainder ==== | |

ceil(X) | rounds the elements of X to the nearest integers towards infinity. |

fix(X) | rounds the elements of X to the nearest integers towards zero. |

floor(X) | rounds the elements of X to the nearest integers towards minus infinity. |

mod(x,y) | is x - n×y where n = floor(x/y) if y <> 0. If y is not an integer and the quotient x/y is within roundoff error of an integer, then n is that integer. |

rem(x,y) | is x - n×y where n = fix(x/y) if y <> 0. If y is not an integer and the quotient x/y is within roundoff error of an integer, then n is that integer. |

round(X) | rounds the elements of X to the nearest integers. |

==== General ==== | |

abs(X) | the absolute value of the elements of X. |

erf(X) | the error function for X. |

erfc(X) | the complementary error function for X. |

max(X,…, N) | returns the highest value of the given arguments. |

mean(X,…,N) | returns the arithmetic mean value of the given arguments. |

min(X,…,N) | returns the lowest value of the given arguments. |

prod(X,…,N) | returns the product of the given arguments. |

sign(X) | For each element of X, SIGN(X) returns 1 if the element is greater than zero, 0 if it equals zero and -1 if it is less than zero. |

sum(X,…,N) | returns the sum of the given arguments. |

==== Logical ==== | |

and(X,Y) | bitwise and of X and Y. |

if(X,Y, Z) | if X is true (not zero), Y is returned. If X is false (equal to zero), Z is returned - if defined - otherwise zero (0). |

not(X) | the bitwise inverse of X. |

or(X,Y) | bitwise or of X and Y. |

==== Table lookup ==== | |

interpolationExtrapolation(XI,X1,Y1,…,XN,YN) | will return the YI value from the given table \[X,Y\] using linear interpolation, extrapolating outside the boundaries of the set. |

interpolationUseEndValues(XI,X1,Y1,…,XN,YN) | will return the YI value from the given table \[X,Y\] using linear interpolation. |

useInputAbove(XI,X1,Y1,…,XN,YN) | will return the YI value from the given table \[X,Y\] using nearest neighbour above. |

useInputBelow(XI,X1,Y1,…,XN,YN) | will return the YI value from the given table \[X,Y\] using nearest neighbour below. |

useInputNearest(XI,X1,Y1,…,XN,YN) | will return the YI value from the given table \[X,Y\] using nearest neighbour. |

==== Arithmetic ==== | |

binomial(N,K) | the binomial coefficient, often also referred to as “n over k”. |

factorial(N) | the product of all the integers from 1 to N. |

function.txt · Last modified: 2023/02/16 14:54 by daria