-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Open
Labels
complexComplex numbersComplex numbersmathsMathematical functionsMathematical functionstriageThis should be discussed on a triage callThis should be discussed on a triage call
Description
I found myself needing to define a convenience function cisd(theta) = cis(deg2rad(theta)), and given that Base already exports sincosd, cosd, sind, and tand, it seems reasonable to add cisd as well.
A proposed implementation that mirrors the cispi implementation could be:
"""
cisd(x)
More accurate method for `cis(deg2rad(x))` (especially for large `x`).
See also [`cis`](@ref), [`cispi`](@ref), [`sincosd`](@ref), [`exp`](@ref), [`angle`](@ref).
# Examples
julia> cisd(180)
-1.0 + 0.0im
julia> cisd(45) ≈ 1/sqrt(2) + im/sqrt(2)
true
"""
function cisd end
function cisd(theta::Real)
s, c = sincosd(theta)
Complex(c, s)
end
function cisd(z::Complex)
v = exp(-deg2rad(imag(z)))
s, c = sincosd(real(z))
Complex(v * c, v * s)
endI'm happy to open a PR with some tests if this seems reasonable.
Metadata
Metadata
Assignees
Labels
complexComplex numbersComplex numbersmathsMathematical functionsMathematical functionstriageThis should be discussed on a triage callThis should be discussed on a triage call