cis
cis Function
Syntax:
cis radians → number
Arguments and Values:
radians—a real.
number—a complex .
Description:
cis returns the value of ei· radians , which is a complex in which the real part is equal to the cosine of radians, and the imaginary part is equal to the sine of radians.
Examples:
(cis 0) → #C(1.0 0.0)
See Also:
Section 12.1.3.3 (Rule of Float Substitutability)
Expanded Reference: cis
Basic usage
cis returns e^(i*radians), a complex number whose real part is cos(radians) and whose imaginary part is sin(radians).
(cis 0)
=> #C(1.0 0.0)
(cis (/ pi 2))
;; => impl-dependent
(cis pi)
;; => impl-dependent
Euler's formula
cis directly implements Euler's formula: e^(itheta) = cos(theta) + isin(theta).
;; Verify that cis matches cos + i*sin
(let ((theta 1.0))
(list (cis theta)
(complex (cos theta) (sin theta))))
=> (#C(0.5403023 0.84147096) #C(0.5403023 0.84147096))
Unit circle representation
cis always returns a complex number on the unit circle (magnitude 1).
(abs (cis 0.0))
=> 1.0
(abs (cis 1.0))
=> 0.99999994
(abs (cis 42.0))
;; => impl-dependent
Constructing complex numbers in polar form
Use cis together with multiplication to create complex numbers from polar coordinates (magnitude and angle).
;; Complex number with magnitude 5 and angle pi/4
(* 5 (cis (/ pi 4)))
;; => impl-dependent
;; Complex number with magnitude 2 and angle pi/3
(* 2 (cis (/ pi 3)))
;; => impl-dependent
Relationship to phase and abs
For any complex number z, (* (abs z) (cis (phase z))) reconstructs z.
(let ((z #c(3.0 4.0)))
(* (abs z) (cis (phase z))))
=> #C(3.0 4.0)