next up previous contents index
Next: User-Defined Functions Up: The Xic Scripting Language Previous: ``Preprocessor'' Directives   Contents   Index


Math Functions

The following functions apply to complex numbers.

Name Returns
cmplx(x, i) Return a complex number
real(c) Return real part of a complex number
imag(c) Return imaginary part of a complex number
mag(c) Return the magnitude of a complex number
ang(c) Return the phase of a complex number

The cmplx function is used to initialize a complex number through assignment, for example

cx = cmplx(1.0, 0.5)
creates a complex number cx with value (1.0 + j0.5). The other functions take a complex number as an argument, and return a scalar result.

The following math functions are defined internally, and all take scalar or complex arguments.

Name Returns
abs(x) absolute value or magnitude of x
acos(x) arc-cosine of x
acosh(x) arc-hyperbolic cosine of x
asin(x) arc-sine of x
asinh(x) arc-hyperbolic sine of x
atan(x) arc-tangent of x
atan2(x, y) arc tangent of x, y
atanh(x) arc-hyperbolic tangent of x
cbrt(x) cube root of x
ceil(x) smallest integer > = x
cos(x) cosine of x
cosh(x) hyperbolic cosine of x
erf(x) error function of x
erfc(x) complementary error function of x
exp(x) e to the x power
floor(x) largest integer < = x
gauss() gaussian random number
int(x) truncated integer value of x
j0(x) Bessel function order 0 of x
j1(x) Bessel function order 1 of x
jn(x, n) Bessel function order n of x
ln(x) natural logarithm of x
log(x) natural logarithm of x, see below
log10(x) base 10 logarithm of x
max(x, y) largest of x, y
min(x, y) smallest of x, y
pow(x, y) x to the y power
random() random value in [0, 1)
rint(x) integer nearest to x
seed(x) seed random number generator
sgn(x) +1, 0, - 1 if x > 0, x = 0, x < 0
sin(x) sine of x
sinh(x) hyperbolic sine of x
sqrt(x) square root of x
tan(x) tangent of x
tanh(x) hyperbolic tangent of x
y0(x) Neumann function order 0 of x
y1(x) Neumann function order 1 of x
yn(x, n) Neumann function order n of x

Most of these functions, when given complex arguments, will compute a complex result. The atan2, seed, Bessel, Neuman, and error functions ignore any imaginary parts and compute a real value only. The ceil, floor, int, rint, and sgn functions apply the operation to real and imaginary parts of complex arguments. The min and max functions generate a complex result containing the operations applied to the real and imaginary parts of the arguments, if at least one argument is complex. The functions listed that take no arguments return scalar values.

With scalar arguments, these functions behave as the corresponding functions in the C library, though the random number functions are specialized to Xic. The seed function applies a seed value to the random number generators. This can be used to ensure that successive runs using random numbers choose different values. The seed value given is converted to an integer before use. The random function returns a random value in the range [0 - - 1) . The numbers generated have a uniform distribution. The gauss function returns Gaussian random numbers with zero mean and unit deviation.

Note regarding the log function
In Xic releases prior to 3.2.23, the log function returned the base-10 logarithm. This definition was changed in 3.2.23, and the log10 function added, for consistency with programming languages, WRspice, and most other software. This will require users to update legacy scripts that use the log function to call log10 instead. However, there is a LogIsLog10 variable that can be set to revert log to base-10. This can be used temporarily, but is not recommended for the long-term.


next up previous contents index
Next: User-Defined Functions Up: The Xic Scripting Language Previous: ``Preprocessor'' Directives   Contents   Index
Stephen R. Whiteley 2017-03-22