Excel COS Function
The Excel COS function returns trigonometric cosine of an angle (angle should be in radians).
The COS function is a built-in function in Excel that is categorized as a Math/Trig Function. It can be used as a worksheet function and a VBA function in Excel. As a worksheet function, the COS function can be used as part of a formula in a worksheet cell. While as a VBA function, this function can be used in a Excel macro code. The Excel macro code can be created using the Microsoft Visual Basic Editor.
Syntax
COS(number)
Parameters
number |
Required. Specify the angle in radian. |
Return Value
Returns the trigonometric cosine of an angle.
Notes
- If the argument is in degrees, multiply it by PI()/180 or use the RADIANS function to convert it to radians.
- If the argument is a non-numeric value, COS returns #VALUE! error.
- If the argument is outside its constraints, COS returns #NUM! error.
Example: Using as Worksheet Function
The example below shows how to use the COS function as worksheet function.
Based on the Excel spreadsheet above, the output of the following worksheet formula will be:
=COS(D5) Result: 1 =COS(D6) Result: 0.866 =COS(D7) Result: 0.707 =COS(D8) Result: 0.500 =COS(D9) Result: 0.259 =COS(D10) Result: 0
Example: Using angles in Degrees
To supply an angle to COS function in degrees, the angle can be multiplied by PI()/180. Alternatively, the angle expressed in degrees can be used in the COS function by converting it into radians using RADIANS function. For example, to get the COS of 60 degrees, the following formula can be used:
=COS(60 * PI()/180) Result: 0.5 =COS(RADIANS(60)) Result: 0.5
Example: Using as VBA Function
The COS function can also be used in VBA code in Microsoft Excel. Consider the example below:
Dim FValue As Double FValue = Cos(1)
In this example, the variable called FValue will contain the value of 0.54030230586814.
❮ Excel Functions