rlfi.tex 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. \documentstyle[11pt,reduce]{article}
  2. \title{RLFI\\
  3. A \REDUCE{} \LaTeX{} Formula Interface\\
  4. Version 1.2.1}
  5. \date{May 23, 1995}
  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, Czech Republic\\
  11. E-mail: liska@siduri.fjfi.cvut.cz}
  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 {\tt on} input to \REDUCE{} system
  57. is typeset 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 typeset \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 typeset.
  76. \item accent which will be typeset 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 typeset 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 typeset 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 typeset 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. In \REDUCE 3.6 the \REDUCE commands have to be typed in lower-case
  134. while the switch {\tt latex} is {\tt on}, in previous versions
  135. the commands had to be typed in upper-case.
  136. {\bf Switches}
  137. \begin{description}
  138. \item[{\tt latex}]
  139. - If {\tt on} output is in \LaTeX{} format. It turns {\tt off} the {\tt
  140. raise} switch if it is set {\tt on} and {\tt on} the {\tt raise} switch
  141. if it is set {\tt off}. By default is {\tt off}.
  142. \item[{\tt lasimp}]
  143. - If {\tt on} formulas are evaluated (simplified), \REDUCE{} works
  144. as usually. If {\tt off} no evaluation is performed and the structure
  145. of formulas is preserved. By default is {\tt on}.
  146. \item[{\tt verbatim}]
  147. - If {\tt on} the \REDUCE{} input, while {\tt latex} switch being {\tt
  148. on}, is printed in \LaTeX{} verbatim environment. The acutal \REDUCE{}
  149. input is printed after the line containing the string {\tt "REDUCE
  150. Input:"}. It turns {\tt on} resp. {\tt off} the {\tt echo} switch when
  151. turned {\tt on} resp. {\tt off}. by default is {\tt off}.
  152. \end{description}
  153. {\bf Operators}
  154. \begin{description}
  155. \item[infix] - \verb+\+
  156. \item[prefix] - {\tt int,dint,df,pdf,sum,product,sqrt} and all \REDUCE{}
  157. prefix operators defined in the \REDUCE{} kernel and the SOLVE module.
  158. \end{description}
  159. \begin{verbatim}
  160. <alg. expression> \ <alg. expression>
  161. int(<function>,<variable>)
  162. dint(<from>,<to>,<function>,<variable>)
  163. df(<function>,<variables>)
  164. <variables> ::= <o-variable>|<o-variable>,<variables>
  165. <o-variable> ::= <variable>|<variable>,<order>
  166. <variable> ::= <kernel>
  167. <order> ::= <integer>
  168. <function> ::= <alg. expression>
  169. <from> ::= <alg. expression>
  170. <to> ::= <alg. expression>
  171. pdf(<function>,<variables>)
  172. sum(<from>,<to>,<function>)
  173. product(<from>,<to>,<function>)
  174. sqrt(<alg. expression>)
  175. \end{verbatim}
  176. {\tt <alg. expression>} is any algebraic expression. Where appropriate,
  177. it can include also relational operators (e.g. argument {\tt <from>} of
  178. {\tt sum} or {\tt product} operators is usually equation). {\tt
  179. <kernel>} is identifier or prefix operator with arguments as described
  180. in \cite{Hearn:95}. Interface supports typesetting lists of algebraic
  181. expressions.
  182. {\bf Statements}
  183. \begin{verbatim}
  184. mathstyle <m-style>;
  185. <m-style> ::= math | displaymath | equation
  186. defid <identifier>,<d-equations>;
  187. <d-equations> ::= <d-equation> | <d-equation>,<d-equations>
  188. <d-equation> ::= <d-print symbol> | <d-font>|<d-accent>
  189. <d-print symbol> ::= name = <print symbol>
  190. <d-font> ::= font = <font>
  191. <d-accent> ::= accent = <accent>
  192. <print symbol> ::= <character> | <special symbol>
  193. <special symbol> ::= alpha|beta|gamma|delta|epsilon|
  194. varepsilon|zeta|eta|theta|vartheta|iota|kappa|lambda|
  195. mu|nu|xi|pi|varpi|rho|varrho|sigma|varsigma|tau|
  196. upsilon|phi|varphi|chi|psi|omega|Gamma|Delta|Theta|
  197. Lambda|Xi|Pi|Sigma|Upsilon|Phi|Psi|Omega|infty|hbar
  198. <font> ::= bold|roman
  199. <accent> ::=hat|check|breve|acute|grave|tilde|bar|vec|
  200. dot|ddot
  201. \end{verbatim}
  202. For special symbols and accents see \cite{Lamport:86}, p. 43, 45, 51.
  203. \begin{verbatim}
  204. defindex <d-operators>;
  205. <d-operators> ::= <d-operator> | <d-operator>,<d-operators>
  206. <d-operator> ::= <prefix operator>(<descriptions>)
  207. <prefix operator> ::= <identifier>
  208. <descriptions> ::= <description> | <description>,
  209. <descriptions>
  210. <description> ::= arg | up | down | leftup | leftdown
  211. \end{verbatim}
  212. The meaning of the statements is briefly described in the preceding
  213. text.
  214. \end{document}