atan

Compute the principal value of the arc tangent of x, return in radians.

Base.atanFunction
atan(y)
atan(y, x)

Compute the inverse tangent of y or y/x, respectively.

For one real argument, this is the angle in radians between the positive x-axis and the point (1, y), returning a value in the interval $[-\pi/2, \pi/2]$.

For two arguments, this is the angle in radians between the positive x-axis and the point (x, y), returning a value in the interval $[-\pi, \pi]$. This corresponds to a standard atan2 function. Note that by convention atan(0.0,x) is defined as $\pi$ and atan(-0.0,x) is defined as $-\pi$ when x < 0.

See also atand for degrees.

Examples

julia> rad2deg(atan(-1/√3))
-30.000000000000004

julia> rad2deg(atan(-1, √3))
-30.000000000000004

julia> rad2deg(atan(1, -√3))
150.0
source
atan(A::AbstractMatrix)

Compute the inverse matrix tangent of a square matrix A.

If A is symmetric or Hermitian, its eigendecomposition (eigen) is used to compute the inverse tangent. Otherwise, the inverse tangent is determined by using log. For the theory and logarithmic formulas used to compute this function, see [AH16_3].

Examples

julia> atan(tan([0.5 0.1; -0.2 0.3]))
2×2 Matrix{ComplexF64}:
  0.5+1.38778e-17im  0.1-2.77556e-17im
 -0.2+6.93889e-17im  0.3-4.16334e-17im

Methods

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

Examples

julia> using UnicodePlots
julia> lineplot(-10, 10, atan, ylim=(-π/2, π/2)) ┌────────────────────────────────────────┐ 1.5708 ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⣀⡠⠤⠤⠤⠤⠤⠤⠖ atan(x) ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⢀⡤⠖⠊⠉⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⢀⡔⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⢀⡎⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣷⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ f(x) ⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⢤⡧⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⠇⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡰⠃⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡔⠁⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⡠⠤⠒⠁⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ -1.5708 ⠤⠒⠒⠒⠒⠒⠒⠊⠉⠉⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ └────────────────────────────────────────┘-10⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀10⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀x⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀

Real Numbers

julia> atan(0)
0.0

julia> atan(-0.0)
-0.0

julia> atan(1.0) / pi
0.25

Complex

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

Tips

See Also

Extended Inputs

Matrix

With Array like input:

julia> methods(atan, (Any,), [LinearAlgebra])# 5 methods for generic function "atan" from Base:
 [1] atan(J::UniformScaling)
     @ LinearAlgebra /opt/hostedtoolcache/julia/1.11.5/x64/share/julia/stdlib/v1.11/LinearAlgebra/src/uniformscaling.jl:173
 [2] atan(D::Diagonal)
     @ LinearAlgebra /opt/hostedtoolcache/julia/1.11.5/x64/share/julia/stdlib/v1.11/LinearAlgebra/src/diagonal.jl:802
 [3] atan(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
 [4] atan(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] atan(A::AbstractMatrix)
     @ LinearAlgebra /opt/hostedtoolcache/julia/1.11.5/x64/share/julia/stdlib/v1.11/LinearAlgebra/src/dense.jl:1273

Tech Notes

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

Version History

Introduced in Julia v1.0 (2018)