第七十九章 Caché 函数大全 $ZARCTAN 函数
反(弧)正切函数。
大纲
$ZARCTAN(n)
参数
- n 任何正数或负数。
描述
$ZARCTAN返回n的三角逆(弧)正切。可能的结果范围从1.57079(圆周率的一半)到0到-1.57079。结果是以弧度表示的。
参数
n
任何正数或负数。它可以指定为值、变量或表达式。可以使用$ZPI特殊变量来指定pi。非数字字符串的计算结果为0。
以下是$ZARCTAN返回的反正切值:
- 2 返回 1.107148717794090502
- 1 返回 .7853981633974483098
- 0 返回 0
- -1 返回 -.7853981633974483098
示例
下面的示例允许计算数字的反正切值:
/// d ##class(PHA.TEST.Function).ZARCTAN()
ClassMethod ZARCTAN()
{
READ "Input a number: ",num
WRITE !,"the arc tangent is: ",$ZARCTAN(num)
QUIT
}
以下示例比较了Caché分数数字($DECIMAL数字)和$DOUBLE数字的结果。在这两种情况下,pi / 2的反正切是一个分数(不是1),但是0的反正切是0:
/// d ##class(PHA.TEST.Function).ZARCTAN1()
ClassMethod ZARCTAN1()
{
WRITE !,"the arc tangent is: ",$ZARCTAN(0.0)
WRITE !,"the arc tangent is: ",$ZARCTAN($DOUBLE(0.0))
WRITE !,"the arc tangent is: ",$ZARCTAN($ZPI)
WRITE !,"the arc tangent is: ",$ZARCTAN($DOUBLE($ZPI))
WRITE !,"the arc tangent is: ",$ZARCTAN($ZPI/2)
WRITE !,"the arc tangent is: ",$ZARCTAN($DOUBLE($ZPI)/2)
}
DHC-APP>d ##class(PHA.TEST.Function).ZARCTAN1()
the arc tangent is: 0
the arc tangent is: 0
the arc tangent is: 1.262627255678911683
the arc tangent is: 1.2626272556789115419
the arc tangent is: 1.003884821853887214
the arc tangent is: 1.0038848218538871659