cot

Compute the cotangent of x expressed in radians.

Base.Math.cotFunction
cot(x)

Compute the cotangent of x, where x is in radians.

source
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{:π})
     @ Base.MathConstants mathconstants.jl:150
 [2] cot(z::Number)
     @ special/trig.jl:1135

Examples

julia> using UnicodePlots
julia> 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.0000000000000002

Complex

julia> cot(0+0im)
NaN + NaN*im

Tips

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)
     @ LinearAlgebra /opt/hostedtoolcache/julia/1.11.5/x64/share/julia/stdlib/v1.11/LinearAlgebra/src/uniformscaling.jl:173
 [2] cot(D::Diagonal)
     @ LinearAlgebra /opt/hostedtoolcache/julia/1.11.5/x64/share/julia/stdlib/v1.11/LinearAlgebra/src/diagonal.jl:802
 [3] cot(A::AbstractMatrix{T}) where T
     @ LinearAlgebra /opt/hostedtoolcache/julia/1.11.5/x64/share/julia/stdlib/v1.11/LinearAlgebra/src/dense.jl:1348

Tech Notes

  • Implemented in terms of tan: cot(x) = inv(tan(x))

Version History

Introduced in Julia v1.0 (2018)