roots.tex 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. \chapter{ROOTS: A REDUCE root finding package}
  2. \label{ROOTS}
  3. \typeout{{ROOTS: A REDUCE root finding package}}
  4. {\footnotesize
  5. \begin{center}
  6. Stanley L. Kameny \\
  7. Los Angeles, U.S.A.
  8. \end{center}
  9. }
  10. \ttindex{ROOTS}
  11. The root finding package is designed so that it can be used as an
  12. independent package, or it can be integrated with and called by {\tt
  13. SOLVE}.\index{SOLVE package ! with ROOTS package}
  14. \section{Top Level Functions}
  15. The top level functions can be called either as symbolic operators from
  16. algebraic mode, or they can be called directly from symbolic mode with
  17. symbolic mode arguments. Outputs are expressed in forms that print out
  18. correctly in algebraic mode.
  19. \subsection{Functions that refer to real roots only}
  20. The three functions \f{REALROOTS}, \f{ISOLATER} and \f{RLROOTNO} can
  21. receive 1, 2 or 3 arguments.
  22. The first argument is the polynomial p, that can be complex and can
  23. have multiple or zero roots. If arg2 and arg3 are not present, all real
  24. roots are found. If the additional arguments are present, they restrict
  25. the region of consideration.
  26. \begin{itemize}
  27. \item If there are two arguments the second is either POSITIVE or NEGATIVE.
  28. The function will only find positive or negative roots
  29. \item If arguments are (p,arg2,arg3) then
  30. \ttindex{EXCLUDE}\ttindex{POSITIVE}\ttindex{NEGATIVE}\ttindex{INFINITY}
  31. Arg2 and Arg3 must be r (a real number) or EXCLUDE r, or a member of
  32. the list POSITIVE, NEGATIVE, INFINITY, -INFINITY. EXCLUDE r causes the
  33. value r to be excluded from the region. The order of the sequence
  34. arg2, arg3 is unimportant. Assuming that arg2 $\leq$ arg3 when both are
  35. numeric, then
  36. \begin{tabular}{l c l}
  37. \{-INFINITY,INFINITY\} & (or \{\}) & all roots; \\
  38. \{arg2,NEGATIVE\} & represents & $-\infty < r < arg2$; \\
  39. \{arg2,POSITIVE\} & represents & $arg2 < r < \infty$;
  40. \end{tabular}
  41. In each of the following, replacing an {\em arg} with EXCLUDE {\em arg}
  42. converts the corresponding inclusive $\leq$ to the exclusive $<$
  43. \begin{tabular}{l c l}
  44. \{arg2,-INFINITY\} & represents & $-\infty < r \leq arg2$; \\
  45. \{arg2,INFINITY\} & represents & $arg2 \leq r < \infty$; \\
  46. \{arg2,arg3\} & represents & $arg2 \leq r \leq arg3$;
  47. \end{tabular}
  48. \item If zero is in the interval the zero root is included.
  49. \end{itemize}
  50. \begin{description}
  51. \ttindex{REALROOTS}
  52. \item[REALROOTS] finds the real roots of the polynomial
  53. p. Precision of computation is guaranteed to be sufficient to
  54. separate all real roots in the specified region. (cf. MULTIROOT for
  55. treatment of multiple roots.)
  56. \ttindex{ISOLATER}
  57. \item[ISOLATER] produces a list of rational intervals, each
  58. containing a single real root of the polynomial p, within the specified
  59. region, but does not find the roots.
  60. \ttindex{RLROOTNO}
  61. \item[RLROOTNO] computes the number of real roots of p in
  62. the specified region, but does not find the roots.
  63. \end{description}
  64. \subsection{Functions that return both real and complex roots}
  65. \begin{description}
  66. \ttindex{ROOTS}
  67. \item[ROOTS p;] This is the main top level function of the roots package.
  68. It will find all roots, real and complex, of the polynomial p to an
  69. accuracy that is sufficient to separate them and which is a minimum of 6
  70. decimal places. The value returned by ROOTS is a
  71. list of equations for all roots. In addition, ROOTS stores separate lists
  72. of real roots and complex roots in the global variables ROOTSREAL and
  73. ROOTSCOMPLEX.\ttindex{ROOTSREAL}\ttindex{ROOTSCOMPLEX}
  74. The output of ROOTS is normally sorted into a standard order:
  75. a root with smaller real part precedes a root with larger real part; roots
  76. with identical real parts are sorted so that larger imaginary part
  77. precedes smaller imaginary part.
  78. However, when a polynomial has been factored algebraically then the
  79. root sorting is applied to each factor separately. This makes the
  80. final resulting order less obvious.
  81. \ttindex{ROOTS\_AT\_PREC}
  82. \item[ROOTS\_AT\_PREC p;] Same as ROOTS except that roots values are
  83. returned to a minimum of the number of decimal places equal to the current
  84. system precision.
  85. \ttindex{ROOT\_VAL}
  86. \item[ROOT\_VAL p;] Same as ROOTS\_AT\_PREC, except that instead of
  87. returning a list of equations for the roots, a list of the root value is
  88. returned. This is the function that SOLVE calls.
  89. \ttindex{NEARESTROOT}
  90. \item[NEARESTROOT(p,s);] This top level function finds the root to
  91. which the method converges given the initial starting origin s, which
  92. can be complex. If there are several roots in the vicinity of s and s
  93. is not significantly closer to one root than it is to all others, the
  94. convergence could arrive at a root that is not truly the nearest root.
  95. This function should therefore be used only when the user is certain
  96. that there is only one root in the immediate vicinity of the
  97. starting point s.
  98. \ttindex{FIRSTROOT}
  99. \item[FIRSTROOT p;] ROOTS is called, but only a single root is computed.
  100. \end{description}
  101. \subsection{Other top level functions}
  102. \begin{description}
  103. \ttindex{GETROOT}\ttindex{ROOTS}\ttindex{REALROOTS}\ttindex{NEARESTROOTS}
  104. \item[GETROOT(n,rr);] If rr has the form of the output of ROOTS, REALROOTS,
  105. or NEARESTROOTS; GETROOT returns the rational, real, or complex value of
  106. the root equation. An error occurs if $n<1$ or $n>$ the number of roots in
  107. rr.
  108. \ttindex{MKPOLY}
  109. \item[MKPOLY rr;] This function can be used to reconstruct a polynomial
  110. whose root equation list is rr and whose denominator is 1. Thus one can
  111. verify that if $rr := ROOTS~p$, and $rr1 := ROOTS~MKPOLY~rr$, then
  112. $rr1 = rr$. (This will be true if {\tt MULTIROOT} and {\tt RATROOT} are ON,
  113. and {\tt ROUNDED} is off.)
  114. However, $MKPOLY~rr - NUM~p = 0$ will be true if and only if all roots of p
  115. have been computed exactly.
  116. \end{description}
  117. \section{Switches Used in Input}
  118. The input of polynomials in algebraic mode is sensitive to the switches
  119. {\tt COMPLEX}, {\tt ROUNDED}, and {\tt ADJPREC}. The correct choice of
  120. input method is important since incorrect choices will result in
  121. undesirable truncation or rounding of the input coefficients.
  122. Truncation or rounding may occur if {\tt ROUNDED} is on and
  123. one of the following is true:
  124. \begin{enumerate}
  125. \item a coefficient is entered in floating point form or rational form.
  126. \item {\tt COMPLEX} is on and a coefficient is imaginary or complex.
  127. \end{enumerate}
  128. Therefore, to avoid undesirable truncation or rounding, then:
  129. \begin{enumerate}
  130. \item {\tt ROUNDED} should be off and input should be
  131. in integer or rational form; or
  132. \item {\tt ROUNDED} can be on if it is acceptable to truncate or round
  133. input to the current value of system precision; or both {\tt ROUNDED} and
  134. {\tt ADJPREC} can be on, in which case system precision will be adjusted
  135. to accommodate the largest coefficient which is input; or \item if the
  136. input contains complex coefficients with very different magnitude for the
  137. real and imaginary parts, then all three switches {\tt ROUNDED}, {\tt
  138. ADJPREC} and {\tt COMPLEX} must be on.
  139. \end{enumerate}
  140. \begin{description}
  141. \item[integer and complex modes] (off {\tt ROUNDED}) any real
  142. polynomial can be input using integer coefficients of any size; integer or
  143. rational coefficients can be used to input any real or complex polynomial,
  144. independent of the setting of the switch {\tt COMPLEX}. These are the most
  145. versatile input modes, since any real or complex polynomial can be input
  146. exactly.
  147. \item[modes rounded and complex-rounded] (on {\tt ROUNDED}) polynomials can be
  148. input using
  149. integer coefficients of any size. Floating point coefficients will be
  150. truncated or rounded, to a size dependent upon the system. If complex
  151. is on, real coefficients can be input to any precision using integer
  152. form, but coefficients of imaginary parts of complex coefficients will
  153. be rounded or truncated.
  154. \end{description}
  155. \section{Root Package Switches}
  156. \begin{description}
  157. \ttindex{RATROOT}
  158. \item[RATROOT] (Default OFF) If {\tt RATROOT} is on all root equations are
  159. output in rational form. Assuming that the mode is {\tt COMPLEX}
  160. ({\em i.e.\ }
  161. {\tt ROUNDED} is off,) the root equations are
  162. guaranteed to be able to be input into \REDUCE\ without truncation or
  163. rounding errors. (Cf. the function MKPOLY described above.)
  164. \ttindex{MULTIROOT}
  165. \item[MULTIROOT] (Default ON) Whenever the polynomial has complex
  166. coefficients or has real coefficients and has multiple roots, as
  167. \ttindex{SQFRF} determined by the Sturm function, the function {\tt SQFRF}
  168. is called automatically to factor the polynomial into square-free factors.
  169. If {\tt MULTIROOT} is on, the multiplicity of the roots will be indicated
  170. in the output of ROOTS or REALROOTS by printing the root output
  171. repeatedly, according to its multiplicity. If {\tt MULTIROOT} is off,
  172. each root will be printed once, and all roots should be normally be
  173. distinct. (Two identical roots should not appear. If the initial
  174. precision of the computation or the accuracy of the output was
  175. insufficient to separate two closely-spaced roots, the program attempts to
  176. increase accuracy and/or precision if it detects equal roots. If,
  177. however, the initial accuracy specified was too low, and it was not
  178. possible to separate the roots, the program will abort.)
  179. \end{description}