CAPL Script

Cos

This reference collection includes Vector documentation reproduced with permission. Snippets may require configuration-specific symbols and are not all standalone programs. Sources and validation limits.

Syntax

double cos(double x);

Function

Calculates cosine of x.

Parameters

Value in radians whose cosine is to be calculated.

Return Values

Cosine of x.

Reference example from the CANoe 12 help. Check the required configuration, database objects and API availability in your installed version; this is not a recorded compiler or runtime test. The following blocks are separate fragments or alternatives, not one combined program.

double x;
x = cos(PI); // result -1
double tangens(double x) {
return sin(x) / cos(x);
}

sin | sqrt | exp

The tangent fragment divides by cos(x) and is undefined at its zeros. Select inputs away from those points and define a near-zero denominator policy before using it in numerical code. PI must be defined in the example context.