home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume15 / calc-1.05 / part16 < prev    next >
Text File  |  1990-10-14  |  57KB  |  1,219 lines

  1. Newsgroups: comp.sources.misc
  2. X-UNIX-From: daveg@csvax.cs.caltech.edu
  3. subject: v15i043: Patch for GNU Emacs Calc, version 1.04 -> 1.05, part 16/20
  4. from: daveg@csvax.cs.caltech.edu (David Gillespie)
  5. Sender: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  6.  
  7. Posting-number: Volume 15, Issue 43
  8. Submitted-by: daveg@csvax.cs.caltech.edu (David Gillespie)
  9. Archive-name: calc-1.05/part16
  10.  
  11. #!/bin/sh
  12. # this is part 16 of a multipart archive
  13. # do not concatenate these parts, unpack them in order with /bin/sh
  14. # file calc.patch continued
  15. #
  16. CurArch=16
  17. if test ! -r s2_seq_.tmp
  18. then echo "Please unpack part 1 first!"
  19.      exit 1; fi
  20. ( read Scheck
  21.   if test "$Scheck" != $CurArch
  22.   then echo "Please unpack part $Scheck next!"
  23.        exit 1;
  24.   else exit 0; fi
  25. ) < s2_seq_.tmp || exit 1
  26. sed 's/^X//' << 'SHAR_EOF' >> calc.patch
  27. X+ form @kbd{k @var{X}} (@code{calc-utp@var{x}}) [@code{utp@var{x}}]
  28. X+ and @kbd{I k @var{X}} [@code{ltp@var{x}}], for various letters
  29. X+ @var{x}.  The arguments to the algebraic functions are the value of
  30. X+ the random variable first, then whatever other parameters define the
  31. X+ distribution.  Note these are among the few Calc functions where the
  32. X+ order of the arguments in algebraic form differs from the order of
  33. X+ arguments as found on the stack.  (The random variable comes last on
  34. X+ the stack, so that you can type, e.g., @kbd{2 @key{RET} 1 @key{RET} 2.5
  35. X+ k N X @key{DEL} 2.8 k N -}, using @kbd{X @key{DEL}} to recover the
  36. X+ original arguments but substitute a new value for @samp{x}.)
  37. X+ 
  38. X+ @kindex k C
  39. X+ @pindex calc-utpc
  40. X+ @tindex utpc
  41. X+ @tindex ltpc
  42. X+ The @samp{utpc(x,v)} function uses the chi-square distribution with
  43. X+ @samp{v} degrees of freedom.  It is the probability that a model is
  44. X+ correct if its chi-square statistic is @samp{x}.
  45. X+ 
  46. X+ @kindex k F
  47. X+ @pindex calc-utpf
  48. X+ @tindex utpf
  49. X+ @tindex ltpf
  50. X+ The @samp{utpf(F,v1,v2)} function uses the F distribution, used in
  51. X+ various statistical tests.  The parameters @samp{v1} and @samp{v2}
  52. X+ are the degrees of freedom in the numerator and denominator,
  53. X+ respectively, used in computing the statistic @samp{F}.
  54. X+ 
  55. X+ @kindex k N
  56. X+ @pindex calc-utpn
  57. X+ @tindex utpn
  58. X+ @tindex ltpn
  59. X+ The @samp{utpn(x,m,s)} function uses a normal (Gaussian) distribution
  60. X+ with mean @samp{m} and standard deviation @samp{s}.  It is the
  61. X+ probability that such a normal-distributed random variable would
  62. X+ exceed @samp{x}.
  63. X+ 
  64. X+ @kindex k P
  65. X+ @pindex calc-utpp
  66. X+ @tindex utpp
  67. X+ @tindex ltpp
  68. X+ The @samp{utpp(n,x)} function uses a Poisson distribution with
  69. X+ mean @samp{x}.  It is the probability that @samp{n} or more such
  70. X+ Poisson random events will occur.
  71. X+ 
  72. X+ @kindex k T
  73. X+ @pindex calc-ltpt
  74. X+ @tindex utpt
  75. X+ @tindex ltpt
  76. X+ The @samp{utpt(t,v)} function uses the Student's ``t'' distribution
  77. X+ with @samp{v} degrees of freedom.  It is the probability that a
  78. X+ t-distributed random variable will be greater than @samp{t}.
  79. X+ (Note:  This computes the distribution function @samp{A(t|v)}
  80. X+ where @samp{A(0|v) = 1} and @samp{A(infinity|v) -> 0}.  The
  81. X+ @code{UTPT} operation on the HP-48 uses a different definition
  82. X+ which returns half of Calc's value:  @samp{UTPT(t,v) = .5*utpt(t,v)}.)
  83. X+ 
  84. X  @node Binary Functions, Matrix Functions, Scientific Functions, Top
  85. X  @chapter Binary Number Functions
  86. X  
  87. X***************
  88. X*** 6550,6556 ****
  89. X  numeric prefix argument, the number is rotated the specified number of
  90. X  bits to the left or right.
  91. X  
  92. X! @node Matrix Functions, Algebra, Binary Functions, Top
  93. X  @chapter Vector and Matrix Functions
  94. X  
  95. X  Many of the commands described here begin with the @kbd{v} prefix.
  96. X--- 9535,9541 ----
  97. X  numeric prefix argument, the number is rotated the specified number of
  98. X  bits to the left or right.
  99. X  
  100. X! @node Matrix Functions, Graphics, Binary Functions, Top
  101. X  @chapter Vector and Matrix Functions
  102. X  
  103. X  Many of the commands described here begin with the @kbd{v} prefix.
  104. X***************
  105. X*** 6562,6567 ****
  106. X--- 9547,9553 ----
  107. X  @menu
  108. X  * Building Vectors::
  109. X  * Extracting Elements::
  110. X+ * Manipulating Vectors::
  111. X  * Vector and Matrix Arithmetic::
  112. X  * Reducing and Mapping::
  113. X  * Vector and Matrix Formats::
  114. X***************
  115. X*** 6641,6647 ****
  116. X  @pindex calc-ident
  117. X  The @kbd{v i} (@code{calc-ident}) function builds an identity matrix of
  118. X  the specified size.  It is a convenient form of @code{calc-diag} where the
  119. X! diagonal element is always one.
  120. X  
  121. X  @kindex v x
  122. X  @pindex calc-index
  123. X--- 9627,9634 ----
  124. X  @pindex calc-ident
  125. X  The @kbd{v i} (@code{calc-ident}) function builds an identity matrix of
  126. X  the specified size.  It is a convenient form of @code{calc-diag} where the
  127. X! diagonal element is always one.  If no prefix argument is given, this
  128. X! command prompts for one.
  129. X  
  130. X  @kindex v x
  131. X  @pindex calc-index
  132. X***************
  133. X*** 6649,6656 ****
  134. X  The @kbd{v x} (@code{calc-index}) [@code{index}] function builds a vector
  135. X  of consecutive integers from 1 to @var{n}, where @var{n} is the numeric
  136. X  prefix argument.  If you do not provide a prefix argument, you will be
  137. X! prompted to enter a suitable number.
  138. X  
  139. X  @kindex v b
  140. X  @pindex calc-build-vector
  141. X  @tindex cvec
  142. X--- 9636,9659 ----
  143. X  The @kbd{v x} (@code{calc-index}) [@code{index}] function builds a vector
  144. X  of consecutive integers from 1 to @var{n}, where @var{n} is the numeric
  145. X  prefix argument.  If you do not provide a prefix argument, you will be
  146. X! prompted to enter a suitable number.  If @var{n} is negative, the result
  147. X! is a vector of negative integers from @var{n} to -1.
  148. X  
  149. X+ With a prefix argument of just @kbd{C-u}, the @kbd{v x} command takes
  150. X+ three values from the stack: @var{n}, @var{start}, and @var{incr} (with
  151. X+ @var{incr} at top-of-stack).  Counting starts at @var{start} and increases
  152. X+ by @var{incr} for successive vector elements.  If @var{start} or @var{n}
  153. X+ is in floating-point format, the resulting vector elements will also be
  154. X+ floats.  Note that @var{start} and @var{incr} may in fact be any kind
  155. X+ of numbers or formulas.
  156. X+ 
  157. X+ When @var{start} and @var{incr} are specified, a negative @var{n} has a
  158. X+ different interpretation:  It causes a geometric instead of arithmetic
  159. X+ sequence to be generated.  For example, @samp{index(-3, a, b)} produces
  160. X+ @samp{[a, a b, a b^2]}.  If you omit @var{incr} in the algebraic form,
  161. X+ @samp{index(@var{n}, @var{start})}, the default value for @var{incr}
  162. X+ is one for positive @var{n} or two for negative @var{n}.
  163. X+ 
  164. X  @kindex v b
  165. X  @pindex calc-build-vector
  166. X  @tindex cvec
  167. X***************
  168. X*** 6658,6718 ****
  169. X  vector of @var{n} copies of the value on the top of the stack, where @var{n}
  170. X  is the numeric prefix argument.  In algebraic formulas, @samp{cvec(x,n,m)}
  171. X  can also be used to build an @var{n}-by-@var{m} matrix of copies of @var{x}.
  172. X! 
  173. X! @kindex v a
  174. X! @pindex calc-arrange-vector
  175. X! @tindex arrange
  176. X! @cindex Arranging a matrix
  177. X! @cindex Reshaping a matrix
  178. X! @cindex Flattening a matrix
  179. X! The @kbd{v a} (@code{calc-arrange-vector}) [@code{arrange}] function
  180. X! rearranges a vector to have a certain number of columns and rows.  The
  181. X! numeric prefix argument specifies the number of columns; if you do not
  182. X! provide an argument, you will be prompted for the number of columns.
  183. X! The vector or matrix on the top of the stack is @dfn{flattened} into a
  184. X! plain vector.  If the number of columns is nonzero, this vector is
  185. X! then formed into a matrix by taking successive groups of @var{n} elements.
  186. X! If the number of columns does not evenly divide the number of elements
  187. X! in the vector, the last row will be short and the result will not be
  188. X! suitable for use as a matrix.  For example, with the matrix
  189. X! @samp{[[1, 2], [3, 4]]} on the stack, @kbd{v a 4} produces
  190. X! @samp{[[1, 2, 3, 4]]} (a 1x4 matrix), @kbd{v a 1} produces
  191. X! @samp{[[1], [2], [3], [4]]} (a 4x1 matrix), @kbd{v a 2} produces
  192. X! @samp{[[1, 2], [3, 4]]} (the original 2x2 matrix), @kbd{v a 3} produces
  193. X! @samp{[[1, 2, 3], [4]]} (not a matrix), and @kbd{v a 0} produces
  194. X! the flattened list @samp{[1, 2, 3, 4]}.
  195. X! 
  196. X! @kindex v s
  197. X! @kindex I v s
  198. X! @pindex calc-sort
  199. X! @tindex sort
  200. X! @tindex rsort
  201. X! The @kbd{v s} (@code{calc-sort}) [@code{sort}] function sorts the elements of
  202. X! a vector into increasing order.  Non-real vector elements are sorted
  203. X! according to a kind of lexicographic ordering.  The @kbd{I v s} [@code{rsort}]
  204. X! function sorts a vector into decreasing order.
  205. X! 
  206. X! @kindex v h
  207. X! @pindex calc-histogram
  208. X! The @kbd{v h} (@code{calc-histogram}) [@code{histogram}] function builds a
  209. X! histogram of a vector of numbers.  Vector elements are assumed to be
  210. X! integers or real numbers in the range [0..@var{n}) for some ``number of
  211. X! bins'' @var{n}, which is the numeric prefix argument given to the
  212. X! command.  The result is a vector of @var{n} counts of how many times
  213. X! each value appeared in the original vector.  Non-integers in the input
  214. X! are rounded down to integers.  Any vector elements outside the specified
  215. X! range are ignored.  (You can tell if elements have been ignored by checking
  216. X! that the elements in the result vector add up to the length of the input
  217. X! vector.)
  218. X  
  219. X! With the Hyperbolic flag, @kbd{v h} pulls two vectors from the stack.
  220. X! The second-to-top vector is the list of numbers as before.  The top
  221. X! vector is an equal-sized list of ``weights'' to attach to the elements
  222. X! of the data vector.  For example, if the first data element is 4.2 and
  223. X! the first weight is 10, then 10 will be added to bin 4 of the result
  224. X! vector.  Without the hyperbolic flag, every element has a weight of one.
  225. X  
  226. X! @node Extracting Elements, Vector and Matrix Arithmetic, Building Vectors, Matrix Functions
  227. X  @section Extracting Vector and Matrix Elements
  228. X  
  229. X  @kindex v r
  230. X--- 9661,9687 ----
  231. X  vector of @var{n} copies of the value on the top of the stack, where @var{n}
  232. X  is the numeric prefix argument.  In algebraic formulas, @samp{cvec(x,n,m)}
  233. X  can also be used to build an @var{n}-by-@var{m} matrix of copies of @var{x}.
  234. X! (Interactively, just use @kbd{v b} twice: once to build a row, then again
  235. X! to build a matrix of copies of that row.)
  236. X  
  237. X! @pindex calc-head
  238. X! @pindex caic-tail
  239. X! @tindex head
  240. X! @tindex tail
  241. X! The @code{calc-head} [@code{head}] function returns the first element
  242. X! of a vector.  The @code{calc-tail} [@code{tail}] function returns the
  243. X! vector with its first element removed.  In both cases, the argument
  244. X! must be a non-empty vector.
  245. X! 
  246. X! @pindex calc-cons
  247. X! @tindex cons
  248. X! The @code{calc-cons} [@code{cons}] function takes a value @var{h} and a
  249. X! vector @var{t} from the stack, and produces the vector whose head is
  250. X! @var{h} and whose tail is @var{t}.  This is similar to @kbd{|}, except
  251. X! if @var{h} is itself a vector, @kbd{|} will concatenate the two vectors
  252. X! whereas @code{cons} will insert @var{h} at the front of the vector @var{t}.
  253. X  
  254. X! @node Extracting Elements, Manipulating Vectors, Building Vectors, Matrix Functions
  255. X  @section Extracting Vector and Matrix Elements
  256. X  
  257. X  @kindex v r
  258. X***************
  259. X*** 6725,6730 ****
  260. X--- 9694,9711 ----
  261. X  The matrix or vector is replaced by the specified row or element in the
  262. X  form of a vector or scalar, respectively.
  263. X  
  264. X+ @cindex Permutations, applying
  265. X+ With a prefix argument of @kbd{C-u} only, @kbd{v r} takes the index of
  266. X+ the element or row from the top of the stack, and the vector or matrix
  267. X+ from the second-to-top position.  If the index is itself a vector of
  268. X+ integers, the result is a vector of the corresponding elements of the
  269. X+ input vector, or a matrix of the corresponding rows of the input matrix.
  270. X+ This command can be used to obtain any permutation of a vector.
  271. X+ 
  272. X+ With @kbd{C-u}, if the index is an interval form with integer components,
  273. X+ it is interpreted as a range of indices and the corresponding subvector or
  274. X+ submatrix is returned.
  275. X+ 
  276. X  @tindex mrrow
  277. X  Given a negative prefix argument, @kbd{v r} instead deletes one row or
  278. X  element from the matrix or vector on the top of the stack.  Thus
  279. X***************
  280. X*** 6749,6754 ****
  281. X--- 9730,9760 ----
  282. X  extract the row as a vector, then @kbd{v c} to extract the column element
  283. X  from that vector.
  284. X  
  285. X+ @kindex v s
  286. X+ @pindex calc-subvector
  287. X+ @tindex subvec
  288. X+ The @kbd{v s} (@code{calc-subvector}) [@code{subvec}] command extracts
  289. X+ a subvector of a vector.  The arguments are the vector, the starting
  290. X+ index, and the ending index, with the ending index in the top-of-stack
  291. X+ position.  The starting index indicates the first element of the vector
  292. X+ to take.  The ending index indicates the first element @emph{past} the
  293. X+ range to be taken.  Thus, @samp{subvec([a, b, c, d, e], 2, 4)} produces
  294. X+ the subvector @samp{[b, c]}.  You could get the same result using
  295. X+ @samp{mrow([a, b, c, d, e], [2 .. 4))}.
  296. X+ 
  297. X+ If either the start or the end index is zero or negative, it is
  298. X+ interpreted as relative to the end of the vector.  Thus
  299. X+ @samp{subvec([a, b, c, d, e], 2, -2)} also produces @samp{[b, c]}.  In
  300. X+ the algebraic form, the end index can be omitted in which case it
  301. X+ is taken as zero, i.e., elements from the starting element to the
  302. X+ end of the vector are used.
  303. X+ 
  304. X+ @xref{Selecting Subformulas}, for an alternative way to operate on
  305. X+ vectors one element at a time.
  306. X+ 
  307. X+ @node Manipulating Vectors, Vector and Matrix Arithmetic, Extracting Elements, Matrix Functions
  308. X+ @section Manipulating Vectors
  309. X+ 
  310. X  @kindex v l
  311. X  @pindex calc-vlength
  312. X  @tindex vlen
  313. X***************
  314. X*** 6757,6763 ****
  315. X  Note that matrices are just vectors of vectors for the purposes of this
  316. X  command.@refill
  317. X  
  318. X! @node Vector and Matrix Arithmetic, Reducing and Mapping, Extracting Elements, Matrix Functions
  319. X  @section Vector and Matrix Arithmetic
  320. X  
  321. X  Basic arithmetic operations like addition and multiplication are defined
  322. X--- 9763,9933 ----
  323. X  Note that matrices are just vectors of vectors for the purposes of this
  324. X  command.@refill
  325. X  
  326. X! @kindex v f
  327. X! @pindex calc-vector-find
  328. X! @tindex find
  329. X! The @kbd{v f} (@code{calc-vector-find}) [@code{find}] command searches
  330. X! along a vector for the first element equal to a given target.  The target
  331. X! is on the top of the stack; the vector is in the second-to-top position.
  332. X! If a match is found, the result is the index of the matching element.
  333. X! Otherwise, the result is zero.  The numeric prefix argument, if given,
  334. X! allows you to select any starting index for the search.
  335. X! 
  336. X! @kindex v a
  337. X! @pindex calc-arrange-vector
  338. X! @tindex arrange
  339. X! @cindex Arranging a matrix
  340. X! @cindex Reshaping a matrix
  341. X! @cindex Flattening a matrix
  342. X! The @kbd{v a} (@code{calc-arrange-vector}) [@code{arrange}] command
  343. X! rearranges a vector to have a certain number of columns and rows.  The
  344. X! numeric prefix argument specifies the number of columns; if you do not
  345. X! provide an argument, you will be prompted for the number of columns.
  346. X! The vector or matrix on the top of the stack is @dfn{flattened} into a
  347. X! plain vector.  If the number of columns is nonzero, this vector is
  348. X! then formed into a matrix by taking successive groups of @var{n} elements.
  349. X! If the number of columns does not evenly divide the number of elements
  350. X! in the vector, the last row will be short and the result will not be
  351. X! suitable for use as a matrix.  For example, with the matrix
  352. X! @samp{[[1, 2], [3, 4]]} on the stack, @kbd{v a 4} produces
  353. X! @samp{[[1, 2, 3, 4]]} (a 1x4 matrix), @kbd{v a 1} produces
  354. X! @samp{[[1], [2], [3], [4]]} (a 4x1 matrix), @kbd{v a 2} produces
  355. X! @samp{[[1, 2], [3, 4]]} (the original 2x2 matrix), @kbd{v a 3} produces
  356. X! @samp{[[1, 2, 3], [4]]} (not a matrix), and @kbd{v a 0} produces
  357. X! the flattened list @samp{[1, 2, 3, 4]}.
  358. X! 
  359. X! @cindex Sorting data
  360. X! @kindex V S
  361. X! @kindex I V S
  362. X! @pindex calc-sort
  363. X! @tindex sort
  364. X! @tindex rsort
  365. X! The @kbd{V S} (@code{calc-sort}) [@code{sort}] command sorts the elements of
  366. X! a vector into increasing order.  Non-real vector elements are sorted
  367. X! according to a kind of lexicographic ordering.  Useful properties of
  368. X! this ordering are that variables are sorted into alphabetical order,
  369. X! and one vector is less or greater than another if the first corresponding
  370. X! unequal elements are less or greater, respectively.  Since quoted strings
  371. X! are stored by Calc internally as vectors of ASCII character codes
  372. X! (@pxref{Strings}), this means strings are also sorted in alphabetical
  373. X! order by this command.
  374. X! 
  375. X! The @kbd{I V S} [@code{rsort}] command sorts a vector into decreasing order.
  376. X! 
  377. X! @cindex Permutation, inverse of
  378. X! @cindex Inverse of permutation
  379. X! @cindex Index tables
  380. X! @cindex Rank tables
  381. X! @kindex V G
  382. X! @kindex I V G
  383. X! @pindex calc-grade
  384. X! @tindex grade
  385. X! @tindex rgrade
  386. X! The @kbd{V G} (@code{calc-grade}) [@code{grade}, @code{rgrade}] command
  387. X! produces an index table or permutation vector which, if applied to the
  388. X! input vector (as the index of @kbd{C-u v r}, say), would sort the vector.
  389. X! A permutation vector is just a vector of integers from 1 to @var{n}, where
  390. X! each integer occurs exactly once.  One application of this is to sort a
  391. X! matrix of data rows using one column as the sort key; extract that column,
  392. X! grade it with @kbd{V G}, then use the result to reorder the original matrix
  393. X! with @kbd{C-u v r}.  Another interesting property of the @code{V G} command
  394. X! is that, if the input is itself a permutation vector, the result will
  395. X! be the inverse of the permutation.  The inverse of an index table is
  396. X! a rank table, whose @var{k}th element says where the @var{k}th original
  397. X! vector element will rest when the vector is sorted.  To get a rank
  398. X! table, just use @kbd{V G V G}.
  399. X! 
  400. X! With the Inverse flag, @kbd{I V G} produces an index table that would
  401. X! sort the input into decreasing order.  Note that @kbd{V S} and @kbd{V G}
  402. X! use a ``stable'' sorting algorithm, i.e., any two elements which are equal
  403. X! will not be moved out of their original order.  Generally there is no way
  404. X! to tell with @kbd{V S}, since two elements which are equal look identical,
  405. X! but with @kbd{V G} this can be an important issue.  In the matrix-of-rows
  406. X! example, suppose you have names and telephone numbers as two columns and
  407. X! you wish to sort by phone number primarily, and by name when the numbers
  408. X! are equal.  You can sort the data matrix by names first, and then again
  409. X! by phone numbers.  Because the sort is stable, any two rows with equal
  410. X! phone numbers will remain sorted by name even after the second sort.
  411. X! 
  412. X! @cindex Histograms
  413. X! @kindex V H
  414. X! @pindex calc-histogram
  415. X! @tindex histogram
  416. X! The @kbd{V H} (@code{calc-histogram}) [@code{histogram}] command builds a
  417. X! histogram of a vector of numbers.  Vector elements are assumed to be
  418. X! integers or real numbers in the range [0..@var{n}) for some ``number of
  419. X! bins'' @var{n}, which is the numeric prefix argument given to the
  420. X! command.  The result is a vector of @var{n} counts of how many times
  421. X! each value appeared in the original vector.  Non-integers in the input
  422. X! are rounded down to integers.  Any vector elements outside the specified
  423. X! range are ignored.  (You can tell if elements have been ignored by noting
  424. X! that the elements in the result vector don't add up to the length of the
  425. X! input vector.)
  426. X! 
  427. X! @kindex H V H
  428. X! With the Hyperbolic flag, @kbd{V H} pulls two vectors from the stack.
  429. X! The second-to-top vector is the list of numbers as before.  The top
  430. X! vector is an equal-sized list of ``weights'' to attach to the elements
  431. X! of the data vector.  For example, if the first data element is 4.2 and
  432. X! the first weight is 10, then 10 will be added to bin 4 of the result
  433. X! vector.  Without the hyperbolic flag, every element has a weight of one.
  434. X! 
  435. X! @kindex v t
  436. X! @pindex calc-transpose
  437. X! @tindex trn
  438. X! The @kbd{v t} (@code{calc-transpose}) [@code{trn}] command computes
  439. X! the transpose of the matrix at the top of the stack.  If the argument
  440. X! is a plain vector, it is treated as a row vector and transposed into
  441. X! a one-column matrix.
  442. X! 
  443. X! @kindex v v
  444. X! @pindex calc-reverse-vector
  445. X! @tindex rev
  446. X! The @kbd{v v} (@code{calc-reverse-vector}) [@code{vec}] command reverses
  447. X! a vector end-for-end.  Given a matrix, it reverses the order of the rows.
  448. X! (To reverse the columns instead, just use @kbd{v t v v v t}.  The same
  449. X! principle can be used to apply other vector commands to the columns of
  450. X! a matrix.)
  451. X! 
  452. X! @kindex v m
  453. X! @pindex calc-mask-vector
  454. X! @tindex vmask
  455. X! The @kbd{v m} (@code{calc-mask-vector}) [@code{vmask}] command uses
  456. X! one vector as a mask to extract elements of another vector.  The mask
  457. X! is in the second-to-top position; the target vector is on the top of
  458. X! the stack.  These vectors must have the same length.  The result is
  459. X! the same as the target vector, but with all elements which correspond
  460. X! to zeros in the mask vector deleted.  Thus, for example,
  461. X! @samp{vmask([1, 0, 1, 0, 1], [a, b, c, d, e])} produces @samp{[a, c, e]}.
  462. X! 
  463. X! @kindex v e
  464. X! @pindex calc-expand-vector
  465. X! @tindex vexp
  466. X! The @kbd{v e} (@code{calc-expand-vector}) [@code{vexp}] command
  467. X! expands a vector according to another mask vector.  The result is a
  468. X! vector the same length as the mask, but with nonzero elements replaced
  469. X! by successive elements from the target vector.  The length of the target
  470. X! vector is normally the number of nonzero elements in the mask.  If the
  471. X! target vector is longer, its last few elements are lost.  If the target
  472. X! vector is shorter, the last few nonzero mask elements are left
  473. X! unreplaced in the result.  Thus @samp{vexp([2, 0, 3, 0, 7], [a, b])}
  474. X! produces @samp{[a, 0, b, 0, 7]}.
  475. X! 
  476. X! @kindex H v e
  477. X! With the Hyperbolic flag, @kbd{v e} takes a filler value from the
  478. X! top of the stack; the mask and target vectors come from the third and
  479. X! second elements of the stack.  This filler is used where the mask is
  480. X! zero:  @samp{vexp([2, 0, 3, 0, 7], [a, b], z)} produces
  481. X! @samp{[a, z, c, z, 7]}.
  482. X! 
  483. X! Another variation on the masking idea is to combine @samp{[a, b, c, d, e]}
  484. X! with the mask @samp{[1, 0, 1, 0, 1]} to produce @samp{[a, 0, c, 0, e]}.
  485. X! You can accomplish this with @kbd{V M a &}, mapping the logical ``and''
  486. X! operation across the two vectors.  @xref{Logical Operations}.  Note that
  487. X! the @code{? :} operation also discussed there allows other types of
  488. X! masking using vectors.
  489. X! 
  490. X! @node Vector and Matrix Arithmetic, Reducing and Mapping, Manipulating Vectors, Matrix Functions
  491. X  @section Vector and Matrix Arithmetic
  492. X  
  493. X  Basic arithmetic operations like addition and multiplication are defined
  494. X***************
  495. X*** 6771,6784 ****
  496. X  @code{re}, @code{im}, @code{polar}, @code{rect}, @code{clean},
  497. X  @code{float}, @code{frac}.  @xref{Function Index}.@refill
  498. X  
  499. X- @kindex v t
  500. X- @pindex calc-transpose
  501. X- @tindex trn
  502. X- The @kbd{v t} (@code{calc-transpose}) [@code{trn}] command computes
  503. X- the transpose of the matrix at the top of the stack.  If the argument
  504. X- is a plain vector, it is treated as a row vector and transposed into
  505. X- a one-column matrix.
  506. X- 
  507. X  @kindex V J
  508. X  @pindex calc-conj-transpose
  509. X  The @kbd{V J} (@code{calc-conj-transpose}) [@code{ctrn}] command computes
  510. X--- 9941,9946 ----
  511. X***************
  512. X*** 6790,6796 ****
  513. X  The @kbd{A} (@code{calc-abs}) [@code{abs}] command computes the
  514. X  Frobenius norm of a vector or matrix argument.  This is the square
  515. X  root of the sum of the squares of the absolute values of the
  516. X! elements of the vector or matrix.@refill
  517. X  
  518. X  @kindex v n
  519. X  @pindex calc-rnorm
  520. X--- 9952,9960 ----
  521. X  The @kbd{A} (@code{calc-abs}) [@code{abs}] command computes the
  522. X  Frobenius norm of a vector or matrix argument.  This is the square
  523. X  root of the sum of the squares of the absolute values of the
  524. X! elements of the vector or matrix.  If the vector is interpreted as
  525. X! a point in two- or three-dimensional space, this is the distance
  526. X! from that point to the origin.@refill
  527. X  
  528. X  @kindex v n
  529. X  @pindex calc-rnorm
  530. X***************
  531. X*** 6819,6828 ****
  532. X  right-handed cross product of two vectors, each of which must have
  533. X  exactly three elements.
  534. X  
  535. X! @kindex V I
  536. X! @pindex calc-inv
  537. X! @tindex inv
  538. X! The @kbd{V I} (@code{calc-inv}) [@code{inv}] command computes the
  539. X  inverse of a square matrix.  If the matrix is singular, the inverse
  540. X  operation is left in symbolic form.  Matrix inverses are recorded so
  541. X  that once an inverse (or determinant) of a particular matrix has been
  542. X--- 9983,9992 ----
  543. X  right-handed cross product of two vectors, each of which must have
  544. X  exactly three elements.
  545. X  
  546. X! @kindex & (matrices)
  547. X! @pindex calc-inv (matrices)
  548. X! @tindex inv (matrices)
  549. X! The @kbd{&} (@code{calc-inv}) [@code{inv}] command computes the
  550. X  inverse of a square matrix.  If the matrix is singular, the inverse
  551. X  operation is left in symbolic form.  Matrix inverses are recorded so
  552. X  that once an inverse (or determinant) of a particular matrix has been
  553. X***************
  554. X*** 6829,6837 ****
  555. X  computed, the inverse and determinant of the matrix can be recomputed
  556. X  quickly in the future.
  557. X  
  558. X! If the argument to @kbd{V I} is a plain number @samp{x}, this
  559. X! command simply computes @samp{1/x}.  The same operation is also
  560. X! available on the @kbd{&} key.
  561. X  
  562. X  @kindex V D
  563. X  @pindex calc-mdet
  564. X--- 9993,10000 ----
  565. X  computed, the inverse and determinant of the matrix can be recomputed
  566. X  quickly in the future.
  567. X  
  568. X! If the argument to @kbd{&} is a plain number @samp{x}, this
  569. X! command simply computes @samp{1/x}.
  570. X  
  571. X  @kindex V D
  572. X  @pindex calc-mdet
  573. X***************
  574. X*** 6915,6921 ****
  575. X  derives from Lisp notation and the theory of functions.  Note that there
  576. X  is no actual Calc function called @code{lambda}; the whole point is that
  577. X  the @code{lambda} expression is used in its symbolic form, not evaluated
  578. X! for an answer.)
  579. X  
  580. X  @kindex V R
  581. X  @pindex calc-reduce
  582. X--- 10078,10087 ----
  583. X  derives from Lisp notation and the theory of functions.  Note that there
  584. X  is no actual Calc function called @code{lambda}; the whole point is that
  585. X  the @code{lambda} expression is used in its symbolic form, not evaluated
  586. X! for an answer.)  (Actually, @code{lambda} does have one one special
  587. X! property:  Its arguments are never evaluated; for example, putting
  588. X! @samp{lambda(x, x*(2+3))} on the stack will not simplify the @samp{2+3}
  589. X! until the @code{lambda} is actually applied to some value of @samp{x}.)
  590. X  
  591. X  @kindex V R
  592. X  @pindex calc-reduce
  593. X***************
  594. X*** 6929,6934 ****
  595. X--- 10095,10108 ----
  596. X  In general, reducing @code{f} over the vector @samp{[a, b, c, d]} produces
  597. X  @samp{f(f(f(a, b), c), d)}.
  598. X  
  599. X+ @kindex H V R
  600. X+ @tindex accum
  601. X+ The @kbd{H V R} command does an accumulation operation.  Here Calc does
  602. X+ the corresponding reduction operation, but instead of producing only
  603. X+ the final result, it produces a vector of all the intermediate results.
  604. X+ Accumulating @code{+} over the vector @samp{[a, b, c, d]} produces the
  605. X+ vector @samp{[a, a + b, a + b + c, a + b + c + d]}.
  606. X+ 
  607. X  @kindex V M
  608. X  @pindex calc-map
  609. X  @tindex map
  610. X***************
  611. X*** 6944,6949 ****
  612. X--- 10118,10145 ----
  613. X  the function requires.  If you give an undefined name, you will be prompted
  614. X  for the number of arguments to use.@refill
  615. X  
  616. X+ @kindex V O
  617. X+ @pindex calc-outer-product
  618. X+ @tindex outer
  619. X+ The @kbd{V O} (@code{calc-outer-product}) command applies a given binary
  620. X+ operator to all possible pairs of elements from two vectors, to produce
  621. X+ a matrix.  For example, @kbd{V O *} with @samp{[a, b]} and @samp{[x, y]}
  622. X+ on the stack produces a multiplication table @samp{[[a x, a y], [b x, b y]]}.
  623. X+ 
  624. X+ @kindex V I
  625. X+ @pindex calc-inner-product
  626. X+ @tindex inner
  627. X+ The @kbd{V I} (@code{calc-inner-product}) command computes the generalized
  628. X+ inner product of two vectors or matrices, given a ``multiplicative''
  629. X+ operator and an ``additive operator.''  These can each actually be any
  630. X+ binary operators; if they are @samp{*} and @samp{+}, respectively, the
  631. X+ result is a standard matrix multiplication.  Each element of the result
  632. X+ is obtained by mapping the multiplicative operator across a row of the
  633. X+ lefthand matrix and a column of the righthand matrix, and then reducing
  634. X+ with the additive operator.  Just as for the standard @kbd{*} command,
  635. X+ this can also do a vector-matrix or matrix-vector inner product, or a
  636. X+ generalized dot product of two plain vectors.
  637. X+ 
  638. X  @tindex add
  639. X  @tindex sub
  640. X  @tindex mul
  641. X***************
  642. X*** 6953,6963 ****
  643. X  @tindex mod
  644. X  @tindex vconcat
  645. X  In algebraic formulas, these operations can be expressed as
  646. X! @samp{apply(@var{oper}, @var{vec})},
  647. X! @samp{reduce(@var{oper}, @var{vec})}, and
  648. X! @samp{map(@var{oper}, @var{v1}, @var{v2}, ...)}.
  649. X  For example, @samp{map(gcd, [10,20,30], x)}.
  650. X! If @var{vec}, or all of the @var{v}'s,
  651. X  are non-vectors, the expression is left in symbolic form.  Here, @var{oper}
  652. X  is any function name like @code{max} or @code{gcd}, or a @code{lambda}
  653. X  expression as described above.  Operators that are
  654. X--- 10149,10166 ----
  655. X  @tindex mod
  656. X  @tindex vconcat
  657. X  In algebraic formulas, these operations can be expressed as
  658. X! 
  659. X! @example
  660. X! apply(@var{oper}, @var{vec})
  661. X! reduce(@var{oper}, @var{vec})
  662. X! accum(@var{oper}, @var{vec})
  663. X! map(@var{oper}, @var{v1}, @var{v2}, ...)
  664. X! outer(@var{oper}, @var{vec1}, @var{vec2})
  665. X! inner(@var{mul-oper}, @var{add-oper}, @var{vec1}, @var{vec2})
  666. X! @end example
  667. X! 
  668. X  For example, @samp{map(gcd, [10,20,30], x)}.
  669. X! If any of the @var{vec}'s, or all of the @var{v}'s,
  670. X  are non-vectors, the expression is left in symbolic form.  Here, @var{oper}
  671. X  is any function name like @code{max} or @code{gcd}, or a @code{lambda}
  672. X  expression as described above.  Operators that are
  673. X***************
  674. X*** 7021,7027 ****
  675. X  have set a mapping mode, that mode stays in effect until you change it.
  676. X  The default mode is map-by-elements.  The mapping mode is also used by
  677. X  the @code{calc-reduce} command, as described in the next section.
  678. X! The mapping mode has no effect if the arguments are plain vectors.
  679. X  
  680. X  Use @kbd{m e} to select map-by-elements mode.  In this mode, the operator
  681. X  is applied to each element of the argument matrix, or to corresponding
  682. X--- 10224,10232 ----
  683. X  have set a mapping mode, that mode stays in effect until you change it.
  684. X  The default mode is map-by-elements.  The mapping mode is also used by
  685. X  the @code{calc-reduce} command, as described in the next section.
  686. X! The mapping mode has no effect if the arguments are plain vectors,
  687. X! and it also has no effect on @kbd{V A}, @kbd{H V R}, @kbd{V O}, or
  688. X! @kbd{V I} commands.
  689. X  
  690. X  Use @kbd{m e} to select map-by-elements mode.  In this mode, the operator
  691. X  is applied to each element of the argument matrix, or to corresponding
  692. X***************
  693. X*** 7060,7065 ****
  694. X--- 10265,10273 ----
  695. X  As another example, you could concatenate two matrices horizontally by
  696. X  mapping @samp{|} (vector concatenation) by rows.
  697. X  
  698. X+ The corresponding algebraic function names are @code{map}, @code{mapr},
  699. X+ @code{mapc}, @code{mapa}, and @code{mapd}, respectively.
  700. X+ 
  701. X  @node Reducing Matrices, , Mapping Matrices, Reducing and Mapping
  702. X  @subsection Reducing Matrices
  703. X  
  704. X***************
  705. X*** 7106,7112 ****
  706. X  @section Vector and Matrix Display Formats
  707. X  
  708. X  Commands for controlling vector and matrix display use the @kbd{v} prefix
  709. X! instead of the usual @kbd{d} prefix.
  710. X  
  711. X  @kindex v <
  712. X  @pindex calc-matrix-left-justify
  713. X--- 10314,10322 ----
  714. X  @section Vector and Matrix Display Formats
  715. X  
  716. X  Commands for controlling vector and matrix display use the @kbd{v} prefix
  717. X! instead of the usual @kbd{d} prefix.  Note that matrix display is also
  718. X! influenced by the @kbd{d O} (@code{calc-flat-language}) mode;
  719. X! @pxref{Normal Language Modes}.
  720. X  
  721. X  @kindex v <
  722. X  @pindex calc-matrix-left-justify
  723. X***************
  724. X*** 7133,7139 ****
  725. X  be used in preparation for yanking a matrix into a buffer running
  726. X  Mathematica.  (In fact, the Mathematica language mode uses this mode;
  727. X  @pxref{Mathematica Language Mode}.)  Note that, regardless of the
  728. X! display mode, either brackets and braces may be used to enter vectors,
  729. X  and parentheses may never be used for this purpose.@refill
  730. X  
  731. X  @kindex v ,
  732. X--- 10343,10349 ----
  733. X  be used in preparation for yanking a matrix into a buffer running
  734. X  Mathematica.  (In fact, the Mathematica language mode uses this mode;
  735. X  @pxref{Mathematica Language Mode}.)  Note that, regardless of the
  736. X! display mode, either brackets or braces may be used to enter vectors,
  737. X  and parentheses may never be used for this purpose.@refill
  738. X  
  739. X  @kindex v ,
  740. X***************
  741. X*** 7141,7194 ****
  742. X  The @kbd{v ,} (@code{calc-vector-commas}) command turns commas on and
  743. X  off in vector and matrix display.@refill
  744. X  
  745. X! @node Algebra, Units, Matrix Functions, Top
  746. X  @chapter Algebra
  747. X  
  748. X! The commands for operating on algebraic formulas use the @kbd{a} key
  749. X! prefix.  @xref{Editing Stack Entries}, to see how to manipulate formulas
  750. X! using regular Emacs editing commands.
  751. X  
  752. X! Many of these commands prompt for a variable name or formula.  If you
  753. X! answer the prompt with a blank line, the variable or formula is taken
  754. X! from top-of-stack, and the normal argument for the command is taken
  755. X! from second-to-top.
  756. X  
  757. X  When doing algebraic work, you may find several of the Calculator's
  758. X! modes to be helpful, including algebraic-simplification mode (@kbd{m A}),
  759. X  algebraic-entry mode (@kbd{m a}), fraction mode (@kbd{m f}), and
  760. X  symbolic mode (@kbd{m s}).  @xref{Mode Settings}, for discussions
  761. X  of these modes.  You may also wish to select ``big'' display mode (@kbd{d B}).
  762. X! @xref{Normal Language Modes}.
  763. X  
  764. X  @menu
  765. X  * Algebraic Manipulation::
  766. X- * Rewrite Rules::
  767. X- * Logical Operations::
  768. X  * Calculus::
  769. X  @end menu
  770. X  
  771. X! @node Algebraic Manipulation, Rewrite Rules, Algebra, Algebra
  772. X  @section Algebraic Manipulation
  773. X  
  774. X  @kindex a s
  775. X  @pindex calc-simplify
  776. X! The @kbd{a s} (@code{calc-simplify}) command applies various algebraic
  777. X! rules to simplify a formula.  This generally entails combining like
  778. X! terms of sums and products.  The result will be a formula which is
  779. X! mathematically equivalent to the original one, but somewhat simpler.
  780. X  
  781. X  @kindex a e
  782. X  @pindex calc-simplify-extended
  783. X! The @kbd{a e} (@code{calc-simplify-extended}) command is like @kbd{a s}
  784. X  except that it applies some additional simplifications which are not
  785. X  ``safe'' in all cases.  For example, powers are simplified according
  786. X  to the rule @samp{(a^b)^c = a^(b c)}, even though this is not always
  787. X! true (consider @samp{sqrt(a^2)} for negative @samp{a}).  The symbolic
  788. X  integrator uses @code{calc-simplify-extended}; one effect of this is
  789. X  that the integrator's results must be used with caution.  Where an
  790. X  integral table will often attach conditions like ``for positive @samp{a}
  791. X! only,'' Calc (and most other symbolic integration programs) will simply
  792. X! produce an unqualified result.
  793. X  
  794. X  @kindex a x
  795. X  @pindex calc-expand
  796. X--- 10351,11489 ----
  797. X  The @kbd{v ,} (@code{calc-vector-commas}) command turns commas on and
  798. X  off in vector and matrix display.@refill
  799. X  
  800. X! @kindex v .
  801. X! @pindex calc-full-vectors
  802. X! The @kbd{v .} (@code{calc-full-vectors}) command turns abbreviated
  803. X! display of long vectors on and off.  In this mode, vectors of six
  804. X! or more elements, or matrices of six or more rows or columns, will
  805. X! be displayed in an abbreviated form that displays only the first
  806. X! three elements and the last element:  @samp{[a, b, c, ..., z]}.
  807. X! When very large vectors are involved this will substantially
  808. X! improve Calc's display speed.
  809. X! 
  810. X! @kindex t .
  811. X! @pindex calc-full-trail-vectors
  812. X! The @kbd{t .} (@code{calc-full-trail-vectors}) command controls a
  813. X! similar mode for recording vectors in the Trail.  If you turn on
  814. X! this mode, vectors of six or more elements and matrices of six or
  815. X! more rows or columns will be abbreviated when they are put in the
  816. X! Trail.  The @kbd{t y} (@code{calc-trail-yank}) command will be
  817. X! unable to recover those vectors.  If you are working with very
  818. X! large vectors, this mode will improve the speed of all operations
  819. X! that involve the trial.
  820. X! 
  821. X! @kindex v /
  822. X! @pindex calc-break-vectors
  823. X! The @kbd{v /} (@code{calc-break-vectors}) command turns multi-line
  824. X! vector display on and off.  Normally, matrices are displayed with one
  825. X! row per line but all other types of vectors are displayed in a single
  826. X! line.  This mode causes all vectors, whether matrices or not, to be
  827. X! displayed with a single element per line.  Sub-vectors within the
  828. X! vectors will still use the normal linear form.
  829. X! 
  830. X! @node Graphics, Algebra, Matrix Functions, Top
  831. X! @chapter Graphics
  832. X! 
  833. X! The commands for graphing data begin with the @kbd{g} prefix key.
  834. X! Calc uses GNUPLOT 2.0 to do graphics.  These commands will only work
  835. X! if GNUPLOT is available on your system.  While GNUPLOT sounds like
  836. X! a relative of GNU Emacs, it is actually completely unrelated.
  837. X! However, it is free software and can be obtained from the Free
  838. X! Software Foundation's machine @samp{prep.ai.mit.edu}.
  839. X! 
  840. X! @vindex calc-gnuplot-name
  841. X! If you have GNUPLOT installed on your system but Calc is unable to
  842. X! find it, you may need to set the @code{calc-gnuplot-name} variable
  843. X! in your @file{.emacs} file.  You may also need to set some Lisp
  844. X! variables to show Calc how to run GNUPLOT on your system; these
  845. X! are described at under @kbd{g D} and @kbd{g O} below.  If you are
  846. X! using the X window system, Calc will configure GNUPLOT for you
  847. X! automatically.
  848. X! 
  849. X! @kindex g f
  850. X! @pindex calc-graph-fast
  851. X! The easiest graphics command is @kbd{g f} (@code{calc-graph-fast}).
  852. X! This command takes two vectors of equal length from the stack.
  853. X! The vector at the top of the stack represents the ``y'' values of
  854. X! the various data points.  The vector in the second-to-top position
  855. X! represents the corresponding ``x'' values.  This command runs
  856. X! GNUPLOT (if it has not already been started by previous graphing
  857. X! commands) and displays the set of data points.  The points will
  858. X! be connected by lines, and there will also be some kind of symbol
  859. X! to indicate the points themselves.
  860. X! 
  861. X! The ``x'' entry may instead be an interval form, in which case suitable
  862. X! ``x'' values are interpolated between the minimum and maximum values of
  863. X! the interval (whether the interval is open or closed is ignored).
  864. X! 
  865. X! The ``y'' entry may be any formula instead of a vector.  Calc effectively
  866. X! uses @kbd{N} (@code{calc-eval-num}) to evaluate variables in the formula;
  867. X! the result of this must be a formula in a single (unassigned) variable.
  868. X! The formula is plotted with this variable taking on the various ``x''
  869. X! values.  Graphs of formulas by default use lines without symbols at the
  870. X! computed data points.  Note that if neither ``x'' nor ``y'' is a vector,
  871. X! Calc guesses at a reasonable number of data points to use.  See the
  872. X! @kbd{g N} command below.
  873. X! 
  874. X! If ``y'' is a formula of the form @samp{xy(X, Y)}) then the result is a
  875. X! parametric plot.  The two arguments of the fictitious @code{xy} function
  876. X! are used as the ``x'' and ``y'' coordinates of the curve, respectively.
  877. X! In this case the ``x'' vector or interval you specified is not directly
  878. X! visible in the graph.  For example, if ``x'' is the interval @samp{[0..360]}
  879. X! and ``y'' is the formula @samp{xy(sin(t), cos(t))}, the resulting graph
  880. X! will be a circle.
  881. X! 
  882. X! Also, ``x'' and ``y'' may each be variable names, in which case Calc
  883. X! looks for suitable vectors, intervals, or formulas stored in those
  884. X! variables.
  885. X! 
  886. X! The ``x'' and ``y'' values for the data points (as pulled from the vectors,
  887. X! calculated from the formulas, or interpolated from the intervals) should
  888. X! be real numbers (integers, fractions, or floats).  If either the ``x''
  889. X! value or the ``y'' value of a given data point is not a real number, that
  890. X! data point will be omitted from the graph.  The points on either side
  891. X! of the invalid point will @emph{not} be connected by a line.
  892. X! 
  893. X! @cindex @code{PlotRejects} variable
  894. X! If you store an empty vector in the variable @code{PlotRejects}
  895. X! (i.e., @kbd{[ ] s PlotRejects}), Calc will append information to
  896. X! this record for every data point which was rejected because its
  897. X! ``x'' or ``y'' values were not real numbers.  The result will be
  898. X! a matrix where each row holds the curve number, data point number,
  899. X! ``x'' value, and ``y'' value for a rejected data point.
  900. X! 
  901. X! @kindex g c
  902. X! @pindex calc-graph-clear
  903. X! To clear the graphics display, type @kbd{g c} (@code{calc-graph-clear}).
  904. X! If the GNUPLOT output device is an X window, the window will go away.
  905. X! Effects on other kinds of output devices will vary.  You don't need
  906. X! to use @kbd{g c} if you don't want to---if you give another @kbd{g f}
  907. X! or @kbd{g p} command later on, it will reuse the existing graphics
  908. X! window if there is one.
  909. X! 
  910. X! The @kbd{g f} command is really shorthand for the following commands:
  911. X! @kbd{C-u g d  g a  g p}.  You can gain more control over your graph
  912. X! by using these commands directly.
  913. X! 
  914. X! @kindex g a
  915. X! @pindex calc-graph-add
  916. X! The @kbd{g a} (@code{calc-graph-add}) command adds the ``curve''
  917. X! represented by the two values on the top of the stack to the current
  918. X! graph.  You can have any number of curves in the same graph.  When
  919. X! you give the @kbd{g p} command, all the curves will be drawn superimposed
  920. X! on the same axes.
  921. X! 
  922. X! The @kbd{g a} command (and many others that affect the current graph)
  923. X! will cause a special buffer, @samp{*Gnuplot Commands*}, to be displayed
  924. X! in another window.  This buffer is a template of the commands that will
  925. X! be sent to GNUPLOT when it is time to draw the graph.  The first
  926. X! @kbd{g a} command adds a @code{plot} command to this buffer.  Succeeding
  927. X! @kbd{g a} commands add extra curves onto that @code{plot} command.
  928. X! Other graph-related commands put other GNUPLOT commands into this
  929. X! buffer.  In normal usage you never need to work with this buffer
  930. X! directly, but you can if you wish.  The only constraint is that there
  931. X! must be only one @code{plot} command, and it must be the last command
  932. X! in the buffer.  If you want to save and later restore a complete graph
  933. X! configuration, you can use regular Emacs commands to save and restore
  934. X! the contents of the @samp{*Gnuplot Commands*} buffer.
  935. X! 
  936. X! If the values on the stack are not variable names, @kbd{g a} will invent
  937. X! variable names for them and store the values in those variables.
  938. X! The ``x'' and ``y'' variables are what go into the @code{plot} command
  939. X! in the template.  If you add a curve that uses a certain variable and
  940. X! then later change that variable, you can replot the graph without having
  941. X! to delete and re-add the curve.  That's because the variable name, not
  942. X! the vector, interval or formula itself, is what was added by @kbd{g a}.
  943. X! 
  944. X! With a numeric prefix argument, the @kbd{g a} command interprets
  945. X! the value on the top of the stack as a vector of ``y'' values
  946. X! (which must each be either vectors, functions, or variable names).
  947. X! Each of these values, matched with the same common ``x'' value,
  948. X! is added as a separate curve to the current graph.  For example,
  949. X! to plot @samp{sin(n x)} for integers @samp{n} from 1 to 5, you could
  950. X! use @kbd{v x} to create a vector of integers (@samp{n}), then @kbd{V M '}
  951. X! or @kbd{V M $} to map @samp{sin(n x)} across this vector.  The
  952. X! resulting vector of formulas is suitable for use as the ``y'' argument
  953. X! to a @kbd{g a} command.  A numeric prefix argument on @kbd{g f} has
  954. X! the same effect as one on @kbd{g a}.
  955. X! 
  956. X! @kindex g d
  957. X! @pindex calc-graph-delete
  958. X! The @kbd{g d} (@code{calc-graph-delete}) command deletes the most
  959. X! recently added curve from the graph.  It has no effect if there are
  960. X! no curves in the graph.  With a numeric prefix argument of any kind,
  961. X! it deletes all of the curves from the graph.
  962. X! 
  963. X! @kindex g j
  964. X! @pindex calc-graph-juggle
  965. X! This @kbd{g j} (@code{calc-graph-juggle}) command moves the curve
  966. X! at the end of the list (the ``most recently added curve'') to the
  967. X! front of the list.  The next-most-recent curve is thus exposed for
  968. X! @kbd{g d} or similar commands to use.  With @kbd{g j} you can work
  969. X! with any curve in the graph even though curve-related commands only
  970. X! affect the last curve in the list.
  971. X! 
  972. X! @kindex g p
  973. X! @pindex calc-graph-plot
  974. X! The @kbd{g p} (@code{calc-graph-plot}) command uses GNUPLOT to draw
  975. X! the graph described in the @samp{*Gnuplot Commands*} buffer.  Any
  976. X! GNUPLOT parameters which are not defined by commands in this buffer
  977. X! are reset to their default values.  The variables named in the @code{plot}
  978. X! command are written to a temporary data file and the variable names
  979. X! are then replaced by the file name in the template.  The resulting
  980. X! plotting commands are fed to the GNUPLOT program.  See the documentation
  981. X! for the GNUPLOT program for more specific information.  All temporary
  982. X! files are removed when plotting is finished.
  983. X! 
  984. X! If you give a formula for ``y'', Calc will remember all the values that
  985. X! it calculates for the formula so that later plots can reuse these values.
  986. X! Calc throws out these saved values when you change any circumstances
  987. X! that may affect the data, such as switching from Degrees to Radians
  988. X! mode, or changing the value of a parameter in the formula.  You can
  989. X! force Calc to recompute the data from scratch by giving a negative
  990. X! numeric prefix argument to @kbd{g p}.
  991. X! 
  992. X! Calc uses a fairly rough step size when graphing formulas over intervals.
  993. X! This is to ensure quick response.  You can ``refine'' a plot by giving
  994. X! a positive numeric prefix argument to @kbd{g p}.  Calc goes through
  995. X! the data points it has computed and saved from previous plots of the
  996. X! function, and computes and inserts a new data point midway between
  997. X! each of the existing points.
  998. X! 
  999. X! @kindex g P
  1000. X! @pindex calc-graph-print
  1001. X! The @kbd{g P} (@code{calc-graph-print}) command is like @kbd{g p},
  1002. X! except that it sends the output to a printer instead of to the
  1003. X! screen.  More precisely, @kbd{g p} looks for @samp{set terminal}
  1004. X! or @samp{set output} commands in the @samp{*Gnuplot Commands*} buffer;
  1005. X! lacking these it uses the default settings.  However, @kbd{g P}
  1006. X! ignores @samp{set terminal} and @samp{set output} commands and
  1007. X! uses a different set of default values.  All of these values are
  1008. X! controlled by the @kbd{g D} and @kbd{g O} commands discussed below.
  1009. X! Provided everything is set up properly, @kbd{g p} will plot to
  1010. X! the screen unless you have specified otherwise and @kbd{g P} will
  1011. X! always plot to the printer.
  1012. X! 
  1013. X! @kindex g g
  1014. X! @pindex calc-graph-grid
  1015. X! The @kbd{g g} (@code{calc-graph-grid}) command turns the ``grid''
  1016. X! on and off.  It is off by default; tick marks appear only at the
  1017. X! edges of the graph.  With the grid turned on, dotted lines appear
  1018. X! across the graph at each tick mark.  Note that this command only
  1019. X! changes the setting in @samp{*Gnuplot Commands*}; to see the effects
  1020. X! of the change you must give another @kbd{g p} command.
  1021. X! 
  1022. X! @kindex g k
  1023. X! @pindex calc-graph-key
  1024. X! The @kbd{g k} (@code{calc-graph-key}) command turns the ``key''
  1025. X! on and off.  The key is a chart in the corner of the graph that
  1026. X! shows the correspondence between curves and line styles.  It is
  1027. X! off by default, and is only really useful if you have several
  1028. X! curves on the same graph.
  1029. X! 
  1030. X! @kindex g N
  1031. X! @pindex calc-graph-num-points
  1032. X! The @kbd{g N} (@code{calc-graph-num-points}) command allows you
  1033. X! to select the number of data points in the graph.  This only affects
  1034. X! curves where neither ``x'' nor ``y'' is specified as a vector.
  1035. X! Enter a blank line to revert to the default value (initially 15).
  1036. X! With a numeric prefix argument this command changes or, if you enter
  1037. X! a blank line, displays the default number of points used for all
  1038. X! graphs that don't specify it explicitly.
  1039. X! 
  1040. X! Data points in the graph of a function are normally computed to a
  1041. X! precision of five digits, regardless of the current precision at
  1042. X! the time. This is usually more than adequate, there are cases where
  1043. X! it will not be.  For example, plotting @samp{1 + x} for @samp{x} in the
  1044. X! interval @samp{[0 .. 1e-6]} will round all the data points down
  1045. X! to 1.0!  Putting the command @samp{set precision @var{n}} in the
  1046. X! @samp{*Gnuplot Commands*} buffer will cause the data to be computed
  1047. X! at precision @var{n} instead of 5.  Since this is such a rare case,
  1048. X! there is no keystroke-based command to set the precision.
  1049. X! 
  1050. X! @kindex g h
  1051. X! @pindex calc-graph-header
  1052. X! The @kbd{g h} (@code{calc-graph-header}) command sets the title
  1053. X! for the graph.  This will show up centered above the graph.
  1054. X! The default title is blank (no title).
  1055. X! 
  1056. X! @kindex g n
  1057. X! @pindex calc-graph-name
  1058. X! The @kbd{g n} (@code{calc-graph-name}) command sets the title of an
  1059. X! individual curve.  Like the other curve-manipulating commands, it
  1060. X! affects the most recently added curve, i.e., the last curve on the
  1061. X! list in the @samp{*Gnuplot Commands*} buffer.  To set the title of
  1062. X! the other curves you must first juggle them to the end of the list
  1063. X! with @kbd{g j}, or edit the @samp{*Gnuplot Commands*} buffer by hand.
  1064. X! Curve titles appear in the key; if the key is turned off they are
  1065. X! not used.
  1066. X! 
  1067. X! @kindex g t
  1068. X! @kindex g T
  1069. X! @pindex calc-graph-title-x
  1070. X! @pindex calc-graph-title-y
  1071. X! The @kbd{g t} (@code{calc-graph-title-x}) and @kbd{g T}
  1072. X! (@code{calc-graph-title-y}) commands set the titles on the ``x''
  1073. X! and ``y'' axes, respectively.  These titles appear next to the
  1074. X! tick marks on the left and bottom edges of the graph, respectively.
  1075. X! Calc does not have commands to control the tick marks themselves,
  1076. X! but you can edit them into the @samp{*Gnuplot Commands*} buffer if
  1077. X! you wish.  See the GNUPLOT documentation for details.
  1078. X! 
  1079. X! @kindex g r
  1080. X! @kindex g R
  1081. X! @pindex calc-graph-range-x
  1082. X! @pindex calc-graph-range-y
  1083. X! The @kbd{g r} (@code{calc-graph-range-x}) and @kbd{g R}
  1084. X! (@code{calc-graph-range-y}) commands set the range of values on the
  1085. X! ``x'' and ``y'' axes, respectively.  You are prompted to enter a
  1086. X! suitable range.  This should be either a pair of numbers of the
  1087. X! form, @samp{@var{min}:@var{max}}, or a blank line to revert to the
  1088. X! default behavior of setting the range based on the range of values
  1089. X! in the data, or @samp{$} to take the range from the top of the stack.
  1090. X! Ranges on the stack can be represented as either interval forms or
  1091. X! vectors:  @samp{[@var{min} .. @var{max}]} or @samp{[@var{min}, @var{max}]}.
  1092. X! 
  1093. X! @kindex g l
  1094. X! @kindex g L
  1095. X! @pindex calc-graph-log-x
  1096. X! @pindex calc-graph-log-y
  1097. X! The @kbd{g l} (@code{calc-graph-log-x}) and @kbd{g L} (@code{calc-graph-log-y})
  1098. X! commands allow you to set either or both of the axes of the graph to
  1099. X! be logarithmic instead of linear.
  1100. X! 
  1101. X! @kindex g s
  1102. X! @pindex calc-graph-line-style
  1103. X! The @kbd{g s} (@code{calc-graph-line-style}) command turns the connecting
  1104. X! lines on or off for the most recently added curve, and optionally selects
  1105. X! the style of lines to be used for that curve.  Plain @kbd{g s} simply
  1106. X! toggles the lines on and off.  With a numeric prefix argument, @kbd{g s}
  1107. X! turns lines on and sets a particular line style.  Line style numbers
  1108. X! start at one and their meanings vary depending on the output device.
  1109. X! GNUPLOT guarantees that there will be at least six different line styles
  1110. X! available for any device.
  1111. X! 
  1112. X! @kindex g S
  1113. X! @pindex calc-graph-point-style
  1114. X! The @kbd{g S} (@code{calc-graph-point-style}) command similarly turns
  1115. X! the symbols at the data points on or off, or sets the point style.
  1116. X! If you turn both lines and points off, the data points will show as
  1117. X! tiny dots.
  1118. X! 
  1119. X! @kindex g D
  1120. X! @pindex calc-graph-device
  1121. X! The @kbd{g D} (@code{calc-graph-device}) command sets the device
  1122. X! (or ``terminal'') name to be used by @kbd{g p} commands on this
  1123. X! graph.  It does not affect the permanent default device name.
  1124. X! If you enter a blank name, the device name reverts to the default.
  1125. X! Enter @samp{?} to see a list of supported devices.
  1126. X! 
  1127. X! With a positive numeric prefix argument, @kbd{g D} instead sets
  1128. X! the default device name, used by all plots in the future which do
  1129. X! not override it with a plain @kbd{g D} command.  If you enter a
  1130. X! blank line this command shows you the current default.  The special
  1131. X! name @code{default} signifies that Calc should choose @code{x11} if
  1132. X! the X window system is in use (as indicated by the presence of a
  1133. X! @code{DISPLAY} environment variable), or otherwise @code{postscript}.
  1134. X! This is the initial default value.
  1135. X! 
  1136. X! With a negative numeric prefix argument, @kbd{g P} sets or displays
  1137. X! the device name used by @kbd{g P} (@code{calc-graph-print}).  This
  1138. X! is initially @code{postscript}.
  1139. X! 
  1140. X! @kindex g O
  1141. X! @pindex calc-graph-output
  1142. X! The @kbd{g O} (@code{calc-graph-output}) command sets the name of
  1143. X! the output file used by GNUPLOT.  For some devices, notably @code{x11},
  1144. X! there is no output file and this information is not used.  Many other
  1145. X! ``devices'' are really file formats like @code{postscript}; in these
  1146. X! cases the output in the desired format goes into the file you name
  1147. X! with @kbd{g O}.
  1148. X! 
  1149. X! Once again, @kbd{g O} with a positive or negative prefix argument
  1150. X! sets the default or printer output file names, respectively.  In each
  1151. X! case you can specify @code{auto}, which causes Calc to invent a temporary
  1152. X! file name for each @kbd{g p} (or @kbd{g P}) command.  This temporary file
  1153. X! will be deleted once it has been displayed or printed.  If the output file
  1154. X! name is not @code{auto}, the file is not automatically deleted.
  1155. X! 
  1156. X! The default and printer devices and output files can be saved
  1157. X! permanently by the @kbd{m m} (@code{calc-save-modes}) command.  The
  1158. X! default number of data points (see @kbd{g N}) and the X geometry
  1159. X! (see @kbd{g X}) are also saved.  Other graph information is @emph{not}
  1160. X! saved; you can save a graph's configuration simply by saving the contents
  1161. X! of the @samp{*Gnuplot Commands*} buffer.
  1162. X! 
  1163. X! @vindex calc-gnuplot-plot-command
  1164. X! @vindex calc-gnuplot-default-device
  1165. X! @vindex calc-gnuplot-default-output
  1166. X! @vindex calc-gnuplot-print-command
  1167. X! @vindex calc-gnuplot-print-device
  1168. X! @vindex calc-gnuplot-print-output
  1169. X! If you are installing Calc you may wish to configure the default and
  1170. X! printer devices and output files for the whole system.  The relevant
  1171. X! Lisp variables are @code{calc-gnuplot-default-device} and @code{-output},
  1172. X! and @code{calc-gnuplot-print-device} and @code{-output}.  The output
  1173. X! file names must be either strings as described above, or Lisp
  1174. X! expressions which are evaluated on the fly to get the output file name.
  1175. X! 
  1176. X! Other important Lisp variables are @code{calc-gnuplot-plot-command} and
  1177. X! @code{calc-gnuplot-print-command}, which give the system commands to
  1178. X! display or print the output of GNUPLOT, respectively.  These may be
  1179. X! @code{nil} if no command is necessary, or strings which can include
  1180. X! @samp{%s} to signify the name of the file to be displayed or printed.
  1181. X! These variables may instead contain Lisp expressions which are evaluated
  1182. X! to display or print the output.
  1183. X! 
  1184. X! @kindex g x
  1185. X! @pindex calc-graph-display
  1186. X! The @kbd{g x} (@code{calc-graph-display}) command lets you specify
  1187. X! on which X window system display your graphs should be drawn.  Enter
  1188. X! a blank line to see the current display name.  This command has no
  1189. X! effect unless the current device is @samp{x11}.
  1190. X! 
  1191. X! @kindex g X
  1192. X! @pindex calc-graph-geometry
  1193. X! The @kbd{g X} (@code{calc-graph-geometry}) command is a similar
  1194. X! command for specifying the position and size of the X window.
  1195. X! The normal value is @samp{default}, which generally means your
  1196. X! window manager will let you place the window interactively.
  1197. X! Entering @samp{800x500+0+0} would create an 800-by-500 pixel
  1198. X! window in the upper-left corner of the screen.
  1199. X! 
  1200. X! There is another buffer called @samp{*Gnuplot Trail*} that holds a
  1201. X! transcript of the session with GNUPLOT.  This shows the commands Calc
  1202. X! has ``typed'' to GNUPLOT and the responses it received.  Calc tries to
  1203. X! notice when an error message has appeared here and display the buffer
  1204. X! for you when this happens.  You can check this buffer yourself if you
  1205. X! suspect something has gone wrong.
  1206. X! 
  1207. X! @kindex g C
  1208. X! @pindex calc-graph-command
  1209. X! The @kbd{g C} (@code{calc-graph-command}) command prompts you to
  1210. X! enter any line of text, then simply sends that line to the current
  1211. X! GNUPLOT process.  The @samp{*Gnuplot Trail*} buffer looks deceptively
  1212. X! like a Shell buffer but you can't type commands in it yourself.
  1213. X! Instead, you must use @kbd{g C} for this purpose.
  1214. SHAR_EOF
  1215. echo "End of part 16, continue with part 17"
  1216. echo "17" > s2_seq_.tmp
  1217. exit 0
  1218.  
  1219.