cospi
Compute the cosine of π*x, where x expressed in half-revolutions.
Base.Math.cospi — Function
cospi(x::T) where T -> float(T)Compute $\cos(\pi x)$ more accurately than cos(pi*x), especially for large x.
Throw a DomainError if isinf(x), return a T(NaN) if isnan(x).
Methods
julia> methods(cospi, (Any,), [Base, Base.Math, Base.MathConstants, Base.MPFR])# 7 methods for generic function "cospi" from Base.Math: [1] cospi(x::BigFloat) @ mpfr.jl:946 [2] cospi(::Missing) @ math.jl:1548 [3] cospi(x::T) where T<:Union{Float16, Float32, Float64} @ special/trig.jl:829 [4] cospi(x::AbstractFloat) @ special/trig.jl:940 [5] cospi(x::Integer) @ special/trig.jl:935 [6] cospi(x::Real) @ math.jl:1543 [7] cospi(z::Complex{T}) where T @ special/trig.jl:978
Examples
Real Numbers
julia> cospi(0)
1.0
julia> cospi(-0.0)
1.0
julia> cospi(0.5)
0.0
julia> cospi(1)
-1.0Complex
julia> cospi(0+0im)
1.0 - 0.0imTips
See Also
Extended Inputs
Tech Notes
cospi(::Real): by pure juliacospi(::BigFloat): by MPFR
Version History
Introduced in Julia v1.0 (2018)