My various dotfiles

concept-numbers.tex 24KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640
  1. % -*- Mode: TeX -*-
  2. \beginsubsection{Numeric Operations}
  3. \DefineSection{NumericOperations}
  4. \clisp\ provides a large variety of operations related to \term{numbers}.
  5. This section provides an overview of those operations by grouping them
  6. into categories that emphasize some of the relationships among them.
  7. \Thenextfigure\ shows \term{operators} relating to
  8. arithmetic operations.
  9. \displaythree{Operators relating to Arithmetic.}{
  10. *&1+&gcd\cr
  11. +&1-&incf\cr
  12. -&conjugate&lcm\cr
  13. /&decf&\cr
  14. }
  15. \Thenextfigure\ shows \term{defined names} relating to
  16. exponential, logarithmic, and trigonometric operations.
  17. \displaythree{Defined names relating to Exponentials, Logarithms, and Trigonometry.}{
  18. abs&cos&signum\cr
  19. acos&cosh&sin\cr
  20. acosh&exp&sinh\cr
  21. asin&expt&sqrt\cr
  22. asinh&isqrt&tan\cr
  23. atan&log&tanh\cr
  24. atanh&phase&\cr
  25. cis&pi&\cr
  26. }
  27. \Thenextfigure\ shows \term{operators} relating to
  28. numeric comparison and predication.
  29. \displaythree{Operators for numeric comparison and predication.}{
  30. /=&>=&oddp\cr
  31. <&evenp&plusp\cr
  32. <=&max&zerop\cr
  33. =&min&\cr
  34. >&minusp&\cr
  35. }
  36. \Thenextfigure\ shows \term{defined names} relating to
  37. numeric type manipulation and coercion.
  38. \displaythree{Defined names relating to numeric type manipulation and coercion.}{
  39. ceiling&float-radix&rational\cr
  40. complex&float-sign&rationalize\cr
  41. decode-float&floor&realpart\cr
  42. denominator&fround&rem\cr
  43. fceiling&ftruncate&round\cr
  44. ffloor&imagpart&scale-float\cr
  45. float&integer-decode-float&truncate\cr
  46. float-digits&mod&\cr
  47. float-precision&numerator&\cr
  48. }
  49. \beginsubsubsection{Associativity and Commutativity in Numeric Operations}
  50. For functions that are mathematically associative (and possibly commutative),
  51. a \term{conforming implementation} may process the \term{arguments} in any manner
  52. consistent with associative (and possibly commutative) rearrangement. This does not
  53. affect the order in which the \term{argument} \term{forms} are \term{evaluated};
  54. for a discussion of evaluation order, \seesection\FunctionForms.
  55. What is unspecified is only the order in which the \term{parameter} \term{values}
  56. are processed. This implies that \term{implementations} may differ in which
  57. automatic \term{coercions} are applied; \seesection\NumericContagionRules.
  58. A \term{conforming program} can control the order of processing explicitly by
  59. separating the operations into separate (possibly nested) \term{function forms},
  60. or by writing explicit calls to \term{functions} that perform coercions.
  61. \beginsubsubsubsection{Examples of Associativity and Commutativity in Numeric Operations}
  62. Consider the following expression, in which we assume that \f{1.0} and
  63. \f{1.0e-15} both denote \term{single floats}:
  64. \code
  65. (+ 1/3 2/3 1.0d0 1.0 1.0e-15)
  66. \endcode
  67. One \term{conforming implementation} might
  68. process the \term{arguments} from left to right,
  69. first adding \f{1/3} and \f{2/3} to get \f{1},
  70. then converting that to a \term{double float}
  71. for combination with \f{1.0d0},
  72. then successively converting and adding \f{1.0} and \f{1.0e-15}.
  73. Another \term{conforming implementation} might process the \term{arguments} from
  74. right to left, first performing a \term{single float} addition of \f{1.0} and
  75. \f{1.0e-15} (perhaps losing accuracy in the process), then converting the sum to
  76. a \term{double float} and adding \f{1.0d0}, then converting \f{2/3} to a
  77. \term{double float} and adding it, and then converting \f{1/3} and adding that.
  78. A third \term{conforming implementation} might first scan all the \term{arguments},
  79. process all the \term{rationals} first to keep that part of the computation exact,
  80. then find an \term{argument} of the largest floating-point format among all the
  81. \term{arguments} and add that, and then add in all other \term{arguments}, converting
  82. each in turn (all in a perhaps misguided attempt to make the computation as accurate
  83. as possible).
  84. In any case, all three strategies are legitimate.
  85. A \term{conforming program} could control the order by writing, for example,
  86. \code
  87. (+ (+ 1/3 2/3) (+ 1.0d0 1.0e-15) 1.0)
  88. \endcode
  89. \endsubsubsubsection%{Examples of Associativity and Commutativity in Numeric Operations}
  90. \endsubsubsection%{Associativity and Commutativity in Numeric Operations}
  91. \beginsubsubsection{Contagion in Numeric Operations}
  92. \DefineSection{NumericContagionRules}
  93. For information about the contagion rules for implicit coercions of \term{arguments}
  94. in numeric operations, see
  95. \secref\RuleOfFloatPrecisionContagion,
  96. \secref\RuleOfFloatAndRationalContagion,
  97. and \secref\RuleOfComplexContagion.
  98. \endsubsubsection%{Contagion in Numeric Operations}
  99. \beginsubsubsection{Viewing Integers as Bits and Bytes}
  100. \beginsubsubsubsection{Logical Operations on Integers}
  101. %% 12.7.0 1
  102. %% 12.7.0 2
  103. Logical operations require \term{integers} as arguments;
  104. %!!! Is this a formal use of "should be signaled"? -kmp 13-May-91
  105. an error \oftype{type-error} should be signaled
  106. if an argument is supplied that is not an \term{integer}.
  107. \term{Integer} arguments to logical operations are treated as if
  108. they were represented in two's-complement notation.
  109. %Internally an implementation
  110. %might or might not use a two's-complement representation.
  111. \Thenextfigure\ shows \term{defined names} relating to
  112. logical operations on numbers.
  113. \displaythree{Defined names relating to logical operations on numbers.}{
  114. ash&boole-ior&logbitp\cr
  115. boole&boole-nand&logcount\cr
  116. boole-1&boole-nor&logeqv\cr
  117. boole-2&boole-orc1&logior\cr
  118. boole-and&boole-orc2&lognand\cr
  119. boole-andc1&boole-set&lognor\cr
  120. boole-andc2&boole-xor&lognot\cr
  121. boole-c1&integer-length&logorc1\cr
  122. boole-c2&logand&logorc2\cr
  123. boole-clr&logandc1&logtest\cr
  124. boole-eqv&logandc2&logxor\cr
  125. }
  126. \endsubsubsubsection%{Logical Operations on Integers}
  127. \beginsubsubsubsection{Byte Operations on Integers}
  128. %% 12.8.0 2
  129. The byte-manipulation \term{functions} use \term{objects}
  130. called \term{byte specifiers} to designate the size and position
  131. of a specific \term{byte} within an \term{integer}.
  132. The representation of a \term{byte specifier} is \term{implementation-dependent};
  133. it might or might not be a \term{number}.
  134. \Thefunction{byte} will construct a \term{byte specifier},
  135. which various other byte-manipulation \term{functions} will accept.
  136. \Thenextfigure\ shows \term{defined names} relating to
  137. manipulating \term{bytes} of \term{numbers}.
  138. \displaythree{Defined names relating to byte manipulation.}{
  139. byte&deposit-field&ldb-test\cr
  140. byte-position&dpb&mask-field\cr
  141. byte-size&ldb&\cr
  142. }
  143. \endsubsubsubsection%{Byte Operations on Integers}
  144. \endsubsubsection%{Viewing Integers as Bits and Bytes}
  145. \endsubsection%{Numeric Operations}
  146. \beginSubsection{Implementation-Dependent Numeric Constants}
  147. \Thenextfigure\ shows \term{defined names} relating to
  148. \term{implementation-dependent} details about \term{numbers}.
  149. \displaytwo{Defined names relating to implementation-dependent details about numbers.}{
  150. double-float-epsilon&most-negative-fixnum\cr
  151. double-float-negative-epsilon&most-negative-long-float\cr
  152. least-negative-double-float&most-negative-short-float\cr
  153. least-negative-long-float&most-negative-single-float\cr
  154. least-negative-short-float&most-positive-double-float\cr
  155. least-negative-single-float&most-positive-fixnum\cr
  156. least-positive-double-float&most-positive-long-float\cr
  157. least-positive-long-float&most-positive-short-float\cr
  158. least-positive-short-float&most-positive-single-float\cr
  159. least-positive-single-float&short-float-epsilon\cr
  160. long-float-epsilon&short-float-negative-epsilon\cr
  161. long-float-negative-epsilon&single-float-epsilon\cr
  162. most-negative-double-float&single-float-negative-epsilon\cr
  163. }
  164. \endSubsection%{Implementation-Dependent Numeric Constants}
  165. \beginsubsection{Rational Computations}
  166. \DefineSection{RationalComputations}
  167. %% 12.1.0 2
  168. The rules in this section apply to \term{rational} computations.
  169. \beginsubsubsection{Rule of Unbounded Rational Precision}
  170. Rational computations cannot overflow in the usual sense
  171. (though there may not be enough storage to represent a result),
  172. since \term{integers} and \term{ratios} may in principle be of any magnitude.
  173. \endsubsubsection%{Rule of Unbounded Rational Precision}
  174. \beginsubsubsection{Rule of Canonical Representation for Rationals}
  175. %% 2.1.2 2
  176. %% 12.1.0 5
  177. If any computation produces a result that is a mathematical ratio of two integers
  178. such that the denominator evenly divides the numerator, then the result is converted
  179. to the equivalent \term{integer}.
  180. %% 2.1.2 1
  181. %% This had been removed, but I couldn't figure out why,
  182. %% so I reinstated it. -kmp 19-Oct-91
  183. If the denominator does not evenly divide the numerator,
  184. the canonical representation of a \term{rational} number is as the \term{ratio}
  185. that numerator and that denominator, where the greatest common divisor of
  186. the numerator and denominator is one, and where the denominator is positive
  187. and greater than one.
  188. When used as input (in the default syntax),
  189. the notation \f{-0} always denotes the \term{integer} \f{0}.
  190. A \term{conforming implementation} must not have a
  191. representation of ``minus zero'' for \term{integers}
  192. that is distinct from its representation of zero for \term{integers}.
  193. However, such a distinction is possible for \term{floats};
  194. see \thetype{float}.
  195. \endsubsubsection%{Rule of Canonical Representation for Rationals}
  196. \beginsubsubsection{Rule of Float Substitutability}
  197. \DefineSection{FloatSubstitutability}
  198. %% 12.5.0 4
  199. When the arguments to an irrational mathematical \term{function}
  200. \reviewer{Barmar: There should be a table of these functions.}
  201. are all \term{rational} and the true mathematical result
  202. is also (mathematically) rational, then unless otherwise noted
  203. an implementation is free to return either an accurate
  204. \term{rational} result
  205. or a \term{single float} approximation.
  206. If the arguments are all \term{rational}
  207. but the result cannot be expressed
  208. as a \term{rational} number, then a \term{single float}
  209. approximation is always returned.
  210. \issue{COMPLEX-RATIONAL-RESULT:EXTEND}
  211. If the arguments to a mathematical \term{function} are all of type
  212. \f{(or rational (complex rational))}
  213. and the true mathematical result is
  214. (mathematically) a complex number with rational real and imaginary
  215. parts, then unless otherwise noted an implementation is free to return
  216. either an accurate result of type \f{(or rational (complex rational))}
  217. or
  218. a \term{single float}
  219. (permissible only if the imaginary part of the true mathematical
  220. result is zero) or \f{(complex single-float)}. If the arguments are
  221. all of type \f{(or rational (complex rational))}
  222. but the result cannot be
  223. expressed as a \term{rational} or \term{complex rational},
  224. then the returned
  225. value will be \oftype{single-float}
  226. (permissible only if the imaginary
  227. part of the true mathematical result is zero) or \f{(complex single-float)}.
  228. \endissue{COMPLEX-RATIONAL-RESULT:EXTEND}
  229. \tablefigtwo{Functions Affected by Rule of Float Substitutability}%
  230. {Function}{Sample Results}{
  231. \funref{abs} & \f{(abs \#c(3 4)) \EV\ 5 \i{or} 5.0} \cr
  232. \funref{acos} & \f{(acos 1) \EV\ 0 \i{or} 0.0} \cr
  233. \funref{acosh} & \f{(acosh 1) \EV\ 0 \i{or} 0.0} \cr
  234. \funref{asin} & \f{(asin 0) \EV\ 0 \i{or} 0.0} \cr
  235. \funref{asinh} & \f{(asinh 0) \EV\ 0 \i{or} 0.0} \cr
  236. \funref{atan} & \f{(atan 0) \EV\ 0 \i{or} 0.0} \cr
  237. \funref{atanh} & \f{(atanh 0) \EV\ 0 \i{or} 0.0} \cr
  238. \funref{cis} & \f{(cis 0) \EV\ \#c(1 0) \i{or} \#c(1.0 0.0)} \cr
  239. \funref{cos} & \f{(cos 0) \EV\ 1 \i{or} 1.0} \cr
  240. \funref{cosh} & \f{(cosh 0) \EV\ 1 \i{or} 1.0} \cr
  241. \funref{exp} & \f{(exp 0) \EV\ 1 \i{or} 1.0} \cr
  242. \funref{expt} & \f{(expt 8 1/3) \EV\ 2 \i{or} 2.0} \cr
  243. \funref{log} & \f{(log 1) \EV\ 0 \i{or} 0.0} \cr
  244. & \f{(log 8 2) \EV\ 3 \i{or} 3.0} \cr
  245. \funref{phase} & \f{(phase 7) \EV\ 0 \i{or} 0.0} \cr
  246. \funref{signum} & \f{(signum \#c(3 4)) \EV\ \#c(3/5 4/5) \i{or} \#c(0.6 0.8)} \cr
  247. \funref{sin} & \f{(sin 0) \EV\ 0 \i{or} 0.0} \cr
  248. \funref{sinh} & \f{(sinh 0) \EV\ 0 \i{or} 0.0} \cr
  249. \funref{sqrt} & \f{(sqrt 4) \EV\ 2 \i{or} 2.0} \cr
  250. & \f{(sqrt 9/16) \EV\ 3/4 \i{or} 0.75} \cr
  251. \funref{tan} & \f{(tan 0) \EV\ 0 \i{or} 0.0} \cr
  252. \funref{tanh} & \f{(tanh 0) \EV\ 0 \i{or} 0.0} \cr
  253. }
  254. \endsubsubsection%{Rule of Float Substitutability}
  255. \endsubsection%{Rational Computations}
  256. \beginsubsection{Floating-point Computations}
  257. \DefineSection{FloatingPointComputations}
  258. The following rules apply to floating point computations.
  259. \issue{CONTAGION-ON-NUMERICAL-COMPARISONS:TRANSITIVE}
  260. \beginsubsubsection{Rule of Float and Rational Contagion}
  261. \DefineSection{RuleOfFloatAndRationalContagion}
  262. %% Barmar noted that the following was said in two different places.
  263. %% I've removed the most casually worded of the two.
  264. %% Hopefully no useful info was lost in the process. -kmp 19-Oct-91
  265. % For \term{functions} that combine arguments of different \term{types},
  266. % when one argument is a \term{rational} and the other is a \term{float},
  267. % the \term{rational} is first converted to a \term{float} of the same format.
  268. % For \term{functions} that compare arguments of different \term{types},
  269. % when one argument is a \term{rational} and the other is
  270. % a \term{float}, \thefunction{rational} is effectively
  271. % called to convert the \term{float} to a \term{rational} and then an exact
  272. % comparison is performed. In the case of \term{complex} numbers, the real and
  273. % imaginary parts are effectively handled individually.
  274. %% 12.1.0 3
  275. When \term{rationals} and \term{floats} are combined by a numerical function,
  276. the \term{rational} is first converted to a \term{float} of the same format.
  277. For \term{functions} such as \funref{+} that take more than two arguments,
  278. it is permitted that part of the operation be carried out exactly using
  279. \term{rationals} and the rest be done using floating-point arithmetic.
  280. When \term{rationals} and \term{floats} are compared by a numerical function,
  281. \thefunction{rational} is effectively called to convert the \term{float}
  282. to a \term{rational} and then an exact
  283. comparison is performed. In the case of \term{complex} numbers,
  284. the real and imaginary parts are effectively handled individually.
  285. \beginsubsubsubsection{Examples of Rule of Float and Rational Contagion}
  286. \code
  287. ;;;; Combining rationals with floats.
  288. ;;; This example assumes an implementation in which
  289. ;;; (float-radix 0.5) is 2 (as in IEEE) or 16 (as in IBM/360),
  290. ;;; or else some other implementation in which 1/2 has an exact
  291. ;;; representation in floating point.
  292. (+ 1/2 0.5) \EV 1.0
  293. (- 1/2 0.5d0) \EV 0.0d0
  294. (+ 0.5 -0.5 1/2) \EV 0.5
  295. ;;;; Comparing rationals with floats.
  296. ;;; This example assumes an implementation in which the default float
  297. ;;; format is IEEE single-float, IEEE double-float, or some other format
  298. ;;; in which 5/7 is rounded upwards by FLOAT.
  299. (< 5/7 (float 5/7)) \EV \term{true}
  300. (< 5/7 (rational (float 5/7))) \EV \term{true}
  301. (< (float 5/7) (float 5/7)) \EV \term{false}
  302. \endcode
  303. % (< 5/7 (rationalize (float 5/7))) \EV \term{implementation-dependent}
  304. % Moon: The rationalize example is screwy since the two lines preceding it are also
  305. % implementation-dependent. Also I don't think it sheds any light on
  306. % the issue at hand (see the name of the subsubsection), so flush it.
  307. \endsubsubsection%{Examples of Rule of Float and Rational Contagion}
  308. \endissue{CONTAGION-ON-NUMERICAL-COMPARISONS:TRANSITIVE}
  309. \endsubsubsection%{Rule of Float and Rational Contagion}
  310. \beginsubsubsection{Rule of Float Approximation}
  311. %% 12.1.0 1
  312. %% 12.5.0 3
  313. Computations with \term{floats} are only approximate,
  314. although they are described as if the results
  315. were mathematically accurate.
  316. Two mathematically identical
  317. expressions may be computationally different because of errors
  318. inherent in the floating-point approximation process.
  319. The precision of a \term{float} is not necessarily
  320. correlated with the accuracy of that number.
  321. For instance, 3.142857142857142857 is a more precise approximation
  322. to $\pi$ than 3.14159, but the latter is more accurate.
  323. The precision refers to the number of bits retained in the representation.
  324. When an operation combines a \term{short float} with a
  325. \term{long float},
  326. the result will be a \term{long float}.
  327. \clisp\ functions assume that the accuracy of
  328. arguments to them does not exceed their precision. Therefore
  329. when two \term{small floats}
  330. are combined, the result is a \term{small float}.
  331. \clisp\ functions
  332. never convert automatically from a larger size to a smaller one.
  333. \endsubsubsection%{Rule of Float Approximation}
  334. \beginsubsubsection{Rule of Float Underflow and Overflow}
  335. %% 12.1.0 2
  336. An error of \term{type} \typeref{floating-point-overflow}
  337. or \typeref{floating-point-underflow} should be signaled if a
  338. floating-point computation causes exponent overflow or underflow, respectively.
  339. \endsubsubsection%{Rule of Float Underflow and Overflow}
  340. \beginsubsubsection{Rule of Float Precision Contagion}
  341. \DefineSection{RuleOfFloatPrecisionContagion}
  342. %% The following was said in two different places.
  343. %% I've removed the most casually worded of the two.
  344. %% Hopefully no useful info was lost in the process. -kmp 19-Oct-91
  345. % When a shorter \term{float} is combined with a longer one in an operation,
  346. % the result will be of the \term{type} of the longer of the two \term{floats}.
  347. %% 12.1.0 5
  348. The result of a numerical function is a \term{float} of the
  349. largest format among all the floating-point arguments to the \term{function}.
  350. \endsubsubsection%{Rule of Float Precision Contagion}
  351. \endsubsection%{Floating-point Computations}
  352. \beginsubsection{Complex Computations}
  353. \DefineSection{ComplexComputations}
  354. %% 12.1.0 6
  355. The following rules apply to \term{complex} computations:
  356. \beginsubsubsection{Rule of Complex Substitutability}
  357. %% Rewritten by KMP.
  358. % Except during the execution of irrational and transcendental \term{functions},
  359. % \term{complex} numbers never result from a numerical \term{function}
  360. % unless one or more of the \term{arguments} is \term{complex}.
  361. Except during the execution of irrational and transcendental \term{functions},
  362. no numerical \term{function} ever \term{yields} a \term{complex} unless
  363. one or more of its \term{arguments} is a \term{complex}.
  364. \endsubsubsection%{Rule of Complex Substitutability}
  365. \beginsubsubsection{Rule of Complex Contagion}
  366. \DefineSection{RuleOfComplexContagion}
  367. % When a
  368. % \issue{REAL-NUMBER-TYPE:X3J13-MAR-89}
  369. % \term{real}
  370. % \endissue{REAL-NUMBER-TYPE:X3J13-MAR-89}
  371. % number
  372. % \reviewer{Barmar: I don't like the word `meets' here.}
  373. % \editornote{KMP: This is all said redundantly in \secref\ComplexComputations\ below,
  374. % so maybe we can merge the two, somehow.} %!!! 26-Dec-90
  375. % meets a \term{complex} number, the
  376. % \issue{REAL-NUMBER-TYPE:X3J13-MAR-89}
  377. % \term{real}
  378. % \endissue{REAL-NUMBER-TYPE:X3J13-MAR-89}
  379. % number is in effect first converted to a
  380. % \term{complex} number by providing an
  381. % imaginary part of {\tt $0$}.
  382. When a
  383. \issue{REAL-NUMBER-TYPE:X3J13-MAR-89}
  384. \term{real}
  385. \endissue{REAL-NUMBER-TYPE:X3J13-MAR-89}
  386. and
  387. a \term{complex} are both part of a computation,
  388. the
  389. \issue{REAL-NUMBER-TYPE:X3J13-MAR-89}
  390. \term{real}
  391. \endissue{REAL-NUMBER-TYPE:X3J13-MAR-89}
  392. is first converted to a \term{complex} by providing an imaginary part of \f{0}.
  393. \endsubsubsection%{Rule of Complex Contagion}
  394. \beginsubsubsection{Rule of Canonical Representation for Complex Rationals}
  395. \DefineSection{RuleOfCanonRepForComplexRationals}
  396. %% 12.1.0 8
  397. If the result of any computation would be a \term{complex}
  398. number whose real part is \oftype{rational} and whose imaginary
  399. part is zero, the result is converted to the \term{rational}
  400. which is the real part.
  401. This rule does not apply to \term{complex} numbers whose parts
  402. are \term{floats}.
  403. For example, \f{\#C(5 0)} and \f{5} are not \term{different} \term{objects} in \clisp
  404. (they are always the \term{same} under \funref{eql});
  405. \f{\#C(5.0 0.0)} and \f{5.0} are always \term{different} \term{objects} in \clisp\
  406. (they are never the \term{same} under \funref{eql},
  407. although they are the \term{same} under \funref{equalp} and \funref{=}).
  408. \beginsubsubsubsection{Examples of Rule of Canonical Representation for Complex Rationals}
  409. \code
  410. #c(1.0 1.0) \EV #C(1.0 1.0)
  411. #c(0.0 0.0) \EV #C(0.0 0.0)
  412. #c(1.0 1) \EV #C(1.0 1.0)
  413. #c(0.0 0) \EV #C(0.0 0.0)
  414. #c(1 1) \EV #C(1 1)
  415. #c(0 0) \EV 0
  416. (typep #c(1 1) '(complex (eql 1))) \EV \term{true}
  417. (typep #c(0 0) '(complex (eql 0))) \EV \term{false}
  418. \endcode
  419. \endsubsubsubsection%{Examples of Rule of Canonical Representation for Complex Rationals}
  420. \endsubsubsection%{Rule of Canonical Representation for Complex Rationals}
  421. \beginsubsubsection{Principal Values and Branch Cuts}
  422. %% 12.5.3 1
  423. Many of the irrational and transcendental functions are multiply defined
  424. in the complex domain; for example, there are in general an infinite
  425. number of complex values for the logarithm function. In each such
  426. case, a \term{principal} \term{value} must be chosen for the function to return.
  427. In general, such values cannot be chosen so as to make the range
  428. continuous; lines in the domain
  429. called branch cuts must be defined, which in turn
  430. define the discontinuities in the range.
  431. %% 12.5.3 2
  432. \clisp\ defines the branch cuts, \term{principal} \term{values}, and boundary
  433. conditions for the complex functions following ``{\PrincipalValues}.'' The branch
  434. cut rules that apply to each function are located with the description of
  435. that function.
  436. %% 12.5.3 17
  437. \Thenextfigure\ lists
  438. the identities that are obeyed
  439. throughout the applicable portion of the complex domain, even on
  440. the branch cuts:
  441. \showthree{Trigonometric Identities for Complex Domain}{
  442. sin i z = i sinh z & sinh i z = i sin z & arctan i z = i arctanh z \cr
  443. cos i z = cosh z & cosh i z = cos z & arcsinh i z = i arcsin z \cr
  444. tan i z = i tanh z & arcsin i z = i arcsinh z & arctanh i z = i arctan z \cr
  445. }
  446. The quadrant numbers referred to in the discussions of branch cuts are as illustrated
  447. in \thenextfigure.
  448. % JGA requested this.
  449. % This is amazingly low-tex and the spacing of dots isn't quite right,
  450. % but I think it's good enough to be intelligible and will suffice until and
  451. % unless something better is devised. -kmp 3-Feb-92
  452. \code
  453. Imaginary Axis
  454. |
  455. |
  456. II | I
  457. |
  458. |
  459. |
  460. ______________________________________ Real Axis
  461. |
  462. |
  463. |
  464. III | IV
  465. |
  466. |
  467. |
  468. |
  469. \endcode
  470. \simplecaption{Quadrant Numbering for Branch Cuts}
  471. \endsubsubsection%{Principal Values and Branch Cuts}
  472. \endsubsection%{Complex Computations}
  473. \beginsubsection{Interval Designators}
  474. \DefineSection{IntervalDesignators}
  475. The \term{compound type specifier} form of the numeric \term{type specifiers}
  476. in \thenextfigure\ permit the user to specify an interval on the real number line
  477. which describe a \term{subtype} of the \term{type} which would be described by the
  478. corresponding \term{atomic type specifier}. A \term{subtype} of some \term{type}
  479. \param{T} is specified using an ordered pair of \term{objects} called
  480. \term{interval designators} for \term{type} \param{T}.
  481. The first of the two \term{interval designators} for \term{type} \param{T} can be
  482. any of the following:
  483. \beginlist
  484. \itemitem{a number \param{N} of \term{type} \param{T}}
  485. This denotes a lower inclusive bound of \param{N}. That is, \term{elements}
  486. of the \term{subtype} of \param{T} will be greater than or equal to \param{N}.
  487. \itemitem{a \term{singleton} \term{list} whose \term{element} is
  488. a number \param{M} of \term{type} \param{T}}
  489. This denotes a lower exclusive bound of \param{M}. That is, \term{elements}
  490. of the \term{subtype} of \param{T} will be greater than \param{M}.
  491. \itemitem{the symbol \misc{*}}
  492. This denotes the absence of a lower bound on the interval.
  493. \endlist
  494. The second of the two \term{interval designators} for \term{type} \param{T} can be
  495. any of the following:
  496. \beginlist
  497. \itemitem{a number \param{N} of \term{type} \param{T}}
  498. This denotes an upper inclusive bound of \param{N}. That is, \term{elements}
  499. of the \term{subtype} of \param{T} will be less than or equal to \param{N}.
  500. \itemitem{a \term{singleton} \term{list} whose \term{element} is
  501. a number \param{M} of \term{type} \param{T}}
  502. This denotes an upper exclusive bound of \param{M}. That is, \term{elements}
  503. of the \term{subtype} of \param{T} will be less than \param{M}.
  504. \itemitem{the symbol \misc{*}}
  505. This denotes the absence of an upper bound on the interval.
  506. \endlist
  507. \endsubsection%{Interval Designators}
  508. \beginsubsection{Random-State Operations}
  509. \Thenextfigure\ lists some \term{defined names} that are applicable to \term{random states}.
  510. \displaythree{Random-state defined names}{
  511. *random-state*&random&\cr
  512. make-random-state&random-state-p&\cr
  513. }
  514. \endsubsection%{Random-State Operations}