Math functions

OSW includes several basic math functions, which are described below. Each function accepts numerical types (ints, floats, doubles, complex and double complex) as well as audio samples, unless otherwise indicated. When audio samples are used, the result is the same as evaluating the function on each sample individually. Use the supplied help patches to see how a particular function can be used in numerical or signal contexts. (Note: in order to use the linked help patches, OSW must already be running.)

Abs [Help Patch]

The absolute value of a number. For ints, floats and doubles, this is the non-negative version of the number, and for complex numbers it is the radius (or square root of the norm).

Acos [Help Patch]

The arccosine, or inverse cosine function.

Asin [Help Patch]

The arcsine, or inverse sine function.

Atan [Help Patch]

The arctangent, or inverse tangent function.

Ceil [Help Patch]

The smallest integer larger than the input value. This function only works with floats, doubles, and floating-point audio samples. (It has no mathematical meaning for the other types.)

Cos [Help Patch]

The cosine function.

Cosh [Help Patch]

The hyperbolic cosine function (ex+e-x)/2.

Exp [Help Patch]

The natural inverse logarithm (i.e., ex ).

Floor [Help Patch]

The greatlest integer less than or equal to the input value. This function only works with floats, doubles, and floating-point audio samples. (It has no mathematical meaning for the other types.)

Frac [Help Patch]

Returns the fractional part of a floating-point number. For example, an input of 2.718281828459 would yield a result of 0.718281828459. This function only works with floats, doubles, and floating-point audio samples.

Log [Help Patch]

The natural (base e) logarithm of a number.

Log10 [Help Patch]

The base 10 logarithm of a number.

Sgn [Help Patch]

This function returns 1 if the number is positive, -1 if the number is negative, or zero if the number is zero. This function works with integers, floats and doubles, as well as integer and floating-point audio samples. It has no meaning on complex numbers and therefore does not accept them as input.

Sin [Help Patch]

The sine function

Sinh [Help Patch]

The hyperbolic sine function (ex-e-x)/2.

Sqrt [Help Patch]

The square root function

Tan [Help Patch]

The tangent function

Tanh [Help Patch]

The hyperbolic tangent function (ex-e-x)/(ex+e-x)

See Also

OSW Programming Details
Expr
Random