cospi
Compute the cosine of π*x
, where x
expressed in half-revolutions.
Base.Math.cospi
— Functioncospi(x)
Compute $\cos(\pi x)$ more accurately than cos(pi*x)
, especially for large 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) @ Base.MPFR mpfr.jl:860 [2] cospi(::Missing) @ math.jl:1533 [3] cospi(x::T) where T<:Union{Float16, Float32, Float64} @ special/trig.jl:821 [4] cospi(x::AbstractFloat) @ special/trig.jl:928 [5] cospi(x::Integer) @ special/trig.jl:923 [6] cospi(x::Real) @ math.jl:1528 [7] cospi(z::Complex{T}) where T @ special/trig.jl:966
Examples
Real Numbers
julia> cospi(0)
1.0
julia> cospi(-0.0)
1.0
julia> cospi(0.5)
0.0
julia> cospi(1)
-1.0
Complex
julia> cospi(0+0im)
1.0 - 0.0im
Tips
See Also
Extended Inputs
Tech Notes
cospi(::Real)
: by pure juliacospi(::BigFloat)
: by MPFR
Version History
Introduced in Julia v1.0 (2018)