home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume24 / gnucalc / part36 < prev    next >
Encoding:
Text File  |  1991-10-31  |  55.5 KB  |  1,750 lines

  1. Newsgroups: comp.sources.misc
  2. From: daveg@synaptics.com (David Gillespie)
  3. Subject:  v24i084:  gnucalc - GNU Emacs Calculator, v2.00, Part36/56
  4. Message-ID: <1991Oct31.214616.2631@sparky.imd.sterling.com>
  5. X-Md4-Signature: 6bec56d735e7b86dd2319265b709ef85
  6. Date: Thu, 31 Oct 1991 21:46:16 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: daveg@synaptics.com (David Gillespie)
  10. Posting-number: Volume 24, Issue 84
  11. Archive-name: gnucalc/part36
  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" != 36; 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. by four, except that they don't occur in years divisible by 100, except
  38. that they @emph{do} in years divisible by 400.  We could work out the
  39. answer by carefully counting the years divisible by four and the
  40. exceptions, but there is a much simpler way that works even if we
  41. don't know the leap year rule.
  42. X
  43. Let's assume the present year is 1991.  Years have 365 days, except
  44. that leap years (whenever they occur) have 366 days.  So let's count
  45. the number of days between now and then, and compare that to the
  46. number of years times 365.  The number of extra days we find must be
  47. equal to the number of leap years there were.
  48. X
  49. @group
  50. @smallexample
  51. 1:  <Mon Jan 1, 10001>     2:  <Mon Jan 1, 10001>     1:  2925593
  52. X    .                      1:  <Tue Jan 1, 1991>          .
  53. X                               .
  54. X
  55. X  ' <jan 1 10001> RET         ' <jan 1 1991> RET          -
  56. X
  57. @end smallexample
  58. @end group
  59. @noindent
  60. @group
  61. @smallexample
  62. 3:  2925593       2:  2925593     2:  2925593     1:  1943
  63. 2:  10001         1:  8010        1:  2923650         .
  64. 1:  1991              .               .
  65. X    .
  66. X
  67. X  10001 RET 1991      -               365 *           -
  68. @end smallexample
  69. @end group
  70. X
  71. @c [fix-ref Date Forms]
  72. @noindent
  73. There will be 1943 leap years before the year 10001.  (Assuming,
  74. of course, that the algorithm for computing leap years remains
  75. unchanged for that long.  @xref{Date Forms}, for some interesting
  76. background information in that regard.)
  77. X
  78. @node Types Answer 7, Types Answer 8, Types Answer 6, Answers to Exercises
  79. @subsection Types Tutorial Exercise 7
  80. X
  81. @noindent
  82. The relative errors must be converted to absolute errors so that
  83. @samp{+/-} notation may be used.
  84. X
  85. @group
  86. @smallexample
  87. 1:  1.              2:  1.
  88. X    .               1:  0.2
  89. X                        .
  90. X
  91. X    20 RET .05 *        4 RET .05 *
  92. @end smallexample
  93. @end group
  94. X
  95. Now we simply chug through the formula.
  96. X
  97. @group
  98. @smallexample
  99. 1:  19.7392088022    1:  394.78 +/- 19.739    1:  6316.5 +/- 706.21
  100. X    .                    .                        .
  101. X
  102. X    2 P 2 ^ *            20 p 1 *                 4 p .2 RET 2 ^ *
  103. @end smallexample
  104. @end group
  105. X
  106. It turns out the @kbd{v u} command will unpack an error form as
  107. well as a vector.  This saves us some retyping of numbers.
  108. X
  109. @group
  110. @smallexample
  111. 3:  6316.5 +/- 706.21     2:  6316.5+/- 706.21
  112. 2:  6316.5                1:  0.1118
  113. 1:  706.21                    .
  114. X    .
  115. X
  116. X    RET v u                   TAB /
  117. @end smallexample
  118. @end group
  119. X
  120. @noindent
  121. Thus the volume is 6316 cubic centimeters, within about 11 percent.
  122. X
  123. @node Types Answer 8, Types Answer 9, Types Answer 7, Answers to Exercises
  124. @subsection Types Tutorial Exercise 8
  125. X
  126. @noindent
  127. The first answer is pretty simple:  @samp{1 / (0 .. 10) = (0.1 .. inf)}.
  128. Since a number in the interval @samp{(0 .. 10)} can get arbitrarily
  129. close to zero, its reciprocal can get arbitrarily large, so the answer
  130. is an interval that effectively means, ``any number greater than 0.1''
  131. but with no upper bound.
  132. X
  133. The second answer, similarly, is @samp{1 / (-10 .. 0) = (-inf .. -0.1)}.
  134. X
  135. Calc normally treats division by zero as an error, so that the formula
  136. @w{@samp{1 / 0}} is left unsimplified.  Our third problem,
  137. @w{@samp{1 / [0 .. 10]}}, also (potentially) divides by zero because zero
  138. is now a member of the interval.  So Calc leaves this one unevaluated, too.
  139. X
  140. If you turn on ``infinite'' mode by pressing @kbd{m i}, you will
  141. instead get the answer @samp{[0.1 .. inf]}, which includes infinity
  142. as a possible value.
  143. X
  144. The fourth calculation, @samp{1 / (-10 .. 10)}, has the same problem.
  145. Zero is buried inside the interval, but it's still a possible value.
  146. It's not hard to see that the actual result of @samp{1 / (-10 .. 10)}
  147. will be either greater than @i{0.1}, or less than @i{-0.1}.  Thus
  148. the interval goes from minus infinity to plus infinity, with a ``hole''
  149. in it from @i{-0.1} to @i{0.1}.  Calc doesn't have any way to
  150. represent this, so it just reports @samp{[-inf .. inf]} as the answer.
  151. It may be disappointing to hear ``the answer lies somewhere between
  152. minus infinity and plus infinity, inclusive,'' but that's the best
  153. that interval arithmetic can do in this case.
  154. X
  155. @node Types Answer 9, Types Answer 10, Types Answer 8, Answers to Exercises
  156. @subsection Types Tutorial Exercise 9
  157. X
  158. @group
  159. @smallexample
  160. 1:  [-3 .. 3]       2:  [-3 .. 3]     2:  [0 .. 9]
  161. X    .               1:  [0 .. 9]      1:  [-9 .. 9]
  162. X                        .                 .
  163. X
  164. X    [ 3 n .. 3 ]        RET 2 ^           TAB RET *
  165. @end smallexample
  166. @end group
  167. X
  168. @noindent
  169. In the first case the result says, ``if a number is between @i{-3} and
  170. 3, its square is between 0 and 9.''  The second case says, ``the product
  171. of two numbers each between @i{-3} and 3 is between @i{-9} and 9.''
  172. X
  173. An interval form is not a number; it is a symbol that can stand for
  174. many different numbers.  Two identical-looking interval forms can stand
  175. for different numbers.
  176. X
  177. The same issue arises when you try to square an error form.
  178. X
  179. @node Types Answer 10, Types Answer 11, Types Answer 9, Answers to Exercises
  180. @subsection Types Tutorial Exercise 10
  181. X
  182. @noindent
  183. Testing the first number, we might arbitrarily choose 17 for @cite{x}.
  184. X
  185. @group
  186. @smallexample
  187. 1:  17 mod 811749613   2:  17 mod 811749613   1:  533694123 mod 811749613
  188. X    .                      811749612              .
  189. X                           .
  190. X
  191. X    17 M 811749613 RET     811749612              ^
  192. @end smallexample
  193. @end group
  194. X
  195. @noindent
  196. Since 533694123 is (considerably) different from 1, the number 811749613
  197. must not be prime.
  198. X
  199. It's awkward to type the number in twice as we did above.  There are
  200. various ways to avoid this, and algebraic entry is one.  In fact, using
  201. a vector mapping operation we can perform several tests at once.  Let's
  202. use this method to test the second number.
  203. X
  204. @group
  205. @smallexample
  206. 2:  [17, 42, 100000]               1:  [1 mod 15485863, 1 mod ... ]
  207. 1:  15485863                           .
  208. X    .
  209. X
  210. X [17 42 100000] 15485863 RET           V M ' ($$ mod $)^($-1) RET
  211. @end smallexample
  212. @end group
  213. X
  214. @noindent
  215. The result is three ones (modulo @cite{n}), so it's very probable that
  216. 15485863 is prime.  (In fact, this number is the millionth prime.)
  217. X
  218. Note that the functions @samp{($$^($-1)) mod $} or @samp{$$^($-1) % $}
  219. would have been hopelessly inefficient, since they would have calculated
  220. the power using full integer arithmetic.
  221. X
  222. Calc has a @kbd{k p} command that does primality testing.  For small
  223. numbers it does an exact test; for large numbers it uses a variant
  224. of the Fermat test we used here.  You can use @kbd{k p} repeatedly
  225. to prove that a large integer is prime with any desired probability.
  226. X
  227. @node Types Answer 11, Types Answer 12, Types Answer 10, Answers to Exercises
  228. @subsection Types Tutorial Exercise 11
  229. X
  230. @noindent
  231. There are several ways to insert a calculated number into an HMS form.
  232. One way to convert a number of seconds to an HMS form is simply to
  233. multiply the number by an HMS form representing one second:
  234. X
  235. @group
  236. @smallexample
  237. 1:  31415926.5359     2:  31415926.5359     1:  8726@@ 38' 46.5359"
  238. X    .                 1:  0@@ 0' 1"              .
  239. X                          .
  240. X
  241. X    P 1e7 *               0@@ 0' 1"              *
  242. X
  243. @end smallexample
  244. @end group
  245. @noindent
  246. @group
  247. @smallexample
  248. 2:  8726@@ 38' 46.5359"             1:  6@@ 6' 2.5359" mod 24@@ 0' 0"
  249. 1:  15@@ 27' 16" mod 24@@ 0' 0"          .
  250. X    .
  251. X
  252. X    x time RET                         +
  253. @end smallexample
  254. @end group
  255. X
  256. @noindent
  257. It will be just after six in the morning.
  258. X
  259. The algebraic @code{hms} function can also be used to build an
  260. HMS form:
  261. X
  262. @group
  263. @smallexample
  264. 1:  hms(0, 0, 10000000. pi)       1:  8726@@ 38' 46.5359"
  265. X    .                                 .
  266. X
  267. X  ' hms(0, 0, 1e7 pi) RET             =
  268. @end smallexample
  269. @end group
  270. X
  271. @noindent
  272. The @kbd{=} key is necessary to evaluate the symbol @samp{pi} to
  273. the actual number 3.14159...
  274. X
  275. @node Types Answer 12, Types Answer 13, Types Answer 11, Answers to Exercises
  276. @subsection Types Tutorial Exercise 12
  277. X
  278. @noindent
  279. As we recall, there are 17 songs of about 2 minutes and 47 seconds
  280. each.
  281. X
  282. @group
  283. @smallexample
  284. 2:  0@@ 2' 47"                    1:  [0@@ 3' 7" .. 0@@ 3' 47"]
  285. 1:  [0@@ 0' 20" .. 0@@ 1' 0"]          .
  286. X    .
  287. X
  288. X    [ 0@@ 20" .. 0@@ 1' ]              +
  289. X
  290. @end smallexample
  291. @end group
  292. @noindent
  293. @group
  294. @smallexample
  295. 1:  [0@@ 52' 59." .. 1@@ 4' 19."]
  296. X    .
  297. X
  298. X    17 *
  299. @end smallexample
  300. @end group
  301. X
  302. @noindent
  303. No matter how long it is, the album will fit nicely on one CD.
  304. X
  305. @node Types Answer 13, Types Answer 14, Types Answer 12, Answers to Exercises
  306. @subsection Types Tutorial Exercise 13
  307. X
  308. @noindent
  309. Type @kbd{' 1 yr RET u c s RET}.  The answer is 31557600 seconds.
  310. X
  311. @node Types Answer 14, Types Answer 15, Types Answer 13, Answers to Exercises
  312. @subsection Types Tutorial Exercise 14
  313. X
  314. @noindent
  315. How long will it take for a signal to get from one end of the computer
  316. to the other?
  317. X
  318. @group
  319. @smallexample
  320. 1:  m / c         1:  3.3356 ns
  321. X    .                 .
  322. X
  323. X ' 1 m / c RET        u c ns RET
  324. @end smallexample
  325. @end group
  326. X
  327. @noindent
  328. (Recall, @samp{c} is a ``unit'' corresponding to the speed of light.)
  329. X
  330. @group
  331. @smallexample
  332. 1:  3.3356 ns     1:  0.81356 ns / ns     1:  0.81356
  333. 2:  4.1 ns            .                       .
  334. X    .
  335. X
  336. X  ' 4.1 ns RET        /                       u s
  337. @end smallexample
  338. @end group
  339. X
  340. @noindent
  341. Thus a signal could take up to 81 percent of a clock cycle just to
  342. go from one place to another inside the computer, assuming the signal
  343. could actually attain the full speed of light.  Pretty tight!
  344. X
  345. @node Types Answer 15, Algebra Answer 1, Types Answer 14, Answers to Exercises
  346. @subsection Types Tutorial Exercise 15
  347. X
  348. @noindent
  349. The speed limit is 55 miles per hour on most highways.  We want to
  350. find the ratio of Sam's speed to the US speed limit.
  351. X
  352. @group
  353. @smallexample
  354. 1:  55 mph         2:  55 mph           3:  11 hr mph / yd
  355. X    .              1:  5 yd / hr            .
  356. X                       .
  357. X
  358. X  ' 55 mph RET       ' 5 yd/hr RET          /
  359. @end smallexample
  360. @end group
  361. X
  362. The @kbd{u s} command doesn't figure out how to simplify this,
  363. but @w{@kbd{u b}} (convert to base units) does.  Now we take the
  364. logarithm base two to find the final answer, assuming that each
  365. successive pill doubles his speed.
  366. X
  367. @group
  368. @smallexample
  369. 1:  19360.       2:  19360.       1:  14.24
  370. X    .            1:  2                .
  371. X                     .
  372. X
  373. X    u b              2                B
  374. @end smallexample
  375. @end group
  376. X
  377. @noindent
  378. Thus Sam can take up to 14 pills without a worry.
  379. X
  380. @node Algebra Answer 1, Algebra Answer 2, Types Answer 15, Answers to Exercises
  381. @subsection Algebra Tutorial Exercise 1
  382. X
  383. @noindent
  384. @c [fix-ref Declarations]
  385. The result @samp{sqrt(x)^2} is simplified back to @cite{x} by the
  386. Calculator, but @samp{sqrt(x^2)} is not.  (Consider what happens
  387. if @w{@cite{x = -4}}.)  If @cite{x} is real, this formula could be
  388. simplified to @samp{abs(x)}, but for general complex arguments even
  389. that is not safe.  (@xref{Declarations}, for a way to tell Calc
  390. that @cite{x} is known to be real.)
  391. X
  392. @node Algebra Answer 2, Algebra Answer 3, Algebra Answer 1, Answers to Exercises
  393. @subsection Algebra Tutorial Exercise 2
  394. X
  395. @noindent
  396. It is easiest to use @kbd{a P x RET} to get a list of solutions.
  397. X
  398. @group
  399. @smallexample
  400. 1:  17 x^2 - 6 x^4 + 3 = 0   2:  17 x^2 - 6 x^4 + 3 = 0
  401. 2:  17 x^2 - 6 x^4 + 3 = 0   1:  [(0, 0.408), (0, -0.408), 1.732, -1.732]
  402. X    .                            .
  403. X
  404. X    RET                          a P x RET
  405. @end smallexample
  406. @end group
  407. X
  408. @noindent
  409. Now we can substitute these into the original formula.
  410. X
  411. @group
  412. @smallexample
  413. 4:  17 x^2 - 6 x^4 + 3 = 0
  414. 3:  [(0., 0.408), (0., -0.408), 1.732, -1.732]
  415. 2:  [(0., 0.408), (0., -0.408), 1.732, -1.732]
  416. 1:  17 x^2 - 6 x^4 + 3
  417. X    .
  418. X
  419. X    M-2 RET TAB   v u DEL
  420. @end smallexample
  421. @end group
  422. X
  423. @noindent
  424. The @kbd{v u} command unpacks @samp{a = 0} to @samp{a} and 0; we then
  425. delete the 0.
  426. X
  427. @group
  428. @smallexample
  429. 3:  17 x^2 - 6 x^4 + 3 = 0
  430. 2:  [(0., 0.408), (0., -0.408), 1.732, -1.732]
  431. 1:  [1e-11, 1e-11, -1e-10, -1e-10]
  432. X    .
  433. X
  434. X    V M $ RET
  435. @end smallexample
  436. @end group
  437. X
  438. @noindent
  439. These numbers are reasonable approximations to zero, considering
  440. the precision to which we computed the solutions.
  441. X
  442. @node Algebra Answer 3, Algebra Answer 4, Algebra Answer 2, Answers to Exercises
  443. @subsection Algebra Tutorial Exercise 3
  444. X
  445. @group
  446. @smallexample
  447. 1:  x sin(pi x)         1:  (sin(pi x) - pi x cos(pi x)) / pi^2
  448. X    .                       .
  449. X
  450. X  ' x sin(pi x) RET   m r   a i x RET
  451. X
  452. @end smallexample
  453. @end group
  454. @noindent
  455. @group
  456. @smallexample
  457. 1:  [y, 1]
  458. 2:  (sin(pi x) - pi x cos(pi x)) / pi^2
  459. X    .
  460. X
  461. X  ' [y,1] RET TAB
  462. X
  463. @end smallexample
  464. @end group
  465. @noindent
  466. @group
  467. @smallexample
  468. 1:  [(sin(pi y) - pi y cos(pi y)) / pi^2, (sin(pi) - pi cos(pi)) / pi^2]
  469. X    .
  470. X
  471. X    V M $ RET
  472. X
  473. @end smallexample
  474. @end group
  475. @noindent
  476. @group
  477. @smallexample
  478. 1:  (sin(pi y) - pi y cos(pi y)) / pi^2 + (pi cos(pi) + sin(pi)) / pi^2
  479. X    .
  480. X
  481. X    V R -
  482. X
  483. @end smallexample
  484. @end group
  485. @noindent
  486. @group
  487. @smallexample
  488. 1:  (sin(3.14159 y) - 3.14159 y cos(3.14159 y)) / 9.8696 - 0.3183
  489. X    .
  490. X
  491. X    =
  492. X
  493. @end smallexample
  494. @end group
  495. @noindent
  496. @group
  497. @smallexample
  498. 1:  [0., -0.95493, 0.63662, -1.5915, 1.2732]
  499. X    .
  500. X
  501. X    v x 5 RET  TAB  V M $ RET
  502. @end smallexample
  503. @end group
  504. X
  505. @node Algebra Answer 4, Rewrites Answer 1, Algebra Answer 3, Answers to Exercises
  506. @subsection Algebra Tutorial Exercise 4
  507. X
  508. @noindent
  509. The hard part is that @kbd{V R +} is no longer sufficient to add up all
  510. the contributions from the slices, since the slices have varying
  511. coefficients.  So first we must come up with a vector of these
  512. coefficients.  Here's one way:
  513. X
  514. @group
  515. @smallexample
  516. 2:  -1                 2:  3                    1:  [4, 2, ..., 4]
  517. 1:  [1, 2, ..., 9]     1:  [-1, 1, ..., -1]         .
  518. X    .                      .
  519. X
  520. X    1 n v x 9 RET          V M ^  3 TAB             -
  521. X
  522. @end smallexample
  523. @end group
  524. @noindent
  525. @group
  526. @smallexample
  527. 1:  [4, 2, ..., 4, 1]      1:  [1, 4, 2, ..., 4, 1]
  528. X    .                          .
  529. X
  530. X    1 |                        1 TAB |
  531. @end smallexample
  532. @end group
  533. X
  534. @noindent
  535. Now we compute the function values.  Note that for this method we need
  536. eleven values, including both endpoints of the desired interval.
  537. X
  538. @group
  539. @smallexample
  540. 2:  [1, 4, 2, ..., 4, 1]
  541. 1:  [1, 1.1, 1.2,  ...  , 1.8, 1.9, 2.]
  542. X    .
  543. X
  544. X 11 RET 1 RET .1 RET  C-u v x
  545. X
  546. @end smallexample
  547. @end group
  548. @noindent
  549. @group
  550. @smallexample
  551. 2:  [1, 4, 2, ..., 4, 1]
  552. 1:  [0., 0.084941, 0.16993, ... ]
  553. X    .
  554. X
  555. X    ' sin(x) ln(x) RET   m r  p 5 RET   V M $ RET
  556. @end smallexample
  557. @end group
  558. X
  559. @noindent
  560. Once again this calls for @kbd{V M * V R +}; a simple @kbd{*} does the
  561. same thing.
  562. X
  563. @group
  564. @smallexample
  565. 1:  11.22      1:  1.122      1:  0.374
  566. X    .              .              .
  567. X
  568. X    *              .1 *           3 /
  569. @end smallexample
  570. @end group
  571. X
  572. @noindent
  573. Wow!  That's even better than the result from the Taylor series method.
  574. X
  575. @node Rewrites Answer 1, Rewrites Answer 2, Algebra Answer 4, Answers to Exercises
  576. @subsection Rewrites Tutorial Exercise 1
  577. X
  578. @noindent
  579. We'll use Big mode to make the formulas more readable.
  580. X
  581. @group
  582. @smallexample
  583. X                                               ___
  584. X                                          2 + V 2
  585. 1:  (2 + sqrt(2)) / (1 + sqrt(2))     1:  --------
  586. X    .                                          ___
  587. X                                          1 + V 2
  588. X
  589. X                                          .
  590. X
  591. X  ' (2+sqrt(2)) / (1+sqrt(2)) RET         d B
  592. @end smallexample
  593. @end group
  594. X
  595. @noindent
  596. Multiplying by the conjugate helps because @cite{(a+b) (a-b) = a^2 - b^2}.
  597. X
  598. @group
  599. @smallexample
  600. X          ___    ___
  601. 1:  (2 + V 2 ) (V 2  - 1)
  602. X    .
  603. X
  604. X  a r a/(b+c) := a*(b-c) / (b^2-c^2) RET
  605. X
  606. @end smallexample
  607. @end group
  608. @noindent
  609. @group
  610. @smallexample
  611. X         ___                         ___
  612. 1:  2 + V 2  - 2                1:  V 2
  613. X    .                               .
  614. X
  615. X  a r a*(b+c) := a*b + a*c          a s
  616. @end smallexample
  617. @end group
  618. X
  619. @noindent
  620. (We could have used @kbd{a x} instead of a rewrite rule for the
  621. second step.)
  622. X
  623. The multiply-by-conjugate rule turns out to be useful in many
  624. different circumstances, such as when the denominator involves
  625. sines and cosines or the imaginary constant @code{i}.
  626. X
  627. @node Rewrites Answer 2, Rewrites Answer 3, Rewrites Answer 1, Answers to Exercises
  628. @subsection Rewrites Tutorial Exercise 2
  629. X
  630. @noindent
  631. Here is the rule set:
  632. X
  633. @group
  634. @smallexample
  635. [ fib(n) := fib(n, 1, 1) :: integer(n) :: n >= 1,
  636. X  fib(1, x, y) := x,
  637. X  fib(n, x, y) := fib(n-1, y, x+y) ]
  638. @end smallexample
  639. @end group
  640. X
  641. @noindent
  642. The first rule turns a one-argument @code{fib} that people like to write
  643. into a three-argument @code{fib} that makes computation easier.  The
  644. second rule converts back from three-argument form once the computation
  645. is done.  The third rule does the computation itself.  It basically
  646. says that if @cite{x} and @cite{y} are two consecutive Fibonacci numbers,
  647. then @cite{y} and @cite{x+y} are the next (overlapping) pair of Fibonacci
  648. numbers.
  649. X
  650. Notice that because the number @cite{n} was ``validated'' by the
  651. conditions on the first rule, there is no need to put conditions on
  652. the other rules because the rule set would never get that far unless
  653. the input were valid.  That further speeds computation, since no
  654. extra conditions need to be checked at every step.
  655. X
  656. Actually, a user with a nasty sense of humor could enter a bad
  657. three-argument @code{fib} call directly, say, @samp{fib(0, 1, 1)},
  658. which would get the rules into an infinite loop.  One thing that would
  659. help keep this from happening by accident would be to use something like
  660. @samp{ZzFib} instead of @code{fib} as the name of the three-argument
  661. function.
  662. X
  663. @node Rewrites Answer 3, Rewrites Answer 4, Rewrites Answer 2, Answers to Exercises
  664. @subsection Rewrites Tutorial Exercise 3
  665. X
  666. @noindent
  667. He got an infinite loop.  First, Calc did as expected and rewrote
  668. @w{@samp{2 + 3 x}} to @samp{f(2, 3, x)}.  Then it looked for ways to
  669. apply the rule again, and found that @samp{f(2, 3, x)} looks like
  670. @samp{a + b x} with @w{@samp{a = 0}} and @samp{b = 1}, so it rewrote to
  671. @samp{f(0, 1, f(2, 3, x))}.  It then wrapped another @samp{f(0, 1, ...)}
  672. around that, and so on, ad infinitum.  Joe should have used @kbd{M-1 a r}
  673. to make sure the rule applied only once.
  674. X
  675. (Actually, even the first step didn't work as he expected.  What Calc
  676. really gives for @kbd{M-1 a r} in this situation is @samp{f(3 x, 1, 2)},
  677. treating 2 as the ``variable,'' and @samp{3 x} as a constant being added
  678. to it.  While this may seem odd, it's just as valid a solution as the
  679. ``obvious'' one.  One way to fix this would be to add the condition
  680. @samp{:: variable(x)} to the rule, to make sure the thing that matches
  681. @samp{x} is indeed a variable, or to change @samp{x} to @samp{quote(x)}
  682. on the lefthand side, so that the rule matches the actual variable
  683. @samp{x} rather than letting @samp{x} stand for something else.)
  684. X
  685. @node Rewrites Answer 4, Rewrites Answer 5, Rewrites Answer 3, Answers to Exercises
  686. @subsection Rewrites Tutorial Exercise 4
  687. X
  688. @noindent
  689. @tindex seq
  690. Here is a suitable set of rules to solve the first part of the problem:
  691. X
  692. @group
  693. @smallexample
  694. [ seq(n, c) := seq(n/2,  c+1) :: n%2 = 0,
  695. X  seq(n, c) := seq(3n+1, c+1) :: n%2 = 1 :: n > 1 ]
  696. @end smallexample
  697. @end group
  698. X
  699. Given the initial formula @samp{seq(6, 0)}, application of these
  700. rules produces the following sequence of formulas:
  701. X
  702. @example
  703. seq( 3, 1)
  704. seq(10, 2)
  705. seq( 5, 3)
  706. seq(16, 4)
  707. seq( 8, 5)
  708. seq( 4, 6)
  709. seq( 2, 7)
  710. seq( 1, 8)
  711. @end example
  712. X
  713. @noindent
  714. whereupon neither of the rules match, and rewriting stops.
  715. X
  716. We can pretty this up a bit with a couple more rules:
  717. X
  718. @group
  719. @smallexample
  720. [ seq(n) := seq(n, 0),
  721. X  seq(1, c) := c,
  722. X  ... ]
  723. @end smallexample
  724. @end group
  725. X
  726. @noindent
  727. Now, given @samp{seq(6)} as the starting configuration, we get 8
  728. as the result.
  729. X
  730. The change to return a vector is quite simple:
  731. X
  732. @group
  733. @smallexample
  734. [ seq(n) := seq(n, []) :: integer(n) :: n > 0,
  735. X  seq(1, v) := v | 1,
  736. X  seq(n, v) := seq(n/2,  v | n) :: n%2 = 0,
  737. X  seq(n, v) := seq(3n+1, v | n) :: n%2 = 1 ]
  738. @end smallexample
  739. @end group
  740. X
  741. @noindent
  742. Given @samp{seq(6)}, the result is @samp{[6, 3, 10, 5, 16, 8, 4, 2, 1]}.
  743. X
  744. Notice that the @cite{n > 1} guard is no longer necessary on the last
  745. rule since the @cite{n = 1} case is now detected by another rule.
  746. But a guard has been added to the initial rule to make sure the
  747. initial value is suitable before the computation begins.
  748. X
  749. While still a good idea, this guard is not as vitally important as it
  750. was for the @code{fib} function, since calling, say, @samp{seq(x, [])}
  751. will not get into an infinite loop.  Calc will not be able to prove
  752. the symbol @samp{x} is either even or odd, so none of the rules will
  753. apply and the rewrites will stop right away.
  754. X
  755. @node Rewrites Answer 5, Rewrites Answer 6, Rewrites Answer 4, Answers to Exercises
  756. @subsection Rewrites Tutorial Exercise 5
  757. X
  758. @noindent
  759. @tindex nterms
  760. If @cite{x} is the sum @cite{a + b}, then `@t{nterms(}@i{x}@t{)}' must
  761. be `@t{nterms(}@i{a}@t{)}' plus `@t{nterms(}@i{b}@t{)}'.  If @cite{x}
  762. is not a sum, then `@t{nterms(}@i{x}@t{)}' = 1.
  763. X
  764. @group
  765. @smallexample
  766. [ nterms(a + b) := nterms(a) + nterms(b),
  767. X  nterms(x)     := 1 ]
  768. @end smallexample
  769. @end group
  770. X
  771. @noindent
  772. Here we have taken advantage of the fact that earlier rules always
  773. match before later rules; @samp{nterms(x)} will only be tried if we
  774. already know that @samp{x} is not a sum.
  775. X
  776. @node Rewrites Answer 6, Programming Answer 1, Rewrites Answer 5, Answers to Exercises
  777. @subsection Rewrites Tutorial Exercise 6
  778. X
  779. @noindent
  780. Here is a rule set that will do the job:
  781. X
  782. @group
  783. @smallexample
  784. [ a*(b + c) := a*b + a*c,
  785. X  opt(a) O(x^n) + opt(b) O(x^m) := O(x^n) :: n <= m
  786. X     :: constant(a) :: constant(b),
  787. X  opt(a) O(x^n) + opt(b) x^m := O(x^n) :: n <= m
  788. X     :: constant(a) :: constant(b),
  789. X  a O(x^n) := O(x^n) :: constant(a),
  790. X  x^opt(m) O(x^n) := O(x^(n+m)),
  791. X  O(x^n) O(x^m) := O(x^(n+m)) ]
  792. @end smallexample
  793. @end group
  794. X
  795. If we really want the @kbd{+} and @kbd{*} keys to operate naturally
  796. on power series, we should put these rules in @code{EvalRules}.  For
  797. testing purposes, it is better to put them in a different variable,
  798. say, @code{O}, first.
  799. X
  800. The first rule just expands products of sums so that the rest of the
  801. rules can assume they have an expanded-out polynomial to work with.
  802. Note that this rule does not mention @samp{O} at all, so it will
  803. apply to any product-of-sum it encounters---this rule may surprise
  804. you if you put it into @code{EvalRules}!
  805. X
  806. In the second rule, the sum of two O's is changed to the smaller O.
  807. The optional constant coefficients are there mostly so that
  808. @samp{O(x^2) - O(x^3)} and @samp{O(x^3) - O(x^2)} are handled
  809. as well as @samp{O(x^2) + O(x^3)}.
  810. X
  811. The third rule absorbs higher powers of @samp{x} into O's.
  812. X
  813. The fourth rule says that a constant times a negligible quantity
  814. is still negligible.  (This rule will also match @samp{O(x^3) / 4},
  815. with @samp{a = 1/4}.)
  816. X
  817. The fifth rule rewrites, for example, @samp{x^2 O(x^3)} to @samp{O(x^5)}.
  818. (It is easy to see that if one of these forms is negligible, the other
  819. is, too.)  Notice the @samp{x^opt(m)} to pick up terms like
  820. @w{@samp{x O(x^3)}}.  Optional powers will match @samp{x} as @samp{x^1}
  821. but not 1 as @samp{x^0}.  This turns out to be exactly what we want here.
  822. X
  823. The sixth rule is the corresponding rule for products of two O's.
  824. X
  825. Another way to solve this problem would be to create a new ``data type''
  826. that represents truncated power series.  We might represent these as
  827. function calls @samp{series(@var{coefs}, @var{x})} where @var{coefs} is
  828. a vector of coefficients for @cite{x^0}, @cite{x^1}, @cite{x^2}, and so
  829. on.  Rules would exist for sums and products of such @code{series}
  830. objects, and as an optional convenience could also know how to combine a
  831. @code{series} object with a normal polynomial.  (With this, and with a
  832. rule that rewrites @samp{O(x^n)} to the equivalent @code{series} form,
  833. you could still enter power series in exactly the same notation as
  834. before.)  Operations on such objects would probably be more efficient,
  835. although the objects would be a bit harder to read.
  836. X
  837. @c [fix-ref Compositions]
  838. Some other symbolic math programs provide a power series data type
  839. similar to this.  Mathematica, for example, has an object that looks
  840. like @samp{PowerSeries[@var{x}, @var{x0}, @var{coefs}, @var{nmin},
  841. @var{nmax}, @var{den}]}, where @var{x0} is the point about which the
  842. power series is taken (we've been assuming this was always zero),
  843. and @var{nmin}, @var{nmax}, and @var{den} allow pseudo-power-series
  844. with fractional or negative powers.  Also, the @code{PowerSeries}
  845. objects have a special display format that makes them look like
  846. @samp{2 x^2 + O(x^4)} when they are printed out.  (@xref{Compositions},
  847. for a way to do this in Calc, although for something as involved as
  848. this it would probably be better to write the formatting routine
  849. in Lisp.)
  850. X
  851. @node Programming Answer 1, Programming Answer 2, Rewrites Answer 6, Answers to Exercises
  852. @subsection Programming Tutorial Exercise 1
  853. X
  854. Just enter the formula @samp{ninteg(cos(pi t^2/2), t, 0, x)}, type
  855. @kbd{Z F}, and answer the questions.  Since this formula contains two
  856. variables, the default argument list will be @samp{(t x)}.  We want to
  857. change this to @samp{(x)} since @cite{t} is really a dummy variable
  858. to be used within @code{ninteg}.
  859. X
  860. The exact keystrokes are @kbd{Z F c fresC RET RET C-b C-b DEL DEL RET y}.
  861. (The @kbd{C-b C-b DEL DEL} are what fix the argument list.)
  862. X
  863. While this definition works, you'll find the @code{erf}-based definition
  864. described afterwards to be much more efficient; @code{erf} is also defined
  865. by an integral (involving @samp{exp(-t^2)}), but Calc has good algorithms
  866. for computing it that don't rely on brute-force numerical integration.
  867. The @kbd{Z F} formula would be @samp{re((i+1) erf(sqrt(pi) (1-i) x / 2) / 2)},
  868. where @code{re} is the function that extracts the real part of a complex
  869. number.  Actually, you'd want to type @kbd{=} on this formula first to
  870. evaluate the @code{pi} and @code{i} variables in it; otherwise your
  871. @kbd{z c} function will return a formula that needs to have @kbd{=}
  872. typed on it each time.
  873. X
  874. @node Programming Answer 2, Programming Answer 3, Programming Answer 1, Answers to Exercises
  875. @subsection Programming Tutorial Exercise 2
  876. X
  877. @noindent
  878. One way is to move the number to the top of the stack, operate on
  879. it, then move it back:  @kbd{C-x ( M-TAB n M-TAB M-TAB C-x )}.
  880. X
  881. Another way is to negate the top three stack entries, then negate
  882. again the top two stack entries:  @kbd{C-x ( M-3 n M-2 n C-x )}.
  883. X
  884. Finally, it turns out that a negative prefix argument causes a
  885. command like @kbd{n} to operate on just the specified stack entry,
  886. which is just what we want:  @kbd{C-x ( M-- 3 n C-x )}.
  887. X
  888. Just for kicks, let's also do it algebraically:
  889. @w{@kbd{C-x ( ' -$$$, $$, $ RET C-x )}}.
  890. X
  891. @node Programming Answer 3, Programming Answer 4, Programming Answer 2, Answers to Exercises
  892. @subsection Programming Tutorial Exercise 3
  893. X
  894. @noindent
  895. Each of these functions can be computed using the stack, or using
  896. algebraic entry, whichever way you prefer:
  897. X
  898. @noindent
  899. Computing @c{$\displaystyle{\sin x \over x}$}
  900. @cite{sin(x) / x}:
  901. X
  902. Using the stack:  @kbd{C-x (  RET S TAB /  C-x )}.
  903. X
  904. Using algebraic entry:  @kbd{C-x (  ' sin($)/$ RET  C-x )}.
  905. X
  906. @noindent
  907. Computing the logarithm:
  908. X
  909. Using the stack:  @kbd{C-x (  TAB B  C-x )}
  910. X
  911. Using algebraic entry:  @kbd{C-x (  ' log($,$$) RET  C-x )}.
  912. X
  913. @noindent
  914. Computing the vector of integers:
  915. X
  916. Using the stack:  @kbd{C-x (  1 RET 1  C-u v x  C-x )}.  (Recall that
  917. @kbd{C-u v x} takes the vector size, starting value, and increment
  918. from the stack.)
  919. X
  920. Alternatively:  @kbd{C-x (  ~ v x  C-x )}.  (The @kbd{~} key pops a
  921. number from the stack and uses it as the prefix argument for the
  922. next command.)
  923. X
  924. Using algebraic entry:  @kbd{C-x (  ' index($) RET  C-x )}.
  925. X
  926. @node Programming Answer 4, Programming Answer 5, Programming Answer 3, Answers to Exercises
  927. @subsection Programming Tutorial Exercise 4
  928. X
  929. @noindent
  930. Here's one way:  @kbd{C-x ( RET V R + TAB v l / C-x )}.
  931. X
  932. @node Programming Answer 5, Programming Answer 6, Programming Answer 4, Answers to Exercises
  933. @subsection Programming Tutorial Exercise 5
  934. X
  935. @group
  936. @smallexample
  937. 2:  1              1:  1.61803398502         2:  1.61803398502
  938. 1:  20                 .                     1:  1.61803398875
  939. X    .                                            .
  940. X
  941. X   1 RET 20         Z < & 1 + Z >                I H P
  942. @end smallexample
  943. @end group
  944. X
  945. @noindent
  946. This answer is quite accurate.
  947. X
  948. @node Programming Answer 6, Programming Answer 7, Programming Answer 5, Answers to Exercises
  949. @subsection Programming Tutorial Exercise 6
  950. X
  951. @noindent
  952. Here is the matrix:
  953. X
  954. @example
  955. [ [ 0, 1 ]   * [a, b] = [b, a + b]
  956. X  [ 1, 1 ] ]
  957. @end example
  958. X
  959. @noindent
  960. Thus @samp{[0, 1; 1, 1]^n * [1, 1]} computes Fibonacci numbers @cite{n+1}
  961. and @cite{n+2}.  Here's one program that does the job:
  962. X
  963. @example
  964. C-x ( ' [0, 1; 1, 1] ^ ($-1) * [1, 1] RET v u DEL C-x )
  965. @end example
  966. X
  967. @noindent
  968. This program is quite efficient because Calc knows how to raise a
  969. matrix (or other value) to the power @cite{n} in only @c{$\log_2 n$}
  970. @cite{log(n,2)}
  971. steps.  For example, this program can compute the 1000th Fibonacci
  972. number (a 209-digit integer!) in about 10 steps; even though the
  973. @kbd{Z < ... Z >} solution had much simpler steps, it would have
  974. required so many steps that it would not have been practical.
  975. X
  976. @node Programming Answer 7, Programming Answer 8, Programming Answer 6, Answers to Exercises
  977. @subsection Programming Tutorial Exercise 7
  978. X
  979. @noindent
  980. The trick here is to compute the harmonic numbers differently, so that
  981. the loop counter itself accumulates the sum of reciprocals.  We use
  982. a separate variable to hold the integer counter.
  983. X
  984. @group
  985. @smallexample
  986. 1:  1          2:  1       1:  .
  987. X    .          1:  4
  988. X                   .
  989. X
  990. X    1 t 1       1 RET 4      Z ( t 2 r 1 1 + s 1 & Z )
  991. @end smallexample
  992. @end group
  993. X
  994. @noindent
  995. The body of the loop goes as follows:  First save the harmonic sum
  996. so far in variable 2.  Then delete it from the stack; the for loop
  997. itself will take care of remembering it for us.  Next, recall the
  998. count from variable 1, add one to it, and feed its reciprocal to
  999. the for loop to use as the step value.  The for loop will increase
  1000. the ``loop counter'' by that amount and keep going until the
  1001. loop counter exceeds 4.
  1002. X
  1003. @group
  1004. @smallexample
  1005. 2:  31                  3:  31
  1006. 1:  3.99498713092       2:  3.99498713092
  1007. X    .                   1:  4.02724519544
  1008. X                            .
  1009. X
  1010. X    r 1 r 2                 RET 31 & +
  1011. @end smallexample
  1012. @end group
  1013. X
  1014. Thus we find that the 30th harmonic number is 3.99, and the 31st
  1015. harmonic number is 4.02.
  1016. X
  1017. @node Programming Answer 8, Programming Answer 9, Programming Answer 7, Answers to Exercises
  1018. @subsection Programming Tutorial Exercise 8
  1019. X
  1020. @noindent
  1021. The first step is to compute the derivative @cite{f'(x)} and thus
  1022. the formula @c{$\displaystyle{x - {f(x) \over f'(x)}}$}
  1023. @cite{x - f(x)/f'(x)}.
  1024. X
  1025. (Because this definition is long, it will be repeated in concise form
  1026. below.  You can use @w{@kbd{M-# m}} to load it from there.  While you are
  1027. entering a @kbd{Z ` Z '} body in a macro, Calc simply collects
  1028. keystrokes without executing them.  In the following diagrams we'll
  1029. pretend Calc actually executed the keystrokes as you typed them,
  1030. just for purposes of illustration.)
  1031. X
  1032. @group
  1033. @smallexample
  1034. 2:  sin(cos(x)) - 0.5            3:  4.5
  1035. 1:  4.5                          2:  sin(cos(x)) - 0.5
  1036. X    .                            1:  -(sin(x) cos(cos(x)))
  1037. X                                     .
  1038. X
  1039. ' sin(cos(x))-0.5 RET 4.5  m r  C-x ( Z `  TAB RET a d x RET
  1040. X
  1041. @end smallexample
  1042. @end group
  1043. @noindent
  1044. @group
  1045. @smallexample
  1046. 2:  4.5
  1047. 1:  x + (sin(cos(x)) - 0.5) / sin(x) cos(cos(x))
  1048. X    .
  1049. X
  1050. X    /  ' x RET TAB -   t 1
  1051. @end smallexample
  1052. @end group
  1053. X
  1054. Now, we enter the loop.  We'll use a repeat loop with a 20-repetition
  1055. limit just in case the method fails to converge for some reason.
  1056. (Normally, the @w{@kbd{Z /}} command will stop the loop before all 20
  1057. repetitions are done.)
  1058. X
  1059. @group
  1060. @smallexample
  1061. 1:  4.5         3:  4.5                     2:  4.5
  1062. X    .           2:  x + (sin(cos(x)) ...    1:  5.24196456928
  1063. X                1:  4.5                         .
  1064. X                    .
  1065. X
  1066. X  20 Z <          RET r 1 TAB                 s l x RET
  1067. @end smallexample
  1068. @end group
  1069. X
  1070. This is the new guess for @cite{x}.  Now we compare it with the
  1071. old one to see if we've converged.
  1072. X
  1073. @group
  1074. @smallexample
  1075. 3:  5.24196     2:  5.24196     1:  5.24196     1:  5.26345856348
  1076. 2:  5.24196     1:  0               .               .
  1077. 1:  4.5             .
  1078. X    .
  1079. X
  1080. X  RET M-TAB         a =             Z /             Z > Z ' C-x )
  1081. @end smallexample
  1082. @end group
  1083. X
  1084. The loop converges in just a few steps to this value.  To check
  1085. the result, we can simply substitute it back into the equation.
  1086. X
  1087. @group
  1088. @smallexample
  1089. 2:  5.26345856348
  1090. 1:  0.499999999997
  1091. X    .
  1092. X
  1093. X RET ' sin(cos($)) RET
  1094. @end smallexample
  1095. @end group
  1096. X
  1097. Let's test the new definition again:
  1098. X
  1099. @group
  1100. @smallexample
  1101. 2:  x^2 - 9           1:  3.
  1102. 1:  1                     .
  1103. X    .
  1104. X
  1105. X  ' x^2-9 RET 1           X
  1106. @end smallexample
  1107. @end group
  1108. X
  1109. Once again, here's the full Newton's Method definition:
  1110. X
  1111. @group
  1112. @example
  1113. C-x ( Z `  TAB RET a d x RET  /  ' x RET TAB -  t 1
  1114. X           20 Z <  RET r 1 TAB  s l x RET
  1115. X                   RET M-TAB  a =  Z /
  1116. X              Z >
  1117. X      Z '
  1118. C-x )
  1119. @end example
  1120. @end group
  1121. X
  1122. @c [fix-ref Nesting and Fixed Points]
  1123. It turns out that Calc has a built-in command for applying a formula
  1124. repeatedly until it converges to a number.  @xref{Nesting and Fixed Points},
  1125. to see how to use it.
  1126. X
  1127. @c [fix-ref Root Finding]
  1128. Also, of course, @kbd{a R} is a built-in command that uses Newton's
  1129. method (among others) to look for numerical solutions to any equation.
  1130. @xref{Root Finding}.
  1131. X
  1132. @node Programming Answer 9, Programming Answer 10, Programming Answer 8, Answers to Exercises
  1133. @subsection Programming Tutorial Exercise 9
  1134. X
  1135. @noindent
  1136. The first step is to adjust @cite{z} to be greater than 5.  A simple
  1137. ``for'' loop will do the job here.  If @cite{z} is less than 5, we
  1138. reduce the problem using @c{$\psi(z) = \psi(z+1) - 1/z$}
  1139. @cite{psi(z) = psi(z+1) - 1/z}.  We go
  1140. on to compute @c{$\psi(z+1)$}
  1141. @cite{psi(z+1)}, and remember to add back a factor of
  1142. @cite{-1/z} when we're done.  This step is repeated until @cite{z > 5}.
  1143. X
  1144. (Because this definition is long, it will be repeated in concise form
  1145. below.  You can use @w{@kbd{M-# m}} to load it from there.  While you are
  1146. entering a @kbd{Z ` Z '} body in a macro, Calc simply collects
  1147. keystrokes without executing them.  In the following diagrams we'll
  1148. pretend Calc actually executed the keystrokes as you typed them,
  1149. just for purposes of illustration.)
  1150. X
  1151. @group
  1152. @smallexample
  1153. 1:  1.             1:  1.
  1154. X    .                  .
  1155. X
  1156. X 1.0 RET       C-x ( Z `  s 1  0 t 2
  1157. @end smallexample
  1158. @end group
  1159. X
  1160. Here, variable 1 holds @cite{z} and variable 2 holds the adjustment
  1161. factor.  If @cite{z < 5}, we use a loop to increase it.
  1162. X
  1163. (By the way, we started with @samp{1.0} instead of the integer 1 because
  1164. otherwise the calculation below will try to do exact fractional arithmetic,
  1165. and will never converge because fractions compare equal only if they
  1166. are exactly equal, not just the same to within the current precision.)
  1167. X
  1168. @group
  1169. @smallexample
  1170. 3:  1.      2:  1.       1:  6.
  1171. 2:  1.      1:  1            .
  1172. 1:  5           .
  1173. X    .
  1174. X
  1175. X  RET 5        a <    Z [  5 Z (  & s + 2  1 s + 1  1 Z ) r 1  Z ]
  1176. @end smallexample
  1177. @end group
  1178. X
  1179. Now we compute the initial part of the sum:  @c{$\ln z - {1 \over 2z}$}
  1180. @cite{ln(z) - 1/2z}
  1181. minus the adjustment factor.
  1182. X
  1183. @group
  1184. @smallexample
  1185. 2:  1.79175946923      2:  1.7084261359      1:  -0.57490719743
  1186. 1:  0.0833333333333    1:  2.28333333333         .
  1187. X    .                      .
  1188. X
  1189. X    L  r 1 2 * &           -  r 2                -
  1190. @end smallexample
  1191. @end group
  1192. X
  1193. Now we evaluate the series.  We'll use another ``for'' loop counting
  1194. up the value of @cite{2 n}.  (Calc does have a summation command,
  1195. @kbd{a +}, but we'll use loops just to get more practice with them.)
  1196. X
  1197. @group
  1198. @smallexample
  1199. 3:  -0.5749       3:  -0.5749        4:  -0.5749      2:  -0.5749
  1200. 2:  2             2:  1:6            3:  1:6          1:  2.3148e-3
  1201. 1:  40            1:  2              2:  2                .
  1202. X    .                 .              1:  36.
  1203. X                                         .
  1204. X
  1205. X   2 RET 40        Z ( RET k b TAB     RET r 1 TAB ^      * /
  1206. X
  1207. @end smallexample
  1208. @end group
  1209. @noindent
  1210. @group
  1211. @smallexample
  1212. 3:  -0.5749       3:  -0.5772      2:  -0.5772     1:  -0.577215664892
  1213. 2:  -0.5749       2:  -0.5772      1:  0               .
  1214. 1:  2.3148e-3     1:  -0.5749          .
  1215. X    .                 .
  1216. X
  1217. X  TAB RET M-TAB       - RET M-TAB      a =     Z /    2  Z )  Z ' C-x )
  1218. @end smallexample
  1219. @end group
  1220. X
  1221. This is the value of @c{$-\gamma$}
  1222. @cite{- gamma}, with a slight bit of roundoff error.
  1223. To get a full 12 digits, let's use a higher precision:
  1224. X
  1225. @group
  1226. @smallexample
  1227. 2:  -0.577215664892      2:  -0.577215664892
  1228. 1:  1.                   1:  -0.577215664901532
  1229. X
  1230. X    1. RET                   p 16 RET X
  1231. @end smallexample
  1232. @end group
  1233. X
  1234. Here's the complete sequence of keystrokes:
  1235. X
  1236. @group
  1237. @example
  1238. C-x ( Z `  s 1  0 t 2
  1239. X           RET 5 a <  Z [  5 Z (  & s + 2  1 s + 1  1 Z ) r 1  Z ]
  1240. X           L r 1 2 * & - r 2 -
  1241. X           2 RET 40  Z (  RET k b TAB RET r 1 TAB ^ * /
  1242. X                          TAB RET M-TAB - RET M-TAB a = Z /
  1243. X                  2  Z )
  1244. X      Z '
  1245. C-x )
  1246. @end example
  1247. @end group
  1248. X
  1249. @node Programming Answer 10, Programming Answer 11, Programming Answer 9, Answers to Exercises
  1250. @subsection Programming Tutorial Exercise 10
  1251. X
  1252. @noindent
  1253. Taking the derivative of a term of the form @cite{x^n} will produce
  1254. a term like @c{$n x^{n-1}$}
  1255. @cite{n x^(n-1)}.  Taking the derivative of a constant
  1256. produces zero.  From this it is easy to see that the @cite{n}th
  1257. derivative of a polynomial, evaluated at @cite{x = 0}, will equal the
  1258. coefficient on the @cite{x^n} term times @cite{n!}.
  1259. X
  1260. (Because this definition is long, it will be repeated in concise form
  1261. below.  You can use @w{@kbd{M-# m}} to load it from there.  While you are
  1262. entering a @kbd{Z ` Z '} body in a macro, Calc simply collects
  1263. keystrokes without executing them.  In the following diagrams we'll
  1264. pretend Calc actually executed the keystrokes as you typed them,
  1265. just for purposes of illustration.)
  1266. X
  1267. @group
  1268. @smallexample
  1269. 2:  5 x^4 + (x + 1)^2          3:  5 x^4 + (x + 1)^2
  1270. 1:  6                          2:  0
  1271. X    .                          1:  6
  1272. X                                   .
  1273. X
  1274. X  ' 5 x^4 + (x+1)^2 RET 6        C-x ( Z `  [ ] t 1  0 TAB
  1275. @end smallexample
  1276. @end group
  1277. X
  1278. @noindent
  1279. Variable 1 will accumulate the vector of coefficients.
  1280. X
  1281. @group
  1282. @smallexample
  1283. 2:  0              3:  0                  2:  5 x^4 + ...
  1284. 1:  5 x^4 + ...    2:  5 x^4 + ...        1:  1
  1285. X    .              1:  1                      .
  1286. X                       .
  1287. X
  1288. X   Z ( TAB         RET 0 s l x RET            M-TAB ! /  s | 1
  1289. @end smallexample
  1290. @end group
  1291. X
  1292. @noindent
  1293. Note that @kbd{s | 1} appends the top-of-stack value to the vector
  1294. in a variable; it is completely analogous to @kbd{s + 1}.  We could
  1295. have written instead, @kbd{r 1 TAB | t 1}.
  1296. X
  1297. @group
  1298. @smallexample
  1299. 1:  20 x^3 + 2 x + 2      1:  0         1:  [1, 2, 1, 0, 5, 0, 0]
  1300. X    .                         .             .
  1301. X
  1302. X    a d x RET                 1 Z )         DEL r 1  Z ' C-x )
  1303. @end smallexample
  1304. @end group
  1305. X
  1306. To convert back, a simple method is just to map the coefficients
  1307. against a table of powers of @cite{x}.
  1308. X
  1309. @group
  1310. @smallexample
  1311. 2:  [1, 2, 1, 0, 5, 0, 0]    2:  [1, 2, 1, 0, 5, 0, 0]
  1312. 1:  6                        1:  [0, 1, 2, 3, 4, 5, 6]
  1313. X    .                            .
  1314. X
  1315. X    6 RET                        1 + 0 RET 1 C-u v x
  1316. X
  1317. @end smallexample
  1318. @end group
  1319. @noindent
  1320. @group
  1321. @smallexample
  1322. 2:  [1, 2, 1, 0, 5, 0, 0]    2:  1 + 2 x + x^2 + 5 x^4
  1323. 1:  [1, x, x^2, x^3, ... ]       .
  1324. X    .
  1325. X
  1326. X    ' x RET TAB V M ^            *
  1327. @end smallexample
  1328. @end group
  1329. X
  1330. Once again, here are the whole polynomial to/from vector programs:
  1331. X
  1332. @group
  1333. @example
  1334. C-x ( Z `  [ ] t 1  0 TAB
  1335. X           Z (  TAB RET 0 s l x RET M-TAB ! /  s | 1
  1336. X                a d x RET
  1337. X         1 Z ) r 1
  1338. X      Z '
  1339. C-x )
  1340. X
  1341. C-x (  1 + 0 RET 1 C-u v x ' x RET TAB V M ^ *  C-x )
  1342. @end example
  1343. @end group
  1344. X
  1345. @node Programming Answer 11, Programming Answer 12, Programming Answer 10, Answers to Exercises
  1346. @subsection Programming Tutorial Exercise 11
  1347. X
  1348. @noindent
  1349. First we define a dummy program to go on the @kbd{z s} key.  The true
  1350. @w{@kbd{z s}} key is supposed to take two numbers from the stack and
  1351. return one number, so @kbd{DEL} as a dummy definition will make
  1352. sure the stack comes out right.
  1353. X
  1354. @group
  1355. @smallexample
  1356. 2:  4          1:  4                         2:  4
  1357. 1:  2              .                         1:  2
  1358. X    .                                            .
  1359. X
  1360. X  4 RET 2       C-x ( DEL C-x )  Z K s RET       2
  1361. @end smallexample
  1362. @end group
  1363. X
  1364. The last step replaces the 2 that was eaten during the creation
  1365. of the dummy @kbd{z s} command.  Now we move on to the real
  1366. definition.  The recurrence needs to be rewritten slightly,
  1367. to the form @cite{s(n,m) = s(n-1,m-1) - (n-1) s(n-1,m)}.
  1368. X
  1369. (Because this definition is long, it will be repeated in concise form
  1370. below.  You can use @kbd{M-# m} to load it from there.)
  1371. X
  1372. @group
  1373. @smallexample
  1374. 2:  4        4:  4       3:  4       2:  4
  1375. 1:  2        3:  2       2:  2       1:  2
  1376. X    .        2:  4       1:  0           .
  1377. X             1:  2           .
  1378. X                 .
  1379. X
  1380. X  C-x (       M-2 RET        a =         Z [  DEL DEL 1  Z :
  1381. X
  1382. @end smallexample
  1383. @end group
  1384. @noindent
  1385. @group
  1386. @smallexample
  1387. 4:  4       2:  4                     2:  3      4:  3    4:  3    3:  3
  1388. 3:  2       1:  2                     1:  2      3:  2    3:  2    2:  2
  1389. 2:  2           .                         .      2:  3    2:  3    1:  3
  1390. 1:  0                                            1:  2    1:  1        .
  1391. X    .                                                .        .
  1392. X
  1393. X  RET 0   a = Z [  DEL DEL 0  Z :  TAB 1 - TAB   M-2 RET     1 -      z s
  1394. @end smallexample
  1395. @end group
  1396. X
  1397. @noindent
  1398. (Note that the value 3 that our dummy @kbd{z s} produces is not correct;
  1399. it is merely a placeholder that will do just as well for now.)
  1400. X
  1401. @group
  1402. @smallexample
  1403. 3:  3               4:  3           3:  3       2:  3      1:  -6
  1404. 2:  3               3:  3           2:  3       1:  9          .
  1405. 1:  2               2:  3           1:  3           .
  1406. X    .               1:  2               .
  1407. X                        .
  1408. X
  1409. X M-TAB M-TAB     TAB RET M-TAB         z s          *          -
  1410. X
  1411. @end smallexample
  1412. @end group
  1413. @noindent
  1414. @group
  1415. @smallexample
  1416. 1:  -6                          2:  4          1:  11      2:  11
  1417. X    .                           1:  2              .       1:  11
  1418. X                                    .                          .
  1419. X
  1420. X  Z ] Z ] C-x )   Z K s RET      DEL 4 RET 2       z s      M-RET k s
  1421. @end smallexample
  1422. @end group
  1423. X
  1424. Even though the result that we got during the definition was highly
  1425. bogus, once the definition is complete the @kbd{z s} command gets
  1426. the right answers.
  1427. X
  1428. Here's the full program once again:
  1429. X
  1430. @group
  1431. @example
  1432. C-x (  M-2 RET a =
  1433. X       Z [  DEL DEL 1
  1434. X       Z :  RET 0 a =
  1435. X            Z [  DEL DEL 0
  1436. X            Z :  TAB 1 - TAB M-2 RET 1 - z s
  1437. X                 M-TAB M-TAB TAB RET M-TAB z s * -
  1438. X            Z ]
  1439. X       Z ]
  1440. C-x )
  1441. @end example
  1442. @end group
  1443. X
  1444. You can read this definition using @kbd{M-# m} (@code{read-kbd-macro})
  1445. followed by @kbd{Z K s}, without having to make a dummy definition
  1446. first, because @code{read-kbd-macro} doesn't need to execute the
  1447. definition as it reads it in.  For this reason, @code{M-# m} is often
  1448. the easiest way to create recursive programs in Calc.
  1449. X
  1450. @node Programming Answer 12, , Programming Answer 11, Answers to Exercises
  1451. @subsection Programming Tutorial Exercise 12
  1452. X
  1453. @noindent
  1454. This turns out to be a much easier way to solve the problem.  Let's
  1455. denote Stirling numbers as calls of the function @samp{s}.
  1456. X
  1457. First, we store the rewrite rules corresponding to the definition of
  1458. Stirling numbers in a convenient variable:
  1459. X
  1460. @smallexample
  1461. s e StirlingRules RET
  1462. [ s(n,n) := 1  :: n >= 0,
  1463. X  s(n,0) := 0  :: n > 0,
  1464. X  s(n,m) := s(n-1,m-1) - (n-1) s(n-1,m) :: n >= m :: m >= 1 ]
  1465. C-c C-c
  1466. @end smallexample
  1467. X
  1468. Now, it's just a matter of applying the rules:
  1469. X
  1470. @group
  1471. @smallexample
  1472. 2:  4          1:  s(4, 2)              1:  11
  1473. 1:  2              .                        .
  1474. X    .
  1475. X
  1476. X  4 RET 2       C-x (  ' s($$,$) RET     a r StirlingRules RET  C-x )
  1477. @end smallexample
  1478. @end group
  1479. X
  1480. As in the case of the @code{fib} rules, it would be useful to put these
  1481. rules in @code{EvalRules} and to add a @samp{:: remember} condition to
  1482. the last rule.
  1483. X
  1484. @c This ends the table-of-contents kludge from above:
  1485. @tex
  1486. \global\let\chapternofonts=\oldchapternofonts
  1487. @end tex
  1488. X
  1489. @c [reference]
  1490. X
  1491. @node Introduction, Data Types, Tutorial, Top
  1492. @chapter Introduction
  1493. X
  1494. @noindent
  1495. This chapter is the beginning of the Calc reference manual.
  1496. It covers basic concepts such as the stack, algebraic and
  1497. numeric entry, undo, numeric prefix arguments, etc.
  1498. X
  1499. @c [when-split]
  1500. @c (Chapter 2, the Tutorial, has been printed in a separate volume.)
  1501. X
  1502. @menu
  1503. * Basic Commands::
  1504. * Help Commands::
  1505. * Stack Basics::
  1506. * Numeric Entry::
  1507. * Algebraic Entry::
  1508. * Quick Calculator::
  1509. * Keypad Mode::
  1510. * Prefix Arguments::
  1511. * Undo::
  1512. * Error Messages::
  1513. * Multiple Calculators::
  1514. * Troubleshooting Commands::
  1515. @end menu
  1516. X
  1517. @node Basic Commands, Help Commands, Introduction, Introduction
  1518. @section Basic Commands
  1519. X
  1520. @noindent
  1521. @pindex calc
  1522. @pindex calc-mode
  1523. @cindex Starting the Calculator
  1524. @cindex Running the Calculator
  1525. To start the Calculator in its standard interface, type @kbd{M-x calc}.
  1526. By default this creates a pair of small windows, @samp{*Calculator*}
  1527. and @samp{*Calc Trail*}.  The former displays the contents of the
  1528. Calculator stack and is manipulated exclusively through Calc commands.
  1529. It is possible (though not usually necessary) to create several Calc
  1530. Mode buffers each of which has an independent stack, undo list, and
  1531. mode settings.  There is exactly one Calc Trail buffer; it records a
  1532. list of the results of all calculations that have been done.  The
  1533. Calc Trail buffer uses a variant of Calc Mode, so Calculator commands
  1534. still work when the trail buffer's window is selected.  It is possible
  1535. to turn the trail window off, but the @samp{*Calc Trail*} buffer still
  1536. exists and is updated silently.  @xref{Trail Commands}.@refill
  1537. X
  1538. @kindex M-# M-#
  1539. @kindex M-# #
  1540. @kindex M-# c
  1541. In most installations, the @kbd{M-#} (Meta-Shift-3) keystroke is a more
  1542. convenient way to start the Calculator.  If you don't have a Meta key,
  1543. press @key{ESC}, then @kbd{#}.  Follow @kbd{M-#} with a letter key
  1544. that says which Calc interface or function you desire.  @kbd{M-# c}
  1545. is equivalent to @kbd{M-x calc}.  @kbd{M-# M-#} or @kbd{M-# #} is
  1546. also generally equivalent to @kbd{M-x calc}.  @xref{Other M-# Commands}.
  1547. X
  1548. @kindex x
  1549. @kindex M-x
  1550. @pindex calc-execute-extended-command
  1551. Most Calc commands use one or two keystrokes.  Lower- and upper-case
  1552. letters are distinct.  Commands may also be entered in @kbd{M-x} form;
  1553. for some commands this is the only form.  As a convenience, the @kbd{x}
  1554. key (@code{calc-execute-extended-command})
  1555. is like @kbd{M-x} except that it enters the initial string @samp{calc-}
  1556. for you.  For example, the following key sequences are equivalent:
  1557. @kbd{S}, @kbd{M-x calc-sin @key{RET}}, @kbd{x sin @key{RET}}.@refill
  1558. X
  1559. @cindex Extensions module
  1560. @cindex @file{calc-ext} module
  1561. The Calculator exists in many parts.  When you type @kbd{M-x calc}, the
  1562. Emacs ``auto-load'' mechanism will bring in only the first part, which
  1563. contains the basic arithmetic functions.  The other parts will be
  1564. auto-loaded the first time you use the more advanced commands like trig
  1565. functions or matrix operations.  This is done to improve the response time
  1566. of the Calculator in the common case when all you need to do is a
  1567. little arithmetic.  If for some reason the Calculator fails to load an
  1568. extension module automatically, you can force it to load all the
  1569. extensions by using the @kbd{m X} or @kbd{M-# L}
  1570. (@code{calc-load-everything}) command.
  1571. @xref{Mode Settings}.@refill
  1572. X
  1573. If you type @kbd{M-x calc} or @kbd{M-# c} with any numeric prefix argument,
  1574. the Calculator is loaded if necessary, but it is not actually started.
  1575. If the argument is positive, the extensions are also loaded if necessary.
  1576. User-written Lisp code that wishes to make use of Calc's arithmetic
  1577. routines can use @samp{(calc 0)} or @samp{(calc 1)} to auto-load the
  1578. Calculator.@refill
  1579. X
  1580. @kindex M-# b
  1581. @pindex full-calc
  1582. If you type @kbd{M-# b}, then next time you use @kbd{M-# c} you
  1583. will get a Calculator that uses the full height of the Emacs screen.
  1584. When full-screen mode is on, @kbd{M-# c} runs the @code{full-calc}
  1585. command instead of @code{calc}.  From the Unix shell you can type
  1586. @samp{emacs -f full-calc} to start a new Emacs specifically for use
  1587. as a calculator.  When Calc is started from the Emacs command line
  1588. like this, Calc's normal ``quit'' commands actually quit Emacs itself.
  1589. X
  1590. @kindex M-# o
  1591. @pindex calc-other-window
  1592. The @kbd{M-# o} command is like @kbd{M-# c} except that the Calc
  1593. window is not actually selected.  If you are already in the Calc
  1594. window, @kbd{M-# o} switches you out of it.  (The regular Emacs
  1595. @kbd{C-x o} command would also work for this, but it has a
  1596. tendency to drop you into the Calc Trail window instead, which
  1597. @kbd{M-# o} takes care not to do.)
  1598. X
  1599. For one quick calculation, you can type @kbd{M-# q} (@code{quick-calc})
  1600. which prompts you for a formula (like @samp{2+3/4}).  The result is
  1601. displayed at the bottom of the Emacs screen without ever creating
  1602. any special Calculator windows.  @xref{Quick Calculator}.
  1603. X
  1604. Finally, if you are using the X window system you may want to try
  1605. @kbd{M-# k} (@code{calc-keypad}) which runs Calc with a
  1606. ``calculator keypad'' picture as well as a stack display.  Click on
  1607. the keys with the mouse to operate the calculator.  @xref{Keypad Mode}.
  1608. X
  1609. @kindex q
  1610. @pindex calc-quit
  1611. @cindex Quitting the Calculator
  1612. @cindex Exiting the Calculator
  1613. The @kbd{q} key (@code{calc-quit}) exits Calc Mode and closes the
  1614. Calculator's window(s).  It does not delete the Calculator buffers.
  1615. If you type @kbd{M-x calc} again, the Calculator will reappear with the
  1616. contents of the stack intact.  Typing @kbd{M-# c} or @kbd{M-# M-#}
  1617. again from inside the Calculator buffer is equivalent to executing
  1618. @code{calc-quit}; you can think of @kbd{M-# M-#} as toggling the
  1619. Calculator on and off.@refill
  1620. X
  1621. @kindex M-# x
  1622. The @kbd{M-# x} key also turns the Calculator off, no matter which
  1623. user interface (standard, Keypad, or Embedded) is current active.
  1624. It also cancels @code{calc-edit} mode if used from there.
  1625. X
  1626. @kindex d SPC
  1627. @kindex d ~
  1628. @pindex calc-refresh
  1629. @cindex Refreshing a garbled display
  1630. @cindex Garbled displays, refreshing
  1631. The @kbd{d SPC} key sequence (@code{calc-refresh}) redraws the contents
  1632. of the Calculator buffer from memory.  Use this if the contents of the
  1633. buffer have been damaged somehow.  The @kbd{d ~} key is also bound to
  1634. @code{calc-refresh}.
  1635. X
  1636. The @kbd{o} key (@code{calc-realign}) moves the cursor back to its
  1637. ``home'' position at the bottom of the Calculator buffer.
  1638. X
  1639. @kindex <
  1640. @kindex >
  1641. @pindex calc-scroll-left
  1642. @pindex calc-scroll-right
  1643. @cindex Horizontal scrolling
  1644. @cindex Scrolling
  1645. @cindex Wide text, scrolling
  1646. The @kbd{<} and @kbd{>} keys are bound to @code{calc-scroll-left} and
  1647. @code{calc-scroll-right}.  These are just like the normal horizontal
  1648. scrolling commands except that they scroll one half-screen at a time by
  1649. default.  (Calc formats its output to fit within the bounds of the
  1650. window whenever it can.)@refill
  1651. X
  1652. @kindex @{
  1653. @kindex @}
  1654. @pindex calc-scroll-down
  1655. @pindex calc-scroll-up
  1656. @cindex Vertical scrolling
  1657. The @kbd{@{} and @kbd{@}} keys are bound to @code{calc-scroll-down}
  1658. and @code{calc-scroll-up}.  They scroll up or down by one-half the
  1659. height of the Calc window.@refill
  1660. X
  1661. @pindex calc-version
  1662. The @code{calc-version} command displays the current version number
  1663. of Calc and the name of the person who installed it on your system.
  1664. (This information is also present in the @samp{*Calc Trail*} buffer,
  1665. and in the output of the @kbd{h h} command.)
  1666. X
  1667. @node Help Commands, Stack Basics, Basic Commands, Introduction
  1668. @section Help Commands
  1669. X
  1670. @noindent
  1671. @cindex Help commands
  1672. @kindex ?
  1673. @pindex calc-help
  1674. The @kbd{?} key (@code{calc-help}) displays a series of brief help messages.
  1675. Some keys (such as @kbd{b} and @kbd{d}) are prefix keys, like Emacs'
  1676. @key{ESC} and @kbd{C-x} prefixes.  You can type
  1677. @kbd{?} after a prefix to see a list of commands beginning with that
  1678. prefix.  (If the message includes @samp{[MORE]}, press @kbd{?} again
  1679. to see additional commands for that prefix.)
  1680. X
  1681. @kindex h h
  1682. @pindex calc-full-help
  1683. The @kbd{h h} (@code{calc-full-help}) command displays all the @kbd{?}
  1684. responses at once.  When printed, this makes a nice, compact (three pages)
  1685. summary of Calc keystrokes.
  1686. X
  1687. In general, the @kbd{h} key prefix introduces various commands that
  1688. provide help within Calc.  Many of the @kbd{h} key functions are
  1689. Calc-specific analogues to the @kbd{C-h} functions for Emacs help.
  1690. X
  1691. @kindex h i
  1692. @kindex M-# i
  1693. @kindex i
  1694. @pindex calc-info
  1695. The @kbd{h i} (@code{calc-info}) command runs the Emacs Info system
  1696. to read this manual on-line.  This is basically the same as typing
  1697. @kbd{C-h i} (the regular way to run the Info system), then, if Info
  1698. is not already in the Calc manual, selecting the beginning of the
  1699. manual.  The @kbd{M-# i} command is another way to read the Calc
  1700. manual; it is different from @kbd{h i} in that it works any time,
  1701. not just inside Calc.  The plain @kbd{i} key is also equivalent to
  1702. @kbd{h i}, though this key is obsolete and may be replaced with a
  1703. different command in a future version of Calc.
  1704. X
  1705. @kindex h t
  1706. @kindex M-# t
  1707. @pindex calc-tutorial
  1708. The @kbd{h t} (@code{calc-tutorial}) command runs the Info system on
  1709. the Tutorial section of the Calc manual.  It is like @kbd{h i},
  1710. except that it selects the starting node of the tutorial rather
  1711. than the beginning of the whole manual.  (It actually selects the
  1712. node @samp{Interactive Tutorial} which tells a few things about
  1713. using the Info system before going on to the actual tutorial.)
  1714. The @kbd{M-# t} key is equivalent to @kbd{h t} (but it works at
  1715. all times).
  1716. X
  1717. @kindex h s
  1718. @kindex M-# s
  1719. @pindex calc-info-summary
  1720. The @kbd{h s} (@code{calc-info-summary}) command runs the Info system
  1721. on the Summary node of the Calc manual.  @xref{Summary}.  The @kbd{M-# s}
  1722. key is equivalent to @kbd{h s}.
  1723. X
  1724. @kindex h k
  1725. @pindex calc-describe-key
  1726. The @kbd{h k} (@code{calc-describe-key}) command looks up a key
  1727. sequence in the Calc manual.  For example, @kbd{h k H a S} looks
  1728. up the documentation on the @kbd{H a S} (@code{calc-solve-for})
  1729. command.  This works by looking up the textual description of
  1730. the keys you press in the @samp{Key Index} of the manual, then
  1731. jumping to the node indicated by the index.
  1732. X
  1733. Most Calc commands do not have traditional Emacs documentation
  1734. strings, since the @kbd{h k} command is both more convenient and
  1735. more instructive.  This means the regular Emacs @kbd{C-h k}
  1736. (@code{describe-key}) command will not be useful for Calc keystrokes.
  1737. SHAR_EOF
  1738. true || echo 'restore of calc.texinfo failed'
  1739. fi
  1740. echo 'End of  part 36'
  1741. echo 'File calc.texinfo is continued in part 37'
  1742. echo 37 > _shar_seq_.tmp
  1743. exit 0
  1744. exit 0 # Just in case...
  1745. -- 
  1746. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  1747. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  1748. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  1749. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  1750.