Skip to main content

$ZARCCOS

Inverse (arc) cosine function.

Synopsis

$ZARCCOS(n)

Parameter

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).

Parameter

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.

The following are arc cosine values returned by $ZARCCOS:

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:

   READ "Input a number: ",num
   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 Caché 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))

See Also

FeedbackOpens in a new tab