Important This documentation space contains information about PATROL Agents when deployed in a TrueSight Operations Management environment. If you are a BMC Helix Operations Management user, see PATROL Agent 21.3 for BMC Helix Operations Management.

cos()


Return the cosine of the argument.

Syntax

cos(radians)

 

Parameters

Parameter

Definition

radians

arc length in radians whose cosine is to be determined*Valid Values* 
–∞ ≤ radians ≤ ∞

Description

The cos() function returns the cosine of radians. The output range for the cos() function is -1 ≤ cos() ≤ 1.

Example

The following example uses the cos() function to draw a crude graph of a cosine waveform over a half period:

 print("Cosine Waveform:\n\n");
print(" -1 -0.5 0 0.5 1\n");
print(" +----+----+----+----+\n");
i = 0.0; while (i <= 3.2) {
printf("%4.2f ",i);
cosine = cos(i);
plot = int(10 * cosine) + 10;
if (plot < 10) {
before = "";
j = 1;
while (j <= plot) {
before = before . " ";
j++;
}
after = "";
j = plot; while (j < 9) {
after = after . " ";
j++;
}
print(before,"*",after,"|");
printf(" cosine = %+8.6f\n",cosine);
}
elsif (plot == 10) {
print(" *");
printf(" cosine = %+8.6f\n",cosine);
}
else {
print(" |");
before = "";
j = 11;
while (j < plot) {
before = before . " ";
j++;
}
print(before,"*");
after = "";
j = plot + 1;
while (j <= 22) {
after = after . " ";
j++;
}
print(after);
printf("cosine = %+8.6f\n",cosine);
}
i = i + 0.1;
}


The example produces the following output:

 Cosine Waveform:
-1 -0.5 0 0.5 1
+----+----+----+----+
0.00 | * cosine = +1.000000
0.10 | * cosine = +0.995004
0.20 | * cosine = +0.980067
0.30 | * cosine = +0.955336
0.40 | * cosine = +0.921061
0.50 | * cosine = +0.877583
0.60 | * cosine = +0.825336
0.70 | * cosine = +0.764842
0.80 | * cosine = +0.696707
0.90 | * cosine = +0.621610
1.00 | * cosine = +0.540302
1.10 | * cosine = +0.453596
1.20 | * cosine = +0.362358
1.30 | * cosine = +0.267499
1.40 |* cosine = +0.169967
1.50 * cosine = +0.070737
1.60 *| cosine = -0.029200
1.70 * | cosine = -0.128844
1.80 * | cosine = -0.227202
1.90 * | cosine = -0.323290
2.00 * | cosine = -0.416147
2.10 * | cosine = -0.504846
2.20 * | cosine = -0.588501
2.30 * | cosine = -0.666276
2.40 * | cosine = -0.737394
2.50 * | cosine = -0.801144
2.60 * | cosine = -0.856889
2.70 * | cosine = -0.904072
2.80 * | cosine = -0.942222
2.90 * | cosine = -0.970958
3.00 * | cosine = -0.989992
3.10 * | cosine = -0.999135
3.20 * | cosine = -0.998295

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*