pk-roots.tex 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. \section{Roots Package}
  2. \begin{Introduction}{Roots Package}
  3. \index{roots}\index{polynomial}
  4. The root finding package is designed so that it can
  5. be used to find some or all of the roots of univariate
  6. polynomials with real or complex coefficients, to the accuracy
  7. specified by the user.
  8. Not all operators of \name{roots package} are described here. For using
  9. the operators
  10. \nameindex{isolater} (intervals isolating real roots)
  11. \nameindex{rlrootno} (number of real roots in an interval)
  12. \nameindex{rootsat-prec} (roots at system precision)
  13. \nameindex{rootval} (result in equation form)
  14. \nameindex{firstroot} (computing only one root)
  15. \nameindex{getroot} (selecting roots from a collection)
  16. please consult the full documentation of the package.
  17. \end{Introduction}
  18. \begin{Operator}{MKPOLY}
  19. \index{polynomial}\index{roots}\index{interpolation}
  20. Given a roots list as returned by \nameref{roots},
  21. the operator \name{mkpoly} constructs a
  22. polynomial which has these numbers as roots.
  23. \begin{Syntax}
  24. \name{mkpoly} \meta{rl}
  25. \end{Syntax}
  26. where \meta{rl} is a \nameref{list} with equations, which
  27. all have the same \nameref{kernel} on their left-hand sides
  28. and numbers as right-hand sides.
  29. \begin{Examples}
  30. mkpoly{x=1,x=-2,x=i,x=-i};&
  31. x**4 + x**3 - x**2 + x - 2\\
  32. \end{Examples}
  33. Note that this polynomial is unique only up to a numeric
  34. factor.
  35. \end{Operator}
  36. \begin{Operator}{NEARESTROOT}
  37. \index{roots}\index{solve}
  38. The operator \name{nearestroot} finds one root of a polynomial
  39. with an iteration using a given starting point.
  40. \begin{Syntax}
  41. \name{nearestroot}\(\meta{p}\,\meta{pt}\)
  42. \end{Syntax}
  43. where \meta{p} is a univariate polynomial
  44. and \meta{pt} is a number.
  45. \begin{Examples}
  46. nearestroot(x^2+2,2);&\{x=1.41421*i\}\\
  47. \end{Examples}
  48. The minimal accuracy of the result values is controlled by
  49. \nameref{rootacc}.
  50. \end{Operator}
  51. \begin{Operator}{REALROOTS}
  52. \index{roots}\index{solve}
  53. The operator \name{realroots} finds that real roots of a polynomial
  54. to an accuracy that is sufficient to separate them and which is
  55. a minimum of 6 decimal places.
  56. \begin{Syntax}
  57. \name{realroots}\(\meta{p}\) or \\
  58. \name{realroots}\(\meta{p}\,\meta{from},\meta{to}\)
  59. \end{Syntax}
  60. where \meta{p} is a univariate polynomial.
  61. The optional parameters \meta{from} and \meta{to} classify
  62. an interval: if given, exactly the real roots in this
  63. interval will be returned. \meta{from} and \meta{to}
  64. can also take the values \name{infinity} or \name{-infinity}.
  65. If omitted all real roots will be returned.
  66. Result is a \nameref{list}
  67. of equations which represent the roots of the polynomial at the
  68. given accuracy.
  69. \begin{Examples}
  70. realroots(x^5-2);&\{x=1.1487\}\\
  71. realroots(x^3-104*x^2+403*x-300,2,infinity);&\{x=3.0,x=100.0\}\\
  72. realroots(x^3-104*x^2+403*x-300,-infinity,2);&\{x=1\}\\
  73. \end{Examples}
  74. The minimal accuracy of the result values is controlled by
  75. \nameref{rootacc}.
  76. \end{Operator}
  77. \begin{Operator}{ROOTACC}
  78. \index{roots}\index{accuracy}
  79. The operator \name{rootacc} allows you to set the accuracy
  80. up to which the roots package computes its results.
  81. \begin{Syntax}
  82. \name{rootacc}\(\meta{n}\)
  83. \end{Syntax}
  84. Here \meta{n} is an integer value. The internal accuracy of
  85. the \name{roots} package is adjusted to a value of
  86. \name{max(6,n)}. The default value is \name{6}.
  87. \end{Operator}
  88. \begin{Operator}{ROOTS}
  89. \index{roots}\index{solve}\index{polynomial}
  90. The operator \name{roots}
  91. is the main top level function of the roots package.
  92. It will find all roots, real and complex, of the polynomial p
  93. to an accuracy that is sufficient to separate them and which is
  94. a minimum of 6 decimal places.
  95. \begin{Syntax}
  96. \name{roots}\(\meta{p}\)
  97. \end{Syntax}
  98. where \meta{p} is a univariate polynomial. Result is a \nameref{list}
  99. of equations which represent the roots of the polynomial at the
  100. given accuracy. In addition, \name{roots} stores
  101. separate lists of real roots and complex roots in the global
  102. variables \nameref{rootsreal} and \nameref{rootscomplex}.
  103. \begin{Examples}
  104. roots(x^5-2);&\begin{multilineoutput}{3cm}
  105. \{x=-0.929316 + 0.675188*i,
  106. x=-0.929316 - 0.675188*i,
  107. x=0.354967 + 1.09248*i,
  108. x=0.354967 - 1.09248*i,
  109. x=1.1487\}
  110. \end{multilineoutput}\\
  111. \end{Examples}
  112. The minimal accuracy of the result values is controlled by
  113. \nameref{rootacc}.
  114. \end{Operator}
  115. \begin{Operator}{ROOT\_VAL}
  116. \index{roots}\index{solve}\index{polynomial}
  117. The operator \name{root\_val} computes the roots of a
  118. univariate polynomial at system precision
  119. (or greater if required for root separation) and presents
  120. its result as a list of numbers.
  121. \begin{Syntax}
  122. \name{roots}\(\meta{p}\)
  123. \end{Syntax}
  124. where \meta{p} is a univariate polynomial.
  125. \begin{Examples}
  126. root_val(x^5-2);&\begin{multilineoutput}{3cm}
  127. \{-0.929316490603 + 0.6751879524*i,
  128. -0.929316490603 - 0.6751879524*i,
  129. 0.354967313105 + 1.09247705578*i,
  130. 0.354967313105 - 1.09247705578*i,
  131. 1.148698355\}
  132. \end{multilineoutput}\\
  133. \end{Examples}
  134. \end{Operator}
  135. \begin{Variable}{ROOTSCOMPLEX}
  136. \index{roots}\index{complex}
  137. When the operator \nameref{roots} is called the complex
  138. roots are collected in the global variable \name{rootscomplex}
  139. as \nameref{list}.
  140. \end{Variable}
  141. \begin{Variable}{ROOTSREAL}
  142. \index{roots}\index{complex}
  143. When the operator \nameref{roots} is called the real
  144. roots are collected in the global variable \name{rootreal}
  145. as \nameref{list}.
  146. \end{Variable}