Next Previous Contents

6. Trigonometric commands

6.1 The pi command

This command puts the constant pi (3.14159...) in the stack.

Example:

> pi
[ 1]          3.14159265358979

6.2 The sin command

This command returns the sine of its argument.

Example:

> set anglemode rad
> pi 2 / sin
[ 1]                         1
> pi 3 * 2 / sin
[ 2]                         1
[ 1]                        -1

6.3 The cos command

This command returns the co-sine of its argument.

Examples:

> set anglemode rad
> pi 2 / cos
[ 1]      6.12303176911189e-17
> pi chs cos
[ 2]      6.12303176911189e-17
[ 1]                        -1

6.4 The tan command

This command returns the tangent of its argument.

Examples:

> set anglemode rad
> pi 4 / tan
[ 1]        0.0137086425343941
> .5 tan
[ 2]        0.0137086425343941
[ 1]       0.00872686779075879

6.5 The asin command

This command returns the arc sine of its argument.

Examples:

> .5 asin
[ 1]         0.523598775598299
> 1 asin
[ 2]         0.523598775598299
[ 1]           1.5707963267949
> 2 asin
[ 3]         0.523598775598299
[ 2]           1.5707963267949
[ 1] (1.5707963267949,
     -1.31695789692482)

6.6 The acos command

This command returns the arc co-sine of its argument.

Examples:

> set anglemode rad
> .5 acos
[ 1]           1.0471975511966
> 1 acos
[ 2]           1.0471975511966
[ 1]                         0
> 2 acos
[ 3]           1.0471975511966
[ 2]                         0
[ 1]     (0,-1.31695789692482)

6.7 The atan command

This command returns the arc tangent of its argument.

Examples:

> set anglemode rad
> 1 atan
[ 1]         0.785398163397448
> 2 atan
[ 2]         0.785398163397448
[ 1]          1.10714871779409
> .2 atan
[ 3]         0.785398163397448
[ 2]          1.10714871779409
[ 1]         0.197395559849881

6.8 The atan2 command

This command returns the arc tangent of y/x, where y is in level two and x is in level one. The signs of both arguments are used to calculate the quadrant of the result.

Examples:

> set anglemode rad
> -4 -1.7 / atan
[ 1]          1.16892567935444
> -4 -1.7 atan2
[ 2]          1.16892567935444
[ 1]         -1.97266697423535

6.9 The d>r command

This command converts from degrees to radians.

Examples:

> 45 d>r
[ 1]         0.785398163397448
> 60 d>r
[ 2]         0.785398163397448
[ 1]           1.0471975511966

6.10 The r>d command

This command converts from radians to degrees.

Examples:

> pi r>d
[ 1]                       180
> pi 3 / r>d
[ 2]                       180
[ 1]                        60


Next Previous Contents