Math functions

OSW includes several basic and advanced math functions, which are described below. Each function accepts numerical types (Integers, Floats, Doubles, Complex and DoubleComplex) 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.

Acosh [Help Patch]

The inverse hyperbolic cosine function.

Acot [Help Patch]

The inverse cotangent function.

Acoth [Help Patch]

The inverse hyperbolic cotangent function.

Acsc [Help Patch]

The inverse cosecent function.

Acsc [Help Patch]

The inverse hyperbolic cosecent function.

Asec [Help Patch]

The inverse secant function.

Asech [Help Patch]

The inverse hyperbolic secant function.

Asin [Help Patch]

The arcsine, or inverse sine function.

Asinh [Help Patch]

The inverse hyperbolic sine function.

Atan [Help Patch]

The arctangent, or inverse tangent function.

Atanh [Help Patch]

The inverse hyperbolic 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.

Cot [Help Patch]

The cotangent (1/tan) function.

Coth [Help Patch]

The hyperbolic cotangent function.

Csc [Help Patch]

The cosecant (1/sin) function.

Csch [Help Patch]

The hyperbolic cosecant function.

Exp [Help Patch]

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

Fact [Help Patch]

The factorial function for integers. For the factorial function of real-valued numbers, see Gamma.

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.

Gamma [Help Patch]

The gamma function, which is similar to the factorial function on real-valued numbers: gamma(x+1) = x!

Gcd [Help Patch]

The greatest-common divisor of two numbers. The greatest-common divisor of two numbers a and b is the largest number g that evenly divides both a and b (i.e., a/g and b/g are both integers.)

Log [Help Patch]

The natural (base e) logarithm of a number.

Log10 [Help Patch]

The base 10 logarithm of a number.

Sec [Help Patch]

The secant (1/cos) function.

Sech [Help Patch]

The hyperbolic secant function.

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

Sinc [Help Patch]

The sinc function: sin(x)/x

Sinh [Help Patch]

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

Sinhc [Help Patch]

The hyperbolic sinc function: sinh(x)/x

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
Complex number functions
Expr
Random