The following rules apply to complex computations:
Except during the execution of irrational and transcendental functions, no numerical function ever yields a complex unless one or more of its arguments is a complex.
When a
real
and
a complex are both part of a computation,
the
real
is first converted to a complex by providing an imaginary part of 0
.
If the result of any computation would be a complex
number whose real part is of type rational
and whose imaginary
part is zero, the result is converted to the rational
which is the real part.
This rule does not apply to complex numbers whose parts
are floats.
For example, #C(5 0)
and 5
are not different objects in Common Lisp
(they are always the same under eql
);
#C(5.0 0.0)
and 5.0
are always different objects in Common Lisp
(they are never the same under eql
,
although they are the same under equalp
and =
).
#c(1.0 1.0) → #C(1.0 1.0) #c(0.0 0.0) → #C(0.0 0.0) #c(1.0 1) → #C(1.0 1.0) #c(0.0 0) → #C(0.0 0.0) #c(1 1) → #C(1 1) #c(0 0) → 0 (typep #c(1 1) '(complex (eql 1))) → true (typep #c(0 0) '(complex (eql 0))) → false
Many of the irrational and transcendental functions are multiply defined in the complex domain; for example, there are in general an infinite number of complex values for the logarithm function. In each such case, a principal value must be chosen for the function to return. In general, such values cannot be chosen so as to make the range continuous; lines in the domain called branch cuts must be defined, which in turn define the discontinuities in the range. Common Lisp defines the branch cuts, principal values, and boundary conditions for the complex functions following “Principal Values and Branch Cuts in Complex APL.” The branch cut rules that apply to each function are located with the description of that function.
The next figure lists the identities that are obeyed throughout the applicable portion of the complex domain, even on the branch cuts:
|
Figure 12.9: Trigonometric Identities for Complex Domain
The quadrant numbers referred to in the discussions of branch cuts are as illustrated in the next figure.