Purpose |
Return the cosine of an angle. |
Syntax |
y = COS(numeric_expression) |
Remarks |
numeric_expression is an angle specified in radians. To convert radians to degrees, multiply by 57.29577951308232##. To convert degrees to radians, multiply by 0.0174532925199433##. For more information on radians, see the ATN function. COS returns an Extended-precision value that always ranges between -1 and +1 inclusive. The Inverse Cosine (ARCCOS) of a value can be calculated as follows: pi# = 3.141592653589793## ArcCos = pi# / 2 - ATN(Value / SQR(1 - Value * Value)) The Hyperbolic Cosine (COSH) of a value can also be calculated: CosH = (EXP(Value) + EXP(-Value)) / 2 The Inverse Hyperbolic Cosine (ARCCOSH) of a value can also be calculated: ArcCosH = LOG(Value + SQR(Value * Value - 1))
' Useful Macro functions MACRO Pi = 3.141592653589793## MACRO DegreesToRadians(dpDegrees) = (dpDegrees*0.0174532925199433##) MACRO RadiansToDegrees(dpRadians) = (dpRadians*57.29577951308232##) |
See also |
|
Example |
pi## = 3.141592653589793## ' we could also use pi## = ATN(1) * 4 FOR I& = 0 TO 360 STEP 45 x$ = "Cosine of " + FORMAT$(I&, "* 0") + _ " degrees = " + FORMAT$(COS(pi## / 180 * _ I&), "* 0.00") NEXT I& |
Result |
Cosine of 0 degrees = 1.00 Cosine of 45 degrees = 0.71 Cosine of 90 degrees = 0.00 Cosine of 135 degrees = -0.71 Cosine of 180 degrees = -1.00 Cosine of 225 degrees = -0.71 Cosine of 270 degrees = 0.00 Cosine of 315 degrees = 0.71 Cosine of 360 degrees = 1.00 |