home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume24 / gnucalc / part35 < prev    next >
Encoding:
Text File  |  1991-10-31  |  55.5 KB  |  1,755 lines

  1. Newsgroups: comp.sources.misc
  2. From: daveg@synaptics.com (David Gillespie)
  3. Subject:  v24i083:  gnucalc - GNU Emacs Calculator, v2.00, Part35/56
  4. Message-ID: <1991Oct31.214552.2554@sparky.imd.sterling.com>
  5. X-Md4-Signature: 17d91c5c5faf3e2cf7d24ae52b02bd56
  6. Date: Thu, 31 Oct 1991 21:45:52 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: daveg@synaptics.com (David Gillespie)
  10. Posting-number: Volume 24, Issue 83
  11. Archive-name: gnucalc/part35
  12. Environment: Emacs
  13. Supersedes: gmcalc: Volume 13, Issue 27-45
  14.  
  15. ---- Cut Here and unpack ----
  16. #!/bin/sh
  17. # do not concatenate these parts, unpack them in order with /bin/sh
  18. # file calc.texinfo continued
  19. #
  20. if test ! -r _shar_seq_.tmp; then
  21.     echo 'Please unpack part 1 first!'
  22.     exit 1
  23. fi
  24. (read Scheck
  25.  if test "$Scheck" != 35; then
  26.     echo Please unpack part "$Scheck" next!
  27.     exit 1
  28.  else
  29.     exit 0
  30.  fi
  31. ) < _shar_seq_.tmp || exit 1
  32. if test ! -f _shar_wnt_.tmp; then
  33.     echo 'x - still skipping calc.texinfo'
  34. else
  35. echo 'x - continuing file calc.texinfo'
  36. sed 's/^X//' << 'SHAR_EOF' >> 'calc.texinfo' &&
  37. * List Answer 14::         Random walk
  38. * Types Answer 1::         Square root of pi times rational
  39. * Types Answer 2::         Infinities
  40. * Types Answer 3::         What can "nan" be?
  41. * Types Answer 4::         Abbey Road
  42. * Types Answer 5::         Friday the 13th
  43. * Types Answer 6::         Leap years
  44. * Types Answer 7::         Erroneous donut
  45. * Types Answer 8::         Dividing intervals
  46. * Types Answer 9::         Squaring intervals
  47. * Types Answer 10::        Fermat's primality test
  48. * Types Answer 11::        pi * 10^7 seconds
  49. * Types Answer 12::        Abbey Road on CD
  50. * Types Answer 13::        Not quite pi * 10^7 seconds
  51. * Types Answer 14::        Supercomputers and c
  52. * Types Answer 15::        Sam the Slug
  53. * Algebra Answer 1::       Squares and square roots
  54. * Algebra Answer 2::       Solving a quartic equation
  55. * Algebra Answer 3::       Integral of x sin(pi x)
  56. * Algebra Answer 4::       Simpson's rule
  57. * Rewrites Answer 1::      Multiplying by conjugate
  58. * Rewrites Answer 2::      Alternative fib rule
  59. * Rewrites Answer 3::      Rewriting opt(a) + opt(b) x
  60. * Rewrites Answer 4::      Sequence of integers
  61. * Rewrites Answer 5::      Number of terms in sum
  62. * Rewrites Answer 6::      Truncated Taylor series
  63. * Programming Answer 1::   Fresnel's C(x)
  64. * Programming Answer 2::   Negate third stack element
  65. * Programming Answer 3::   Compute sin(x) / x, etc.
  66. * Programming Answer 4::   Average value of a list
  67. * Programming Answer 5::   Continued fraction phi
  68. * Programming Answer 6::   Matrix Fibonacci numbers
  69. * Programming Answer 7::   Harmonic number greater than 4
  70. * Programming Answer 8::   Newton's method
  71. * Programming Answer 9::   Digamma function
  72. * Programming Answer 10::  Unpacking a polynomial
  73. * Programming Answer 11::  Recursive Stirling numbers
  74. * Programming Answer 12::  Stirling numbers with rewrites
  75. @end menu
  76. X
  77. @c The following kludgery prevents the individual answers from
  78. @c being entered on the table of contents.
  79. @tex
  80. \global\let\oldwrite=\write
  81. \global\def\skipwrite#1#2{\let\write=\oldwrite}
  82. \global\let\oldchapternofonts=\chapternofonts
  83. \global\def\chapternofonts{\let\write=\skipwrite\oldchapternofonts}
  84. @end tex
  85. X
  86. @node RPN Answer 1, RPN Answer 2, Answers to Exercises, Answers to Exercises
  87. @subsection RPN Tutorial Exercise 1
  88. X
  89. @noindent
  90. @kbd{1 @key{RET} 2 @key{RET} 3 @key{RET} 4 + * -}
  91. X
  92. The result is @c{$1 - (2 \times (3 + 4)) = -13$}
  93. @cite{1 - (2 * (3 + 4)) = -13}.
  94. X
  95. @node RPN Answer 2, RPN Answer 3, RPN Answer 1, Answers to Exercises
  96. @subsection RPN Tutorial Exercise 2
  97. X
  98. @noindent
  99. @c{$2\times4 + 7\times9.5 + {5\over4} = 75.75$}
  100. @cite{2*4 + 7*9.5 + 5/4 = 75.75}
  101. X
  102. After computing the intermediate term @c{$2\times4 = 8$}
  103. @cite{2*4 = 8}, you can leave
  104. that result on the stack while you compute the second term.  With
  105. both of these results waiting on the stack you can then compute the
  106. final term, then press @kbd{+ +} to add everything up.
  107. X
  108. @group
  109. @smallexample
  110. 2:  2          1:  8          3:  8          2:  8
  111. 1:  4              .          2:  7          1:  66.5
  112. X    .                         1:  9.5            .
  113. X                                  .
  114. X
  115. X  2 RET 4          *          7 RET 9.5          *
  116. X
  117. @end smallexample
  118. @end group
  119. @noindent
  120. @group
  121. @smallexample
  122. 4:  8          3:  8          2:  8          1:  75.75
  123. 3:  66.5       2:  66.5       1:  67.75          .
  124. 2:  5          1:  1.25           .
  125. 1:  4              .
  126. X    .
  127. X
  128. X  5 RET 4          /              +              +
  129. @end smallexample
  130. @end group
  131. X
  132. Alternatively, you could add the first two terms before going on
  133. with the third term.
  134. X
  135. @group
  136. @smallexample
  137. 2:  8          1:  74.5       3:  74.5       2:  74.5       1:  75.75
  138. 1:  66.5           .          2:  5          1:  1.25           .
  139. X    .                         1:  4              .
  140. X                                  .
  141. X
  142. X   ...             +            5 RET 4          /              +
  143. @end smallexample
  144. @end group
  145. X
  146. On an old-style RPN calculator this second method would have the
  147. advantage of using only three stack levels.  But since Calc's stack
  148. can grow arbitrarily large this isn't really an issue.  Which method
  149. you choose is purely a matter of taste.
  150. X
  151. @node RPN Answer 3, RPN Answer 4, RPN Answer 2, Answers to Exercises
  152. @subsection RPN Tutorial Exercise 3
  153. X
  154. @noindent
  155. The @key{TAB} key provides a way to operate on the number in level 2.
  156. X
  157. @group
  158. @smallexample
  159. 3:  10         3:  10         4:  10         3:  10         3:  10
  160. 2:  20         2:  30         3:  30         2:  30         2:  21
  161. 1:  30         1:  20         2:  20         1:  21         1:  30
  162. X    .              .          1:  1              .              .
  163. X                                  .
  164. X
  165. X                  TAB             1              +             TAB
  166. @end smallexample
  167. @end group
  168. X
  169. Similarly, @key{M-TAB} gives you access to the number in level 3.
  170. X
  171. @group
  172. @smallexample
  173. 3:  10         3:  21         3:  21         3:  30         3:  11
  174. 2:  21         2:  30         2:  30         2:  11         2:  21
  175. 1:  30         1:  10         1:  11         1:  21         1:  30
  176. X    .              .              .              .              .
  177. X
  178. X                  M-TAB           1 +           M-TAB          M-TAB
  179. @end smallexample
  180. @end group
  181. X
  182. @node RPN Answer 4, Algebraic Answer 1, RPN Answer 3, Answers to Exercises
  183. @subsection RPN Tutorial Exercise 4
  184. X
  185. @noindent
  186. Either @kbd{( 2 , 3 )} or @kbd{( 2 @key{SPC} 3 )} would have worked,
  187. but using both the comma and the space at once yields:
  188. X
  189. @group
  190. @smallexample
  191. 1:  ( ...      2:  ( ...      1:  (2, ...    2:  (2, ...    2:  (2, ...
  192. X    .          1:  2              .          1:  (2, ...    1:  (2, 3)
  193. X                   .                             .              .
  194. X
  195. X    (              2              ,             SPC            3 )
  196. @end smallexample
  197. @end group
  198. X
  199. Joe probably tried to type @kbd{@key{TAB} @key{DEL}} to swap the
  200. extra incomplete object to the top of the stack and delete it.
  201. But a feature of Calc is that @key{DEL} on an incomplete object
  202. deletes just one component out of that object, so he had to press
  203. @key{DEL} twice to finish the job.
  204. X
  205. @group
  206. @smallexample
  207. 2:  (2, ...    2:  (2, 3)     2:  (2, 3)     1:  (2, 3)
  208. 1:  (2, 3)     1:  (2, ...    1:  ( ...          .
  209. X    .              .              .
  210. X
  211. X                  TAB            DEL            DEL
  212. @end smallexample
  213. @end group
  214. X
  215. (As it turns out, deleting the second-to-top stack entry happens often
  216. enough that Calc provides a special key, @kbd{M-DEL}, to do just that.
  217. @kbd{M-DEL} is just like @kbd{TAB DEL}, except that it doesn't exhibit
  218. the ``feature'' that tripped poor Joe.)
  219. X
  220. @node Algebraic Answer 1, Algebraic Answer 2, RPN Answer 4, Answers to Exercises
  221. @subsection Algebraic Entry Tutorial Exercise 1
  222. X
  223. @noindent
  224. Type @kbd{' sqrt($) @key{RET}}.
  225. X
  226. If the @kbd{Q} key is broken, you could use @kbd{' $^0.5 @key{RET}}.
  227. Or, RPN style, @kbd{0.5 ^}.
  228. X
  229. (Actually, @samp{$^1:2}, using the fraction one-half as the power, is
  230. a closer equivalent, since @samp{9^0.5} yields @cite{3.0} whereas
  231. @samp{sqrt(9)} and @samp{9^1:2} yield the exact integer @cite{3}.)
  232. X
  233. @node Algebraic Answer 2, Algebraic Answer 3, Algebraic Answer 1, Answers to Exercises
  234. @subsection Algebraic Entry Tutorial Exercise 2
  235. X
  236. @noindent
  237. In the formula @samp{2 x (1+y)}, @samp{x} was interpreted as a function
  238. name with @samp{1+y} as its argument.  Assigning a value to a variable
  239. has no relation to a function by the same name.  Joe needed to use an
  240. explicit @samp{*} symbol here:  @samp{2 x*(1+y)}.
  241. X
  242. @node Algebraic Answer 3, Modes Answer 1, Algebraic Answer 2, Answers to Exercises
  243. @subsection Algebraic Entry Tutorial Exercise 3
  244. X
  245. @noindent
  246. The result from @kbd{1 @key{RET} 0 /} will be the formula @cite{1 / 0}.
  247. The ``function'' @samp{/} cannot be evaluated when its second argument
  248. is zero, so it is left in symbolic form.  When you now type @kbd{0 *},
  249. the result will be zero because Calc uses the general rule that ``zero
  250. times anything is zero.''
  251. X
  252. @c [fix-ref Infinities]
  253. The @kbd{m i} command enables an @dfn{infinite mode} in which @cite{1 / 0}
  254. results in a special symbol that represents ``infinity.''  If you
  255. multiply infinity by zero, Calc uses another special new symbol to
  256. show that the answer is ``indeterminate.''  @xref{Infinities}, for
  257. further discussion of infinite and indeterminate values.
  258. X
  259. @node Modes Answer 1, Modes Answer 2, Algebraic Answer 3, Answers to Exercises
  260. @subsection Modes Tutorial Exercise 1
  261. X
  262. @noindent
  263. Calc always stores its numbers in decimal, so even though one-third has
  264. an exact base-3 representation (@samp{3#0.1}), it is still stored as
  265. 0.3333333 (chopped off after 12 or however many decimal digits) inside
  266. the calculator's memory.  When this inexact number is converted back
  267. to base 3 for display, it may still be slightly inexact.  When we
  268. multiply this number by 3, we get 0.999999, also an inexact value.
  269. X
  270. When Calc displays a number in base 3, it has to decide how many digits
  271. to show.  If the current precision is 12 (decimal) digits, that corresponds
  272. to @samp{12 / log10(3) = 25.15} base-3 digits.  Because 25.15 is not an
  273. exact integer, Calc shows only 25 digits, with the result that stored
  274. numbers carry a little bit of extra information that may not show up on
  275. the screen.  When Joe entered @samp{3#0.2}, the stored number 0.666666
  276. happened to round to a pleasing value when it lost that last 0.15 of a
  277. digit, but it was still inexact in Calc's memory.  When he divided by 2,
  278. he still got the dreaded inexact value 0.333333.  (Actually, he divided
  279. 0.666667 by 2 to get 0.333334, which is why he got something a little
  280. higher than 3#0.1 instead of a little lower.)
  281. X
  282. If Joe didn't want to be bothered with all this, he could have typed
  283. @kbd{M-24 d n} to display with one less digit than the default.  (If
  284. you give @kbd{d n} a negative argument, it uses default-minus-that,
  285. so @kbd{M-- d n} would be an easier way to get the same effect.)  Those
  286. inexact results would still be lurking there, but they would now be
  287. rounded to nice, natural-looking values for display purposes.  (Remember,
  288. @samp{0.022222} in base 3 is like @samp{0.099999} in base 10; rounding
  289. off one digit will round the number up to @samp{0.1}.)  Depending on the
  290. nature of your work, this hiding of the inexactness may be a benefit or
  291. a danger.  With the @kbd{d n} command, Calc gives you the choice.
  292. X
  293. Incidentally, another consequence of all this is that if you type
  294. @kbd{M-30 d n} to display more digits than are ``really there,''
  295. you'll see garbage digits at the end of the number.  (In decimal
  296. display mode, with decimally-stored numbers, these garbage digits are
  297. always zero so they vanish and you don't notice them.)  Because Calc
  298. rounds off that 0.15 digit, there is the danger that two numbers could
  299. be slightly different internally but still look the same.  If you feel
  300. uneasy about this, set the @kbd{d n} precision to be a little higher
  301. than normal; you'll get ugly garbage digits, but you'll always be able
  302. to tell two distinct numbers apart.
  303. X
  304. An interesting side note is that most computers store their
  305. floating-point numbers in binary, and convert to decimal for display.
  306. Thus everyday programs have the same problem:  Decimal 0.1 cannot be
  307. represented exactly in binary (try it: @kbd{0.1 d 2}), so @samp{0.1 * 10}
  308. comes out as an inexact approximation to 1 on some machines (though
  309. they generally arrange to hide it from you by rounding off one digit as
  310. we did above).  Because Calc works in decimal instead of binary, you can
  311. be sure that numbers that look exact @emph{are} exact as long as you stay
  312. in decimal display mode.
  313. X
  314. It's not hard to show that any number that can be represented exactly
  315. in binary, octal, or hexadecimal is also exact in decimal, so the kinds
  316. of problems we saw in this exercise are likely to be severe only when
  317. you use a relatively unusual radix like 3.
  318. X
  319. @node Modes Answer 2, Modes Answer 3, Modes Answer 1, Answers to Exercises
  320. @subsection Modes Tutorial Exercise 2
  321. X
  322. If the radix is 15 or higher, we can't use the letter @samp{e} to mark
  323. the exponent because @samp{e} is interpreted as a digit.  When Calc
  324. needs to display scientific notation in a high radix, it writes
  325. @samp{16#F.E8F*16.^15}.  You can enter a number like this as an
  326. algebraic entry.  Also, pressing @kbd{e} without any digits before it
  327. normally types @kbd{1e}, but in a high radix it types @kbd{16.^} and
  328. puts you in algebraic entry:  @kbd{16#f.e8f RET e 15 RET *} is another
  329. way to enter this number.
  330. X
  331. The reason Calc puts a decimal point in the @samp{16.^} is to prevent
  332. huge integers from being generated if the exponent is large (consider
  333. @samp{16#1.23*16^1000}, where we compute @samp{16^1000} as a giant
  334. exact integer and then throw away most of the digits when we multiply
  335. it by the floating-point @samp{16#1.23}).  While this wouldn't normally
  336. matter for display purposes, it could give you a nasty surprise if you
  337. copied that number into a file and later yanked it back into Calc.
  338. X
  339. @node Modes Answer 3, Modes Answer 4, Modes Answer 2, Answers to Exercises
  340. @subsection Modes Tutorial Exercise 3
  341. X
  342. @noindent
  343. The answer he got was @cite{0.5000000000006399}.
  344. X
  345. The problem is not that the square operation is inexact, but that the
  346. sine of 45 that was already on the stack was accurate to only 12 places.
  347. Arbitrary-precision calculations still only give answers as good as
  348. their inputs.
  349. X
  350. The real problem is that there is no 12-digit number which, when
  351. squared, comes out to 0.5 exactly.  The @kbd{f [} and @kbd{f ]}
  352. commands decrease or increase a number by one unit in the last
  353. place (according to the current precision).  They are useful for
  354. determining facts like this.
  355. X
  356. @group
  357. @smallexample
  358. 1:  0.707106781187      1:  0.500000000001
  359. X    .                       .
  360. X
  361. X    45 S                    2 ^
  362. X
  363. @end smallexample
  364. @end group
  365. @noindent
  366. @group
  367. @smallexample
  368. 1:  0.707106781187      1:  0.707106781186      1:  0.499999999999
  369. X    .                       .                       .
  370. X
  371. X    U  DEL                  f [                     2 ^
  372. @end smallexample
  373. @end group
  374. X
  375. A high-precision calculation must be carried out in high precision
  376. all the way.  The only number in the original problem which was known
  377. exactly was the quantity 45 degrees, so the precision must be raised
  378. before anything is done after the number 45 has been entered in order
  379. for the higher precision to be meaningful.
  380. X
  381. @node Modes Answer 4, Arithmetic Answer 1, Modes Answer 3, Answers to Exercises
  382. @subsection Modes Tutorial Exercise 4
  383. X
  384. @noindent
  385. Many calculations involve real-world quantities, like the width and
  386. height of a piece of wood or the volume of a jar.  Such quantities
  387. can't be measured exactly anyway, and if the data that is input to
  388. a calculation is inexact, doing exact arithmetic on it is a waste
  389. of time.
  390. X
  391. Fractions become unwieldy after too many calculations have been
  392. done with them.  For example, the sum of the reciprocals of the
  393. integers from 1 to 10 is 7381:2520.  The sum from 1 to 30 is
  394. 9304682830147:2329089562800.  After a point it will take a long
  395. time to add even one more term to this sum, but a floating-point
  396. calculation of the sum will not have this problem.
  397. X
  398. Also, rational numbers cannot express the results of all calculations.
  399. There is no fractional form for the square root of two, so if you type
  400. @w{@kbd{2 Q}}, Calc has no choice but to give you a floating-point answer.
  401. X
  402. @node Arithmetic Answer 1, Arithmetic Answer 2, Modes Answer 4, Answers to Exercises
  403. @subsection Arithmetic Tutorial Exercise 1
  404. X
  405. @noindent
  406. Dividing two integers that are larger than the current precision may
  407. give a floating-point result that is inaccurate even when rounded
  408. down to an integer.  Consider @cite{123456789 / 2} when the current
  409. precision is 6 digits.  The true answer is @cite{61728394.5}, but
  410. with a precision of 6 this will be rounded to @c{$12345700.0/2.0 = 61728500.0$}
  411. @cite{12345700.@: / 2.@: = 61728500.}.
  412. The result, when converted to an integer, will be off by 106.
  413. X
  414. Here are two solutions:  Raise the precision enough that the
  415. floating-point round-off error is strictly to the right of the
  416. decimal point.  Or, convert to fraction mode so that @cite{123456789 / 2}
  417. produces the exact fraction @cite{123456789:2}, which can be rounded
  418. down by the @kbd{F} command without ever switching to floating-point
  419. format.
  420. X
  421. @node Arithmetic Answer 2, Vector Answer 1, Arithmetic Answer 1, Answers to Exercises
  422. @subsection Arithmetic Tutorial Exercise 2
  423. X
  424. @noindent
  425. @kbd{27 @key{RET} 9 B} could give the exact result @cite{3:2}, but it
  426. does a floating-point calculation instead and produces @cite{1.5}.
  427. X
  428. Calc will find an exact result for a logarithm if the result is an integer
  429. or the reciprocal of an integer.  But there is no efficient way to search
  430. the space of all possible rational numbers for an exact answer, so Calc
  431. doesn't try.
  432. X
  433. @node Vector Answer 1, Vector Answer 2, Arithmetic Answer 2, Answers to Exercises
  434. @subsection Vector Tutorial Exercise 1
  435. X
  436. @noindent
  437. Duplicate the vector, compute its length, then divide the vector
  438. by its length:  @kbd{@key{RET} A /}.
  439. X
  440. @group
  441. @smallexample
  442. 1:  [1, 2, 3]  2:  [1, 2, 3]      1:  [0.27, 0.53, 0.80]  1:  1.
  443. X    .          1:  3.74165738677      .                       .
  444. X                   .
  445. X
  446. X    r 1            RET A              /                       A
  447. @end smallexample
  448. @end group
  449. X
  450. The final @kbd{A} command shows that the normalized vector does
  451. indeed have unit length.
  452. X
  453. @node Vector Answer 2, Matrix Answer 1, Vector Answer 1, Answers to Exercises
  454. @subsection Vector Tutorial Exercise 2
  455. X
  456. @noindent
  457. The average position is equal to the sum of the products of the
  458. positions times their corresponding probabilities.  This is the
  459. definition of the dot product operation.  So all you need to do
  460. is to put the two vectors on the stack and press @kbd{*}.
  461. X
  462. @node Matrix Answer 1, Matrix Answer 2, Vector Answer 2, Answers to Exercises
  463. @subsection Matrix Tutorial Exercise 1
  464. X
  465. @noindent
  466. The trick is to multiply by a vector of ones.  Use @kbd{r 4 [1 1 1] *} to
  467. get the row sum.  Similarly, use @kbd{[1 1] r 4 *} to get the column sum.
  468. X
  469. @node Matrix Answer 2, Matrix Answer 3, Matrix Answer 1, Answers to Exercises
  470. @subsection Matrix Tutorial Exercise 2
  471. X
  472. @ifinfo
  473. @group
  474. @example
  475. X   x + a y = 6
  476. X   x + b y = 10
  477. @end example
  478. @end group
  479. @end ifinfo
  480. @tex
  481. \turnoffactive
  482. $$ \eqalign{ x &+ a y = 6 \cr
  483. X             x &+ b y = 10}
  484. $$
  485. @end tex
  486. X
  487. Just enter the righthand side vector, then divide by the lefthand side
  488. matrix as usual.
  489. X
  490. @group
  491. @smallexample
  492. 1:  [6, 10]    2:  [6, 10]         1:  [6 - 4 a / (b - a), 4 / (b - a) ]
  493. X    .          1:  [ [ 1, a ]          .
  494. X                     [ 1, b ] ]
  495. X                   .
  496. X
  497. ' [6 10] RET     ' [1 a; 1 b] RET      /
  498. @end smallexample
  499. @end group
  500. X
  501. This can be made more readable using @kbd{d B} to enable ``big'' display
  502. mode:
  503. X
  504. @group
  505. @smallexample
  506. X          4 a     4
  507. 1:  [6 - -----, -----]
  508. X         b - a  b - a
  509. @end smallexample
  510. @end group
  511. X
  512. Type @kbd{d N} to return to ``normal'' display mode afterwards.
  513. X
  514. @node Matrix Answer 3, List Answer 1, Matrix Answer 2, Answers to Exercises
  515. @subsection Matrix Tutorial Exercise 3
  516. X
  517. @noindent
  518. To solve @c{$A^T A \, X = A^T B$}
  519. @cite{trn(A) * A * X = trn(A) * B}, first we compute
  520. @c{$A' = A^T A$}
  521. @cite{A2 = trn(A) * A} and @c{$B' = A^T B$}
  522. @cite{B2 = trn(A) * B}; now, we have a
  523. system @c{$A' X = B'$}
  524. @cite{A2 * X = B2} which we can solve using Calc's @samp{/}
  525. command.
  526. X
  527. @ifinfo
  528. @group
  529. @example
  530. X    a + 2b + 3c = 6
  531. X   4a + 5b + 6c = 2
  532. X   7a + 6b      = 3
  533. X   2a + 4b + 6c = 11
  534. @end example
  535. @end group
  536. @end ifinfo
  537. @tex
  538. \turnoffactive
  539. $$ \openup1\jot \tabskip=0pt plus1fil
  540. \halign to\displaywidth{\tabskip=0pt
  541. X   $\hfil#$&$\hfil{}#{}$&
  542. X   $\hfil#$&$\hfil{}#{}$&
  543. X   $\hfil#$&${}#\hfil$\tabskip=0pt plus1fil\cr
  544. X  a&+&2b&+&3c&=6 \cr
  545. X 4a&+&5b&+&6c&=2 \cr
  546. X 7a&+&6b& &  &=3 \cr
  547. X 2a&+&4b&+&6c&=11 \cr}
  548. $$
  549. @end tex
  550. X
  551. The first step is to enter the coefficient matrix.  We'll store it in
  552. quick variable number 7 for later reference.  Next, we compute the
  553. @c{$B'$}
  554. @cite{B2} vector.
  555. X
  556. @group
  557. @smallexample
  558. 1:  [ [ 1, 2, 3 ]             2:  [ [ 1, 4, 7, 2 ]     1:  [57, 84, 96]
  559. X      [ 4, 5, 6 ]                   [ 2, 5, 6, 4 ]         .
  560. X      [ 7, 6, 0 ]                   [ 3, 6, 0, 6 ] ]
  561. X      [ 2, 4, 6 ] ]           1:  [6, 2, 3, 11]
  562. X    .                             .
  563. X
  564. ' [1 2 3; 4 5 6; 7 6 0; 2 4 6] RET  s 7  v t  [6 2 3 11]   *
  565. @end smallexample
  566. @end group
  567. X
  568. @noindent
  569. Now we compute the matrix @c{$A'$}
  570. @cite{A2} and divide.
  571. X
  572. @group
  573. @smallexample
  574. 2:  [57, 84, 96]          1:  [-11.64, 14.08, -3.64]
  575. 1:  [ [ 70, 72, 39 ]          .
  576. X      [ 72, 81, 60 ]
  577. X      [ 39, 60, 81 ] ]
  578. X    .
  579. X
  580. X    r 7 v t r 7 *             /
  581. @end smallexample
  582. @end group
  583. X
  584. @noindent
  585. (The actual computed answer will be slightly inexact due to
  586. round-off error.)
  587. X
  588. Notice that the answers are similar to those for the @c{$3\times3$}
  589. @asis{3x3} system
  590. solved in the text.  That's because the fourth equation that was
  591. added to the system is almost identical to the first one multiplied
  592. by two.  (If it were identical, we would have gotten the exact same
  593. answer since the @c{$4\times3$}
  594. @asis{4x3} system would be equivalent to the original @c{$3\times3$}
  595. @asis{3x3}
  596. system.)
  597. X
  598. Since the first and fourth equations aren't quite equivalent, they
  599. can't both be satisfied at once.  Let's plug our answers back into
  600. the original system of equations to see how well they match.
  601. X
  602. @group
  603. @smallexample
  604. 2:  [-11.64, 14.08, -3.64]     1:  [5.6, 2., 3., 11.2]
  605. 1:  [ [ 1, 2, 3 ]                  .
  606. X      [ 4, 5, 6 ]
  607. X      [ 7, 6, 0 ]
  608. X      [ 2, 4, 6 ] ]
  609. X    .
  610. X
  611. X    r 7                            TAB *
  612. @end smallexample
  613. @end group
  614. X
  615. @noindent
  616. This is reasonably close to our original @cite{B} vector,
  617. @cite{[6, 2, 3, 11]}.
  618. X
  619. @node List Answer 1, List Answer 2, Matrix Answer 3, Answers to Exercises
  620. @subsection List Tutorial Exercise 1
  621. X
  622. @noindent
  623. We can use @kbd{v x} to build a vector of integers.  This needs to be
  624. adjusted to get the range of integers we desire.  Mapping @samp{-}
  625. across the vector will accomplish this, although it turns out the
  626. plain @samp{-} key will work just as well.
  627. X
  628. @group
  629. @smallexample
  630. 2:  2                              2:  2
  631. 1:  [1, 2, 3, 4, 5, 6, 7, 8, 9]    1:  [-4, -3, -2, -1, 0, 1, 2, 3, 4]
  632. X    .                                  .
  633. X
  634. X    2  v x 9 RET                       5 V M -   or   5 -
  635. @end smallexample
  636. @end group
  637. X
  638. @noindent
  639. Now we use @kbd{V M ^} to map the exponentiation operator across the
  640. vector.
  641. X
  642. @group
  643. @smallexample
  644. 1:  [0.0625, 0.125, 0.25, 0.5, 1, 2, 4, 8, 16]
  645. X    .
  646. X
  647. X    V M ^
  648. @end smallexample
  649. @end group
  650. X
  651. @node List Answer 2, List Answer 3, List Answer 1, Answers to Exercises
  652. @subsection List Tutorial Exercise 2
  653. X
  654. @noindent
  655. Given @cite{x} and @cite{y} vectors in quick variables 1 and 2 as before,
  656. the first job is to form the matrix that describes the problem.
  657. X
  658. @ifinfo
  659. @example
  660. X   m*x + b*1 = y
  661. @end example
  662. @end ifinfo
  663. @tex
  664. \turnoffactive
  665. $$ m \times x + b \times 1 = y $$
  666. @end tex
  667. X
  668. Thus we want a @c{$19\times2$}
  669. @asis{19x2} matrix with our @cite{x} vector as one column and
  670. ones as the other column.  So, first we build the column of ones, then
  671. we combine the two columns to form our @cite{A} matrix.
  672. X
  673. @group
  674. @smallexample
  675. 2:  [1.34, 1.41, 1.49, ... ]    1:  [ [ 1.34, 1 ]
  676. 1:  [1, 1, 1, ...]                    [ 1.41, 1 ]
  677. X    .                                 [ 1.49, 1 ]
  678. X                                      @dots{}
  679. X
  680. X    r 1 1 v b 19 RET                M-2 v p v t   s 3
  681. @end smallexample
  682. @end group
  683. X
  684. @noindent
  685. Now we compute @c{$A^T y$}
  686. @cite{trn(A) * y} and @c{$A^T A$}
  687. @cite{trn(A) * A} and divide.
  688. X
  689. @group
  690. @smallexample
  691. 1:  [33.36554, 13.613]    2:  [33.36554, 13.613]
  692. X    .                     1:  [ [ 98.0003, 41.63 ]
  693. X                                [  41.63,   19   ] ]
  694. X                              .
  695. X
  696. X v t r 2 *                    r 3 v t r 3 *
  697. @end smallexample
  698. @end group
  699. X
  700. @noindent
  701. (Hey, those numbers look familiar!)
  702. X
  703. @group
  704. @smallexample
  705. 1:  [0.52141679, -0.425978]
  706. X    .
  707. X
  708. X    /
  709. @end smallexample
  710. @end group
  711. X
  712. Since we were solving equations of the form @c{$m \times x + b \times 1 = y$}
  713. @cite{m*x + b*1 = y}, these
  714. numbers should be @cite{m} and @cite{b}, respectively.  Sure enough, they
  715. agree exactly with the result computed using @kbd{V M} and @kbd{V R}!
  716. X
  717. The moral of this story:  @kbd{V M} and @kbd{V R} will probably solve
  718. your problem, but there is often an easier way using the higher-level
  719. arithmetic functions!
  720. X
  721. @c [fix-ref Curve Fitting]
  722. In fact, there is a built-in @kbd{a F} command that does least-squares
  723. fits.  @xref{Curve Fitting}.
  724. X
  725. @node List Answer 3, List Answer 4, List Answer 2, Answers to Exercises
  726. @subsection List Tutorial Exercise 3
  727. X
  728. @noindent
  729. Move to one end of the list and press @kbd{C-@@} (or @kbd{C-SPC} or
  730. whatever) to set the mark, then move to the other end of the list
  731. and type @w{@kbd{M-# g}}.
  732. X
  733. @group
  734. @smallexample
  735. 1:  [2.3, 6, 22, 15.1, 7, 15, 14, 7.5, 2.5]
  736. X    .
  737. @end smallexample
  738. @end group
  739. X
  740. To make things interesting, let's assume we don't know at a glance
  741. how many numbers are in this list.  Then we could type:
  742. X
  743. @group
  744. @smallexample
  745. 2:  [2.3, 6, 22, ... ]     2:  [2.3, 6, 22, ... ]
  746. 1:  [2.3, 6, 22, ... ]     1:  126356422.5
  747. X    .                          .
  748. X
  749. X    RET                        V R *
  750. X
  751. @end smallexample
  752. @end group
  753. @noindent
  754. @group
  755. @smallexample
  756. 2:  126356422.5            2:  126356422.5     1:  7.94652913734
  757. 1:  [2.3, 6, 22, ... ]     1:  9                   .
  758. X    .                          .
  759. X
  760. X    TAB                        v l                 I ^
  761. @end smallexample
  762. @end group
  763. X
  764. @noindent
  765. (The @kbd{I ^} command computes the @var{n}th root of a number.
  766. You could also type @kbd{& ^} to take the reciprocal of 9 and
  767. then raise the number to that power.)
  768. X
  769. @node List Answer 4, List Answer 5, List Answer 3, Answers to Exercises
  770. @subsection List Tutorial Exercise 4
  771. X
  772. @noindent
  773. A number @cite{j} is a divisor of @cite{n} if @c{$n \mathbin{\hbox{\code{\%}}} j = 0$}
  774. @samp{n % j = 0}.  The first
  775. step is to get a vector that identifies the divisors.
  776. X
  777. @group
  778. @smallexample
  779. 2:  30                  2:  [0, 0, 0, 2, ...]    1:  [1, 1, 1, 0, ...]
  780. 1:  [1, 2, 3, 4, ...]   1:  0                        .
  781. X    .                       .
  782. X
  783. X 30 RET v x 30 RET   s 1    V M %  0                 V M a =  s 2
  784. @end smallexample
  785. @end group
  786. X
  787. @noindent
  788. This vector has 1's marking divisors of 30 and 0's marking non-divisors.
  789. X
  790. The zeroth divisor function is just the total number of divisors.
  791. The first divisor function is the sum of the divisors.
  792. X
  793. @group
  794. @smallexample
  795. 1:  8      3:  8                    2:  8                    2:  8
  796. X           2:  [1, 2, 3, 4, ...]    1:  [1, 2, 3, 0, ...]    1:  72
  797. X           1:  [1, 1, 1, 0, ...]        .                        .
  798. X               .
  799. X
  800. X   V R +       r 1 r 2                  V M *                  V R +
  801. @end smallexample
  802. @end group
  803. X
  804. @noindent
  805. Once again, the last two steps just compute a dot product for which
  806. a simple @kbd{*} would have worked equally well.
  807. X
  808. @node List Answer 5, List Answer 6, List Answer 4, Answers to Exercises
  809. @subsection List Tutorial Exercise 5
  810. X
  811. @noindent
  812. The obvious first step is to obtain the list of factors with @kbd{k f}.
  813. This list will always be in sorted order, so if there are duplicates
  814. they will be right next to each other.  A suitable method is to compare
  815. the list with a copy of itself shifted over by one.
  816. X
  817. @group
  818. @smallexample
  819. 1:  [3, 7, 7, 7, 19]   2:  [3, 7, 7, 7, 19]     2:  [3, 7, 7, 7, 19, 0]
  820. X    .                  1:  [3, 7, 7, 7, 19, 0]  1:  [0, 3, 7, 7, 7, 19]
  821. X                           .                        .
  822. X
  823. X    19551 k f              RET 0 |                  TAB 0 TAB |
  824. X
  825. @end smallexample
  826. @end group
  827. @noindent
  828. @group
  829. @smallexample
  830. 1:  [0, 0, 1, 1, 0, 0]   1:  2          1:  0
  831. X    .                        .              .
  832. X
  833. X    V M a =                  V R +          0 a =
  834. @end smallexample
  835. @end group
  836. X
  837. @noindent
  838. Note that we have to arrange for both vectors to have the same length
  839. so that the mapping operation works; no prime factor will ever be
  840. zero, so adding zeros on the left and right is safe.  From then on
  841. the job is pretty straightforward.
  842. X
  843. Incidentally, Calc provides the @c{\dfn{M\"obius} $\mu$}
  844. @dfn{Moebius mu} function which is
  845. zero if and only if its argument is square-free.  It would be a much
  846. more convenient way to do the above test in practice.
  847. X
  848. @node List Answer 6, List Answer 7, List Answer 5, Answers to Exercises
  849. @subsection List Tutorial Exercise 6
  850. X
  851. @noindent
  852. First use @kbd{v x 6 RET} to get a list of integers, then @kbd{V M v x}
  853. to get a list of lists of integers!
  854. X
  855. @node List Answer 7, List Answer 8, List Answer 6, Answers to Exercises
  856. @subsection List Tutorial Exercise 7
  857. X
  858. @noindent
  859. Here's one solution.  First, compute the triangular list from the previous
  860. exercise and type @kbd{1 -} to subtract one from all the elements.
  861. X
  862. @group
  863. @smallexample
  864. 1:  [ [0],
  865. X      [0, 1],
  866. X      [0, 1, 2],
  867. X      @dots{}
  868. X
  869. X    1 -
  870. @end smallexample
  871. @end group
  872. X
  873. The numbers down the lefthand edge of the list we desire are called
  874. the ``triangular numbers'' (now you know why!).  The @cite{n}th
  875. triangular number is the sum of the integers from 1 to @cite{n}, and
  876. can be computed directly by the formula @c{$n (n+1) \over 2$}
  877. @cite{n * (n+1) / 2}.
  878. X
  879. @group
  880. @smallexample
  881. 2:  [ [0], [0, 1], ... ]    2:  [ [0], [0, 1], ... ]
  882. 1:  [0, 1, 2, 3, 4, 5]      1:  [0, 1, 3, 6, 10, 15]
  883. X    .                           .
  884. X
  885. X    v x 6 RET 1 -               V M ' $ ($+1)/2 RET
  886. @end smallexample
  887. @end group
  888. X
  889. @noindent
  890. Adding this list to the above list of lists produces the desired
  891. result:
  892. X
  893. @group
  894. @smallexample
  895. 1:  [ [0],
  896. X      [1, 2],
  897. X      [3, 4, 5],
  898. X      [6, 7, 8, 9],
  899. X      [10, 11, 12, 13, 14],
  900. X      [15, 16, 17, 18, 19, 20] ]
  901. X      .
  902. X
  903. X      V M +
  904. @end smallexample
  905. @end group
  906. X
  907. If we did not know the formula for triangular numbers, we could have
  908. computed them using a @kbd{V U +} command.  We could also have
  909. gotten them the hard way by mapping a reduction across the original
  910. triangular list.
  911. X
  912. @group
  913. @smallexample
  914. 2:  [ [0], [0, 1], ... ]    2:  [ [0], [0, 1], ... ]
  915. 1:  [ [0], [0, 1], ... ]    1:  [0, 1, 3, 6, 10, 15]
  916. X    .                           .
  917. X
  918. X    RET                         V M V R +
  919. @end smallexample
  920. @end group
  921. X
  922. @noindent
  923. (This means ``map a @kbd{V R +} command across the vector,'' and
  924. since each element of the main vector is itself a small vector,
  925. @kbd{V R +} computes the sum of its elements.)
  926. X
  927. @node List Answer 8, List Answer 9, List Answer 7, Answers to Exercises
  928. @subsection List Tutorial Exercise 8
  929. X
  930. @noindent
  931. The first step is to build a list of values of @cite{x}.
  932. X
  933. @group
  934. @smallexample
  935. 1:  [1, 2, 3, ..., 21]  1:  [0, 1, 2, ..., 20]  1:  [0, 0.25, 0.5, ..., 5]
  936. X    .                       .                       .
  937. X
  938. X    v x 21 RET              1 -                     4 /  s 1
  939. @end smallexample
  940. @end group
  941. X
  942. Next, we compute the Bessel function values.
  943. X
  944. @group
  945. @smallexample
  946. 1:  [0., 0.124, 0.242, ..., -0.328]
  947. X    .
  948. X
  949. X    V M ' besJ(1,$) RET
  950. @end smallexample
  951. @end group
  952. X
  953. @noindent
  954. (Another way to do this would be @kbd{1 TAB V M f j}.)
  955. X
  956. A way to isolate the maximum value is to compute the maximum using
  957. @kbd{V R X}, then compare all the Bessel values with that maximum.
  958. X
  959. @group
  960. @smallexample
  961. 2:  [0., 0.124, 0.242, ... ]   1:  [0, 0, 0, ... ]    2:  [0, 0, 0, ... ]
  962. 1:  0.5801562                      .                  1:  1
  963. X    .                                                     .
  964. X
  965. X    RET V R X                      V M a =                RET V R +    DEL
  966. @end smallexample
  967. @end group
  968. X
  969. @noindent
  970. It's a good idea to verify, as in the last step above, that only
  971. one value is equal to the maximum.  (After all, a plot of @c{$\sin x$}
  972. @cite{sin(x)}
  973. might have many points all equal to the maximum value, 1.)
  974. X
  975. The vector we have now has a single 1 in the position that indicates
  976. the maximum value of @cite{x}.  Now it is a simple matter to convert
  977. this back into the corresponding value itself.
  978. X
  979. @group
  980. @smallexample
  981. 2:  [0, 0, 0, ... ]         1:  [0, 0., 0., ... ]    1:  1.75
  982. 1:  [0, 0.25, 0.5, ... ]        .                        .
  983. X    .
  984. X
  985. X    r 1                         V M *                    V R +
  986. @end smallexample
  987. @end group
  988. X
  989. If @kbd{a =} had produced more than one @cite{1} value, this method
  990. would have given the sum of all maximum @cite{x} values; not very
  991. useful!  In this case we could have used @kbd{v m} (@code{calc-mask-vector})
  992. instead.  This command deletes all elements of a ``data'' vector that
  993. correspond to zeros in a ``mask'' vector, leaving us with, in this
  994. example, a vector of maximum @cite{x} values.
  995. X
  996. The built-in @kbd{a X} command maximizes a function using more
  997. efficient methods.  Just for illustration, let's use @kbd{a X}
  998. to maximize @samp{besJ(1,x)} over this same interval.
  999. X
  1000. @group
  1001. @smallexample
  1002. 2:  besJ(1, x)                 1:  [1.84115, 0.581865]
  1003. 1:  [0 .. 5]                       .
  1004. X    .
  1005. X
  1006. ' besJ(1,x), [0..5] RET            a X x RET
  1007. @end smallexample
  1008. @end group
  1009. X
  1010. @noindent
  1011. The output from @kbd{a X} is a vector containing the value of @cite{x}
  1012. that maximizes the function, and the function's value at that maximum.
  1013. As you can see, our simple search got quite close to the right answer.
  1014. X
  1015. @node List Answer 9, List Answer 10, List Answer 8, Answers to Exercises
  1016. @subsection List Tutorial Exercise 9
  1017. X
  1018. @noindent
  1019. Step one is to convert our integer into vector notation.
  1020. X
  1021. @group
  1022. @smallexample
  1023. 1:  25129925999           3:  25129925999
  1024. X    .                     2:  10
  1025. X                          1:  [11, 10, 9, ..., 1, 0]
  1026. X                              .
  1027. X
  1028. X    25129925999 RET           10 RET 12 RET v x 12 RET -
  1029. X
  1030. @end smallexample
  1031. @end group
  1032. @noindent
  1033. @group
  1034. @smallexample
  1035. 1:  25129925999              1:  [0, 2, 25, 251, 2512, ... ]
  1036. 2:  [100000000000, ... ]         .
  1037. X    .
  1038. X
  1039. X    V M ^   s 1                  V M \
  1040. @end smallexample
  1041. @end group
  1042. X
  1043. @noindent
  1044. (Recall, the @kbd{\} command computes an integer quotient.)
  1045. X
  1046. @group
  1047. @smallexample
  1048. 1:  [0, 2, 5, 1, 2, 9, 9, 2, 5, 9, 9, 9]
  1049. X    .
  1050. X
  1051. X    10 V M %   s 2
  1052. @end smallexample
  1053. @end group
  1054. X
  1055. Next we must increment this number.  This involves adding one to
  1056. the last digit, plus handling carries.  There is a carry out of a
  1057. digit to the left if that digit is a nine and all the digits to
  1058. the right of it are nines.
  1059. X
  1060. @group
  1061. @smallexample
  1062. 1:  [0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1]   1:  [1, 1, 1, 0, 0, 1, ... ]
  1063. X    .                                          .
  1064. X
  1065. X    9 V M a =                                  v v
  1066. X
  1067. @end smallexample
  1068. @end group
  1069. @noindent
  1070. @group
  1071. @smallexample
  1072. 1:  [1, 1, 1, 0, 0, 0, ... ]   1:  [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1]
  1073. X    .                              .
  1074. X
  1075. X    V U *                          v v 1 |
  1076. @end smallexample
  1077. @end group
  1078. X
  1079. @noindent
  1080. Accumulating @kbd{*} across a vector of ones and zeros will preserve
  1081. only the initial run of ones.  These are the carries into all digits
  1082. except the rightmost digit.  Concatenating a one on the right takes
  1083. care of aligning the carries properly, and also adding one to the
  1084. rightmost digit.
  1085. X
  1086. @group
  1087. @smallexample
  1088. 2:  [0, 0, 0, 0, ... ]     1:  [0, 0, 2, 5, 1, 2, 9, 9, 2, 6, 0, 0, 0]
  1089. 1:  [0, 0, 2, 5, ... ]         .
  1090. X    .
  1091. X
  1092. X    0 r 2 |                    V M +  10 V M %
  1093. @end smallexample
  1094. @end group
  1095. X
  1096. @noindent
  1097. Here we have concatenated 0 to the @emph{left} of the original number;
  1098. this takes care of shifting the carries by one with respect to the
  1099. digits that generated them.
  1100. X
  1101. Finally, we must convert this list back into an integer.
  1102. X
  1103. @group
  1104. @smallexample
  1105. 3:  [0, 0, 2, 5, ... ]        2:  [0, 0, 2, 5, ... ]
  1106. 2:  1000000000000             1:  [1000000000000, 100000000000, ... ]
  1107. 1:  [100000000000, ... ]          .
  1108. X    .
  1109. X
  1110. X    10 RET 12 ^  r 1              |
  1111. X
  1112. @end smallexample
  1113. @end group
  1114. @noindent
  1115. @group
  1116. @smallexample
  1117. 1:  [0, 0, 20000000000, 5000000000, ... ]    1:  25129926000
  1118. X    .                                            .
  1119. X
  1120. X    V M *                                        V R +
  1121. @end smallexample
  1122. @end group
  1123. X
  1124. @noindent
  1125. Another way to do this final step would be to reduce the formula
  1126. @w{@cite{10 $$ + $}} across the vector of digits.
  1127. X
  1128. @group
  1129. @smallexample
  1130. 1:  [0, 0, 2, 5, ... ]        1:  25129926000
  1131. X    .                             .
  1132. X
  1133. X                                  V R ' 10 $$ + $ RET
  1134. @end smallexample
  1135. @end group
  1136. X
  1137. @node List Answer 10, List Answer 11, List Answer 9, Answers to Exercises
  1138. @subsection List Tutorial Exercise 10
  1139. X
  1140. @noindent
  1141. For the list @cite{[a, b, c, d]}, the result is @cite{((a = b) = c) = d},
  1142. which will compare @cite{a} and @cite{b} to produce a 1 or 0, which is
  1143. then compared with @cite{c} to produce another 1 or 0, which is then
  1144. compared with @cite{d}.  This is not at all what Joe wanted.
  1145. X
  1146. Here's a more correct method:
  1147. X
  1148. @group
  1149. @smallexample
  1150. 1:  [7, 7, 7, 8, 7]      2:  [7, 7, 7, 8, 7]
  1151. X    .                    1:  7
  1152. X                             .
  1153. X
  1154. X  ' [7,7,7,8,7] RET          RET v r 1 RET
  1155. X
  1156. @end smallexample
  1157. @end group
  1158. @noindent
  1159. @group
  1160. @smallexample
  1161. 1:  [1, 1, 1, 0, 1]      1:  0
  1162. X    .                        .
  1163. X
  1164. X    V M a =                  V R *
  1165. @end smallexample
  1166. @end group
  1167. X
  1168. @node List Answer 11, List Answer 12, List Answer 10, Answers to Exercises
  1169. @subsection List Tutorial Exercise 11
  1170. X
  1171. @noindent
  1172. The circle of unit radius consists of those points @cite{(x,y)} for which
  1173. @cite{x^2 + y^2 < 1}.  We start by generating a vector of @cite{x^2}
  1174. and a vector of @cite{y^2}.
  1175. X
  1176. We can make this go a bit faster by using the @kbd{v .} and @kbd{t .}
  1177. commands.
  1178. X
  1179. @group
  1180. @smallexample
  1181. 2:  [2., 2., ..., 2.]          2:  [2., 2., ..., 2.]
  1182. 1:  [2., 2., ..., 2.]          1:  [1.16, 1.98, ..., 0.81]
  1183. X    .                              .
  1184. X
  1185. X v . t .  2. v b 100 RET RET       V M k r
  1186. X
  1187. @end smallexample
  1188. @end group
  1189. @noindent
  1190. @group
  1191. @smallexample
  1192. 2:  [2., 2., ..., 2.]          1:  [0.026, 0.96, ..., 0.036]
  1193. 1:  [0.026, 0.96, ..., 0.036]  2:  [0.53, 0.81, ..., 0.094]
  1194. X    .                              .
  1195. X
  1196. X    1 -  2 V M ^                   TAB  V M k r  1 -  2 V M ^
  1197. @end smallexample
  1198. @end group
  1199. X
  1200. Now we sum the @cite{x^2} and @cite{y^2} values, compare with 1 to
  1201. get a vector of 1/0 truth values, then sum the truth values.
  1202. X
  1203. @group
  1204. @smallexample
  1205. 1:  [0.56, 1.78, ..., 0.13]    1:  [1, 0, ..., 1]    1:  84
  1206. X    .                              .                     .
  1207. X
  1208. X    +                              1 V M a <             V R +
  1209. @end smallexample
  1210. @end group
  1211. X
  1212. @noindent
  1213. The ratio @cite{84/100} should approximate the ratio @c{$\pi/4$}
  1214. @cite{pi/4}.
  1215. X
  1216. @group
  1217. @smallexample
  1218. 1:  0.84       1:  3.36       2:  3.36       1:  1.0695
  1219. X    .              .          1:  3.14159        .
  1220. X
  1221. X    100 /          4 *            P              /
  1222. @end smallexample
  1223. @end group
  1224. X
  1225. @noindent
  1226. Our estimate, 3.36, is off by about 7%.  We could get a better estimate
  1227. by taking more points (say, 1000), but it's clear that this method is
  1228. not very efficient!
  1229. X
  1230. (Naturally, since this example uses random numbers your own answer
  1231. will be slightly different than the one shown here!)
  1232. X
  1233. If you typed @kbd{v .} and @kbd{t .} before, type them again to
  1234. return to full-sized display of vectors.
  1235. X
  1236. @node List Answer 12, List Answer 13, List Answer 11, Answers to Exercises
  1237. @subsection List Tutorial Exercise 12
  1238. X
  1239. @noindent
  1240. This problem can be made a lot easier by taking advantage of some
  1241. symmetries.  First of all, after some thought it's clear that the
  1242. @cite{y} axis can be ignored altogether.  Just pick a random @cite{x}
  1243. component for one end of the match, pick a random direction @c{$\theta$}
  1244. @cite{theta},
  1245. and see if @cite{x} and @c{$x + \cos \theta$}
  1246. @cite{x + cos(theta)} (which is the @cite{x}
  1247. coordinate of the other endpoint) cross a line.  The lines are at
  1248. integer coordinates, so this happens when the two numbers surround
  1249. an integer.
  1250. X
  1251. Since the two endpoints are equivalent, we may as well choose the leftmost
  1252. of the two endpoints as @cite{x}.  Then @cite{theta} is an angle pointing
  1253. to the right, in the range -90 to 90 degrees.  (We could use radians, but
  1254. it would feel like cheating to refer to @c{$\pi/2$}
  1255. @cite{pi/2} radians while trying
  1256. to estimate @c{$\pi$}
  1257. @cite{pi}!)
  1258. X
  1259. In fact, since the field of lines is infinite we can choose the
  1260. coordinates 0 and 1 for the lines on either side of the leftmost
  1261. endpoint.  The rightmost endpoint will be between 0 and 1 if the
  1262. match does not cross a line, or between 1 and 2 if it does.  So:
  1263. Pick random @cite{x} and @c{$\theta$}
  1264. @cite{theta}, compute @c{$x + \cos \theta$}
  1265. @cite{x + cos(theta)},
  1266. and count how many of the results are greater than one.  Simple!
  1267. X
  1268. We can make this go a bit faster by using the @kbd{v .} and @kbd{t .}
  1269. commands.
  1270. X
  1271. @group
  1272. @smallexample
  1273. 1:  [0.52, 0.71, ..., 0.72]    2:  [0.52, 0.71, ..., 0.72]
  1274. X    .                          1:  [78.4, 64.5, ..., -42.9]
  1275. X                                   .
  1276. X
  1277. v . t . 1. v b 100 RET  V M k r    180. v b 100 RET  V M k r  90 -
  1278. @end smallexample
  1279. @end group
  1280. X
  1281. @noindent
  1282. (The next step may be slow, depending on the speed of your computer.)
  1283. X
  1284. @group
  1285. @smallexample
  1286. 2:  [0.52, 0.71, ..., 0.72]    1:  [0.72, 1.14, ..., 1.45]
  1287. 1:  [0.20, 0.43, ..., 0.73]        .
  1288. X    .
  1289. X
  1290. X    m d  V M C                     +
  1291. X
  1292. @end smallexample
  1293. @end group
  1294. @noindent
  1295. @group
  1296. @smallexample
  1297. 1:  [0, 1, ..., 1]       1:  0.64            1:  3.125
  1298. X    .                        .                   .
  1299. X
  1300. X    1 V M a >                V R + 100 /         2 TAB /
  1301. @end smallexample
  1302. @end group
  1303. X
  1304. Let's try the third method, too.  We'll use random integers up to
  1305. one million.  The @kbd{k r} command with an integer argument picks
  1306. a random integer.
  1307. X
  1308. @group
  1309. @smallexample
  1310. 2:  [1000000, 1000000, ..., 1000000]   2:  [78489, 527587, ..., 814975]
  1311. 1:  [1000000, 1000000, ..., 1000000]   1:  [324014, 358783, ..., 955450]
  1312. X    .                                      .
  1313. X
  1314. X    1000000 v b 100 RET RET                V M k r  TAB  V M k r
  1315. X
  1316. @end smallexample
  1317. @end group
  1318. @noindent
  1319. @group
  1320. @smallexample
  1321. 1:  [1, 1, ..., 25]      1:  [1, 1, ..., 0]     1:  0.56
  1322. X    .                        .                      .
  1323. X
  1324. X    V M k g                  1 V M a =              V R + 100 /
  1325. X
  1326. @end smallexample
  1327. @end group
  1328. @noindent
  1329. @group
  1330. @smallexample
  1331. 1:  10.714        1:  3.273
  1332. X    .                 .
  1333. X
  1334. X    6 TAB /           Q
  1335. @end smallexample
  1336. @end group
  1337. X
  1338. For a proof of this property of the GCD function, see section 4.5.2,
  1339. exercise 10, of Knuth's @emph{Art of Computer Programming}, volume II.
  1340. X
  1341. If you typed @kbd{v .} and @kbd{t .} before, type them again to
  1342. return to full-sized display of vectors.
  1343. X
  1344. @node List Answer 13, List Answer 14, List Answer 12, Answers to Exercises
  1345. @subsection List Tutorial Exercise 13
  1346. X
  1347. @noindent
  1348. First, we put the string on the stack as a vector of ASCII codes.
  1349. X
  1350. @group
  1351. @smallexample
  1352. 1:  [84, 101, 115, ..., 51]
  1353. X    .
  1354. X
  1355. X    "Testing, 1, 2, 3 RET
  1356. @end smallexample
  1357. @end group
  1358. X
  1359. @noindent
  1360. Note that the @kbd{"} key, like @kbd{$}, initiates algebraic entry so
  1361. there was no need to type an apostrophe.  Also, Calc didn't mind that
  1362. we omitted the closing @kbd{"}.  (The same goes for all closing delimiters
  1363. like @kbd{)} and @kbd{]} at the end of a formula.
  1364. X
  1365. We'll show two different approaches here.  In the first, we note that
  1366. if the input vector is @cite{[a, b, c, d]}, then the hash code is
  1367. @cite{3 (3 (3a + b) + c) + d = 27a + 9b + 3c + d}.  In other words,
  1368. it's a sum of descending powers of three times the ASCII codes.
  1369. X
  1370. @group
  1371. @smallexample
  1372. 2:  [84, 101, 115, ..., 51]    2:  [84, 101, 115, ..., 51]
  1373. 1:  16                         1:  [15, 14, 13, ..., 0]
  1374. X    .                              .
  1375. X
  1376. X    RET v l                        v x 16 RET -
  1377. X
  1378. @end smallexample
  1379. @end group
  1380. @noindent
  1381. @group
  1382. @smallexample
  1383. 2:  [84, 101, 115, ..., 51]    1:  1960915098    1:  121
  1384. 1:  [14348907, ..., 1]             .                 .
  1385. X    .
  1386. X
  1387. X    3 TAB V M ^                    *                 511 %
  1388. @end smallexample
  1389. @end group
  1390. X
  1391. @noindent
  1392. Once again, @kbd{*} elegantly summarizes most of the computation.
  1393. But there's an even more elegant approach:  Reduce the formula
  1394. @kbd{3 $$ + $} across the vector.  Recall that this represents a
  1395. function of two arguments that computes its first argument times three
  1396. plus its second argument.
  1397. X
  1398. @group
  1399. @smallexample
  1400. 1:  [84, 101, 115, ..., 51]    1:  1960915098
  1401. X    .                              .
  1402. X
  1403. X    "Testing, 1, 2, 3 RET          V R ' 3$$+$ RET
  1404. @end smallexample
  1405. @end group
  1406. X
  1407. @noindent
  1408. If you did the decimal arithmetic exercise, this will be familiar.
  1409. Basically, we're turning a base-3 vector of digits into an integer,
  1410. except that our ``digits'' are much larger than real digits.
  1411. X
  1412. Instead of typing @kbd{511 %} again to reduce the result, we can be
  1413. cleverer still and notice that rather than computing a huge integer
  1414. and taking the modulo at the end, we can take the modulo at each step
  1415. without affecting the result.  While this means there are more
  1416. arithmetic operations, the numbers we operate on remain small so
  1417. the operations are faster.
  1418. X
  1419. @group
  1420. @smallexample
  1421. 1:  [84, 101, 115, ..., 51]    1:  121
  1422. X    .                              .
  1423. X
  1424. X    "Testing, 1, 2, 3 RET          V R ' (3$$+$)%511 RET
  1425. @end smallexample
  1426. @end group
  1427. X
  1428. Why does this work?  Think about a two-step computation:
  1429. @w{@cite{3 (3a + b) + c}}.  Taking a result modulo 511 basically means
  1430. subtracting off enough 511's to put the result in the desired range.
  1431. So the result when we take the modulo after every step is,
  1432. X
  1433. @ifinfo
  1434. @example
  1435. 3 (3 a + b - 511 m) + c - 511 n
  1436. @end example
  1437. @end ifinfo
  1438. @tex
  1439. \turnoffactive
  1440. $$ 3 (3 a + b - 511 m) + c - 511 n $$
  1441. @end tex
  1442. X
  1443. @noindent
  1444. for some suitable integers @cite{m} and @cite{n}.  Expanding out by
  1445. the distributive law yields
  1446. X
  1447. @ifinfo
  1448. @example
  1449. 9 a + 3 b + c - 511*3 m - 511 n
  1450. @end example
  1451. @end ifinfo
  1452. @tex
  1453. \turnoffactive
  1454. $$ 9 a + 3 b + c - 511\times3 m - 511 n $$
  1455. @end tex
  1456. X
  1457. @noindent
  1458. The @cite{m} term in the latter formula is redundant because any
  1459. contribution it makes could just as easily be made by the @cite{n}
  1460. term.  So we can take it out to get an equivalent formula with
  1461. @cite{n' = 3m + n},
  1462. X
  1463. @ifinfo
  1464. @example
  1465. 9 a + 3 b + c - 511 n'
  1466. @end example
  1467. @end ifinfo
  1468. @tex
  1469. \turnoffactive
  1470. $$ 9 a + 3 b + c - 511 n' $$
  1471. @end tex
  1472. X
  1473. @noindent
  1474. which is just the formula for taking the modulo only at the end of
  1475. the calculation.  Therefore the two methods are essentially the same.
  1476. X
  1477. Later in the tutorial we will encounter @dfn{modulo forms}, which
  1478. basically automate the idea of reducing every intermediate result
  1479. modulo some value @i{M}.
  1480. X
  1481. @node List Answer 14, Types Answer 1, List Answer 13, Answers to Exercises
  1482. @subsection List Tutorial Exercise 14
  1483. X
  1484. We want to use @kbd{H V U} to nest a function which adds a random
  1485. step to an @cite{(x,y)} coordinate.  The function is a bit long, but
  1486. otherwise the problem is quite straightforward.
  1487. X
  1488. @group
  1489. @smallexample
  1490. 2:  [0, 0]     1:  [ [    0,       0    ]
  1491. 1:  50               [  0.4288, -0.1695 ]
  1492. X    .                [ -0.4787, -0.9027 ]
  1493. X                     ...
  1494. X
  1495. X    [0,0] 50       H V U ' <# + [random(2.0)-1, random(2.0)-1]> RET
  1496. @end smallexample
  1497. @end group
  1498. X
  1499. Just as the text recommended, we used @samp{< >} nameless function
  1500. notation to keep the two @code{random} calls from being evaluated
  1501. before nesting even begins.
  1502. X
  1503. We now have a vector of @cite{[x, y]} sub-vectors, which by Calc's
  1504. rules acts like a matrix.  We can transpose this matrix and unpack
  1505. to get a pair of vectors, @cite{x} and @cite{y}, suitable for graphing.
  1506. X
  1507. @group
  1508. @smallexample
  1509. 2:  [ 0, 0.4288, -0.4787, ... ]
  1510. 1:  [ 0, -0.1696, -0.9027, ... ]
  1511. X    .
  1512. X
  1513. X    v t  v u  g f
  1514. @end smallexample
  1515. @end group
  1516. X
  1517. Incidentally, because the @cite{x} and @cite{y} are completely
  1518. independent in this case, we could have done two separate commands
  1519. to create our @cite{x} and @cite{y} vectors of numbers directly.
  1520. X
  1521. To make a random walk of unit steps, we note that @code{sincos} of
  1522. a random direction exactly gives us a @cite{[x, y]} step of unit
  1523. length; in fact, the new nesting function is even briefer, though
  1524. we might want to lower the precision a bit for it.
  1525. X
  1526. @group
  1527. @smallexample
  1528. 2:  [0, 0]     1:  [ [    0,      0    ]
  1529. 1:  50               [  0.1318, 0.9912 ]
  1530. X    .                [ -0.5965, 0.3061 ]
  1531. X                     ...
  1532. X
  1533. X    [0,0] 50   m d  p 6 RET   H V U ' <# + sincos(random(360.0))> RET
  1534. @end smallexample
  1535. @end group
  1536. X
  1537. Another @kbd{v t v u g f} sequence will graph this new random walk.
  1538. X
  1539. An interesting twist on these random walk functions would be to use
  1540. complex numbers instead of 2-vectors to represent points on the plane.
  1541. In the first example, we'd use something like @samp{random + random*(0,1)},
  1542. and in the second we could use polar complex numbers with random phase
  1543. angles.  (This exercise was first suggested in this form by Randal
  1544. Schwartz.)
  1545. X
  1546. @node Types Answer 1, Types Answer 2, List Answer 14, Answers to Exercises
  1547. @subsection Types Tutorial Exercise 1
  1548. X
  1549. @noindent
  1550. If the number is the square root of @c{$\pi$}
  1551. @cite{pi} times a rational number,
  1552. then its square, divided by @c{$\pi$}
  1553. @cite{pi}, should be a rational number.
  1554. X
  1555. @group
  1556. @smallexample
  1557. 1:  1.26508260337    1:  0.509433962268   1:  2486645810:4881193627
  1558. X    .                    .                    .
  1559. X
  1560. X                         2 ^ P /              c F
  1561. @end smallexample
  1562. @end group
  1563. X
  1564. @noindent
  1565. Technically speaking this is a rational number, but not one that is
  1566. likely to have arisen in the original problem.  More likely, it just
  1567. happens to be the fraction which most closely represents some
  1568. irrational number to within 12 digits.
  1569. X
  1570. But perhaps our result was not quite exact.  Let's reduce the
  1571. precision slightly and try again:
  1572. X
  1573. @group
  1574. @smallexample
  1575. 1:  0.509433962268     1:  27:53
  1576. X    .                      .
  1577. X
  1578. X    U p 10 RET             c F
  1579. @end smallexample
  1580. @end group
  1581. X
  1582. @noindent
  1583. Aha!  It's unlikely that an irrational number would equal a fraction
  1584. this simple to within ten digits, so our original number was probably
  1585. @c{$\sqrt{27 \pi / 53}$}
  1586. @cite{sqrt(27 pi / 53)}.
  1587. X
  1588. Notice that we didn't need to re-round the number when we reduced the
  1589. precision.  Remember, arithmetic operations always round their inputs
  1590. to the current precision before starting.
  1591. X
  1592. @node Types Answer 2, Types Answer 3, Types Answer 1, Answers to Exercises
  1593. @subsection Types Tutorial Exercise 2
  1594. X
  1595. @noindent
  1596. @samp{inf / inf = nan}.  Perhaps @samp{1} is the ``obvious'' answer.
  1597. But if @w{@samp{17 inf = inf}}, then @samp{17 inf / inf = inf / inf = 17}, too.
  1598. X
  1599. @samp{exp(inf) = inf}.  It's tempting to say that the exponential
  1600. of infinity must be ``bigger'' than ``regular'' infinity, but as
  1601. far as Calc is concerned all infinities are as just as big.
  1602. In other words, as @cite{x} goes to infinity, @cite{e^x} also goes
  1603. to infinity, but the fact the @cite{e^x} grows much faster than
  1604. @cite{x} is not relevant here.
  1605. X
  1606. @samp{exp(-inf) = 0}.  Here we have a finite answer even though
  1607. the input is infinite.
  1608. X
  1609. @samp{sqrt(-inf) = (0, 1) inf}.  Remember that @cite{(0, 1)}
  1610. represents the imaginary number @cite{i}.  Here's a derivation:
  1611. @samp{sqrt(-inf) = @w{sqrt((-1) * inf)} = sqrt(-1) * sqrt(inf)}.
  1612. The first part is, by definition, @cite{i}; the second is @code{inf}
  1613. because, once again, all infinities are the same size.
  1614. X
  1615. @samp{sqrt(uinf) = uinf}.  In fact, we do know something about the
  1616. direction because @code{sqrt} is defined to return a value in the
  1617. right half of the complex plane.  But Calc has no notation for this,
  1618. so it settles for the conservative answer @code{uinf}.
  1619. X
  1620. @samp{abs(uinf) = inf}.  No matter which direction @cite{x} points,
  1621. @samp{abs(x)} always points along the positive real axis.
  1622. X
  1623. @samp{ln(0) = -inf}.  Here we have an infinite answer to a finite
  1624. input.  As in the @cite{1 / 0} case, Calc will only use infinities
  1625. here if you have turned on ``infinite'' mode.  Otherwise, it will
  1626. treat @samp{ln(0)} as an error.
  1627. X
  1628. @node Types Answer 3, Types Answer 4, Types Answer 2, Answers to Exercises
  1629. @subsection Types Tutorial Exercise 3
  1630. X
  1631. @noindent
  1632. We can make @samp{inf - inf} be any real number we like, say,
  1633. @cite{a}, just by claiming that we added @cite{a} to the first
  1634. infinity but not to the second.  This is just as true for complex
  1635. values of @cite{a}, so @code{nan} can stand for a complex number.
  1636. (And, similarly, @code{uinf} can stand for an infinity that points
  1637. in any direction in the complex plane, such as @samp{(0, 1) inf}).
  1638. X
  1639. In fact, we can multiply the first @code{inf} by two.  Surely
  1640. @w{@samp{2 inf - inf = inf}}, but also @samp{2 inf - inf = inf - inf = nan}.
  1641. So @code{nan} can even stand for infinity.  Obviously it's just
  1642. as easy to make it stand for minus infinity as for plus infinity.
  1643. X
  1644. The moral of this story is that ``infinity'' is a slippery fish
  1645. indeed, and Calc tries to handle it by having a very simple model
  1646. for infinities (only the direction counts, not the ``size''); but
  1647. Calc is careful to write @code{nan} any time this simple model is
  1648. unable to tell what the true answer is.
  1649. X
  1650. @node Types Answer 4, Types Answer 5, Types Answer 3, Answers to Exercises
  1651. @subsection Types Tutorial Exercise 4
  1652. X
  1653. @group
  1654. @smallexample
  1655. 2:  0@@ 47' 26"              1:  0@@ 2' 47.411765"
  1656. 1:  17                          .
  1657. X    .
  1658. X
  1659. X    0@@ 47' 26" RET 17           /
  1660. @end smallexample
  1661. @end group
  1662. X
  1663. @noindent
  1664. The average song length is two minutes and 47.4 seconds.
  1665. X
  1666. @group
  1667. @smallexample
  1668. 2:  0@@ 2' 47.411765"     1:  0@@ 3' 7.411765"    1:  0@@ 53' 6.000005"
  1669. 1:  0@@ 0' 20"                .                      .
  1670. X    .
  1671. X
  1672. X    20"                      +                      17 *
  1673. @end smallexample
  1674. @end group
  1675. X
  1676. @noindent
  1677. The album would be 53 minutes and 6 seconds long.
  1678. X
  1679. @node Types Answer 5, Types Answer 6, Types Answer 4, Answers to Exercises
  1680. @subsection Types Tutorial Exercise 5
  1681. X
  1682. @noindent
  1683. Let's suppose it's January 14, 1991.  The easiest thing to do is
  1684. to keep trying 13ths of months until Calc reports a Friday.
  1685. We can do this by manually entering dates, or by using @kbd{t I}:
  1686. X
  1687. @group
  1688. @smallexample
  1689. 1:  <Wed Feb 13, 1991>    1:  <Wed Mar 13, 1991>   1:  <Sat Apr 13, 1991>
  1690. X    .                         .                        .
  1691. X
  1692. X    ' <2/13> RET       DEL    ' <3/13> RET             t I
  1693. @end smallexample
  1694. @end group
  1695. X
  1696. @noindent
  1697. (Calc assumes the current year if you don't say otherwise.)
  1698. X
  1699. This is getting tedious---we can keep advancing the date by typing
  1700. @kbd{t I} over and over again, but let's automate the job by using
  1701. vector mapping.  The @kbd{t I} command actually takes a second
  1702. ``how-many-months'' argument, which defaults to one.  This
  1703. argument is exactly what we want to map over:
  1704. X
  1705. @group
  1706. @smallexample
  1707. 2:  <Sat Apr 13, 1991>     1:  [<Mon May 13, 1991>, <Thu Jun 13, 1991>,
  1708. 1:  [1, 2, 3, 4, 5, 6]          <Sat Jul 13, 1991>, <Tue Aug 13, 1991>,
  1709. X    .                           <Fri Sep 13, 1991>, <Sun Oct 13, 1991>]
  1710. X                               .
  1711. X
  1712. X    v x 6 RET                  V M t I
  1713. @end smallexample
  1714. @end group
  1715. X
  1716. @ifinfo
  1717. @noindent
  1718. Et voila, September 13, 1991 is a Friday.
  1719. @end ifinfo
  1720. @tex
  1721. \noindent
  1722. {\it Et voil{\accent"12 a}}, September 13, 1991 is a Friday.
  1723. @end tex
  1724. X
  1725. @group
  1726. @smallexample
  1727. 1:  242
  1728. X    .
  1729. X
  1730. ' <sep 13> - <jan 14> RET
  1731. @end smallexample
  1732. @end group
  1733. X
  1734. @noindent
  1735. And the answer to our original question:  242 days to go.
  1736. X
  1737. @node Types Answer 6, Types Answer 7, Types Answer 5, Answers to Exercises
  1738. @subsection Types Tutorial Exercise 6
  1739. X
  1740. @noindent
  1741. The full rule for leap years is that they occur in every year divisible
  1742. SHAR_EOF
  1743. true || echo 'restore of calc.texinfo failed'
  1744. fi
  1745. echo 'End of  part 35'
  1746. echo 'File calc.texinfo is continued in part 36'
  1747. echo 36 > _shar_seq_.tmp
  1748. exit 0
  1749. exit 0 # Just in case...
  1750. -- 
  1751. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  1752. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  1753. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  1754. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  1755.