tri.lat 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918
  1. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2. %%%%% Typesetting REDUCE output with TeX %%%%%
  3. %%%%% by Werner Antweiler %%%%%
  4. %%%%% University of Cologne Computer Center %%%%%
  5. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  6. \input tridefs
  7. \def\9{\TeX-REDUCE-Interface}
  8. %
  9. % LaTeX Version
  10. %
  11. \documentstyle[twocolumn]{article}
  12. \begin{document}
  13. %
  14. % Titel
  15. %
  16. \title{\Huge A \9}
  17. \author{Werner Antweiler\thanks{All three authors are with:
  18. Rechenzentrum der Universit\"{a}t zu K\"{o}ln
  19. (University of Cologne Computer Center),
  20. Abt. Anwendungssoftware (Application Software
  21. Department), Robert-Koch-Stra\ss e 10, 5000 K\"{o}ln 41,
  22. West Germany.} \\
  23. Andreas Strotmann\\
  24. Volker Winkelmann\\
  25. University of Cologne Computer Center, West Germany}
  26. \date{Revised Version, \today}
  27. \maketitle
  28. %
  29. \section{Introduction}
  30. %
  31. REDUCE is a well known computer algebra system invented by
  32. Anthony C. Hearn. While every effort was made to improve
  33. the system's algebraic capabilities, the readability of the
  34. output remained poor by modern typesetting standards.
  35. Although a pretty-printer is already incorporated in REDUCE,
  36. the output is produced only in line-printer quality.
  37. The simple idea to produce high quality output from REDUCE
  38. is to link REDUCE with Donald E. Knuth's famous \TeX\ typesetting
  39. language. This draft reviews our efforts in this direction.
  40. Our major goals we pursue with TRI are:
  41. \begin{itemize}
  42. \item We want to produce REDUCE-output in typesetting quality.
  43. \item The intermediate files (\TeX-input files) should be easy to edit.
  44. The reason is that it is likely that the proposed
  45. line-breaks are sub-optimal from the user's point of view.
  46. \item We apply a \TeX-like algorithm which ``optimizes''
  47. the line-breaking over the whole expression. This differs
  48. fundamentally from the standard left-to-right,
  49. one-line look-ahead
  50. pretty-printers of REDUCE, LISP and the like.
  51. \end{itemize}
  52. We introduce a program written in RLISP\footnote{the REDUCE
  53. implementation language, an extended Standard LISP with an
  54. ALGOL-like syntax.} which typesets REDUCE
  55. formulas with \TeX. Our \9 incorporates three
  56. levels of \TeX\ output: without line breaking, with line breaking,
  57. and with line breaking plus indentation. While speed
  58. without line breaking is comparable to that achieved with
  59. REDUCE's pretty-printer, line breaking consumes much more CPU time.
  60. Nevertheless, we reckon with a cost increase due to line breaking
  61. which is almost linear in the length of the expression to be broken.
  62. Our line breaking algorithm mimics \TeX's line breaking in a
  63. rather rudimentary fashion.
  64. This paper deals with some of the ideas and algorithms we have
  65. programmed and it summarizes some of the experiments we have made
  66. with our program.
  67. Furthermore, at the end of this paper we provide a small user's manual
  68. which gives a short introduction to the use of our \9.
  69. For simplicity's sake the name ``\9'' will be abbreviated to ``TRI''
  70. in this paper.
  71. %
  72. \section{From REDUCE to \TeX: basic concepts}
  73. %
  74. The function {\tt TeXvarpri} is the interface to the algebraic
  75. portion of REDUCE. It first calls a function named {\tt makeprefix}.
  76. Its job is to change a REDUCE algebraic expression to a standard
  77. prefix list while retaining the tree structure of the whole expression.
  78. After this has been done, the
  79. new intermediate expression is passed to the most important module
  80. of TRI: the {\tt maketag/makefunc}-family of functions.
  81. These functions recursively expand the structured list
  82. (or operator tree) into a flat list, translating each REDUCE symbol or
  83. expression into so-called \TeX-items on passing by.
  84. For that reason, the resulting list is called the \TeX-item list.
  85. If the simple \TeX-mode (without line breaking) was chosen, this list
  86. is then printed immediately without further considerations.
  87. Translation and printing this way is almost as fast as with
  88. the standard REDUCE pretty printer.\par
  89. When line-breaking has been enabled things get a bit more complicated.
  90. The greatest effort with TRI was to implement the line-breaking
  91. algorithm. More than half of the entire TRI code deals with this
  92. task.
  93. The ultimate goal is to add some ``break items'', i.e. \verb|\nl|-%
  94. \TeX-commands\footnote{This is not a \TeX-primitive but a TRI-specific
  95. \TeX-macro command which expands into a lot of stuff.},
  96. marking --- in a certain way --- optimal line-breaks.
  97. Additionally, these break items can be followed immediately by
  98. ``indentation items'', i.e. \verb|\OFF{...}| \TeX-commands\footnote{see
  99. previous footnote}, specifying the amount of indentation
  100. (in scaled points) applicable for the next new line.
  101. The problem is to choose the right points where to insert these
  102. special \TeX-items. Therefore, the \TeX-item list undergoes
  103. three further transformation steps.\par
  104. First, the \TeX-item list gets enlarged by so-called ``glue items''.
  105. Glue items are two-element lists, where the first element is a width
  106. info and the second element is a penalty info.
  107. The width is determined according to the class of the two \TeX-items
  108. to the left and to the right. Each \TeX-item is associated with
  109. one out of eight classes. Following Knuth's \TeX book [Knu86],
  110. these classes are ORD (for ordinary items),
  111. LOP (for large operators such as square roots),
  112. BIN and REL (for binary and relational operators), OPN and CLO (for
  113. opening and closing parentheses), PCT (for punctuation) and finally
  114. INN (for ``inner'' items such as \TeX-brackets and -macros).
  115. The data for the width information is stored in a matrix.
  116. Therefore, for each pair of classes it is easy to determine how much
  117. (if any) space should be inserted between two consecutive \TeX-items.
  118. \par
  119. The ``penalty'' is
  120. a value in the range of $-10000\ldots+10000$ indicating a mark-up on a
  121. potential break-point, thus determining if this point is a
  122. fairly good (if negative) or bad (if positive) choice.
  123. The amount of penalty depends heuristically
  124. (a) on the kind of \TeX-items surrounding the glue item,
  125. (b) on the bracket nesting, and finally
  126. (c) on special characteristics.\footnote{For example, the plus- and
  127. the difference operator have special impact on the amount of
  128. penalty. These operators are considered as extremely good places
  129. for breaking up a line.}\par
  130. During the second level, the \TeX-item list is transformed
  131. into a so-called breaklist consisting of {\em active} and
  132. {\em passive} nodes.
  133. A passive node is simply a width info giving the total width of
  134. \TeX-items not interspersed by glue items. On the other hand,
  135. active nodes are glue items enlarged by a third element, the
  136. offset info, indicating an indentation level which is used later
  137. for computing the actual amount of indentation.
  138. Active nodes are used as potential breakpoints.
  139. Moreover, while creating the breaklist, the \TeX-item list will be
  140. modified if necessary according to the length of fractions and square
  141. roots which cannot be broken if retained in their ``classical''
  142. form. Hence fractions look like {\tt (...)/(...)} if they don't fit
  143. into a single line, especially in the case of large
  144. polynomial fractions.\par
  145. The third and most important level is the line-breaking algorithm
  146. itself. The idea how to break lines is based
  147. on the article by Knuth/Plass(1981). Line-breaking can occur at
  148. active nodes only. So, you can loop through the breaklist considering
  149. all potential break-points. But in order to find a suitable way
  150. in a reasonable amount of time you have to limit the number of
  151. potential breakpoints considered. This is performed by associating
  152. a ``badness'' with each potential breakpoint, describing how
  153. good looking or bad looking a line turns out.
  154. If the badness is less than
  155. a given amount of ``tolerance'' --- as set by the user ---
  156. then an active node is considered to be feasible and becomes
  157. a delta node. A delta node is simply an active node enlarged
  158. by four further infos: an identification number for this node,
  159. a pointer to the best feasible break-point (i.e. delta-node)
  160. to come from,%
  161. \footnote{If one were to break the formula at this delta-node, the
  162. best place to start this line is given by this pointer. Note that
  163. this pointer points backward through the list. When all delta nodes
  164. have been inserted, you start at the very last delta node (which
  165. is always at the end of breaklist) and skip backward from one
  166. delta node to the next delta node pointed at. Thus, you find the
  167. best way to break up the list.}
  168. the total amount of demerits (a compound value derived from
  169. badness and penalty) accumulated so far, and a value indicating
  170. the amount of indentation applied to a new line beginning at this
  171. node.
  172. When the function dealing with line-breaking has stepped through
  173. the list, the breakpoints will have been determined.
  174. Afterwards all glue items (i.e. active nodes)
  175. are deleted from the \TeX-item list while break- and indentation-%
  176. items for those nodes marked as break-points are inserted.
  177. \par
  178. Finally the \TeX-item list is printed with regular ASCII-characters.
  179. The readabiltiy of the intermediate output is low,
  180. but it should be quite good enough for users to do some final
  181. editing work.
  182. Nevertheless, the nesting structure of the term is kept
  183. visible when printed, so it will be easy to distinguish between
  184. parenthesis levels simply by considering the amount of indentation.
  185. % ----------------------------------------------------------------------
  186. \section{Postprocessing with the module ``tridefs.tex''}
  187. % ----------------------------------------------------------------------
  188. When a \TeX-output file has been created with TRI it has to be
  189. processed by \TeX\ itself. But before you run \TeX\ you should make sure
  190. the file looks the way you want it. Sometimes you will
  191. find it necessary to add some \TeX-code of your own or delete some
  192. other \TeX-code. This is also the right time to
  193. check the line breaks marked by \verb|\nl|-commands.
  194. This job is up to you before you finally run \TeX.\par
  195. During the \TeX-run the sizes of brackets are determined. This task is
  196. not done by TRI. In order to produce proper sized brackets
  197. we put some \verb|\left(| and \verb|\right)| \TeX-commands
  198. where brackets are opened or closed. A new problem arises when
  199. an expression has been broken up into several lines. Since, for every
  200. line, the number of \verb|\left(| and \verb|\right)|
  201. \TeX-commands must match
  202. but bracketed expressions may start in one line and end in another,
  203. we have to insert the required number of ``dummy'' parentheses
  204. (i.e. \verb|\right.| and \verb|\left.| \TeX-commands)
  205. at the end of the current line and the beginning of the following line.
  206. This task is handled by the \verb|\nl|-\TeX-macro.\par
  207. There is a caveat against this method.
  208. Since opening and closing brackets
  209. needn't lie in the same line, it is possible that the height of the
  210. brackets can differ although they should correspond in height. That will
  211. happen if the height of the text in the opening line has a height
  212. different from the text in the closing line. We haven't found a
  213. way of tackling this problem yet, but we think it is possible to program
  214. a small \TeX-macro for this task.\par
  215. There is at least one more line of \TeX-code you have to
  216. insert by hand into the \TeX-input file produced by TRI. This line runs
  217. \begin{verbatim}
  218. \input tridefs
  219. \end{verbatim}
  220. and inputs the module {\tt tridefs.tex} into the file. This is necessary
  221. because otherwise \TeX\ won't know how to deal with our macro calls.
  222. If you use the \TeX-input file as a ``stand-alone'' file, don't
  223. forget a final \verb|\bye| at the end of the text. If you use
  224. code produced by TRI as part of a larger text then simply put
  225. the input-line just at the beginning of your text.
  226. %
  227. \section{Experiments}
  228. %
  229. We have tested TRI on a Micro-VAX operating under ULTRIX,
  230. with no other users working during this phase in order to minimize
  231. interference with other processes, e.g., caused by paging.
  232. The TRI code has been compiled with the PSL~3.4 compiler.
  233. The following table presents results obtained with a small number of
  234. different terms. All data were measured in CPU-seconds
  235. as displayed by LISP's TIME-facility.
  236. For expressions where special packages such as {\tt solve} and {\tt int}
  237. were involved we have taken only effective output-time, i.e. the time
  238. consumption caused by producing the output and not by calculating
  239. the algebraic result.\footnote{That means we assigned the result of an
  240. evaluation to an itermediate variable, and then we printed this
  241. intermediate variable. Thus we could eliminate the time overhead
  242. produced by ``pure'' evaluation. Nevertheless, in terms of effective
  243. interactive answering time, the sum of evaluation and printing time
  244. might be much more interesting than the ``pure'' printing time.
  245. In such a context the percentage overhead caused by printing is
  246. the critical point. But since we talk about printing we decided
  247. to document the ``pure'' printing time.} First we display
  248. the six expressions we have tested.\par
  249. $$(x+y)^{12}\eqno(1)$$
  250. $$(x+y)^{24}\eqno(2)$$
  251. $$(x+y)^{36}\eqno(3)$$
  252. $$(x+y)^{16}/(v-w)^{16}\eqno(4)$$
  253. $$solve((1+\xi)x^2-2\xi x+\xi,x)\eqno(5)$$
  254. $$solve(x^3+x^2\mu+\nu,x)\eqno(6)$$
  255. The following table shows the results:
  256. %
  257. \medskip
  258. \begin{center}
  259. {\tt
  260. \begin{tabular}{|c|r|r|r|r|} \hline
  261. {\small\rm No.}&{\small\rm normal}&{\small\rm TeX}&
  262. {\small\rm Break}&{\small\rm Indent}\\
  263. \hline
  264. 1& 0.65& 0.75& 3.30& 3.37\\
  265. 2& 1.38& 1.79&11.81&12.10\\
  266. 3& 2.31& 3.11&19.33&19.77\\
  267. 4& 1.87& 2.26&11.78& 9.64\\
  268. 5& 0.46& 0.75& 0.90& 0.88\\
  269. 6& 4.52&21.52&31.34&29.78\\
  270. \hline
  271. \end{tabular}
  272. }
  273. \medskip
  274. \end{center}
  275. %
  276. This short table should give you an impression of the
  277. performance of TRI. It goes without saying that on other machines
  278. results may turn out which are quite different from our results. But our
  279. intention is to show the relative and not the absolute performance.
  280. Note that printing times are a function of expression complexity,
  281. as shown by rows three and six.
  282. % ----------------------------------------------------------------------
  283. \section{User's Guide to the TRI}
  284. % ----------------------------------------------------------------------
  285. If you intend to use TRI you are required to load the compiled code.
  286. This can be performed with the command
  287. \begin{verbatim}
  288. load!-package 'tri;
  289. \end{verbatim}
  290. During the load, some default initializations are performed. The
  291. default page width is set to 15 centimeters, the tolerance for
  292. line breaking is set to 20 by default. Moreover, TRI is enabled
  293. to translate greek names, e.g. TAU or PSI, into equivalent \TeX\
  294. symbols, e.g. $\tau$ or $\psi$, respectively. Letters are printed
  295. lowercase as defined through assertion of the set LOWERCASE. The whole
  296. operation produces the following lines of output
  297. \begin{verbatim}
  298. % TeX-REDUCE-Interface 0.50
  299. % set GREEK asserted
  300. % set LOWERCASE asserted
  301. % \hsize=150mm
  302. % \tolerance 20
  303. \end{verbatim}
  304. Make sure you have at least version 0.50 installed at your site.
  305. Now you can switch the three TRI modes on and off as you like.
  306. You can use the switches alternatively and incrementally.
  307. That means you have to switch on TeX for receiving standard
  308. \TeX-output, or TeXBreak to receive broken \TeX-output, or
  309. TeXIndent to receive broken \TeX-output plus indentation.
  310. More specifically, if you switch off {\tt TeXBreak} you implicitly quit
  311. {\tt TeXIndent}, too, or, if you switch off {\tt TeX}, you
  312. implicitly quit {\tt TeXBreak} and, consequently, {\tt TeXIndent}.\par
  313. The most crucial point in defining how TRI breaks multiple lines
  314. of \TeX-code is your choice of the page width and the tolerance.
  315. As mentioned earlier, ``tolerance'' is related to \TeX's famous
  316. line-breaking algorithm. The value of ``tolerance'' determines which
  317. potential breakpoints are considered feasible and which are not. The
  318. higher the tolerance, the more breakpoints become feasible as determined
  319. by the value of ``badness'' associated with each breakpoint. Breakpoints
  320. are considered feasible if the badness is less than the tolerance.
  321. You can easily change the tolerance using
  322. \begin{verbatim}
  323. TeXtolerance(tolerance);
  324. \end{verbatim}
  325. where the {\em tolerance} is a positive integer in the closed interval
  326. $[0,10000]$.
  327. A tolerance of 0 means that actually no breakpoint will be considered
  328. feasible (except those carrying a negative penalty), while a value
  329. of 10000 allows any breakpoint to be considered feasible.
  330. Obviously, the choice of a tolerance has a great impact on the time
  331. consumption of our line-breaking algorithm since time consumption
  332. increases in proportion to the number of feasible breakpoints.
  333. So, the question is what values to choose. For line-breaking without
  334. indentation, suitable values for the tolerance lie between 10 and 100.
  335. As a rule of thumb, you should use higher values the deeper the term
  336. is nested --- if you can estimate. If you use indentation, you have to
  337. use much higher tolerance values. This is necessary because badness
  338. is worsened by indentation. Accordingly, TRI has to try harder to find
  339. suitable places where to break. Reasonable values for tolerance
  340. here lie between 700 and 1500. A value of 1000 should be your first
  341. guess. That will work for most expressions in a reasonable amount of
  342. time.\par
  343. The page width of the \TeX\ output page,
  344. measured in millimeters\footnote{You can
  345. also specify page width in scaled points (sp).
  346. Note: 1~pt = 65536~sp = 1/72.27~inch. The function automatically chooses
  347. the appropiate dimension according to the size: all values greater than
  348. 400 are considered to be scaled points.}, can be changed by using
  349. \begin{verbatim}
  350. TeXpagewidth(page-width);
  351. \end{verbatim}
  352. You should choose a page width according to your purposes,
  353. but allow a few centimeters for errors in TRI's attempt to
  354. emulate \TeX's metric.
  355. For example, specify 140 millimeters for an effective page width of
  356. 150 or 160 millimeters. That way you have a certain safety-margin to
  357. the borders of the page.\par
  358. Sometimes you want to add your own translations for REDUCE-symbols
  359. to be mapped to \TeX-items.
  360. For such a task, TRI provides a function named
  361. {\tt TeXlet} which binds any REDUCE-symbol to one of the predefined
  362. \TeX-items. A call to this function has the following syntax:
  363. \begin{verbatim}
  364. TeXlet(REDUCE-symbol,TeX-item)
  365. \end{verbatim}
  366. Three examples show how to do it right:
  367. \begin{verbatim}
  368. TeXlet(velocity,'!v);
  369. TeXlet(gamma,"\Gamma ");
  370. TeXlet(acceleration,"\vartheta ");
  371. \end{verbatim}
  372. Besides this method of single assertions you can choose to assert
  373. one of (currently) two standard sets providing substitutions
  374. for lowercase and greek letters. These sets are loaded by default.
  375. You can switch these sets on or off using the functions
  376. \begin{verbatim}
  377. TeXassertset setname;
  378. TeXretractset setname;
  379. \end{verbatim}
  380. where the setnames {\tt GREEK} and {\tt LOWERCASE}
  381. are currently defined and available.
  382. So far you have learned only how to connect REDUCE-atoms with predefined
  383. \TeX-items but not how to create new \TeX-items itself. We provide a
  384. way for adding standard \TeX-items of any class {\tt ORD, BIN, REL,
  385. OPN, CLO, PCT} and {\tt LOP} except for class {\tt INN} which is
  386. reserved for internal use by TRI only. You can call the function
  387. \begin{verbatim}
  388. TeXitem(item,class,list-of-widths)
  389. \end{verbatim}
  390. e.g. together with a binding
  391. \begin{verbatim}
  392. TeXitem("\nabla ",ORD,
  393. {546135,437818,377748});
  394. TeXlet(NABLA,"\nabla ");
  395. \end{verbatim}
  396. where {\em item} is a legal \TeX-code name\footnote{Please note that
  397. any \TeX-name ending with a letter must be followed by a blank
  398. to prevent interference with letters of following \TeX-items.
  399. Note also that you can legalize a name by defining it as a \TeX-macro
  400. and declaring its width.},
  401. {\em class} is one of seven classes (see above) and {\em list-of-widths}
  402. is a non-empty list of elements, each one representing the width of
  403. the item in successive super-/subscript depth levels.
  404. That means that the first entry is the width in display mode,
  405. the second stands for scriptstyle and the third stands for
  406. scriptscriptstyle in \TeX-terminology.
  407. Starting with version 0.50, all arguments can be supplied without
  408. quotation marks, i.e., LISP notation is no longer required
  409. but still possible.\par
  410. But how can you retrieve the width information required?
  411. For this purpose we provide a small interactive \TeX\ facility
  412. called {\tt redwidth.tex}.
  413. It repeatedly prompts you for the \TeX-items for which you want
  414. to retrieve the width information.\par
  415. Finally, another command is supplied which displays all
  416. information stored about a specific \TeX-item.
  417. If, for example, you call
  418. \begin{verbatim}
  419. TeXdisplay(NABLA);
  420. \end{verbatim}
  421. TRI will respond with
  422. \begin{verbatim}
  423. % TeX item \nabla is of class ORD and
  424. has following widths:
  425. % 8.333358pt 6.680572pt 5.763977pt
  426. \end{verbatim}
  427. %
  428. \section{Examples}
  429. %
  430. Some examples shall demonstrate the capabilities of TRI.
  431. For each example we state (a) the REDUCE command (i.e.
  432. the input), (b) the tolerance if it differs from the default, and
  433. (c) the output as produced in a \TeX\ run. The examples are
  434. displayed at the end of this article.\par
  435. %
  436. \section{Caveats}
  437. %
  438. Techniques for printing mathematical expressions are available
  439. everywhere. TRI adds only a highly specialized version for
  440. most REDUCE output. The emphasis is on the word {\em most}.
  441. One major caveat is that we cannot print SYMBOLIC-mode output
  442. from REDUCE. This could be done best in a WEB-like programming-plus-%
  443. documentation style. Nevertheless, as Knuth's WEB is allready available
  444. for PASCAL and C, hopefully someone will write a LISP-WEB or a
  445. REDUCE-WEB as well.\par
  446. \LaTeX\ users will be disappointed that we have not mentioned yet if and
  447. how TRI co-operates with \LaTeX. Nevertheless, TRI can be used
  448. together with \LaTeX, as this document proves. But there are some
  449. important restrictions. First, read in the module ``tridefs.tex''
  450. at the very beginning of a \LaTeX-run, before you apply any
  451. \LaTeX-specific command. Furthermore, the \TeX-macros used
  452. in this module {\em do} interfere with \LaTeX's own macros.
  453. You cannot use \LaTeX's \verb|\(|, \verb|\)|, \verb|\[| and \verb|\]|
  454. commands while you are using ``tridefs.tex''. If you avoid to
  455. use them you should be able to run TRI with \LaTeX\ smoothly.
  456. \par
  457. Whenever you discover a bug in our program please let us
  458. know. Send us a short report accompanied by an output listing.%
  459. \footnote{You can reach us via electronic mail at the following
  460. address: reduce@rrz.uni-koeln.de} We will try to fix the error.
  461. %
  462. \section{Distribution}
  463. %
  464. The whole TRI package consists of following files:
  465. \begin{itemize}
  466. \item {\tt tri.latex}: This text as a \TeX-input file.
  467. \item {\tt tri.tex}: A long version of this report, where we explain
  468. our breaking algorithm thoroughly.
  469. \item {\tt tri.red}: This is the REDUCE-LISP source code
  470. for TRI (approximately 58 KBytes of code).
  471. \item {\tt tridefs.tex}: The \TeX-input file to be used together with
  472. output from TRI.
  473. \item {\tt redwidth.tex}: This is the \TeX-input file for interactive
  474. determination of \TeX-item widths.
  475. \item {\tt tritest.red}: Run this REDUCE file to check if TRI works
  476. correctly.
  477. \item {\tt tritest.tex}: When you have run the file {\tt tritest.red},
  478. just make a \TeX\ run with this file to see all the nice things
  479. TRI is able to produce.
  480. \end{itemize}
  481. You can obtain TRI package from a network library at The
  482. RAND Corporation, Santa Monica, Ca./USA.
  483. Simply send a note {\tt send index} to the network address
  484. {\tt reduce-netlib@rand.org} and you will receive a description
  485. on how to use the REDUCE netlib followed by a directory.
  486. Specific files may be requested with the command
  487. {\tt send }{\em library file}, where {\em library} is one the
  488. catalogues containing the different REDUCE packages, and {\em file}
  489. is the name of a particular file. For example, you can use
  490. the message {\tt send tex tri.red} to obtain the RLISP-code of
  491. the \9.
  492. % ----------------------------------------------------------------------
  493. \begin{thebibliography}{Knu88}
  494. \bibitem[Ant86]{an:be}Antweiler, W.; Strotmann, A.; Pfenning, Th.;
  495. Winkelmann, V.: {\em Zwischenbericht \"{u}ber den Status der
  496. Arbeiten am REDUCE-\TeX-Anschlu\ss.}
  497. Internal Paper, Rechenzentrum an der Universit\"{a}t
  498. zu K\"{o}ln, November 1986.
  499. \bibitem[Ant89]{an:Ab}Antweiler, W.: {\em A \TeX{}-REDUCE-Interface.}
  500. Arbeits\-bericht RRZK 8901 des Regionalen Rechen\-zentrums an der
  501. Uni\-versi\-t\"{a}t zu K\"{o}ln, Februar 1989.
  502. \bibitem[Fat87]{fa:Te}Fateman, Richard J.:
  503. {\em\TeX\ Output from MACSYMA-like Systems.}
  504. ACM SIGSAM Bulletin, Vol. 21, No. 4, Issue \#82, pp. 1--5,
  505. November 1987.
  506. \bibitem[Knu81]{kn:br}Knuth, Donald E.; Plass, Michael F.:
  507. {\em Breaking Paragraphs into Lines.}
  508. Software---Practice and Experience, Vol. 11,
  509. pp. 1119--1184, 1981.
  510. \bibitem[Knu86]{kn:Te}Knuth, Donald E.: {\em The \TeX\-book.}
  511. Addison-Wesley, Readings/Ma. Sixth printing, 1986.
  512. \bibitem[Hea87]{he:RE}Hearn, Anthony C.: {\em REDUCE User's Manual,
  513. Version 3.3.} The RAND Corporation, Santa Monica, Ca.,
  514. July 1987.
  515. \end{thebibliography}
  516. %
  517. %
  518. \onecolumn
  519. %
  520. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  521. %%%%% %%%%%
  522. %%%%% Examples for the TRI %%%%%
  523. %%%%% %%%%%
  524. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  525. %
  526. \TRIexa{Standard}{TeXindent}{250}{\verb|(x+y)**16/(v-w)**16|}
  527. $$\displaylines{\qdd
  528. \(x^{16}
  529. +16\cdot x^{15}\cdot y
  530. +120\cdot x^{14}\cdot y^{2}
  531. +560\cdot x^{13}\cdot y^{3}\nl
  532. \OFF{327680}
  533. +1820\cdot x^{12}\cdot y^{4}
  534. +4368\cdot x^{11}\cdot y^{5}
  535. +8008\cdot x^{10}\cdot y^{6}\nl
  536. \OFF{327680}
  537. +11440\cdot x^{9}\cdot y^{7}
  538. +12870\cdot x^{8}\cdot y^{8}
  539. +11440\cdot x^{7}\cdot y^{9}\nl
  540. \OFF{327680}
  541. +8008\cdot x^{6}\cdot y^{10}
  542. +4368\cdot x^{5}\cdot y^{11}
  543. +1820\cdot x^{4}\cdot y^{12}\nl
  544. \OFF{327680}
  545. +560\cdot x^{3}\cdot y^{13}
  546. +120\cdot x^{2}\cdot y^{14}
  547. +16\cdot x\cdot y^{15}
  548. +y^{16}
  549. \)
  550. /\nl
  551. \(v^{16}
  552. -16\cdot v^{15}\cdot w
  553. +120\cdot v^{14}\cdot w^{2}
  554. -560\cdot v^{13}\cdot w^{3}\nl
  555. \OFF{327680}
  556. +1820\cdot v^{12}\cdot w^{4}
  557. -4368\cdot v^{11}\cdot w^{5}
  558. +8008\cdot v^{10}\cdot w^{6}
  559. -11440\cdot v^{9}\cdot w^{7}\nl
  560. \OFF{327680}
  561. +12870\cdot v^{8}\cdot w^{8}
  562. -11440\cdot v^{7}\cdot w^{9}
  563. +8008\cdot v^{6}\cdot w^{10}
  564. -4368\cdot v^{5}\cdot w^{11}\nl
  565. \OFF{327680}
  566. +1820\cdot v^{4}\cdot w^{12}
  567. -560\cdot v^{3}\cdot w^{13}
  568. +120\cdot v^{2}\cdot w^{14}
  569. -16\cdot v\cdot w^{15}
  570. +w^{16}
  571. \)
  572. \Nl}$$
  573. \TRIexa{Integration}{TeX}{-}{\verb|int(1/(x**3+2),x)|}
  574. $$
  575. -
  576. \(\frac{2^{\frac{1}{
  577. 3}}\cdot
  578. \(2\cdot
  579. \sqrt{3}\cdot
  580. \arctan
  581. \(\frac{2^{\frac{1}{
  582. 3}}
  583. -2\cdot x}{
  584. 2^{\frac{1}{
  585. 3}}\cdot
  586. \sqrt{3}}
  587. \)
  588. +
  589. \ln
  590. \(2^{\frac{2}{
  591. 3}}
  592. -2^{\frac{1}{
  593. 3}}\cdot x
  594. +x^{2}
  595. \)
  596. -2\cdot
  597. \ln
  598. \(2^{\frac{1}{
  599. 3}}
  600. +x
  601. \)
  602. \)
  603. }{
  604. 12}
  605. \)
  606. $$
  607. \TRIexa{Integration}{TeXindent}{1000}%
  608. {\verb|int(1/(x{*}{*}4+3*x{*}{*}2-1,x)|}
  609. $$\displaylines{\qdd
  610. \(\sqrt{2}\cdot
  611. \(3\cdot
  612. \sqrt{
  613. \sqrt{13}
  614. -3}\cdot
  615. \sqrt{13}\cdot
  616. \ln
  617. \(-
  618. \(\sqrt{
  619. \sqrt{13}
  620. -3}\cdot
  621. \sqrt{2}
  622. \)
  623. +2\cdot x
  624. \)
  625. \nl
  626. \OFF{2260991}
  627. -3\cdot
  628. \sqrt{
  629. \sqrt{13}
  630. -3}\cdot
  631. \sqrt{13}\cdot
  632. \ln
  633. \(\sqrt{
  634. \sqrt{13}
  635. -3}\cdot
  636. \sqrt{2}
  637. +2\cdot x
  638. \)
  639. \nl
  640. \OFF{2260991}
  641. +13\cdot
  642. \sqrt{
  643. \sqrt{13}
  644. -3}\cdot
  645. \ln
  646. \(-
  647. \(\sqrt{
  648. \sqrt{13}
  649. -3}\cdot
  650. \sqrt{2}
  651. \)
  652. +2\cdot x
  653. \)
  654. \nl
  655. \OFF{2260991}
  656. -13\cdot
  657. \sqrt{
  658. \sqrt{13}
  659. -3}\cdot
  660. \ln
  661. \(\sqrt{
  662. \sqrt{13}
  663. -3}\cdot
  664. \sqrt{2}
  665. +2\cdot x
  666. \)
  667. \nl
  668. \OFF{2260991}
  669. +6\cdot
  670. \sqrt{
  671. \sqrt{13}
  672. +3}\cdot
  673. \sqrt{13}\cdot
  674. \arctan
  675. \(\frac{2\cdot x}{
  676. \sqrt{
  677. \sqrt{13}
  678. +3}\cdot
  679. \sqrt{2}}
  680. \)
  681. \nl
  682. \OFF{2260991}
  683. -26\cdot
  684. \sqrt{
  685. \sqrt{13}
  686. +3}\cdot
  687. \arctan
  688. \(\frac{2\cdot x}{
  689. \sqrt{
  690. \sqrt{13}
  691. +3}\cdot
  692. \sqrt{2}}
  693. \)
  694. \)
  695. \)
  696. /104
  697. \Nl}$$
  698. \TRIexa{Solving Equations}{TeXindent}{1000}%
  699. {\verb|solve(x**3+x**2*mu+nu=0,x)|}
  700. $$\displaylines{\qdd
  701. \{x=
  702. \[-
  703. \(\(\(9\cdot
  704. \sqrt{4\cdot \mu ^{3}\cdot \nu
  705. +27\cdot \nu ^{2}}
  706. -2\cdot
  707. \sqrt{3}\cdot \mu ^{3}
  708. -27\cdot
  709. \sqrt{3}\cdot \nu
  710. \)
  711. ^{\frac{2}{
  712. 3}}\cdot
  713. \sqrt{3}\cdot i\nl
  714. \OFF{3675021}
  715. +
  716. \(9\cdot
  717. \sqrt{4\cdot \mu ^{3}\cdot \nu
  718. +27\cdot \nu ^{2}}
  719. -2\cdot
  720. \sqrt{3}\cdot \mu ^{3}
  721. -27\cdot
  722. \sqrt{3}\cdot \nu
  723. \)
  724. ^{\frac{2}{
  725. 3}}\nl
  726. \OFF{3675021}
  727. +2\cdot
  728. \(9\cdot
  729. \sqrt{4\cdot \mu ^{3}\cdot \nu
  730. +27\cdot \nu ^{2}}
  731. -2\cdot
  732. \sqrt{3}\cdot \mu ^{3}
  733. -27\cdot
  734. \sqrt{3}\cdot \nu
  735. \)
  736. ^{\frac{1}{
  737. 3}}\cdot \nl
  738. \OFF{3675021}
  739. 2^{\frac{1}{
  740. 3}}\cdot 3^{\frac{1}{
  741. 6}}\cdot
  742. \mu
  743. -2^{\frac{2}{
  744. 3}}\cdot
  745. \sqrt{3}\cdot 3^{\frac{1}{
  746. 3}}\cdot
  747. i\cdot \mu ^{2}
  748. +2^{\frac{2}{
  749. 3}}\cdot 3^{\frac{1}{
  750. 3}}\cdot
  751. \mu ^{2}
  752. \)
  753. /\nl
  754. \OFF{3347341}
  755. \(6\cdot
  756. \(9\cdot
  757. \sqrt{4\cdot \mu ^{3}\cdot \nu
  758. +27\cdot \nu ^{2}}
  759. -2\cdot
  760. \sqrt{3}\cdot \mu ^{3}
  761. -27\cdot
  762. \sqrt{3}\cdot \nu
  763. \)
  764. ^{\frac{1}{
  765. 3}}\cdot 2^{\frac{1}{
  766. 3}}\cdot
  767. 3^{\frac{1}{
  768. 6}}
  769. \)
  770. \)
  771. \]
  772. \CO\nl
  773. \OFF{327680}
  774. x=
  775. \[\(\(9\cdot
  776. \sqrt{4\cdot \mu ^{3}\cdot \nu
  777. +27\cdot \nu ^{2}}
  778. -2\cdot
  779. \sqrt{3}\cdot \mu ^{3}
  780. -27\cdot
  781. \sqrt{3}\cdot \nu
  782. \)
  783. ^{\frac{2}{
  784. 3}}\cdot
  785. \sqrt{3}\cdot i\nl
  786. \OFF{2837617}
  787. -
  788. \(9\cdot
  789. \sqrt{4\cdot \mu ^{3}\cdot \nu
  790. +27\cdot \nu ^{2}}
  791. -2\cdot
  792. \sqrt{3}\cdot \mu ^{3}
  793. -27\cdot
  794. \sqrt{3}\cdot \nu
  795. \)
  796. ^{\frac{2}{
  797. 3}}\nl
  798. \OFF{2837617}
  799. -2\cdot
  800. \(9\cdot
  801. \sqrt{4\cdot \mu ^{3}\cdot \nu
  802. +27\cdot \nu ^{2}}
  803. -2\cdot
  804. \sqrt{3}\cdot \mu ^{3}
  805. -27\cdot
  806. \sqrt{3}\cdot \nu
  807. \)
  808. ^{\frac{1}{
  809. 3}}\cdot \nl
  810. \OFF{2837617}
  811. 2^{\frac{1}{
  812. 3}}\cdot 3^{\frac{1}{
  813. 6}}\cdot \mu
  814. -2^{\frac{2}{
  815. 3}}\cdot
  816. \sqrt{3}\cdot 3^{\frac{1}{
  817. 3}}\cdot i\cdot
  818. \mu ^{2}
  819. -2^{\frac{2}{
  820. 3}}\cdot 3^{\frac{1}{
  821. 3}}\cdot
  822. \mu ^{2}
  823. \)
  824. /\nl
  825. \OFF{2509937}
  826. \(6\cdot
  827. \(9\cdot
  828. \sqrt{4\cdot \mu ^{3}\cdot \nu
  829. +27\cdot \nu ^{2}}
  830. -2\cdot
  831. \sqrt{3}\cdot \mu ^{3}
  832. -27\cdot
  833. \sqrt{3}\cdot \nu
  834. \)
  835. ^{\frac{1}{
  836. 3}}\cdot 2^{\frac{1}{
  837. 3}}\cdot 3^{
  838. \frac{1}{
  839. 6}}
  840. \)
  841. \]
  842. \CO\nl
  843. \OFF{327680}
  844. x=
  845. \[\(\(9\cdot
  846. \sqrt{4\cdot \mu ^{3}\cdot \nu
  847. +27\cdot \nu ^{2}}
  848. -2\cdot
  849. \sqrt{3}\cdot \mu ^{3}
  850. -27\cdot
  851. \sqrt{3}\cdot \nu
  852. \)
  853. ^{\frac{2}{
  854. 3}}\nl
  855. \OFF{2837617}
  856. -
  857. \(9\cdot
  858. \sqrt{4\cdot \mu ^{3}\cdot \nu
  859. +27\cdot \nu ^{2}}
  860. -2\cdot
  861. \sqrt{3}\cdot \mu ^{3}
  862. -27\cdot \nl
  863. \OFF{3675021}
  864. \sqrt{3}\cdot \nu
  865. \)
  866. ^{\frac{1}{
  867. 3}}\cdot 2^{\frac{1}{
  868. 3}}\cdot 3^{
  869. \frac{1}{
  870. 6}}\cdot \mu
  871. +2^{\frac{2}{
  872. 3}}\cdot 3^{\frac{1}{
  873. 3}}\cdot
  874. \mu ^{2}
  875. \)
  876. /\nl
  877. \OFF{2509937}
  878. \(3\cdot
  879. \(9\cdot
  880. \sqrt{4\cdot \mu ^{3}\cdot \nu
  881. +27\cdot \nu ^{2}}
  882. -2\cdot
  883. \sqrt{3}\cdot \mu ^{3}
  884. -27\cdot
  885. \sqrt{3}\cdot \nu
  886. \)
  887. ^{\frac{1}{
  888. 3}}\cdot 2^{\frac{1}{
  889. 3}}\cdot 3^{
  890. \frac{1}{
  891. 6}}
  892. \)
  893. \]
  894. \}
  895. \Nl}$$
  896. \TRIexa{Matrix Printing}{TeX}{--}{%
  897. \verb|mat((1,a-b,1/(c-d)),(a**2-b**2,1,sqrt(c)),((a+b)/(c-d),sqrt(d),1))|
  898. }
  899. $$
  900. \pmatrix{1&a
  901. -b&
  902. \frac{1}{
  903. c
  904. -d}\cr
  905. a^{2}
  906. -b^{2}&1&
  907. \sqrt{c}\cr
  908. \frac{a
  909. +b}{
  910. c
  911. -d}&
  912. \sqrt{d}&1\cr
  913. }
  914. $$
  915. %
  916. %
  917. \end{document}