cosd

cosd(x)

Compute cosine of x, where x is in degrees

Examples

julia> cosd(45)
0.7071067811865476

This example calculates the cosine of 45 degrees using the cosd function. The result is approximately 0.7071067811865476.

julia> angle = 60
julia> cosd(angle)
0.5000000000000001

Here, we assign the value 60 to the variable angle and then calculate the cosine of angle using cosd. The result is approximately 0.5000000000000001.

julia> angles = [30, 45, 60, 90]
julia> cosd.(angles)
4-element Array{Float64,1}:
 0.8660254037844387
 0.7071067811865476
 0.5000000000000001
 6.123233995736766e-17

In this example, we have an array of angles [30, 45, 60, 90]. We use the broadcasting syntax cosd.(angles) to calculate the cosine of each angle in the array. The resulting array contains the cosine values for each angle.

Common mistake example:

julia> cosd(90)
6.123233995736766e-17

Sometimes, users expect the cosine of 90 degrees to be exactly zero. However, due to floating-point precision, the result is a very small number close to zero. It's important to be aware of these precision limitations when working with trigonometric functions in Julia.

See Also

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

Add a Note

The format of note supported is markdown, use triple backtick to start and end a code block.

*Required Field
Details

Checking you are not a robot: