tan

Compute the tangent of x expressed in radians.

Base.tanFunction
tan(x)

Compute tangent of x, where x is in radians.

source
tan(A::AbstractMatrix)

Compute the matrix tangent of a square matrix A.

If A is symmetric or Hermitian, its eigendecomposition (eigen) is used to compute the tangent. Otherwise, the tangent is determined by calling exp.

Examples

julia> tan(fill(1.0, (2,2)))
2×2 Matrix{Float64}:
 -1.09252  -1.09252
 -1.09252  -1.09252

Methods

julia> methods(tan, (Any,), [Base, Base.Math, Base.MathConstants, Base.MPFR])# 8 methods for generic function "tan" from Base:
 [1] tan(a::Float16)
     @ Base.Math math.jl:1511
 [2] tan(a::ComplexF16)
     @ Base.Math math.jl:1512
 [3] tan(x::BigFloat)
     @ Base.MPFR mpfr.jl:860
 [4] tan(::Irrational{:π})
     @ Base.MathConstants mathconstants.jl:149
 [5] tan(::Missing)
     @ Base.Math math.jl:1533
 [6] tan(x::T) where T<:Union{Float32, Float64}
     @ Base.Math special/trig.jl:216
 [7] tan(x::Real)
     @ Base.Math math.jl:1528
 [8] tan(z::Complex)
     @ complex.jl:932

Examples

julia> using UnicodePlots
julia> lineplot(-2π, 2π, tan, xlim=(-7, 7), ylim=(-4, 4)) ┌────────────────────────────────────────┐ 4 ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ tan(x) ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⢰⠃⠀⠀⠀⠀⠀⠀⠀⢰⠃⠀⠀⠀⠀⠀⡇⠀⢰⠁⠀⠀⠀⠀⠀⠀⠀⢰⠁⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⢀⠜⠀⠀⠀⠀⠀⠀⠀⢀⠜⠀⠀⠀⠀⠀⠀⠀⣇⠎⠀⠀⠀⠀⠀⠀⠀⢀⠎⠀⠀⠀⠀⠀⠀⠀⠀⠀ f(x) ⠤⠤⠤⠤⠤⠤⠤⠤⠤⡤⠮⠤⠤⠤⠤⠤⠤⠤⡤⡯⠤⠤⠤⠤⠤⠤⠤⡤⠮⠤⠤⠤⠤⠤⠤⠤⠤⠤ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⡴⠁⠀⠀⠀⠀⠀⠀⠀⡴⠁⡇⠀⠀⠀⠀⠀⠀⡔⠁⠀⠀⠀⠀⠀⠀⠀⡔⠁⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⢀⠇⠀⠀⠀⠀⠀⠀⠀⢀⠇⠀⠀⡇⠀⠀⠀⠀⢠⠃⠀⠀⠀⠀⠀⠀⠀⢠⠃⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ -4 ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ └────────────────────────────────────────┘-7⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀7⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀x⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀

Real Numbers

julia> tan(0)
0.0

julia> tan(-0.0)
-0.0

julia> tan(pi/4)
0.9999999999999999

julia> tan(pi/2)
1.633123935319537e16

julia> tan(pi)
0.0

Complex

julia> tan(0+0im)
0.0 - 0.0im

Tips

See Also

Extended Inputs

Matrix

With Array like input:

julia> methods(tan, (Any,), [LinearAlgebra])# 5 methods for generic function "tan" from Base:
 [1] tan(J::UniformScaling)
     @ LinearAlgebra /opt/hostedtoolcache/julia/1.11.5/x64/share/julia/stdlib/v1.11/LinearAlgebra/src/uniformscaling.jl:173
 [2] tan(A::Hermitian{var"#s5028", S} where {var"#s5028"<:Complex, S<:(AbstractMatrix{<:var"#s5028"})})
     @ LinearAlgebra /opt/hostedtoolcache/julia/1.11.5/x64/share/julia/stdlib/v1.11/LinearAlgebra/src/symmetric.jl:714
 [3] tan(D::Diagonal)
     @ LinearAlgebra /opt/hostedtoolcache/julia/1.11.5/x64/share/julia/stdlib/v1.11/LinearAlgebra/src/diagonal.jl:802
 [4] tan(A::Union{Hermitian{var"#s5029", S}, Symmetric{var"#s5029", S}} where {var"#s5029"<:Real, S})
     @ LinearAlgebra /opt/hostedtoolcache/julia/1.11.5/x64/share/julia/stdlib/v1.11/LinearAlgebra/src/symmetric.jl:710
 [5] tan(A::AbstractMatrix)
     @ LinearAlgebra /opt/hostedtoolcache/julia/1.11.5/x64/share/julia/stdlib/v1.11/LinearAlgebra/src/dense.jl:1134

Tech Notes

  • tan(::Real): by pure julia
  • tan(::BigFloat): by MPFR

Version History

Introduced in Julia v1.0 (2018)