| 1 |
.. comment: -*- fill-column: 72; mode: rst -*- |
| 2 |
|
| 3 |
|
| 4 |
========================= |
| 5 |
Introduction to polexpr |
| 6 |
========================= |
| 7 |
|
| 8 |
.. toctree:: |
| 9 |
:hidden: |
| 10 |
:maxdepth: 2 |
| 11 |
|
| 12 |
polexpr-ref |
| 13 |
polexpr-changes |
| 14 |
|
| 15 |
|
| 16 |
.. only :: latex |
| 17 |
|
| 18 |
Introduction to polexpr |
| 19 |
----------------------- |
| 20 |
|
| 21 |
polexpr_ is a TeX and LaTeX macro package. |
| 22 |
|
| 23 |
To use it with Plain or formats other than LaTeX:: |
| 24 |
|
| 25 |
\input polexpr.sty |
| 26 |
|
| 27 |
To use it with LaTeX:: |
| 28 |
|
| 29 |
\usepackage{polexpr} |
| 30 |
|
| 31 |
polexpr_ loads xintexpr_ and extends its syntax with a polynomial type. |
| 32 |
|
| 33 |
Polynomials are defined via the :ref:`\\poldef <quick>` parser and |
| 34 |
can then be manipulated via TeX macros for various operations such |
| 35 |
as obtaining G.C.D.s, computing derivatives, or indefinite |
| 36 |
integrals... many of these functionalities are available directly |
| 37 |
via functions in the syntax recognized by the ``\poldef`` parser. |
| 38 |
|
| 39 |
Apart from the final step of internally creating some TeX macros |
| 40 |
associated with the polynomial name, this is all done completely |
| 41 |
expandably, and a polynomial expression can be fetched directly to |
| 42 |
``\xinteval`` for a completely expandable operation from start to |
| 43 |
finish. |
| 44 |
|
| 45 |
For polynomials fully declared via ``\poldef``, root localization |
| 46 |
implementing the `Sturm algorithm`_ is available via macros. |
| 47 |
Arbitrarily long decimal expansion of all real roots can be |
| 48 |
obtained, and all rational roots can be found exactly. |
| 49 |
|
| 50 |
The legacy documentation section which showed examples of root |
| 51 |
localization has been moved to the `polexpr-examples.pdf |
| 52 |
<polexpr-examples.pdf>`_ document, where both the TeX code and its |
| 53 |
output are displayed. |
| 54 |
|
| 55 |
To access this document (if the previous link for some reason does not |
| 56 |
work):: |
| 57 |
|
| 58 |
texdoc polexpr-examples |
| 59 |
|
| 60 |
|
| 61 |
Usage via xintsession_ |
| 62 |
---------------------- |
| 63 |
|
| 64 |
The simplest manner to get a feeling for the package abilities regarding |
| 65 |
in particular root localization is to use it on the command line |
| 66 |
via the xintsession_ interface. Here is an example:: |
| 67 |
|
| 68 |
$ rlwrap etex xintsession |
| 69 |
[...xintsession welcome message...] |
| 70 |
Starting in exact mode (floating point evaluations use 16 digits) |
| 71 |
>>> &pol |
| 72 |
pol mode (i.e. function definitions use \poldef) |
| 73 |
>>> f(x) := x^7 - x^6 - 2x + 1; |
| 74 |
f = x^7-x^6-2*x+1 |
| 75 |
--> &GenFloat(f) lets f become usable as function in fp mode |
| 76 |
--> &ROOTS(f) (resp. &ROOTS(f,N)) finds all rational roots exactly and |
| 77 |
all irrational roots with at least 10 (resp. N) fractional digits |
| 78 |
>>> &ROOTS(f) |
| 79 |
Solving for real roots of f and assigning them (please wait...) |
| 80 |
(mult. 1) Rootf_1 = -1.0719678841... |
| 81 |
(mult. 1) Rootf_2 = 0.4962386948... |
| 82 |
(mult. 1) Rootf_3 = 1.3151140860... |
| 83 |
Square-free irrational part: x^7-x^6-2*x+1 |
| 84 |
--> &REFINEROOTS(f,N) to extend real irr. roots to N fractional digits |
| 85 |
>>> &REFINEROOTS(f,40) |
| 86 |
Refining real roots of f to 40 digits (please wait...) |
| 87 |
(mult. 1) Rootf_1 = -1.0719678841080266034109100331975342338141... |
| 88 |
(mult. 1) Rootf_2 = 0.4962386948771497344730618510143671567979... |
| 89 |
(mult. 1) Rootf_3 = 1.3151140860165192656960005018679846354234... |
| 90 |
|
| 91 |
The xintsession_ interface allows to define polynomial variables via its |
| 92 |
``&pol`` mode. It also exposes :ref:`all polynomial functions added to the |
| 93 |
xintexpr syntax <polexpr08>` by ``polexpr``. Further, as seen in the |
| 94 |
example above it also covers some of the ``polexpr`` capabilities |
| 95 |
currently implemented via user macros. This is to be considered a work |
| 96 |
in progress, the above ``&ROOTS`` and ``&REFINEROOTS`` may be renamed |
| 97 |
into something else, and may have been so already since this |
| 98 |
documentation was written. |
| 99 |
|
| 100 |
Any input on the command line at the xintsession_ ``>>>`` prompt which |
| 101 |
starts with a backslash is executed as TeX macros, so all macros of |
| 102 |
``polexpr`` are in fact already available, including those typesetting |
| 103 |
material in background of the interactive session on command line. The |
| 104 |
``&ROOTS`` and ``&REFINEROOTS`` direct their outputs to the |
| 105 |
terminal rather than to the TeX page as would the typesetting macros |
| 106 |
defined by ``polexpr`` itself. |
| 107 |
|
| 108 |
|
| 109 |
License is LPPL 1.3c |
| 110 |
-------------------- |
| 111 |
|
| 112 |
This work is distributed under the conditions of the |
| 113 |
LaTeX Project Public License version 1.3c. |
| 114 |
|
| 115 |
See README.md for details. |
| 116 |
|
| 117 |
|
| 118 |
In memoriam: Jürgen Gilg (1966-2022) |
| 119 |
------------------------------------ |
| 120 |
|
| 121 |
My first contact with Jürgen was in January 2018, and his *little |
| 122 |
question* about usage of xintexpr_ for differentiating polynomials |
| 123 |
proved the direct cause for the :ref:`creation of polexpr |
| 124 |
<firstrelease>`. His regular comments and questions (often, jointly |
| 125 |
with Thomas Söll) largely contributed to motivate the author into |
| 126 |
investing time and effort into the somewhat strange occupation of |
| 127 |
developing such unusual TeX/LaTeX packages. The topics of our |
| 128 |
discussions evolved over the years and were not limited to TeX, LaTeX, |
| 129 |
PSTricks or PostScript matters. |
| 130 |
|
| 131 |
I learned to discover and appreciate his unassuming and kind character. |
| 132 |
He was very conscientious in all his projects with others and was often |
| 133 |
overly generous in his appreciation of people's contributions. On |
| 134 |
receiving the sad news of his unexpected and untimely death, I initially |
| 135 |
thought I had been knowing him for at least 10 years, but it is actually |
| 136 |
only a bit more than 4 years... I will sorely miss this friendship with |
| 137 |
a gentle soul from *over the Rhine*. |
| 138 |
|
| 139 |
I dedicate the work which has gone into polexpr_ to Jürgen's memory. |
| 140 |
|
| 141 |
|
| 142 |
.. _polexpr: https://www.ctan.org/pkg/polexpr |
| 143 |
|
| 144 |
.. _xinttools: |
| 145 |
.. _xintfrac: |
| 146 |
.. _xint: https://www.ctan.org/pkg/xint |
| 147 |
|
| 148 |
.. _xintexpr: https://www.ctan.org/pkg/xintexpr |
| 149 |
|
| 150 |
.. _xintsession: https://www.ctan.org/pkg/xintsession |
| 151 |
|
| 152 |
.. _Wilkinson polynomial: https://en.wikipedia.org/wiki/Wilkinson%27s_polynomial |
| 153 |
|
| 154 |
.. _Sturm algorithm: |
| 155 |
.. _Sturm Theorem: https://en.wikipedia.org/wiki/Sturm%27s_theorem |
| 156 |
|
| 157 |
.. _DocUtils: http://docutils.sourceforge.net/docs/index.html |
| 158 |
|
| 159 |
|
| 160 |
.. Local variables: |
| 161 |
.. sentence-end-double-space: t; |
| 162 |
.. End: |