cot
Compute the cotangent of x expressed in radians.
Base.Math.cot — Function
cot(x::T) where {T <: Number} -> float(T)Compute the cotangent of x, where x is in radians.
Throw a DomainError if isinf(x), return a T(NaN) if isnan(x).
cot(A::AbstractMatrix)Compute the matrix cotangent of a square matrix A.
Methods
julia> methods(cot, (Any,), [Base, Base.Math, Base.MathConstants, Base.MPFR])# 2 methods for generic function "cot" from Base.Math: [1] cot(::Irrational{:π}) @ mathconstants.jl:150 [2] cot(z::Number) @ special/trig.jl:1153
Examples
julia> using UnicodePlotsjulia> lineplot(-2π, 2π, cot, xlim=(-7, 7), ylim=(-4, 4))┌────────────────────────────────────────┐ 4 │⠀⠀⢸⠀⠀⠀⠀⠀⠀⠀⠀⢸⠀⠀⠀⠀⠀⠀⠀⠀⣿⠀⠀⠀⠀⠀⠀⠀⠀⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│ cot(x) │⠀⠀⢸⠀⠀⠀⠀⠀⠀⠀⠀⢸⠀⠀⠀⠀⠀⠀⠀⠀⣿⠀⠀⠀⠀⠀⠀⠀⠀⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│ │⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⡏⡆⠀⠀⠀⠀⠀⠀⠀⠈⡆⠀⠀⠀⠀⠀⠀⠀⠀⠀│ │⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⡇⡇⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀│ │⠀⠀⠀⢱⠀⠀⠀⠀⠀⠀⠀⠀⢱⠀⠀⠀⠀⠀⠀⠀⡇⢣⠀⠀⠀⠀⠀⠀⠀⠀⢣⠀⠀⠀⠀⠀⠀⠀⠀⠀│ │⠀⠀⠀⠈⡆⠀⠀⠀⠀⠀⠀⠀⠈⡆⠀⠀⠀⠀⠀⠀⡇⠈⡆⠀⠀⠀⠀⠀⠀⠀⠈⡆⠀⠀⠀⠀⠀⠀⠀⠀│ │⠀⠀⠀⠀⠈⢆⠀⠀⠀⠀⠀⠀⠀⠘⢆⠀⠀⠀⠀⠀⡇⠀⠘⢄⠀⠀⠀⠀⠀⠀⠀⠘⢄⠀⠀⠀⠀⠀⠀⠀│ f(x) │⠤⠤⠤⠤⠤⠬⠦⡤⠤⠤⠤⠤⠤⠤⠬⠦⡤⠤⠤⠤⡧⠤⠤⠬⠦⡤⠤⠤⠤⠤⠤⠤⠬⠦⡤⠤⠤⠤⠤⠤│ │⠀⠀⠀⠀⠀⠀⠀⠑⡄⠀⠀⠀⠀⠀⠀⠀⠑⡄⠀⠀⡇⠀⠀⠀⠀⠱⡀⠀⠀⠀⠀⠀⠀⠀⠱⡀⠀⠀⠀⠀│ │⠀⠀⠀⠀⠀⠀⠀⠀⠸⡀⠀⠀⠀⠀⠀⠀⠀⠸⡀⠀⡇⠀⠀⠀⠀⠀⠸⡀⠀⠀⠀⠀⠀⠀⠀⠹⡀⠀⠀⠀│ │⠀⠀⠀⠀⠀⠀⠀⠀⠀⢧⠀⠀⠀⠀⠀⠀⠀⠀⢧⠀⡇⠀⠀⠀⠀⠀⠀⢇⠀⠀⠀⠀⠀⠀⠀⠀⢇⠀⠀⠀│ │⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⠀⠀⠀⠀⠀⠀⠀⠀⢸⠀⡇⠀⠀⠀⠀⠀⠀⢸⠀⠀⠀⠀⠀⠀⠀⠀⢸⠀⠀⠀│ │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⡄⠀⠀⠀⠀⠀⠀⠀⠸⡀⡇⠀⠀⠀⠀⠀⠀⠸⡀⠀⠀⠀⠀⠀⠀⠀⢸⠀⠀⠀│ │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⡇⡇⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀│ -4 │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⡇⡇⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀│ └────────────────────────────────────────┘ ⠀-7⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀7⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀x⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
Real Numbers
julia> cot(0)
Inf
julia> cot(-0.0)
-Inf
julia> cot(pi)
-Inf
julia> cot(pi/2)
6.123233995736766e-17
julia> cot(pi/4)
1.0000000000000002Complex
julia> cot(0+0im)
NaN + NaN*imTips
See Also
Extended Inputs
Matrix
With Array like input:
julia> methods(cot, (Any,), [LinearAlgebra])# 3 methods for generic function "cot" from Base.Math: [1] cot(J::UniformScaling) @ /opt/hostedtoolcache/julia/1.12.2/x64/share/julia/stdlib/v1.12/LinearAlgebra/src/uniformscaling.jl:176 [2] cot(D::Diagonal) @ /opt/hostedtoolcache/julia/1.12.2/x64/share/julia/stdlib/v1.12/LinearAlgebra/src/diagonal.jl:879 [3] cot(A::AbstractMatrix{T}) where T @ /opt/hostedtoolcache/julia/1.12.2/x64/share/julia/stdlib/v1.12/LinearAlgebra/src/dense.jl:1496
Tech Notes
- Implemented in terms of
tan:cot(x) = inv(tan(x))
Version History
Introduced in Julia v1.0 (2018)