Trigonometric Functions

Prev Next

Function Names

sin, sin deg, cos, cos deg, tan, tan deg, asin, asin deg, acos, acos deg, atan, atan deg

Description

All common trigonometric functions are supported. All function names ending with deg use angles measured in degrees and not in radians. In case the input value is not valid for a particular function, e.g. atan(2), or results into infinite values, then void values will be returned accordingly.

Non-numeric values (including dates) are passed through without modifications. This is particularly suitable in combination with vectorization in order to pass through blank contents, explanatory text, etc.

Vectorization: This function supports vectorization in the 1st function parameter. Instead of providing a single value, you can provide a set or even a nested set which contain multiple values. The function will then process every value and its return value contains a corresponding set containing all results.

Radian based Degree based Function description
sin sin deg Sine
cos cos deg Cosine
tan tan deg Tangent
asin asin deg Arcsine (inverse sine)
acos acos deg Arccosine (inverse cosine)
atan atan deg Arctangent (inverse tangent)

Call as: function

Restrictions

Indirect parameter passing is disabled
Vectorization is allowed in the 1st function parameter

Parameter count

1

Parameters

No.TypeDescription
1
input
all types
set
Value

Value or set containing multiple values (vectorization)

Return value

TypeDescription
all types
set
Result

Calculated value(s)

Examples

               pi[] = asin(1)*2;
               echo( "Pi: ", pi[] );
               echo( cos( pi[] / 4 ) ); // 45 deg.
               echo( sin deg( 30 ) );   // 30 deg.
               echo( asin deg( 1 ) );   // 90 deg.
               echo( sin deg( { 0, 15, 30, 45, 60, 90 } ) ); // Vectorization
               echo( asin( 2 ) ); // Invalid value

Output

Pi: 3.1415926536
0.7071067812
0.5
90
{0,0.2588190451,0.5,0.7071067812,0.8660254038,1}
# Invalid Value #
Try it yourself: Open LIB_Function_sin.b4p in B4P_Examples.zip. Decompress before use.

See also

Hyperbolic Functions