diff --git a/base/mathconstants.jl b/base/mathconstants.jl index 156dc9e1ce39a..7e0dbda3c19a4 100644 --- a/base/mathconstants.jl +++ b/base/mathconstants.jl @@ -123,4 +123,10 @@ Base.literal_pow(::typeof(^), ::Irrational{:ℯ}, ::Val{p}) where {p} = exp(p) Base.log(::Irrational{:ℯ}) = 1 # use 1 to correctly promote expressions like log(x)/log(ℯ) Base.log(::Irrational{:ℯ}, x::Number) = log(x) +Base.sin(::Irrational{:π}) = 0.0 +Base.cos(::Irrational{:π}) = -1.0 +Base.sincos(::Irrational{:π}) = (0.0, -1.0) +Base.tan(::Irrational{:π}) = 0.0 +Base.cot(::Irrational{:π}) = -1/0 + end # module diff --git a/base/special/exp.jl b/base/special/exp.jl index 7e7f9b100b439..57c72291b01df 100644 --- a/base/special/exp.jl +++ b/base/special/exp.jl @@ -333,7 +333,7 @@ See also [`exp2`](@ref), [`exp10`](@ref) and [`cis`](@ref). julia> exp(1.0) 2.718281828459045 -julia> exp(im * pi) == cis(pi) +julia> exp(im * pi) ≈ cis(pi) true ``` """ exp(x::Real) diff --git a/test/math.jl b/test/math.jl index b74c14a54b9b3..cdcc1c5c6a47d 100644 --- a/test/math.jl +++ b/test/math.jl @@ -53,6 +53,11 @@ end @test occursin("3.14159", sprint(show, MIME"text/plain"(), π)) @test repr(Any[pi ℯ; ℯ pi]) == "Any[π ℯ; ℯ π]" @test string(pi) == "π" + + @test sin(π) === sinpi(1) == tan(π) == sinpi(1 // 1) == 0 + @test cos(π) === cospi(1) == sec(π) == cospi(1 // 1) == -1 + @test csc(π) == 1/0 && cot(π) == -1/0 + @test sincos(π) === sincospi(1) == (0, -1) end @testset "frexp,ldexp,significand,exponent" begin