# cos

cos(x)

Compute cosine of `x`, where `x` is in radians

## Examples

1. Calculate the cosine of a single value:

``````julia> cos(0)
1.0``````

This example calculates the cosine of 0 radians.

2. Evaluate the cosine of an array of values:

``````julia> angles = [0, π/4, π/2, π];
julia> cos(angles)
4-element Array{Float64,1}:
1.0
0.7071067811865476
6.123233995736766e-17
-1.0``````

It computes the cosine of each angle in the `angles` array.

3. Calculate the cosine of a variable:
``````julia> x = 1.2;
julia> cos(x)
0.3623577544766736``````

This example calculates the cosine of the variable `x`.

Common mistake example:

``````julia> cos("1.5")
ERROR: MethodError: no method matching cos(::String)``````

In this example, the argument provided to `cos` is not a valid input. The `cos` function expects the input to be a numeric value representing radians. Make sure to pass a numeric value as the argument to `cos` to avoid such errors.

acos, acosd, acosh, acot, acotd, acoth, acsc, acscd, acsch, asec, asecd, asech, asin, asind, asinh, atan, atan2, atand, atanh, cos, cosc, cosd, cosh, cospi, cot, cotd, coth, csc, cscd, csch, deg2rad, rad2deg, sin, sinc, sind, sinh, sinpi, tan, tand, tanh,

## User Contributed Notes

Ryan on 2015-11-14
``````julia> cos(0.2)
0.9800665778412416``````