This topic describes the functions used for defining functions in a piecewise manner and how these functions handle real arguments.  Complex Variable FunctionsComplex_Variable_Functions describes how they handle complex arguments.  Note that the rules used to simplify expressions involving these functions take into account the user-declared domain of variables (see the Author > Variable Domain command8MNT4Y).


ABS(x) simplifies to the absolute value of x.  An absolute value can be entered and is displayed using vertical bars to delimit the argument.  Hence if x is 0 or a positive number, |x| simplifies to x.  If x is a negative number, |x| simplifies to -x.


SIGN(x) simplifies to the sign of x.  Hence if x is a positive number, SIGN(x) simplifies to 1.  If x is a negative number, SIGN(x) simplifies to -1.  Since the sign of 0 is indeterminate, SIGN(0) simplifies to plus-or-minus 1.


The functions MIN and MAX can take any number of arguments, a vector, or a matrix.  If given a vector (see Vectors and MatricesVectors_and_Matrices), they are applied to the elements of the vector.  If given a matrix, they are applied to the rows of the matrix, and the results are returned as a vector.


MAX(x1, x2, ..., xn) simplifies to the maximum value of its arguments.  MAX(x , y) simplifies to the equivalent expression ABS(x-y)/2 + (x+y)/2.


MIN(x1, x2 ,..., xn) simplifies to the minimum value of its arguments.  MIN(x, y) simplifies to the equivalent expression (x+y)/2 - ABS(x-y)/2.


STEP(x), the unit step function, simplifies to 1 if x > 0; and to 0 if x < 0.  If the sign of x cannot be determined, STEP(x) simplifies to (SIGN(x)+1)/2.


CHI, the piecewise indicator function, is defined as follows:


       CHI(a, x, b) simplifies to 1 if a < x < b; to 0 if x < a < b or if a < b < x; and to -CHI(b, x, a) if b < a.  If the relation between a, b, and x cannot be determined, CHI(a, x, b) simplifies to SIGN(x-a)/2 - SIGN(x-b)/2.

       CHI(x) simplifies to CHI(0, x, 1).

       CHI(a, x) simplifies to CHI(a, x, 1).

       CHI(a, x, b, c) simplifies to c if x = a; to 1-c if x = b; otherwise it simplifies to CHI(a, x, b).

       CHI(a, x, b, c, d) simplifies to c if x = a; to d if x = b; otherwise it simplifies to CHI(a, x, b).


FLOOR(m) simplifies to the greatest integer less than or equal to m.  If m is nonnegative, this is equivalent to the integer-part of m.  FLOOR(m, n) is equivalent to FLOOR(m/n) but is slightly more efficient.  For example,

FLOOR(5.73)

FLOOR(573, 100)

both simplify to 5.


CEILING(m) simplifies to the smallest integer greater than or equal to m.  CEILING(m, n) is equivalent to CEILING(m/n) but is slightly more efficient.  If m or n are not numbers, CEILING(m, n) simplifies to the equivalent expression  - FLOOR(- m/n).  For example,

CEILING(5.73)

CEILING(573, 100)

both simplify to 6.


ROUND(m) simplifies to the nearest integer to m.  ROUND(m, n) is equivalent to ROUND(m/n) but is slightly more efficient.  For example,

ROUND(5.73)

ROUND(573, 100)

both simplify to 6.


MOD(m, n) simplifies to m modulo n (i.e. the nonnegative remainder of m/n).  MOD(m, 0) simplifies to m.  Since n defaults to 1, MOD(m) simplifies to the fractional-part of m.  For example,

MOD(5.73)

MOD(573, 100)

simplify to 73/100 and 73, respectively.  If m, n>0, and p>0 are integers, MOD(m^p, n) is computed efficiently using the power-mod algorithm to raise m to the power p modulo n.  For example,

VECTOR(MOD(3^(10^n),10007),n,1,10)

simplifies to [9014, 4995, 6823, 5079, 2749, 8517, 594, 6074, 7480, 493].


MODS(m, n) simplifies to the symmetric m modulo n which will be in the half-open interval [-n/2,n/2).  MODS(m, 0) simplifies to m.  n defaults to 1.  

MODS(5.73)

MODS(573, 100)

simplify to -27/100 and -27, respectively.  If m, n>0, and p>0 are integers, MODS(m^p, n) is computed efficiently using the power-mod algorithm to raise m to the power p modulo n.  For example,

VECTOR(MODS(3^(10^n),10007),n,1,10)

simplifies to [-993, 4995, -3184, -4928, 2749, -1490, 594, -3933, -2527, 493].


POLY_MOD(u, n) simplifies to the polynomial whose coefficients are those of u reduced by the modulus n, where n is an integer and u is a polynomial having numeric coefficients.


POLY_MODS(u, n) simplifies to the polynomial whose coefficients are those of u reduced by the symmetric modulus n, where n is an integer and u is a polynomial having numeric coefficients.


Other Built-in Functions and ConstantsBuilt_in_Functions_and_Constants 

Created with the Personal Edition of HelpNDoc: News and information about help authoring tools and software