rlfi.tex 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. \documentstyle[11pt,reduce]{article}
  2. \title{RLFI\\
  3. A \REDUCE{} \LaTeX{} Formula Interface\\
  4. Version 1.2}
  5. \date{October 2, 1992}
  6. \author{Richard Liska, Ladislav Drska\\
  7. Computational Physics Group\\
  8. Faculty of Nuclear Sciences and Physical Engineering\\
  9. Czech Technical University in Prague\\
  10. Brehova 7, 115 19 Prague 1, Czechoslovakia\\
  11. E-mail: tjerl@aci.cvut.cs}
  12. \begin{document}
  13. \maketitle
  14. \vskip1.cm
  15. High quality typesetting of mathematical formulas is a quite tedious
  16. task. One of the most sophisticated typesetting programs for
  17. mathematical text \TeX{} \cite{Knuth:84}, together with its widely used
  18. macro package \LaTeX{} \cite{Lamport:86}, has a strange syntax of
  19. mathematical formulas, especially of the complicated type. This is the
  20. main reason which lead us to designing the formula interface between the
  21. computer algebra system \REDUCE{} and the document preparation system
  22. \LaTeX{}. The other reason is that all available syntaxes of the
  23. \REDUCE{} formula output are line oriented and thus not suitable for
  24. typesetting in mathematical text. The idea of interfacing a computer
  25. algebra system to a typesetting program has already been used, eg. in
  26. \cite{Fateman:87} presenting the \TeX{} output of the MACSYMA computer
  27. algebra system.
  28. The formula interface presented here adds to \REDUCE{} the new syntax of
  29. formula output, namely \LaTeX{} syntax, and can also be named \REDUCE{} -
  30. \LaTeX{} translator. Text generated by \REDUCE{} in this syntax can be
  31. directly used in \LaTeX{} source documents. Various mathematical
  32. constructions are supported by the interface including subscripts,
  33. superscripts, font changing, Greek letters, divide-bars, integral and
  34. sum signs, derivatives etc.
  35. The interface can be used in two ways:
  36. \begin{itemize}
  37. \item for typesetting of results of \REDUCE{} algebraic calculations.
  38. \item for typesetting of users formulas.
  39. \end{itemize}
  40. The latter can even be used by users unfamiliar with the \REDUCE{}
  41. system, because the \REDUCE{} input syntax of formulas is almost the
  42. same as the syntax of the majority of programming languages. We aimed
  43. at speeding up the process of formula typesetting, because we are
  44. convinced, that the writing of correct complicated formulas in the
  45. \REDUCE{} syntax is a much more simpler task than writing them in the
  46. \LaTeX{} syntax full of keywords and special characters \verb+ \, {, ^+
  47. etc. It is clear, that not every formula produced by the interface is
  48. typeset in the best format from an aesthetic point of view. When a user
  49. is not satisfied with the result, he can add some \LaTeX{} commands to the
  50. \REDUCE{} output - \LaTeX{} input.
  51. The interface is connected to \REDUCE{} by three new switches and
  52. several statements. To activate the \LaTeX{} output mode the switch {\tt
  53. LATEX} must be set {\tt ON}. This switch, similar to the switch {\tt
  54. FORT} producing FORTRAN output, being {\tt ON} causes all outputs to be
  55. written in the \LaTeX{} syntax of formulas. The switch {\tt VERBATIM} is
  56. used for input printing control. If it is ON input to \REDUCE{} system
  57. is typesetted in \LaTeX{} verbatim environment after the line containing
  58. the string {\tt REDUCE Input:}.
  59. The switch {\tt LASIMP} controls the algebraic evaluation of input
  60. formulas. If it is {\tt ON} every formula is evaluated, simplified and
  61. written in the form given by ordinary \REDUCE{} statements and switches
  62. such as {\tt FACTOR}, {\tt ORDER}, {\tt RAT} etc. In the case when the
  63. {\tt LASIMP} switch is {\tt OFF} evaluation, simplification or
  64. reordering of formulas is not performed and \REDUCE{} acts only as a
  65. formula parser and the form of the formula output is exactly the same as
  66. that of the input, the only difference remains in the syntax. The mode
  67. {\tt OFF LASIMP} is designed especially for typesetting of formulas for
  68. which the user needs preservation of their structure. This switch has
  69. no meaning if the switch {\tt LATEX} is {\tt OFF} and thus is working
  70. only for \LaTeX{} output.
  71. For every identifier used in the typesetted \REDUCE{} formula
  72. the following properties can be defined by the statement {\tt DEFID}:
  73. \begin{itemize}
  74. \item its printing symbol (Greek letters can be used).
  75. \item the font in which the symbol will be typesetted.
  76. \item accent which will be typesetted above the symbol.
  77. \end{itemize}
  78. Symbols with indexes are treated in \REDUCE{} as operators. Each index
  79. corresponds to an argument of the operator. The meaning of operator
  80. arguments (where one wants to typeset them) is declared by the statement
  81. {\tt DEFINDEX}. This statement causes the arguments to be typesetted as
  82. subscripts or superscripts (on left or right-hand side of the operator)
  83. or as arguments of the operator.
  84. The statement {\tt MATHSTYLE} defines the style of formula typesetting.
  85. The variable {\tt LALINE!*} defines the length of output lines.
  86. The fractions with horizontal divide bars are typesetted by using the
  87. new \REDUCE{} infix operator \verb+\+. This operator is not
  88. algebraically simplified. During typesetting of powers the checking on
  89. the form of the power base and exponent is performed to determine the
  90. form of the typesetted expression (eg. sqrt symbol, using parentheses).
  91. Some special forms can be typeset by using \REDUCE{} prefix operators.
  92. These are as follows:
  93. \begin{itemize}
  94. \item {\tt INT} - integral of an expression.
  95. \item {\tt DINT} - definite integral of an expression.
  96. \item {\tt DF} - derivative of an expression.
  97. \item {\tt PDF} - partial derivative of an expression.
  98. \item {\tt SUM} - sum of expressions.
  99. \item {\tt PRODUCT} - product of expressions.
  100. \item {\tt SQRT} - square root of expression.
  101. \end{itemize}
  102. There are still some problems unsolved in the present version of the
  103. interface as follows:
  104. \begin{itemize}
  105. \item breaking the formulas which do not fit on one line.
  106. \item automatic decision where to use divide bars in fractions.
  107. \item distinction of two- or more-character identifiers from the product
  108. of one-character symbols.
  109. \item typesetting of matrices.
  110. \end{itemize}
  111. \vskip0.5cm
  112. \centerline{\bf Description of files}
  113. \begin{description}
  114. \item[RLFI.RED] - \REDUCE{} source file for this interface.
  115. \item[RLFI.TEX] - this document.
  116. \item[RLFI.BIB] - bibliography file for this document.
  117. \item[RLFI.TST] - test file for this interface.
  118. \item[RLFI.LOG] - \LaTeX{} output of the test session,
  119. can be directly used as \LaTeX{} input file.
  120. \end{description}
  121. \centerline{\bf Remark}
  122. After finishing presented interface, we have found another work
  123. \cite{Antweiler:89}, which solves the same problem. The RLFI package has
  124. been described in \cite{Drska:90} too.
  125. \bibliography{rlfi}
  126. \bibliographystyle{plain}
  127. \vskip0.5cm
  128. \section{APPENDIX: Summary and syntax}
  129. {\bf Warning}
  130. The RLFI package can be used only on systems supporting lower case
  131. letters with {\tt OFF RAISE} statement. The package distinquishes the
  132. upper and lower case letters, so be carefull in typing them.
  133. {\bf Switches}
  134. \begin{description}
  135. \item[{\tt LATEX}]
  136. - If {\tt ON} output is in \LaTeX{} format. It turns {\tt OFF} the {\tt
  137. RAISE} switch if it is set {\tt ON} and {\tt ON} the {\tt RAISE} switch
  138. if it is set {\tt OFF}. By default is {\tt OFF}.
  139. \item[{\tt LASIMP}]
  140. - If {\tt ON} formulas are evaluated (simplified), \REDUCE{} works
  141. as usually. If {\tt OFF} no evaluation is performed and the structure
  142. of formulas is preserved. By default is {\tt ON}.
  143. \item[{\tt VERBATIM}]
  144. - If {\tt ON} the \REDUCE{} input, while {\tt LATEX} switch being {\tt
  145. ON}, is printed in \LaTeX{} verbatim environment. The acutal \REDUCE{}
  146. input is printed after the line containing the string {\tt "REDUCE
  147. Input:"}. It turns {\tt ON} resp. {\tt OFF} the {\tt ECHO} switch when
  148. turned {\tt ON} resp. {\tt OFF}. By default is {\tt OFF}.
  149. \end{description}
  150. {\bf Operators}
  151. \begin{description}
  152. \item[infix] - \verb+\+
  153. \item[prefix] - {\tt INT,DINT,DF,PDF,SUM,PRODUCT,SQRT} and all \REDUCE{}
  154. prefix operators defined in the \REDUCE{} kernel and the SOLVE module.
  155. \end{description}
  156. \begin{verbatim}
  157. <alg. expression> \ <alg. expression>
  158. INT(<function>,<variable>)
  159. DINT(<from>,<to>,<function>,<variable>)
  160. DF(<function>,<variables>)
  161. <variables> ::= <o-variable>|<o-variable>,<variables>
  162. <o-variable> ::= <variable>|<variable>,<order>
  163. <variable> ::= <kernel>
  164. <order> ::= <integer>
  165. <function> ::= <alg. expression>
  166. <from> ::= <alg. expression>
  167. <to> ::= <alg. expression>
  168. PDF(<function>,<variables>)
  169. SUM(<from>,<to>,<function>)
  170. PRODUCT(<from>,<to>,<function>)
  171. SQRT(<alg. expression>)
  172. \end{verbatim}
  173. {\tt <alg. expression>} is any algebraic expression. Where appropriate,
  174. it can include also relational operators (e.g. argument {\tt <from>} of
  175. {\tt SUM} or {\tt PRODUCT} operators is usually equation). {\tt
  176. <kernel>} is identifier or prefix operator with arguments as described
  177. in \cite{Hearn:91}. Interface supports typesetting lists of algebraic
  178. expressions.
  179. {\bf Statements}
  180. \begin{verbatim}
  181. MATHSTYLE <m-style>;
  182. <m-style> ::= math | displaymath | equation
  183. DEFID <identifier>,<d-equations>;
  184. <d-equations> ::= <d-equation> | <d-equation>,<d-equations>
  185. <d-equation> ::= <d-print symbol> | <d-font>|<d-accent>
  186. <d-print symbol> ::= NAME = <print symbol>
  187. <d-font> ::= FONT = <font>
  188. <d-accent> ::= ACCENT = <accent>
  189. <print symbol> ::= <character> | <special symbol>
  190. <special symbol> ::= alpha|beta|gamma|delta|epsilon|
  191. varepsilon|zeta|eta|theta|vartheta|iota|kappa|lambda|
  192. mu|nu|xi|pi|varpi|rho|varrho|sigma|varsigma|tau|
  193. upsilon|phi|varphi|chi|psi|omega|Gamma|Delta|Theta|
  194. Lambda|Xi|Pi|Sigma|Upsilon|Phi|Psi|Omega|infty|hbar
  195. <font> ::= bold|roman
  196. <accent> ::=hat|check|breve|acute|grave|tilde|bar|vec|
  197. dot|ddot
  198. \end{verbatim}
  199. For special symbols and accents see \cite{Lamport:86}, p. 43, 45, 51.
  200. \begin{verbatim}
  201. DEFINDEX <d-operators>;
  202. <d-operators> ::= <d-operator> | <d-operator>,<d-operators>
  203. <d-operator> ::= <prefix operator>(<descriptions>)
  204. <prefix operator> ::= <identifier>
  205. <descriptions> ::= <description> | <description>,
  206. <descriptions>
  207. <description> ::= ARG | UP | DOWN | LEFTUP | LEFTDOWN
  208. \end{verbatim}
  209. The meaning of the statements is briefly described in the preceding
  210. text.
  211. \end{document}