\$ZARCCOS (ObjectScript)

Inverse (arc) cosine function.

Synopsis

\$ZARCCOS(n)

Argument

Argument Description
n A signed decimal number.

Description

\$ZARCCOS returns the trigonometric inverse (arc) cosine of n. The result is given in radians (to 18 decimal places).

Argument

n

Signed decimal number ranging from 1 to -1 (inclusive). It can be specified as a value, a variable, or an expression. Numbers outside the range generate an <ILLEGAL VALUE> error.

A non-numeric string is evaluated as 0. For evaluation of mixed numeric strings and non-numeric strings, refer to Strings As Numbers in Using ObjectScript.

The following are arc cosine values returned by \$ZARCCOS:

n Returned Arc Cosine
1 returns 0
0 returns 1.570796326794896619
-1 returns pi (3.141592653589793238)

Examples

The following example permits you to compare the arc cosine and the arc sine of a number:

IF num>1 { WRITE !,"ILLEGAL VALUE: number too big" }
ELSEIF num<-1 { WRITE !,"ILLEGAL VALUE: number too small" }
ELSE {
WRITE !,"the arc cosine is: ",\$ZARCCOS(num)
WRITE !,"the arc sine is: ",\$ZARCSIN(num)
}
QUIT

The following example compares the results from InterSystems IRIS fractional numbers (\$DECIMAL numbers) and \$DOUBLE numbers. In both cases, the arc cosine of 1 is exactly 0:

WRITE !,"the arc cosine is: ",\$ZARCCOS(0.0)
WRITE !,"the arc cosine is: ",\$ZARCCOS(\$DOUBLE(0.0))
WRITE !,"the arc cosine is: ",\$ZARCCOS(1.0)
WRITE !,"the arc cosine is: ",\$ZARCCOS(\$DOUBLE(1.0))
WRITE !,"the arc cosine is: ",\$ZARCCOS(-1.0)
WRITE !,"the arc cosine is: ",\$ZARCCOS(\$DOUBLE(-1.0))