tan
tan(x)
Compute tangent of x
, where x
is in radians
Examples
In the Julia programming language, the function tan(x)
is used to compute the tangent of x
, where x
is in radians.
-
Compute tangent of an angle:
julia> tan(0.5) 0.5463024898437905
This example computes the tangent of the angle 0.5 radians.
-
Compute tangent of multiple angles:
julia> angles = [0.1, 0.2, 0.3]; julia> tan.(angles) 3-element Array{Float64,1}: 0.10033467208545047 0.2027100355086725 0.30933624960962357
It computes the tangent of each angle in the array
angles
using broadcast syntaxtan.(angles)
. - Compute tangent of a negative angle:
julia> tan(-0.8) -1.0296385570503641
It computes the tangent of a negative angle.
Common mistake example:
julia> tan(pi/2)
ERROR: DomainError with tan, pi/2 is not a valid argument
In this example, pi/2
is not a valid argument for the tangent function because the tangent of pi/2
is undefined. Ensure that the input value is within the valid domain of the tangent function to avoid such errors.
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.