File tree Expand file tree Collapse file tree 2 files changed +22
-16
lines changed Expand file tree Collapse file tree 2 files changed +22
-16
lines changed Original file line number Diff line number Diff line change @@ -535,42 +535,42 @@ end
535535# return Complex(abs(iz)/r/2, copysign(r,iz))
536536# end
537537
538- # compute exp(im*theta)
539- function cis (theta:: Real )
540- s, c = sincos (theta)
541- Complex (c, s)
542- end
543-
544538"""
545- cis(z )
539+ cis(x )
546540
547- Return `` \\ exp(iz )``.
541+ More efficient method for `exp(im*x)` by using Euler's formula: ``cos(x) + i sin(x) = \\ exp(i x )``.
548542
549- See also [`cispi`](@ref), [`angle`](@ref).
543+ See also [`cispi`](@ref), [`sincos`](@ref), [`exp`](@ref), [` angle`](@ref).
550544
551545# Examples
552546```jldoctest
553547julia> cis(π) ≈ -1
554548true
555549```
556550"""
551+ function cis end
552+ function cis (theta:: Real )
553+ s, c = sincos (theta)
554+ Complex (c, s)
555+ end
556+
557557function cis (z:: Complex )
558558 v = exp (- imag (z))
559559 s, c = sincos (real (z))
560560 Complex (v * c, v * s)
561561end
562562
563- cispi (theta:: Real ) = Complex (reverse (sincospi (theta))... )
564-
565563"""
566- cispi(z )
564+ cispi(x )
567565
568- Compute ``\\ exp(i\\ pi x)`` more accurately than `cis(pi*x)`, especially for large `x`.
566+ More accurate method for `cis(pi*x)` (especially for large `x`).
567+
568+ See also [`cis`](@ref), [`sincospi`](@ref), [`exp`](@ref), [`angle`](@ref).
569569
570570# Examples
571571```jldoctest
572- julia> cispi(1 )
573- - 1.0 + 0.0im
572+ julia> cispi(10000 )
573+ 1.0 + 0.0im
574574
575575julia> cispi(0.25 + 1im)
5765760.030556854645952924 + 0.030556854645952924im
@@ -579,6 +579,9 @@ julia> cispi(0.25 + 1im)
579579!!! compat "Julia 1.6"
580580 This function requires Julia 1.6 or later.
581581"""
582+ function cispi end
583+ cispi (theta:: Real ) = Complex (reverse (sincospi (theta))... )
584+
582585function cispi (z:: Complex )
583586 sipi, copi = sincospi (z)
584587 return complex (real (copi) - imag (sipi), imag (copi) + real (sipi))
Original file line number Diff line number Diff line change @@ -565,7 +565,10 @@ exp(A::Transpose{<:Any,<:AbstractMatrix}) = transpose(exp(parent(A)))
565565"""
566566 cis(A::AbstractMatrix)
567567
568- Compute ``\\ exp(i A)`` for a square matrix ``A``.
568+ More efficient method for `exp(im*A)` of square matrix `A`
569+ (especially if `A` is `Hermitian` or real-`Symmetric`).
570+
571+ See also [`cispi`](@ref), [`sincos`](@ref), [`exp`](@ref).
569572
570573!!! compat "Julia 1.7"
571574 Support for using `cis` with matrices was added in Julia 1.7.
You can’t perform that action at this time.
0 commit comments