Debian Codegraph @

texmf-dist/doc/generic/polexpr/polexpr-ref.html

raw
1
2 <!DOCTYPE html>
3
4 <html lang="en">
5 <head>
6 <meta charset="utf-8" />
7 <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.18.1: http://docutils.sourceforge.net/" />
8
9 <title>polexpr reference &#8212; polexpr 0.8.7a documentation</title>
10 <link rel="stylesheet" type="text/css" href="polexpr.css" />
11 <link rel="next" title="CHANGES" href="polexpr-changes.html" />
12 <link rel="prev" title="Introduction to polexpr" href="polexpr.html" />
13 </head><body>
14 <div class="related" role="navigation" aria-label="related navigation">
15 <h3>Navigation</h3>
16 <ul>
17 <li class="right" style="margin-right: 10px">
18 <a href="polexpr-changes.html" title="CHANGES"
19 accesskey="N">next</a></li>
20 <li class="right" >
21 <a href="polexpr.html" title="Introduction to polexpr"
22 accesskey="P">previous</a> |</li>
23 <li class="nav-item nav-item-0"><a href="polexpr.html">polexpr 0.8.7a documentation</a> &#187;</li>
24 <li class="nav-item nav-item-this"><a href="">polexpr reference</a></li>
25 </ul>
26 </div>
27
28 <div class="document">
29 <div class="documentwrapper">
30 <div class="bodywrapper">
31 <div class="body" role="main">
32
33 <section id="polexpr-reference">
34 <h1>polexpr reference</h1>
35 <section id="syntax-overview-via-examples">
36 <span id="quick"></span><h2>Syntax overview via examples</h2>
37 <p>The syntax to define a new polynomial is:</p>
38 <div class="highlight-latex notranslate"><div class="highlight"><pre><span></span><span class="k">\poldef</span> polname(x):= expression in variable x;
39 </pre></div>
40 </div>
41 <p>The expression will be parsed by the services of <a class="reference external" href="https://www.ctan.org/pkg/xintexpr">xintexpr</a>, with some
42 polynomial aware functions added to its syntax; they are described in
43 detail <a class="reference internal" href="#polexpr08"><span class="std std-ref">below</span></a>. The parser accepts and will handle
44 exactly arbitrarily big integers or fractions.</p>
45 <div class="admonition note">
46 <p class="admonition-title">Note</p>
47 <p><a class="reference external" href="https://www.ctan.org/pkg/xintexpr">xintexpr</a> does not automatically reduce fractions to lowest terms,
48 and, so far (but this may change in future) neither does <a class="reference internal" href="#poldef"><span class="std std-ref">\poldef</span></a>.
49 See <a class="reference internal" href="#rdcoeffs"><span class="std std-ref">rdcoeffs()</span></a> and the macro
50 <a class="reference internal" href="#polreducecoeffs"><span class="std std-ref">\PolReduceCoeffs</span></a>.</p>
51 </div>
52 <ul>
53 <li><p>In place of <code class="docutils literal notranslate"><span class="pre">x</span></code> an arbitrary <em>dummy variable</em> is authorized,
54 i.e. per default one <code class="docutils literal notranslate"><span class="pre">a,</span> <span class="pre">..,</span> <span class="pre">z,</span> <span class="pre">A,</span> <span class="pre">..,</span> <span class="pre">Z</span></code> (more letters can be declared
55 under Unicode engines).</p></li>
56 <li><p><code class="docutils literal notranslate"><span class="pre">polname</span></code> is a word (no space) built with <em>letters</em>, <em>digits</em>, and
57 the <code class="docutils literal notranslate"><span class="pre">&#64;</span></code>, <code class="docutils literal notranslate"><span class="pre">_</span></code> and <code class="docutils literal notranslate"><span class="pre">'</span></code> characters are allowed. The polynomial
58 name <strong>must</strong> start with a letter.</p>
59 <p>For guidelines regarding <code class="docutils literal notranslate"><span class="pre">_</span></code> and <code class="docutils literal notranslate"><span class="pre">&#64;</span></code> see <a class="reference internal" href="#technicalities">Technicalities</a>.</p>
60 </li>
61 <li><p>The colon before the equality sign is optional and its (reasonable)
62 catcode does not matter.</p></li>
63 <li><p>The semi-colon at the end of the expression is mandatory. It is not
64 allowed to arise from expansion (despite the fact that the expression
65 itself will be parsed using only expansion), it must be “visible”
66 immediately.</p></li>
67 </ul>
68 <p>There are some potential problems (refer to the <a class="reference internal" href="#technicalities">Technicalities</a> section at
69 bottom of this page) with the semi-colon as expression terminator, so an
70 alternative syntax is provided, which avoids it altogether:</p>
71 <div class="highlight-latex notranslate"><div class="highlight"><pre><span></span><span class="k">\PolDef</span><span class="na">[optional letter]</span><span class="nb">{</span>&lt;polname&gt;<span class="nb">}{</span>&lt;expr. using letter as indeterminate&gt;<span class="nb">}</span>
72 </pre></div>
73 </div>
74 <p>The <code class="docutils literal notranslate"><span class="pre">\PolDef</span></code> optional first argument defaults to <code class="docutils literal notranslate"><span class="pre">x</span></code> and must be
75 used as the indeterminate in the expression.</p>
76 <p>Examples:</p>
77 <p><code class="docutils literal notranslate"><span class="pre">\poldef</span> <span class="pre">f(x):=</span> <span class="pre">1</span> <span class="pre">-</span> <span class="pre">x</span> <span class="pre">+</span> <span class="pre">quo(x^5,1</span> <span class="pre">-</span> <span class="pre">x</span> <span class="pre">+</span> <span class="pre">x^2);</span></code></p>
78 <dl>
79 <dt><code class="docutils literal notranslate"><span class="pre">\PolDef{f}{1</span> <span class="pre">-</span> <span class="pre">x</span> <span class="pre">+</span> <span class="pre">quo(x^5,1</span> <span class="pre">-</span> <span class="pre">x</span> <span class="pre">+</span> <span class="pre">x^2)}</span></code></dt><dd><p>Both parse the polynomial
80 expression, and they create internally macros serving to
81 incarnate the polynomial, its coefficients, and the associated
82 polynomial function.</p>
83 <p>The polynomial can then be used in further polynomial definitions,
84 be served as argument to package macros, or appear as a variable in
85 various functions <a class="reference internal" href="#polexpr08">described later</a>.</p>
86 <div class="admonition warning">
87 <p class="admonition-title">Warning</p>
88 <p>Both the function <code class="docutils literal notranslate"><span class="pre">quo()</span></code> (as shown in the example above), and
89 the infix operator <code class="docutils literal notranslate"><span class="pre">/</span></code> are mapped to the Euclidean quotient.</p>
90 <p>This usage of <code class="docutils literal notranslate"><span class="pre">/</span></code> to stand for the Euclidean quotient is
91 <strong>deprecated</strong> and reserved for a (somewhat improbable) possible
92 extension of the package to handle rational functions as well.</p>
93 </div>
94 <div class="admonition attention" id="warningtacit">
95 <p class="admonition-title">Attention</p>
96 <p>Tacit multiplication rules let the parser when encountering
97 <code class="docutils literal notranslate"><span class="pre">1/2</span> <span class="pre">x^2</span></code> skip the space and thus handle it as <code class="docutils literal notranslate"><span class="pre">1/(2*x^2)</span></code>.
98 But then it gives zero, because <cite>/</cite> stands for the Euclidean
99 quotient operation here.</p>
100 <p>Thus one must use <code class="docutils literal notranslate"><span class="pre">(1/2)x^2</span></code> or <code class="docutils literal notranslate"><span class="pre">1/2*x^2</span></code> or
101 <code class="docutils literal notranslate"><span class="pre">(1/2)*x^2</span></code> for disambiguation: <code class="docutils literal notranslate"><span class="pre">x</span> <span class="pre">-</span> <span class="pre">1/2*x^2</span> <span class="pre">+</span> <span class="pre">1/3*x^3...</span></code>. It is
102 simpler to move the denominator to the right: <code class="docutils literal notranslate"><span class="pre">x</span> <span class="pre">-</span> <span class="pre">x^2/2</span> <span class="pre">+</span>
103 <span class="pre">x^3/3</span> <span class="pre">-</span> <span class="pre">...</span></code>.</p>
104 <p>It is worth noting that <code class="docutils literal notranslate"><span class="pre">1/2(x-1)(x-2)</span></code> suffers the same issue:
105 <a class="reference external" href="https://www.ctan.org/pkg/xintexpr">xintexpr</a>‘s tacit multiplication always “ties more”, hence this
106 gets interpreted as <code class="docutils literal notranslate"><span class="pre">1/(2*(x-1)*(x-2))</span></code> not as
107 <code class="docutils literal notranslate"><span class="pre">(1/2)*(x-1)*(x-2)</span></code> and then gives zero by
108 polynomial division. Thus, in such cases, use one of
109 <code class="docutils literal notranslate"><span class="pre">(1/2)(x-1)(x-2)</span></code>, <code class="docutils literal notranslate"><span class="pre">1/2*(x-1)(x-2)</span></code> or <code class="docutils literal notranslate"><span class="pre">(x-1)(x-2)/2</span></code>.</p>
110 </div>
111 <p><code class="docutils literal notranslate"><span class="pre">\poldef</span> <span class="pre">P(x):=...;</span></code> defines <code class="docutils literal notranslate"><span class="pre">P</span></code> as a <em>polynomial function</em>,
112 which can be used inside <code class="docutils literal notranslate"><span class="pre">\xinteval</span></code>, as:</p>
113 <div class="highlight-latex notranslate"><div class="highlight"><pre><span></span><span class="k">\xinteval</span><span class="nb">{</span>P(3 + 7 + 11)<span class="nb">}</span>
114 </pre></div>
115 </div>
116 <p>or even as:</p>
117 <div class="highlight-latex notranslate"><div class="highlight"><pre><span></span><span class="k">\xinteval</span><span class="nb">{</span>P(Q1 + Q2 + Q3)<span class="nb">}</span>
118 </pre></div>
119 </div>
120 <p>where <code class="docutils literal notranslate"><span class="pre">Q1</span></code>, <code class="docutils literal notranslate"><span class="pre">Q2</span></code>, <code class="docutils literal notranslate"><span class="pre">Q3</span></code> are polynomials. The evaluation result,
121 if not a scalar, will then be printed as <code class="docutils literal notranslate"><span class="pre">pol([c0,c1,...])</span></code> which
122 stands for a polynomial variable having the listed coefficients; see
123 <a class="reference internal" href="#pol"><span class="std std-ref">pol()</span></a>.</p>
124 <p>Indeed, as seen above with <code class="docutils literal notranslate"><span class="pre">Q1</span></code>, the symbol <code class="docutils literal notranslate"><span class="pre">P</span></code> also stands for
125 a <em>variable of polynomial type</em>, which serves as argument to
126 polynomial specific functions such as <a class="reference internal" href="#deg"><span class="std std-ref">deg()</span></a> or
127 <a class="reference internal" href="#polgcd"><span class="std std-ref">polgcd()</span></a>, or as argument to other polynomials (as
128 above), or even simply stands for its own in algebraic expressions
129 such as:</p>
130 <div class="highlight-latex notranslate"><div class="highlight"><pre><span></span><span class="k">\poldef</span> Q(z):= P<span class="nb">^</span>2 + z<span class="nb">^</span>10;
131 </pre></div>
132 </div>
133 <p>Notice that in the above, the <code class="docutils literal notranslate"><span class="pre">(z)</span></code> part is mandatory, as it informs
134 <code class="docutils literal notranslate"><span class="pre">\poldef</span></code> of the letter used for the indeterminate. In the above
135 <code class="docutils literal notranslate"><span class="pre">P(z)^2</span></code> would give the same as <code class="docutils literal notranslate"><span class="pre">P^2</span></code> but the latter is slightly
136 more efficient.</p>
137 <p>One needs to acquire a good understanding of when the symbol <code class="docutils literal notranslate"><span class="pre">P</span></code>
138 will stand for a function and when it will stand for a variable.</p>
139 <ul>
140 <li><p>If <code class="docutils literal notranslate"><span class="pre">P</span></code> and
141 <code class="docutils literal notranslate"><span class="pre">Q</span></code> are both declared polynomials then:</p>
142 <div class="highlight-latex notranslate"><div class="highlight"><pre><span></span>(P+Q)(3)<span class="c">% &lt;--- attention, does (P+Q)*3, not P(3)+Q(3)</span>
143 </pre></div>
144 </div>
145 <p>is currently evaluated as <code class="docutils literal notranslate"><span class="pre">(P+Q)*3</span></code>, because <code class="docutils literal notranslate"><span class="pre">P+Q</span></code> is not
146 known as a <em>function</em>, but <em>only as a variable of polynomial
147 type</em>. Note that <a class="reference internal" href="#evalp"><span class="std std-ref">evalp(P+Q,3)</span></a> gives as expected
148 the same as <code class="docutils literal notranslate"><span class="pre">P(3)+Q(3)</span></code>.</p>
149 </li>
150 <li><p>Also:</p>
151 <div class="highlight-latex notranslate"><div class="highlight"><pre><span></span>(P)(3)<span class="c">% &lt;--- attention, does P*3, not P(3)</span>
152 </pre></div>
153 </div>
154 <p>will compute <code class="docutils literal notranslate"><span class="pre">P*3</span></code>, because one can not in current <a class="reference external" href="https://www.ctan.org/pkg/xintexpr">xintexpr</a> syntax
155 enclose a function name in parentheses: consequently it is the variable
156 which is used here.</p>
157 </li>
158 </ul>
159 <p>There is a <em>meager possibility</em> that in future some internal changes
160 to <a class="reference external" href="https://www.ctan.org/pkg/xintexpr">xintexpr</a> would let <code class="docutils literal notranslate"><span class="pre">(P)(3)</span></code> actually compute <code class="docutils literal notranslate"><span class="pre">P(3)</span></code> and
161 <code class="docutils literal notranslate"><span class="pre">(P+Q)(3)</span></code> compute <code class="docutils literal notranslate"><span class="pre">P(3)</span> <span class="pre">+</span> <span class="pre">Q(3)</span></code>, but note that <code class="docutils literal notranslate"><span class="pre">(P)(P)</span></code> will
162 then do <code class="docutils literal notranslate"><span class="pre">P(P)</span></code> and not <code class="docutils literal notranslate"><span class="pre">P*P</span></code>, the latter, current
163 interpretation, looking more intuitive. Anyway, do not rely too
164 extensively on tacit <code class="docutils literal notranslate"><span class="pre">*</span></code> and use explicit <code class="docutils literal notranslate"><span class="pre">(P+Q)*(1+2)</span></code> if this
165 is what is intended.</p>
166 </dd>
167 <dt><code class="docutils literal notranslate"><span class="pre">\PolLet{g}={f}</span></code></dt><dd><p>saves a copy of <code class="docutils literal notranslate"><span class="pre">f</span></code> under name <code class="docutils literal notranslate"><span class="pre">g</span></code>. Also usable without <code class="docutils literal notranslate"><span class="pre">=</span></code>.</p>
168 <p>Has exactly the same effect as <code class="docutils literal notranslate"><span class="pre">\poldef</span> <span class="pre">g(x):=f;</span></code> or <code class="docutils literal notranslate"><span class="pre">\poldef</span>
169 <span class="pre">g(w):=f(w);</span></code>.</p>
170 </dd>
171 <dt><code class="docutils literal notranslate"><span class="pre">\poldef</span> <span class="pre">f(z):=</span> <span class="pre">f^2;</span></code></dt><dd><p>redefines <code class="docutils literal notranslate"><span class="pre">f</span></code> in terms of itself. Prior to <code class="docutils literal notranslate"><span class="pre">0.8</span></code> one needed
172 the right hand side to be <code class="docutils literal notranslate"><span class="pre">f(z)^2</span></code>. Also, now <code class="docutils literal notranslate"><span class="pre">sqr(f)</span></code> is
173 possible (also <code class="docutils literal notranslate"><span class="pre">sqr(f(x))</span></code> but not <code class="docutils literal notranslate"><span class="pre">sqr(f)(x)</span></code>).</p>
174 <p>It may look strange that an indeterminate variable is used on
175 left-hand-side even though it may be absent of right-hand-side, as
176 it seems to define <code class="docutils literal notranslate"><span class="pre">f</span></code> always as a polynomial function.</p>
177 <p>This is a legacy of pre-<code class="docutils literal notranslate"><span class="pre">0.8</span></code> context.</p>
178 <div class="admonition important">
179 <p class="admonition-title">Important</p>
180 <p>Note that <code class="docutils literal notranslate"><span class="pre">f^2(z)</span></code> or <code class="docutils literal notranslate"><span class="pre">sqr(f)(z)</span></code> will give a logical but
181 perhaps unexpected result: first <code class="docutils literal notranslate"><span class="pre">f^2</span></code> is computed, then the
182 opening parenthesis is seen which inserts a tacit multiplication
183 <code class="docutils literal notranslate"><span class="pre">*</span></code>, so in the end it is as if the input had been <code class="docutils literal notranslate"><span class="pre">f^2</span> <span class="pre">*</span> <span class="pre">z</span></code>.
184 Although <code class="docutils literal notranslate"><span class="pre">f</span></code> is both a variable and a function, <code class="docutils literal notranslate"><span class="pre">f^2</span></code> is
185 computed as a polynomial <em>variable</em> and ceases being a function.</p>
186 </div>
187 </dd>
188 <dt><code class="docutils literal notranslate"><span class="pre">\poldef</span> <span class="pre">f(T):=</span> <span class="pre">f(f);</span></code></dt><dd><p>again modifies <code class="docutils literal notranslate"><span class="pre">f</span></code>. Here it is used both as variable and as
189 a function. Prior to <code class="docutils literal notranslate"><span class="pre">0.8</span></code> it needed to be <code class="docutils literal notranslate"><span class="pre">f(f(T))</span></code>.</p>
190 </dd>
191 <dt><code class="docutils literal notranslate"><span class="pre">\poldef</span> <span class="pre">k(z):=</span> <span class="pre">f-g(g^2)^2;</span></code></dt><dd><p>if everybody followed, this should now define the zero polynomial…
192 And <code class="docutils literal notranslate"><span class="pre">f-sqr(g(sqr(g)))</span></code> computes the same thing.</p>
193 <p>We can check this in a typeset document like this:</p>
194 <div class="highlight-latex notranslate"><div class="highlight"><pre><span></span><span class="k">\poldef</span> f(x):= 1 - x + quo(x<span class="nb">^</span>5,1 - x + x<span class="nb">^</span>2);<span class="c">%</span>
195 <span class="k">\PolLet</span><span class="nb">{</span>g<span class="nb">}</span>=<span class="nb">{</span>f<span class="nb">}</span><span class="c">%</span>
196 <span class="k">\poldef</span> f(z):= f<span class="nb">^</span>2;<span class="c">%</span>
197 <span class="k">\poldef</span> f(T):= f(f);<span class="c">%</span>
198 <span class="k">\poldef</span> k(w):= f-sqr(g(sqr(g)));<span class="c">%</span>
199 <span class="sb">$$</span><span class="nb">f</span><span class="o">(</span><span class="nb">x</span><span class="o">)</span><span class="nb"> </span><span class="o">=</span><span class="nb"> </span><span class="nv">\vcenter</span><span class="nb">{</span><span class="nv">\hsize</span><span class="m">10</span><span class="nb">cm </span><span class="nv">\PolTypeset</span><span class="nb">{f}} </span><span class="s">$$</span>
200 <span class="sb">$$</span><span class="nb">g</span><span class="o">(</span><span class="nb">z</span><span class="o">)</span><span class="nb"> </span><span class="o">=</span><span class="nb"> </span><span class="nv">\PolTypeset</span><span class="nb">{g} </span><span class="s">$$</span>
201 <span class="sb">$$</span><span class="nb">k</span><span class="o">(</span><span class="nb">z</span><span class="o">)</span><span class="nb"> </span><span class="o">=</span><span class="nb"> </span><span class="nv">\PolTypeset</span><span class="nb">{k} </span><span class="s">$$</span>
202 <span class="k">\immediate\write</span>128<span class="nb">{</span>f(x)=<span class="k">\PolToExpr</span><span class="nb">{</span>f<span class="nb">}}</span><span class="c">% ah, here we see it also</span>
203 </pre></div>
204 </div>
205 </dd>
206 <dt><code class="docutils literal notranslate"><span class="pre">\poldef</span> <span class="pre">f'(x):=</span> <span class="pre">diff1(f);</span></code></dt><dd><p>(new at <code class="docutils literal notranslate"><span class="pre">0.8</span></code>)</p>
207 </dd>
208 <dt><code class="docutils literal notranslate"><span class="pre">\PolDiff{f}{f'}</span></code></dt><dd><p>Both set <code class="docutils literal notranslate"><span class="pre">f'</span></code> (or any other chosen name) to the derivative
209 of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p>
210 <div class="admonition important">
211 <p class="admonition-title">Important</p>
212 <p>This is not done automatically. If some new definition needs to use
213 the derivative of some available polynomial, that derivative
214 polynomial must have been previously defined: something such as
215 <code class="docutils literal notranslate"><span class="pre">f'(3)^2</span></code> will not work without a prior definition of <code class="docutils literal notranslate"><span class="pre">f'</span></code>.</p>
216 <p>But one can now use <code class="docutils literal notranslate"><span class="pre">diff1(f)</span></code> for on-the-spot construction with no
217 permanent declaration, so here <code class="docutils literal notranslate"><span class="pre">evalp(diff1(f),3)^2</span></code>. And
218 <code class="docutils literal notranslate"><span class="pre">diff1(f)^2</span></code> is same as <code class="docutils literal notranslate"><span class="pre">f'^2</span></code>, assuming here <code class="docutils literal notranslate"><span class="pre">f'</span></code> was declared
219 to be the derived polynomial.</p>
220 <p>Notice that the name <code class="docutils literal notranslate"><span class="pre">diff1()</span></code> is experimental and may change. Use
221 <code class="docutils literal notranslate"><span class="pre">\PolDiff{f}{f'}</span></code> as the stable interface.</p>
222 </div>
223 </dd>
224 <dt><code class="docutils literal notranslate"><span class="pre">\PolTypeset{P}</span></code></dt><dd><p>Typesets (switching to math mode if in text mode):</p>
225 <div class="highlight-latex notranslate"><div class="highlight"><pre><span></span><span class="k">\poldef</span> f(x):=(3+x)<span class="nb">^</span>5;<span class="c">%</span>
226 <span class="k">\PolDiff</span><span class="nb">{</span>f<span class="nb">}{</span>f&#39;<span class="nb">}</span><span class="k">\PolDiff</span><span class="nb">{</span>f&#39;<span class="nb">}{</span>f&#39;&#39;<span class="nb">}</span><span class="k">\PolDiff</span><span class="nb">{</span>f&#39;&#39;<span class="nb">}{</span>f&#39;&#39;&#39;<span class="nb">}</span><span class="c">%</span>
227 <span class="sb">$$</span><span class="nb">f</span><span class="o">(</span><span class="nb">z</span><span class="o">)</span><span class="nb"> </span><span class="o">=</span><span class="nb"> </span><span class="nv">\PolTypeset</span><span class="o">[</span><span class="nb">z</span><span class="o">]</span><span class="nb">{f} </span><span class="s">$$</span>
228 <span class="sb">$$</span><span class="nb">f&#39;</span><span class="o">(</span><span class="nb">z</span><span class="o">)</span><span class="nb"> </span><span class="o">=</span><span class="nb"> </span><span class="nv">\PolTypeset</span><span class="o">[</span><span class="nb">z</span><span class="o">]</span><span class="nb">{f&#39;} </span><span class="s">$$</span>
229 <span class="sb">$$</span><span class="nb">f&#39;&#39;</span><span class="o">(</span><span class="nb">z</span><span class="o">)</span><span class="nb"> </span><span class="o">=</span><span class="nb"> </span><span class="nv">\PolTypeset</span><span class="o">[</span><span class="nb">z</span><span class="o">]</span><span class="nb">{f&#39;&#39;} </span><span class="s">$$</span>
230 <span class="sb">$$</span><span class="nb">f&#39;&#39;&#39;</span><span class="o">(</span><span class="nb">z</span><span class="o">)=</span><span class="nb"> </span><span class="nv">\PolTypeset</span><span class="o">[</span><span class="nb">z</span><span class="o">]</span><span class="nb">{f&#39;&#39;&#39;} </span><span class="s">$$</span>
231 </pre></div>
232 </div>
233 <p>See <a class="reference internal" href="#poltypeset">its documentation</a> for the configurability
234 via macros.</p>
235 <p>Since <code class="docutils literal notranslate"><span class="pre">0.8</span></code> <a class="reference internal" href="#poltypeset">\PolTypeset</a> accepts directly an
236 expression, it does not have to be a pre-declared polynomial name:</p>
237 <div class="highlight-latex notranslate"><div class="highlight"><pre><span></span><span class="k">\PolTypeset</span><span class="nb">{</span>mul(x-i,i=1..5)<span class="nb">}</span>
238 </pre></div>
239 </div>
240 </dd>
241 <dt><code class="docutils literal notranslate"><span class="pre">\PolToExpr{P}</span></code></dt><dd><p>Expandably (contrarily to <a class="reference internal" href="#poltypeset">\PolTypeset</a>)
242 produces <code class="docutils literal notranslate"><span class="pre">c_n*x^n</span> <span class="pre">+</span> <span class="pre">...</span> <span class="pre">+</span> <span class="pre">c_0</span></code> starting from the leading
243 coefficient. The <code class="docutils literal notranslate"><span class="pre">+</span></code> signs are omitted if followed by negative
244 coefficients.</p>
245 <p>This is useful for console or file output. This syntax is Maple and
246 PSTricks <code class="docutils literal notranslate"><span class="pre">\psplot[algebraic]</span></code> compatible; and also it is
247 compatible with <code class="docutils literal notranslate"><span class="pre">\poldef</span></code> input syntax, of course. See
248 <a class="reference internal" href="#id70">\PolToExprCaret</a> for configuration of the <code class="docutils literal notranslate"><span class="pre">^</span></code>, for example to
249 use rather <code class="docutils literal notranslate"><span class="pre">**</span></code> for Python syntax compliance.</p>
250 <p>Changed at <code class="docutils literal notranslate"><span class="pre">0.8</span></code>: the <code class="docutils literal notranslate"><span class="pre">^</span></code> in output is by default of catcode 12
251 so in a draft document one can use <code class="docutils literal notranslate"><span class="pre">\PolToExpr{P}</span></code> inside the
252 typesetting flow (without requiring math mode, where the <code class="docutils literal notranslate"><span class="pre">*</span></code> would
253 be funny and <code class="docutils literal notranslate"><span class="pre">^12</span></code> would only put the <code class="docutils literal notranslate"><span class="pre">1</span></code> as exponent anyhow;
254 but arguably in text mode the <code class="docutils literal notranslate"><span class="pre">+</span></code> and <code class="docutils literal notranslate"><span class="pre">-</span></code> are not satisfactory
255 for math, except sometimes in monospace typeface, and anyhow TeX is
256 unable to break the expression across lines, barring special help).</p>
257 <p>See <a class="reference internal" href="#poltoexpr"><span class="std std-ref">\PolToExpr{&lt;pol. expr.&gt;}</span></a> and related macros for customization.</p>
258 <p>Extended at <code class="docutils literal notranslate"><span class="pre">0.8</span></code> to accept as argument not only the name of a
259 polynomial variable but more generally any polynomial expression.</p>
260 </dd>
261 </dl>
262 </section>
263 <section id="using-defined-polynomials-in-floating-point-context">
264 <h2>Using defined polynomials in floating point context</h2>
265 <p>Exact manipulations with fractional coefficients may quickly lead to
266 very large denominators. For numerical evaluations, it is advisable
267 to a use a floating point context. But for the polynomial to be
268 usable as a function in floating point context, an extra step beyond
269 <code class="docutils literal notranslate"><span class="pre">\poldef</span></code> is required: see <a class="reference internal" href="#polgenfloatvariant">\PolGenFloatVariant</a>. Then the
270 <code class="docutils literal notranslate"><span class="pre">\xintfloateval</span></code> macro from <a class="reference external" href="https://www.ctan.org/pkg/xintexpr">xintexpr</a> will recognize the polynomial
271 as a genuine function (with already float-rounded coefficients, and
272 using a Horner scheme).</p>
273 <p>But <a class="reference internal" href="#polgenfloatvariant">\PolGenFloatVariant</a> must be used each time the polynomial gets
274 redefined or a new polynomial is created out of it. Functions such as
275 for example <a class="reference internal" href="#deg"><span class="std std-ref">deg()</span></a> which handle the polynomial as an entity
276 are only available within the <code class="docutils literal notranslate"><span class="pre">\poldef</span></code> and <code class="docutils literal notranslate"><span class="pre">\xinteval</span></code> (or
277 <code class="docutils literal notranslate"><span class="pre">\xintexpr</span></code>) parsers. Inside <code class="docutils literal notranslate"><span class="pre">\xintfloateval</span></code> a polynomial can only
278 serve as a numerical function (and only after declaration via
279 <a class="reference internal" href="#polgenfloatvariant">\PolGenFloatVariant</a>), and not as a variable.</p>
280 <p>In some cases one may wish to replace a polynomial having acquired
281 very big fractional coefficients with a new one whose coefficients
282 have been float-rounded. See <a class="reference internal" href="#polmapcoeffs"><span class="std std-ref">\PolMapCoeffs</span></a>
283 which can be used for example with the <code class="docutils literal notranslate"><span class="pre">\xintFloat</span></code> macro from the
284 <a class="reference external" href="https://www.ctan.org/pkg/xint">xintfrac</a> package to achieve this.</p>
285 </section>
286 <section id="the-polexpr-0-8-extensions-to-the-xintexpr-syntax">
287 <span id="polexpr08"></span><h2>The polexpr <code class="docutils literal notranslate"><span class="pre">0.8</span></code> extensions to the <code class="docutils literal notranslate"><span class="pre">\xintexpr</span></code> syntax</h2>
288 <p>All the syntax elements described in this section can be used in the
289 <code class="docutils literal notranslate"><span class="pre">\xintexpr/\xinteval</span></code> context (where polynomials can be obtained from
290 the <code class="docutils literal notranslate"><span class="pre">pol([])</span></code> constructor, once polexpr is loaded): their usage is
291 not limited to only <code class="docutils literal notranslate"><span class="pre">\poldef</span></code> context.</p>
292 <div class="admonition note">
293 <p class="admonition-title">Note</p>
294 <p>If a variable <code class="docutils literal notranslate"><span class="pre">myPol</span></code> defined via <code class="docutils literal notranslate"><span class="pre">\xintdefvar</span></code> turns out
295 to be a polynomial, the difference with those declared via <code class="docutils literal notranslate"><span class="pre">\poldef</span></code>
296 will be:</p>
297 <ol class="arabic">
298 <li><p><code class="docutils literal notranslate"><span class="pre">myPol</span></code> is not usable as <em>function</em>, but only as a variable.
299 Attention that <code class="docutils literal notranslate"><span class="pre">f(x)</span></code> if <code class="docutils literal notranslate"><span class="pre">f</span></code> is only a variable (even a
300 polynomial one) will actually compute <code class="docutils literal notranslate"><span class="pre">f</span> <span class="pre">*</span> <span class="pre">x</span></code>.</p></li>
301 <li><p><code class="docutils literal notranslate"><span class="pre">myPol</span></code> is not known to the polexpr package, hence for example the
302 macros to achieve localization of its roots are unavailable.</p>
303 <p>In a parallel universe I perhaps have implemented this expandably
304 which means it could then be accessible with syntax such as
305 <code class="docutils literal notranslate"><span class="pre">rightmostroot(pol([42,1,34,2,-8,1]))</span></code> but…</p>
306 </li>
307 </ol>
308 </div>
309 <section id="warning-about-unstability-of-the-new-syntax">
310 <h3>Warning about unstability of the new syntax</h3>
311 <div class="admonition warning">
312 <p class="admonition-title">Warning</p>
313 <p>Consider the entirety of this section as <strong>UNSTABLE</strong> and
314 <strong>EXPERIMENTAL</strong> (except perhaps regarding <code class="docutils literal notranslate"><span class="pre">+</span></code>, <code class="docutils literal notranslate"><span class="pre">-</span></code> and <code class="docutils literal notranslate"><span class="pre">*</span></code>).</p>
315 <p>And this applies even to items not explicitly flagged with one of
316 <strong>unstable</strong>, <strong>Unstable</strong>, or <strong>UNSTABLE</strong> which only reflect that
317 documentation was written over a period of time exceeding one minute,
318 enough for the author mood changes to kick in.</p>
319 <p>It is hard to find good names at the start of a life-long extension
320 program of functionalities, and perhaps in future it will be
321 preferred to rename everything or give to some functions other
322 meanings. Such quasi-complete renamings happened already a few times
323 during the week devoted to development.</p>
324 </div>
325 </section>
326 <section id="infix-operators">
327 <h3>Infix operators <code class="docutils literal notranslate"><span class="pre">+,</span> <span class="pre">-,</span> <span class="pre">*,</span> <span class="pre">/,</span> <span class="pre">**,</span> <span class="pre">^</span></code></h3>
328 <blockquote>
329 <div><p>As has been explained in the <a class="reference internal" href="#syntax-overview-via-examples">Syntax overview via examples</a>
330 section these infix operators have been made polynomial aware, not
331 only in the <code class="docutils literal notranslate"><span class="pre">\poldef</span></code> context, but generally in any
332 <code class="docutils literal notranslate"><span class="pre">\xintexpr/\xinteval</span></code> context, inclusive of <code class="docutils literal notranslate"><span class="pre">\xintdeffunc</span></code>.</p>
333 <p>Conversely functions declared via <code class="docutils literal notranslate"><span class="pre">\xintdeffunc</span></code> and making use of
334 these operators will automatically be able to accept polynomials
335 declared from <code class="docutils literal notranslate"><span class="pre">\poldef</span></code> as variables.</p>
336 <p>Usage of <code class="docutils literal notranslate"><span class="pre">/</span></code> for euclidean division of polynomials is <strong>deprecated</strong>.
337 Only in case of a scalar denominator is it to be considered stable.
338 Please use rather <code class="docutils literal notranslate"><span class="pre">quo()</span></code>.</p>
339 </div></blockquote>
340 </section>
341 <section id="experimental-infix-operators">
342 <h3>Experimental infix operators <code class="docutils literal notranslate"><span class="pre">//,</span> <span class="pre">/:</span></code></h3>
343 <blockquote>
344 <div><p>Here is the tentative behaviour of <code class="docutils literal notranslate"><span class="pre">A//B</span></code> according to types:</p>
345 <ul class="simple">
346 <li><p><code class="docutils literal notranslate"><span class="pre">A</span></code> non scalar and <code class="docutils literal notranslate"><span class="pre">B</span></code> non scalar: euclidean quotient,</p></li>
347 <li><p><code class="docutils literal notranslate"><span class="pre">A</span></code> scalar and <code class="docutils literal notranslate"><span class="pre">B</span></code> scalar: floored division,</p></li>
348 <li><p><code class="docutils literal notranslate"><span class="pre">A</span></code> scalar and <code class="docutils literal notranslate"><span class="pre">B</span></code> non scalar: produces zero,</p></li>
349 <li><p><code class="docutils literal notranslate"><span class="pre">A</span></code> non scalar and <code class="docutils literal notranslate"><span class="pre">B</span></code> scalar: coefficient per
350 coefficient floored division.</p></li>
351 </ul>
352 <p>This is an <strong>experimental</strong> overloading of the <code class="docutils literal notranslate"><span class="pre">//</span></code> and <code class="docutils literal notranslate"><span class="pre">/:</span></code>
353 from <code class="docutils literal notranslate"><span class="pre">\xintexpr</span></code>.</p>
354 <p>The behaviour in the last case, but not only, is to be considerd
355 <strong>unstable</strong>. The alternative would be for <code class="docutils literal notranslate"><span class="pre">A//B</span></code> with <code class="docutils literal notranslate"><span class="pre">B</span></code>
356 scalar to act as <code class="docutils literal notranslate"><span class="pre">quo(A,B)</span></code>. But, we have currently chosen to let
357 <code class="docutils literal notranslate"><span class="pre">//B</span></code> for a scalar <code class="docutils literal notranslate"><span class="pre">B</span></code> act coefficient-wise on the numerator.
358 Beware that it thus means it can be employed with the idea of doing
359 euclidean division only by checking that <code class="docutils literal notranslate"><span class="pre">B</span></code> is non-scalar.</p>
360 <p>The <code class="docutils literal notranslate"><span class="pre">/:</span></code> operator provides the associated remainder so always
361 <code class="docutils literal notranslate"><span class="pre">A</span></code> is reconstructed from <code class="docutils literal notranslate"><span class="pre">(A//B)*B</span> <span class="pre">+</span> <span class="pre">A/:B</span></code>.</p>
362 <p>If <code class="docutils literal notranslate"><span class="pre">:</span></code> is active character use <code class="docutils literal notranslate"><span class="pre">/\string:</span></code> (it is safer to use
363 <code class="docutils literal notranslate"><span class="pre">/\string</span> <span class="pre">:</span></code> if it is not known if <code class="docutils literal notranslate"><span class="pre">:</span></code> has catcode other, letter,
364 or is active, but note that <code class="docutils literal notranslate"><span class="pre">/:</span></code> is fine and needs no precaution if
365 <code class="docutils literal notranslate"><span class="pre">:</span></code> has catcode letter, it is only an active <code class="docutils literal notranslate"><span class="pre">:</span></code> which is
366 problematic, like for all other characters possibly used in an
367 expression).</p>
368 <blockquote>
369 <div><p><strong>UNSTABLE</strong></p>
370 <p>As explained above, there are (among other things) hesitations
371 about behaviour with <code class="docutils literal notranslate"><span class="pre">pol2</span></code> a scalar.</p>
372 </div></blockquote>
373 </div></blockquote>
374 </section>
375 <section id="comparison-operators">
376 <h3>Comparison operators <code class="docutils literal notranslate"><span class="pre">&lt;,</span> <span class="pre">&gt;,</span> <span class="pre">&lt;=,</span> <span class="pre">&gt;=,</span> <span class="pre">==,</span> <span class="pre">!=</span></code></h3>
377 <blockquote>
378 <div><p><strong>NOT YET IMPLEMENTED</strong></p>
379 <p>As the internal representation by <a class="reference external" href="https://www.ctan.org/pkg/xint">xintfrac</a> and <a class="reference external" href="https://www.ctan.org/pkg/xintexpr">xintexpr</a> of
380 fractions does not currently require them to be in reduced terms,
381 such operations would be a bit costly as they could not benefit from
382 the <code class="docutils literal notranslate"><span class="pre">\pdfstrcmp</span></code> engine primitive. In fact <a class="reference external" href="https://www.ctan.org/pkg/xintexpr">xintexpr</a> does not use
383 it yet anywhere, even for normalized pure integers, although it could
384 speed up signifcantly certain aspects of core arithmetic.</p>
385 <p>Equality of polynomials can currently be tested by computing the
386 difference, which is a bit costly. And of course the <code class="docutils literal notranslate"><span class="pre">deg()</span></code>
387 function allows comparing degrees. In this context note the
388 following syntax:</p>
389 <div class="highlight-latex notranslate"><div class="highlight"><pre><span></span>(deg(Q)) ?? <span class="nb">{</span> zero <span class="nb">}</span> <span class="nb">{</span> non-zero scalar <span class="nb">}</span> <span class="nb">{</span> non-scalar <span class="nb">}</span>
390 </pre></div>
391 </div>
392 <p>for branching.</p>
393 </div></blockquote>
394 </section>
395 <section id="pol-nutple-expression">
396 <span id="pol"></span><h3><code class="docutils literal notranslate"><span class="pre">pol(&lt;nutple</span> <span class="pre">expression&gt;)</span></code></h3>
397 <blockquote>
398 <div><p>This converts a nutple <code class="docutils literal notranslate"><span class="pre">[c0,c1,...,cN]</span></code> into the polynomial
399 variable having these coefficients. Attention that the square
400 brackets are <strong>mandatory</strong>, except of course if the argument is
401 actually an expression producing such a “nutple”.</p>
402 <blockquote>
403 <div><p>Currently, this process will not normalize the coefficients (such
404 as reducing to lowest terms), it only trims out the leading zero
405 coefficients.</p>
406 </div></blockquote>
407 <p>Inside <code class="docutils literal notranslate"><span class="pre">\xintexpr</span></code>, this is the only (allowed) way to create ex
408 nihilo a polynomial variable; inside <code class="docutils literal notranslate"><span class="pre">\poldef</span></code> it is an alternative
409 input syntax which is more efficient than the input <code class="docutils literal notranslate"><span class="pre">c0</span> <span class="pre">+</span> <span class="pre">c1</span> <span class="pre">*</span> <span class="pre">x</span> <span class="pre">+</span> <span class="pre">c2</span> <span class="pre">*</span>
410 <span class="pre">x^2</span> <span class="pre">+</span> <span class="pre">...</span></code>.</p>
411 </div></blockquote>
412 <div class="admonition important">
413 <p class="admonition-title">Important</p>
414 <p>Whenever an expression with polynomials collapses to a constant, it
415 becomes a scalar. There is currently no distinction during the
416 parsing of expressions by <code class="docutils literal notranslate"><span class="pre">\poldef</span></code>
417 or <code class="docutils literal notranslate"><span class="pre">\xintexpr</span></code> between constant polynomial variables and scalar
418 variables.</p>
419 <p>Naturally, <code class="docutils literal notranslate"><span class="pre">\poldef</span></code> can be used to declare a constant polynomial
420 <code class="docutils literal notranslate"><span class="pre">P</span></code>, then <code class="docutils literal notranslate"><span class="pre">P</span></code> can also be used as function having a value
421 independent of argument, but as a variable, it is non-distinguishable
422 from a scalar (of course functions such as <code class="docutils literal notranslate"><span class="pre">deg()</span></code> tacitly
423 consider scalars to be constant polynomials).</p>
424 <p>Notice that we tend to use the vocable “variable” to refer to
425 arbitrary expressions used as function arguments, without implying
426 that we are actually referring to pre-declared variables in the sense
427 of <code class="docutils literal notranslate"><span class="pre">\xintdefvar</span></code>.</p>
428 </div>
429 </section>
430 <section id="lpol-nutple-expression">
431 <span id="lpol"></span><h3><code class="docutils literal notranslate"><span class="pre">lpol(&lt;nutple</span> <span class="pre">expression&gt;)</span></code></h3>
432 <blockquote>
433 <div><p>This converts a nutple <code class="docutils literal notranslate"><span class="pre">[cN,...,c1,c0]</span></code> into the polynomial
434 variable having these coefficients, with leading coefficients coming
435 first in the input. Attention that the square brackets are
436 <strong>mandatory</strong>, except of course if the argument is actually an
437 expression producing such a “nutple”.</p>
438 <blockquote>
439 <div><p>Currently, this process will not normalize the coefficients (such
440 as reducing to lowest terms), it only trims out the leading zero
441 coefficients.</p>
442 <p><strong>NAME UNSTABLE</strong></p>
443 </div></blockquote>
444 <p>It can be used in <code class="docutils literal notranslate"><span class="pre">\poldef</span></code> as an alternative input syntax, which
445 is more efficient than using the algebraic notation with monomials.</p>
446 <p>(new with <code class="docutils literal notranslate"><span class="pre">0.8.1</span></code>, an empty nutple will cause breakage)</p>
447 </div></blockquote>
448 </section>
449 <section id="xinteval-pol-expr">
450 <span id="xintevalpolexpr"></span><h3><code class="docutils literal notranslate"><span class="pre">\xinteval{&lt;pol.</span> <span class="pre">expr.&gt;}</span></code></h3>
451 <blockquote>
452 <div><p>This is documented here for lack of a better place: it evaluates the
453 polynomial expression then outputs the “string” <code class="docutils literal notranslate"><span class="pre">pol([c0,</span> <span class="pre">c1,</span> <span class="pre">...,</span> <span class="pre">cN])</span></code>
454 if the degree <code class="docutils literal notranslate"><span class="pre">N</span></code> is at least one (and the usual scalar output else).</p>
455 <p>The “pol” word uses letter catcodes, which is actually mandatory for
456 this output to be usable as input, but it does not make sense to use
457 this inside <code class="docutils literal notranslate"><span class="pre">\poldef</span></code> or <code class="docutils literal notranslate"><span class="pre">\xintexpr</span></code> at it means basically
458 executing <code class="docutils literal notranslate"><span class="pre">pol(coeffs(..expression..))</span></code> which is but a convoluted
459 way to obtain the same result as <code class="docutils literal notranslate"><span class="pre">(..expression..)</span></code> (the
460 parentheses delimiting the polynomial expression).</p>
461 <p>For example, <code class="docutils literal notranslate"><span class="pre">\xinteval{(1+pol([0,1]))^10}</span></code> expands (in two steps)
462 to:</p>
463 <div class="highlight-latex notranslate"><div class="highlight"><pre><span></span>pol([1, 10, 45, 120, 210, 252, 210, 120, 45, 10, 1])
464 </pre></div>
465 </div>
466 <p>You do need loading polexpr for this, else of course <code class="docutils literal notranslate"><span class="pre">pol([])</span></code>
467 remains unknown to <code class="docutils literal notranslate"><span class="pre">\xinteval{}</span></code> as well as the polynomial algebra !
468 This example can also be done as
469 <code class="docutils literal notranslate"><span class="pre">\xinteval{subs((1+x)^10,x=pol([0,1]))}</span></code>.</p>
470 <p>I hesitated using as output the polynomial notation as produced by
471 <a class="reference internal" href="#poltoexpr">\PolToExpr{}</a>, but finally opted for this.</p>
472 </div></blockquote>
473 </section>
474 <section id="evalp-pol-expr-pol-expr">
475 <span id="evalp"></span><h3><code class="docutils literal notranslate"><span class="pre">evalp(&lt;pol.</span> <span class="pre">expr.&gt;,</span> <span class="pre">&lt;pol.</span> <span class="pre">expr&gt;)</span></code></h3>
476 <blockquote>
477 <div><p>Evaluates the first argument as a polynomial function of the
478 second. Usually the second argument will be scalar, but this is not
479 required:</p>
480 <div class="highlight-latex notranslate"><div class="highlight"><pre><span></span><span class="k">\poldef</span> K(x):= evalp(-3x<span class="nb">^</span>3-5x+1,-27x<span class="nb">^</span>4+5x-2);
481 </pre></div>
482 </div>
483 <p>If the first argument is an already declared polynomial <code class="docutils literal notranslate"><span class="pre">P</span></code>, use
484 rather the functional form <code class="docutils literal notranslate"><span class="pre">P()</span></code> (which can accept a numerical as
485 well as polynomial argument) as it is more efficient.</p>
486 <p>One can also use <code class="docutils literal notranslate"><span class="pre">subs()</span></code> syntax <a class="footnote-reference brackets" href="#id2" id="id1" role="doc-noteref"><span class="fn-bracket">[</span>1<span class="fn-bracket">]</span></a> (see <a class="reference external" href="https://www.ctan.org/pkg/xintexpr">xintexpr</a> documentation):</p>
487 <div class="highlight-latex notranslate"><div class="highlight"><pre><span></span><span class="k">\poldef</span> K(x):= subs(-3y<span class="nb">^</span>3-5y+1, y = -27x<span class="nb">^</span>4+5x-2);
488 </pre></div>
489 </div>
490 <p>but the <code class="docutils literal notranslate"><span class="pre">evalp()</span></code> will use a Horner evaluation scheme which is
491 usually more efficient.</p>
492 <aside class="footnote brackets" id="id2" role="note">
493 <span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#id1">1</a><span class="fn-bracket">]</span></span>
494 <p>by the way Maple uses the opposite, hence wrong, order
495 <code class="docutils literal notranslate"><span class="pre">subs(x=...,</span> <span class="pre">P)</span></code> but was written before computer science
496 reached the <a class="reference external" href="https://www.ctan.org/pkg/xintexpr">xintexpr</a> heights. However it makes validating
497 Maple results by polexpr sometimes cumbersome, but perhaps
498 they will update it at some point.</p>
499 </aside>
500 <blockquote>
501 <div><p><strong>name unstable</strong></p>
502 <p><code class="docutils literal notranslate"><span class="pre">poleval</span></code>? <code class="docutils literal notranslate"><span class="pre">evalpol</span></code>? <code class="docutils literal notranslate"><span class="pre">peval</span></code>? <code class="docutils literal notranslate"><span class="pre">evalp</span></code>? <code class="docutils literal notranslate"><span class="pre">value</span></code>?
503 <code class="docutils literal notranslate"><span class="pre">eval</span></code>? <code class="docutils literal notranslate"><span class="pre">evalat</span></code>? <code class="docutils literal notranslate"><span class="pre">eval1at2</span></code>? <code class="docutils literal notranslate"><span class="pre">evalat2nd</span></code>?</p>
504 <p>Life is so complicated when one asks questions. Not everybody does,
505 though, as is amply demonstrated these days.</p>
506 <p><strong>syntax unstable</strong></p>
507 <p>I am hesitating about permuting the order of the arguments.</p>
508 </div></blockquote>
509 </div></blockquote>
510 </section>
511 <section id="deg-pol-expr">
512 <span id="deg"></span><h3><code class="docutils literal notranslate"><span class="pre">deg(&lt;pol.</span> <span class="pre">expr.&gt;)</span></code></h3>
513 <blockquote>
514 <div><p>Computes the degree.</p>
515 </div></blockquote>
516 <div class="admonition important">
517 <p class="admonition-title">Important</p>
518 <p>As <code class="docutils literal notranslate"><span class="pre">\xintexpr</span></code> does not yet support infinities, the degree of
519 the zero polynomial is <code class="docutils literal notranslate"><span class="pre">-1</span></code>. Beware that this breaks additivity
520 of degrees, but <code class="docutils literal notranslate"><span class="pre">deg(P)&lt;0</span></code> correctly detects the zero polynomial,
521 and <code class="docutils literal notranslate"><span class="pre">deg(P)&lt;=0</span></code> detects scalars.</p>
522 </div>
523 </section>
524 <section id="coeffs-pol-expr">
525 <h3><code class="docutils literal notranslate"><span class="pre">coeffs(&lt;pol.</span> <span class="pre">expr.&gt;)</span></code></h3>
526 <blockquote>
527 <div><p>Produces the nutple <code class="docutils literal notranslate"><span class="pre">[c0,c1,...,cN]</span></code> of coefficients. The highest
528 degree coefficient is always non zero (except for the zero
529 polynomial…).</p>
530 <blockquote>
531 <div><p><strong>name unstable</strong></p>
532 <p>I am considering in particular using <code class="docutils literal notranslate"><span class="pre">polcoeffs()</span></code> to avoid
533 having to overload <code class="docutils literal notranslate"><span class="pre">coeffs()</span></code> in future when matrix type
534 will be added to <a class="reference external" href="https://www.ctan.org/pkg/xintexpr">xintexpr</a>.</p>
535 </div></blockquote>
536 </div></blockquote>
537 </section>
538 <section id="lcoeffs-pol-expr">
539 <span id="lcoeffs"></span><h3><code class="docutils literal notranslate"><span class="pre">lcoeffs(&lt;pol.</span> <span class="pre">expr.&gt;)</span></code></h3>
540 <blockquote>
541 <div><p>Produces the nutple <code class="docutils literal notranslate"><span class="pre">[cN,....,c1,c0]</span></code> of coefficients, starting
542 with the highest degree coefficient.</p>
543 <p>(new with <code class="docutils literal notranslate"><span class="pre">0.8.1</span></code>)</p>
544 </div></blockquote>
545 </section>
546 <section id="coeff-pol-expr-num-expr">
547 <h3><code class="docutils literal notranslate"><span class="pre">coeff(&lt;pol.</span> <span class="pre">expr.&gt;,</span> <span class="pre">&lt;num.</span> <span class="pre">expr.&gt;)</span></code></h3>
548 <blockquote>
549 <div><p>As expected. Produces zero if the numerical index is negative or
550 higher than the degree.</p>
551 <blockquote>
552 <div><p><strong>name, syntax and output unstable</strong></p>
553 <p>I am hesitating with <code class="docutils literal notranslate"><span class="pre">coeff(n,pol)</span></code> syntax and also perhaps using
554 <code class="docutils literal notranslate"><span class="pre">polcoeff()</span></code> in order to avoid having to overload <code class="docutils literal notranslate"><span class="pre">coeff()</span></code>
555 when matrix type will be added to <a class="reference external" href="https://www.ctan.org/pkg/xintexpr">xintexpr</a>.</p>
556 <p>The current behaviour is at odds with legacy
557 <a class="reference internal" href="#polnthcoeff"><span class="std std-ref">\PolNthCoeff{&lt;polname&gt;}{&lt;index&gt;}</span></a> regarding negative indices.
558 Accessing leading or sub-leading coefficients can be done with
559 other syntax, see <a class="reference internal" href="#lc-pol-expr">lc(&lt;pol. expr.&gt;)</a>, and in some contexts it
560 is useful to be able to rely on the fact that coefficients with
561 negative indices do vanish, so I am for time being maintaining this.</p>
562 </div></blockquote>
563 </div></blockquote>
564 </section>
565 <section id="lc-pol-expr">
566 <span id="lc"></span><h3><code class="docutils literal notranslate"><span class="pre">lc(&lt;pol.</span> <span class="pre">expr.&gt;)</span></code></h3>
567 <blockquote>
568 <div><p>The leading coefficient. The same result can be obtained from
569 <code class="docutils literal notranslate"><span class="pre">coeffs(pol)[-1]</span></code>, which shows also how to generalize to access
570 sub-leading coefficients. See the <a class="reference external" href="https://www.ctan.org/pkg/xintexpr">xintexpr</a> documentation for
571 Python-like indexing syntax.</p>
572 </div></blockquote>
573 </section>
574 <section id="monicpart-pol-expr">
575 <h3><code class="docutils literal notranslate"><span class="pre">monicpart(&lt;pol.</span> <span class="pre">expr.&gt;)</span></code></h3>
576 <blockquote>
577 <div><p>Divides by the leading coefficient, except that <code class="docutils literal notranslate"><span class="pre">monicpart(0)==0</span></code>.</p>
578 <blockquote>
579 <div><p><strong>unstable</strong></p>
580 <p>Currently the coefficients are reduced to lowest terms (contrarily
581 to legacy behaviour of <a class="reference internal" href="#polmakemonic">\PolMakeMonic</a>), and
582 additionally the <a class="reference external" href="https://www.ctan.org/pkg/xint">xintfrac</a> <code class="docutils literal notranslate"><span class="pre">\xintREZ</span></code> macro is applied which
583 extracts powers of ten from numerator or denominator and stores
584 them internally separately. This is generally beneficial to
585 efficiency of multiplication.</p>
586 </div></blockquote>
587 </div></blockquote>
588 </section>
589 <section id="cont-pol-expr">
590 <span id="cont"></span><h3><code class="docutils literal notranslate"><span class="pre">cont(&lt;pol.</span> <span class="pre">expr.&gt;)</span></code></h3>
591 <blockquote>
592 <div><p>The (fractional) greatest common divisor of the polynomial
593 coefficients. It is always produced as an irreducible (non-negative)
594 fraction. According to Gauss theorem the content of a product is the
595 product of the contents.</p>
596 <blockquote>
597 <div><p><strong>name and syntax unstable</strong></p>
598 <p>At <code class="docutils literal notranslate"><span class="pre">0.8</span></code> it was created as <code class="docutils literal notranslate"><span class="pre">icontent()</span></code> to match the legacy
599 macro <a class="reference internal" href="#policontent">\PolIContent</a>, whose name in 2018 was
600 chosen in relation to Maple’s function <code class="docutils literal notranslate"><span class="pre">icontent()</span></code>, possibly
601 because at that time I had not seen that Maple also had a
602 <code class="docutils literal notranslate"><span class="pre">content()</span></code> function. Name changed at <code class="docutils literal notranslate"><span class="pre">0.8.1</span></code>.</p>
603 <p>It will change syntax if in future multivariate polynomials are
604 supported, and <code class="docutils literal notranslate"><span class="pre">icontent()</span></code> will then make a come-back.</p>
605 </div></blockquote>
606 </div></blockquote>
607 </section>
608 <section id="primpart-pol-expr">
609 <h3><code class="docutils literal notranslate"><span class="pre">primpart(&lt;pol.</span> <span class="pre">expr.&gt;)</span></code></h3>
610 <blockquote>
611 <div><p>The quotient (except for the zero polynomial) by
612 <code class="docutils literal notranslate"><span class="pre">cont(&lt;pol.</span> <span class="pre">expr.&gt;)</span></code>. This is thus a polynomial with
613 integer coefficients having <code class="docutils literal notranslate"><span class="pre">1</span></code> as greatest common divisor. The
614 sign of the leading coefficient is the same as in the original.</p>
615 <p>And <code class="docutils literal notranslate"><span class="pre">primpart(0)==0</span></code>.</p>
616 <p>The trailing zeros of the integer coefficients are extracted
617 into a power of ten exponent part, in the internal representation.</p>
618 </div></blockquote>
619 </section>
620 <section id="quorem-pol-expr-pol-expr">
621 <h3><code class="docutils literal notranslate"><span class="pre">quorem(&lt;pol.</span> <span class="pre">expr.&gt;,</span> <span class="pre">&lt;pol.</span> <span class="pre">expr.&gt;)</span></code></h3>
622 <blockquote>
623 <div><p>Produces a nutple <code class="docutils literal notranslate"><span class="pre">[Q,R]</span></code> with <code class="docutils literal notranslate"><span class="pre">Q</span></code> the euclidean quotient and
624 <code class="docutils literal notranslate"><span class="pre">R</span></code> the remainder.</p>
625 <blockquote>
626 <div><p><strong>name unstable</strong></p>
627 <p><code class="docutils literal notranslate"><span class="pre">poldiv()</span></code>?</p>
628 </div></blockquote>
629 </div></blockquote>
630 </section>
631 <section id="quo-pol-expr-pol-expr">
632 <h3><code class="docutils literal notranslate"><span class="pre">quo(&lt;pol.</span> <span class="pre">expr.&gt;,</span> <span class="pre">&lt;pol.</span> <span class="pre">expr.&gt;)</span></code></h3>
633 <blockquote>
634 <div><p>The euclidean quotient.</p>
635 <p>The deprecated <code class="docutils literal notranslate"><span class="pre">pol1/pol2</span></code> syntax computes the same polynomial.</p>
636 </div></blockquote>
637 </section>
638 <section id="rem-pol-expr-pol-expr">
639 <h3><code class="docutils literal notranslate"><span class="pre">rem(&lt;pol.</span> <span class="pre">expr.&gt;,</span> <span class="pre">&lt;pol.</span> <span class="pre">expr.&gt;)</span></code></h3>
640 <blockquote>
641 <div><p>The euclidean remainder. If <code class="docutils literal notranslate"><span class="pre">pol2</span></code> is a (non-zero) scalar, this is
642 zero.</p>
643 <p>There is no infix operator associated to this, for lack of evident
644 notation. Please advise.</p>
645 <p><code class="docutils literal notranslate"><span class="pre">/:</span></code> can be used if one is certain that <code class="docutils literal notranslate"><span class="pre">pol2</span></code> is of
646 degree at least one. But read the warning about it being unstable
647 even in that case.</p>
648 </div></blockquote>
649 </section>
650 <section id="prem-pol-expr-1-pol-expr-2">
651 <span id="prem"></span><h3><code class="docutils literal notranslate"><span class="pre">prem(&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">1&gt;,</span> <span class="pre">&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">2&gt;)</span></code></h3>
652 <blockquote>
653 <div><p>Produces a nutple <code class="docutils literal notranslate"><span class="pre">[m,</span> <span class="pre">spR]</span></code> where <code class="docutils literal notranslate"><span class="pre">spR</span></code> is the (special) pseudo
654 Euclidean remainder. Its description is:</p>
655 <ul>
656 <li><p>the standard euclidean remainder <code class="docutils literal notranslate"><span class="pre">R</span></code> is <code class="docutils literal notranslate"><span class="pre">spR/m</span></code></p></li>
657 <li><p><code class="docutils literal notranslate"><span class="pre">m</span> <span class="pre">=</span> <span class="pre">b^f</span></code> with <code class="docutils literal notranslate"><span class="pre">b</span></code> equal to the <strong>absolute value</strong> of the
658 leading coefficient of <code class="docutils literal notranslate"><span class="pre">pol2</span></code>,</p></li>
659 <li><p><code class="docutils literal notranslate"><span class="pre">f</span></code> is the number of non-zero coefficients in the euclidean
660 quotient, if <code class="docutils literal notranslate"><span class="pre">deg(pol2)&gt;0</span></code> (even if the remainder vanishes).</p>
661 <p>If <code class="docutils literal notranslate"><span class="pre">pol2</span></code> is a scalar however, the function outputs <code class="docutils literal notranslate"><span class="pre">[1,0]</span></code>.</p>
662 </li>
663 </ul>
664 <p>With these definitions one can show that if both <code class="docutils literal notranslate"><span class="pre">pol1</span></code> and
665 <code class="docutils literal notranslate"><span class="pre">pol2</span></code> have integer coefficients, then this is also the case of
666 <code class="docutils literal notranslate"><span class="pre">spR</span></code>, which makes its interest (and also <code class="docutils literal notranslate"><span class="pre">m*Q</span></code> has integer
667 coefficients, with <code class="docutils literal notranslate"><span class="pre">Q</span></code> the euclidean quotient, if <code class="docutils literal notranslate"><span class="pre">deg(pol2)&gt;0</span></code>).
668 Also, <code class="docutils literal notranslate"><span class="pre">prem()</span></code> is computed faster than <code class="docutils literal notranslate"><span class="pre">rem()</span></code> for such integer
669 coefficients polynomials.</p>
670 <div class="admonition hint">
671 <p class="admonition-title">Hint</p>
672 <p>If you want the euclidean quotient <code class="docutils literal notranslate"><span class="pre">R</span></code> evaluated via <code class="docutils literal notranslate"><span class="pre">spR/m</span></code>
673 (which may be faster, even with non integer coefficients) use
674 <code class="docutils literal notranslate"><span class="pre">subs(last(x)/first(x),x=prem(P,Q))</span></code> syntax as it avoids
675 computing <code class="docutils literal notranslate"><span class="pre">prem(P,Q)</span></code> twice. This does the trick both in
676 <code class="docutils literal notranslate"><span class="pre">\poldef</span></code> or in <code class="docutils literal notranslate"><span class="pre">\xintdefvar</span></code>.</p>
677 <p>However, as is explained in the <a class="reference external" href="https://www.ctan.org/pkg/xintexpr">xintexpr</a> documentation, using
678 such syntax in an <code class="docutils literal notranslate"><span class="pre">\xintdeffunc</span></code> is (a.t.t.o.w) illusory, due to
679 technicalities of how <code class="docutils literal notranslate"><span class="pre">subs()</span></code> gets converted into nested
680 expandable macros. One needs an auxiliary function like this:</p>
681 <div class="highlight-latex notranslate"><div class="highlight"><pre><span></span><span class="k">\xintdeffunc</span> lastoverfirst(x):=last(x)/first(x);
682 <span class="k">\xintdeffunc</span> myR(x)=lastoverfirst(prem(x));
683 </pre></div>
684 </div>
685 <p>Then, <code class="docutils literal notranslate"><span class="pre">myR(pol1,pol2)</span></code> will evaluate <code class="docutils literal notranslate"><span class="pre">prem(pol1,pol2)</span></code> only
686 once and compute a polynomial identical to the euclidean
687 remainder (internal representations of coefficients may differ).</p>
688 </div>
689 <p>In this case of integer coefficients polynomials, the polexpr
690 internal representation of the integer coefficients in the pseudo
691 remainder will be with unit denominators only if that was already the
692 case for those of <code class="docutils literal notranslate"><span class="pre">pol1</span></code> and <code class="docutils literal notranslate"><span class="pre">pol2</span></code> (no automatic reduction to
693 lowest terms is made prior or after computation).</p>
694 <p>Pay attention here that <code class="docutils literal notranslate"><span class="pre">b</span></code> is the <strong>absolute value</strong> of the
695 leading coefficient of <code class="docutils literal notranslate"><span class="pre">pol2</span></code>. Thus the coefficients of the
696 pseudo-remainder have the same signs as those of the standard
697 remainder. This diverges from Maple’s function with the same name.</p>
698 </div></blockquote>
699 </section>
700 <section id="divmod-pol-expr-1-pol-expr-2">
701 <h3><code class="docutils literal notranslate"><span class="pre">divmod(&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">1&gt;,</span> <span class="pre">&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">2&gt;)</span></code></h3>
702 <blockquote>
703 <div><p>Overloads the scalar <code class="docutils literal notranslate"><span class="pre">divmod()</span></code> and associates it with the
704 experimental <code class="docutils literal notranslate"><span class="pre">//</span></code> and <code class="docutils literal notranslate"><span class="pre">/:</span></code> as extended to the polynomial type.</p>
705 <p>In particular when both <code class="docutils literal notranslate"><span class="pre">pol1</span></code> and <code class="docutils literal notranslate"><span class="pre">pol2</span></code> are scalars, this is
706 the usual <code class="docutils literal notranslate"><span class="pre">divmod()</span></code> (as in Python) and for <code class="docutils literal notranslate"><span class="pre">pol1</span></code> and <code class="docutils literal notranslate"><span class="pre">pol2</span></code>
707 non constant polynomials, this is the same as <code class="docutils literal notranslate"><span class="pre">quorem()</span></code>.</p>
708 <blockquote>
709 <div><p><strong>Highly unstable</strong> overloading of <code class="docutils literal notranslate"><span class="pre">\xinteval</span></code>‘s <code class="docutils literal notranslate"><span class="pre">divmod()</span></code>.</p>
710 </div></blockquote>
711 </div></blockquote>
712 </section>
713 <section id="mod-pol-expr-1-pol-expr-2">
714 <h3><code class="docutils literal notranslate"><span class="pre">mod(&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">1&gt;,</span> <span class="pre">&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">2&gt;)</span></code></h3>
715 <blockquote>
716 <div><p>The <code class="docutils literal notranslate"><span class="pre">R</span></code> of the <code class="docutils literal notranslate"><span class="pre">divmod()</span></code> output. Same as <code class="docutils literal notranslate"><span class="pre">R</span></code> of <code class="docutils literal notranslate"><span class="pre">quorem()</span></code>
717 when the second argument <code class="docutils literal notranslate"><span class="pre">pol2</span></code> is of degree at least one.</p>
718 <blockquote>
719 <div><p><strong>Highly unstable</strong> overloading of <code class="docutils literal notranslate"><span class="pre">\xinteval</span></code>‘s <code class="docutils literal notranslate"><span class="pre">mod()</span></code>.</p>
720 </div></blockquote>
721 </div></blockquote>
722 </section>
723 <section id="polgcd-pol-expr-1-pol-expr-2">
724 <h3><code class="docutils literal notranslate"><span class="pre">polgcd(&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">1&gt;,</span> <span class="pre">&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">2&gt;,</span> <span class="pre">...)</span></code></h3>
725 <blockquote>
726 <div><p>Evaluates to the greatest common polynomial divisor of all the
727 polynomial inputs. The output is a <strong>primitive</strong> (in particular,
728 with integer coefficients) polynomial. It is zero if and only if all
729 inputs vanish.</p>
730 <p>Attention, there must be either at least two polynomial variables, or
731 alternatively, only one argument which then must be a bracketed list
732 or some expression or variable evaluating to such a “nutple” whose
733 items are polynomials (see the documentation of the scalar <code class="docutils literal notranslate"><span class="pre">gcd()</span></code>
734 in <a class="reference external" href="https://www.ctan.org/pkg/xintexpr">xintexpr</a>).</p>
735 <blockquote>
736 <div><p>The two variable case could (and was, during development) have been
737 defined at user level like this:</p>
738 <div class="highlight-latex notranslate"><div class="highlight"><pre><span></span><span class="k">\xintdeffunc</span> polgcd<span class="nb">_</span>(P,Q):=
739 (deg(Q))??<span class="nb">{</span>P<span class="nb">}{</span>1<span class="nb">}{</span>polgcd<span class="nb">_</span>(Q,primpart(last(prem(P,Q))))<span class="nb">}</span>;
740 <span class="k">\xintdeffunc</span> polgcd(P,Q):=polgcd<span class="nb">_</span>(primpart(P),primpart(Q));<span class="c">%</span>
741 </pre></div>
742 </div>
743 <p>This is basically what is done internally for two polynomials, up
744 to some internal optimizations.</p>
745 </div></blockquote>
746 <p><strong>UNSTABLE</strong></p>
747 <p>I hesitate between returning a <em>primitive</em> or a <em>monic</em> polynomial.
748 Maple returns a primitive polynomial if all inputs <a class="footnote-reference brackets" href="#id4" id="id3" role="doc-noteref"><span class="fn-bracket">[</span>2<span class="fn-bracket">]</span></a> have integer
749 coefficients, else it returns a monic polynomial, but this is
750 complicated technically for us to add such a check and would add
751 serious overhead.</p>
752 <p>Internally, computations are done using primitive
753 integer-coefficients polynomials (as can be seen in the function
754 template above). So I decided finally to output a primitive
755 polynomial, as one can always apply <code class="docutils literal notranslate"><span class="pre">monicpart()</span></code> to it.</p>
756 <p>Attention that this is at odds with behaviour of the legacy
757 <a class="reference internal" href="#polgcd">\PolGCD</a> (non expandable) macro.</p>
758 <aside class="footnote brackets" id="id4" role="note">
759 <span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#id3">2</a><span class="fn-bracket">]</span></span>
760 <p>actually, only two polynomial arguments are allowed by Maple’s
761 <code class="docutils literal notranslate"><span class="pre">gcd()</span></code> as far as I know.</p>
762 </aside>
763 </div></blockquote>
764 </section>
765 <section id="resultant-pol-expr-1-pol-expr-2">
766 <h3><code class="docutils literal notranslate"><span class="pre">resultant(&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">1&gt;,</span> <span class="pre">&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">2&gt;)</span></code></h3>
767 <blockquote>
768 <div><p>The resultant.</p>
769 <blockquote>
770 <div><p><strong>NOT YET IMPLEMENTED</strong></p>
771 </div></blockquote>
772 </div></blockquote>
773 </section>
774 <section id="disc-pol-expr">
775 <h3><code class="docutils literal notranslate"><span class="pre">disc(&lt;pol.</span> <span class="pre">expr.&gt;)</span></code></h3>
776 <blockquote>
777 <div><p>The discriminant.</p>
778 <blockquote>
779 <div><p><strong>NOT YET IMPLEMENTED</strong></p>
780 </div></blockquote>
781 </div></blockquote>
782 </section>
783 <section id="polpowmod-pol-expr-1-num-expr-pol-expr-2">
784 <h3><code class="docutils literal notranslate"><span class="pre">polpowmod(&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">1&gt;,</span> <span class="pre">&lt;num.</span> <span class="pre">expr.&gt;,</span> <span class="pre">&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">2&gt;)</span></code></h3>
785 <blockquote>
786 <div><p>Modular exponentiation: <code class="docutils literal notranslate"><span class="pre">mod(pol1^N,</span> <span class="pre">pol2)</span></code> in a more efficient
787 manner than first computing <code class="docutils literal notranslate"><span class="pre">pol1^N</span></code> then reducing modulo <code class="docutils literal notranslate"><span class="pre">pol2</span></code>.</p>
788 <p>Attention that this is using the <code class="docutils literal notranslate"><span class="pre">mod()</span></code> operation, whose current
789 experimental status is as follows:</p>
790 <ul class="simple">
791 <li><p>if <code class="docutils literal notranslate"><span class="pre">deg(pol2)&gt;0</span></code>, the euclidean remainder operation,</p></li>
792 <li><p>if <code class="docutils literal notranslate"><span class="pre">pol2</span></code> is a scalar, coefficient-wise reduction modulo <code class="docutils literal notranslate"><span class="pre">pol2</span></code>.</p></li>
793 </ul>
794 <p><strong>UNSTABLE</strong></p>
795 <blockquote>
796 <div><p>This is currently implemented at high level via <code class="docutils literal notranslate"><span class="pre">\xintdeffunc</span></code> and
797 recursive definitions, which were copied over from a scalar example
798 in the <a class="reference external" href="https://www.ctan.org/pkg/xintexpr">xintexpr</a> manual:</p>
799 <div class="highlight-latex notranslate"><div class="highlight"><pre><span></span><span class="k">\xintdeffunc</span> polpowmod<span class="nb">_</span>(P, m, Q) :=
800 isone(m)?
801 <span class="c">% m=1: return P modulo Q</span>
802 <span class="nb">{</span> mod(P,Q) <span class="nb">}</span>
803 <span class="c">% m &gt; 1: test if odd or even and do recursive call</span>
804 <span class="nb">{</span> odd(m)? <span class="nb">{</span> mod(P*sqr(polpowmod<span class="nb">_</span>(P, m//2, Q)), Q) <span class="nb">}</span>
805 <span class="nb">{</span> mod( sqr(polpowmod<span class="nb">_</span>(P, m//2, Q)), Q) <span class="nb">}</span>
806 <span class="nb">}</span>
807 ;<span class="c">%</span>
808 <span class="k">\xintdeffunc</span> polpowmod(P, m, Q) := (m)?<span class="nb">{</span>polpowmod<span class="nb">_</span>(P, m, Q)<span class="nb">}{</span>1<span class="nb">}</span>;<span class="c">%</span>
809 </pre></div>
810 </div>
811 <p>Negative exponents are not currently implemented.</p>
812 <p>For example:</p>
813 <div class="highlight-latex notranslate"><div class="highlight"><pre><span></span><span class="k">\xinteval</span><span class="nb">{</span>subs(polpowmod(1+x,100,x<span class="nb">^</span>7),x=pol([0,1]))<span class="nb">}</span>
814 <span class="k">\xinteval</span><span class="nb">{</span>subs(polpowmod(1+x,20,10), x=pol([0,1]))<span class="nb">}</span>
815 </pre></div>
816 </div>
817 <p>produce respectively:</p>
818 <div class="highlight-latex notranslate"><div class="highlight"><pre><span></span>pol([1, 100, 4950, 161700, 3921225, 75287520, 1192052400])
819 pol([1, 0, 0, 0, 5, 4, 0, 0, 0, 0, 6, 0, 0, 0, 0, 4, 5, 0, 0, 0, 1])
820 </pre></div>
821 </div>
822 </div></blockquote>
823 </div></blockquote>
824 </section>
825 <section id="rdcoeffs-pol-expr">
826 <span id="rdcoeffs"></span><h3><code class="docutils literal notranslate"><span class="pre">rdcoeffs(&lt;pol.</span> <span class="pre">expr.&gt;)</span></code></h3>
827 <blockquote>
828 <div><p>This operates on the internal representation of the coefficients,
829 reducing them to lowest terms.</p>
830 <blockquote>
831 <div><p><strong>name HIGHLY undecided</strong></p>
832 </div></blockquote>
833 </div></blockquote>
834 </section>
835 <section id="rdzcoeffs-pol-expr">
836 <h3><code class="docutils literal notranslate"><span class="pre">rdzcoeffs(&lt;pol.</span> <span class="pre">expr.&gt;)</span></code></h3>
837 <blockquote>
838 <div><p>This operates on the internal representation of the coefficients,
839 reducing them to lowest terms then extracting from numerator
840 or denominator the maximal power of ten to store as a decimal
841 exponent.</p>
842 <p>This is sometimes favourable to more efficient polynomial algebra
843 computations.</p>
844 <blockquote>
845 <div><p><strong>name HIGHLY undecided</strong></p>
846 </div></blockquote>
847 </div></blockquote>
848 </section>
849 <section id="diff1-pol-expr">
850 <h3><code class="docutils literal notranslate"><span class="pre">diff1(&lt;pol.</span> <span class="pre">expr.&gt;)</span></code></h3>
851 <blockquote>
852 <div><p>The first derivative.</p>
853 <blockquote>
854 <div><p><strong>name UNSTABLE</strong></p>
855 <p>This name may be used in future to be the partial derivative with
856 respect to a first variable.</p>
857 </div></blockquote>
858 </div></blockquote>
859 </section>
860 <section id="diff2-pol-expr">
861 <h3><code class="docutils literal notranslate"><span class="pre">diff2(&lt;pol.</span> <span class="pre">expr.&gt;)</span></code></h3>
862 <blockquote>
863 <div><p>The second derivative.</p>
864 <blockquote>
865 <div><p><strong>name UNSTABLE</strong></p>
866 <p>This name may be used in future to be the partial derivative with
867 respect to a second variable.</p>
868 </div></blockquote>
869 </div></blockquote>
870 </section>
871 <section id="diffn-pol-expr-p-num-expr-n">
872 <h3><code class="docutils literal notranslate"><span class="pre">diffn(&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">P&gt;,</span> <span class="pre">&lt;num.</span> <span class="pre">expr.</span> <span class="pre">n&gt;)</span></code></h3>
873 <blockquote>
874 <div><p>The <code class="docutils literal notranslate"><span class="pre">n</span></code>th derivative of <code class="docutils literal notranslate"><span class="pre">P</span></code>. For <code class="docutils literal notranslate"><span class="pre">n&lt;0</span></code> computes iterated primitives
875 vanishing at the origin.</p>
876 <p>The coefficients are not reduced to lowest terms.</p>
877 <blockquote>
878 <div><p><strong>name and syntax UNSTABLE</strong></p>
879 <p>I am also considering reversing the order of the arguments.</p>
880 </div></blockquote>
881 </div></blockquote>
882 </section>
883 <section id="antider-pol-expr-p">
884 <h3><code class="docutils literal notranslate"><span class="pre">antider(&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">P&gt;)</span></code></h3>
885 <blockquote>
886 <div><p>The primitive of <code class="docutils literal notranslate"><span class="pre">P</span></code> with no constant term. Same as <code class="docutils literal notranslate"><span class="pre">diffn(P,-1)</span></code>.</p>
887 </div></blockquote>
888 </section>
889 <section id="intfrom-pol-expr-p-pol-expr-c">
890 <h3><code class="docutils literal notranslate"><span class="pre">intfrom(&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">P&gt;,</span> <span class="pre">&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">c&gt;)</span></code></h3>
891 <blockquote>
892 <div><p>The primitive of <code class="docutils literal notranslate"><span class="pre">P</span></code> vanishing at <code class="docutils literal notranslate"><span class="pre">c</span></code>, i.e. <code class="docutils literal notranslate"><span class="pre">\int_c^x</span> <span class="pre">P(t)dt</span></code>.</p>
893 <p>Also <code class="docutils literal notranslate"><span class="pre">c</span></code> can be a polynomial… so if <code class="docutils literal notranslate"><span class="pre">c</span></code> is monomial <code class="docutils literal notranslate"><span class="pre">x</span></code>
894 this will give zero!</p>
895 <blockquote>
896 <div><p><strong>UNSTABLE</strong></p>
897 <p>Allowing general polynomial variable for <code class="docutils literal notranslate"><span class="pre">c</span></code> adds a bit of
898 overhead to the case of a pure scalar. So I am hesitating
899 maintaining this feature whose interest appears dubious.</p>
900 </div></blockquote>
901 <div class="admonition attention">
902 <p class="admonition-title">Attention</p>
903 <p>As the two arguments are both allowed to be polynomials, if by
904 inadvertance one exchanges the two, there is no error but the
905 meaning of <code class="docutils literal notranslate"><span class="pre">intfrom(c,P)</span></code> is completely otherwise, as it
906 produces <code class="docutils literal notranslate"><span class="pre">c*(x</span> <span class="pre">-</span> <span class="pre">P)</span></code> if <code class="docutils literal notranslate"><span class="pre">c</span></code> is a scalar:</p>
907 <div class="highlight-latex notranslate"><div class="highlight"><pre><span></span>&gt;&gt;&gt; <span class="nb">&amp;</span>pol
908 pol mode (i.e. function definitions use <span class="k">\poldef</span>)
909 &gt;&gt;&gt; P(x):=1+x<span class="nb">^</span>2;
910 P = x<span class="nb">^</span>2+1
911 --&gt; <span class="nb">&amp;</span>GenFloat(P) lets P become usable as function in fp mode
912 --&gt; <span class="nb">&amp;</span>ROOTS(P) (resp. <span class="nb">&amp;</span>ROOTS(P,N)) finds all rational roots exactly and
913 all irrational roots with at least 10 (resp. N) fractional digits
914 &gt;&gt;&gt; intfrom(P,1);
915 @<span class="nb">_</span>1 pol([-4/3, 1, 0, 1/3])
916 &gt;&gt;&gt; intfrom(1,P);
917 @<span class="nb">_</span>2 pol([-1, 1, -1])
918 &gt;&gt;&gt; <span class="nb">&amp;</span>bye
919 </pre></div>
920 </div>
921 </div>
922 </div></blockquote>
923 </section>
924 <section id="integral-pol-expr-p-pol-expr-a-pol-expr-b">
925 <h3><code class="docutils literal notranslate"><span class="pre">integral(&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">P&gt;,</span> <span class="pre">[&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">a&gt;,</span> <span class="pre">&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">b&gt;])</span></code></h3>
926 <blockquote>
927 <div><p><code class="docutils literal notranslate"><span class="pre">\int_a^b</span> <span class="pre">P(t)dt</span></code>.</p>
928 <div class="admonition warning">
929 <p class="admonition-title">Warning</p>
930 <p>The brackets here are not denoting an optional argument but a
931 <em>mandatory</em> nutple argument <code class="docutils literal notranslate"><span class="pre">[a,</span> <span class="pre">b]</span></code> with <em>two items</em>. No real
932 recoverable-from error check is done on the input syntax. The
933 input can be an <a class="reference external" href="https://www.ctan.org/pkg/xintexpr">xintexpr</a> variable which happens to be a nutple
934 with two items, or any expression which evaluates to such a
935 nutple.</p>
936 </div>
937 <p><code class="docutils literal notranslate"><span class="pre">a</span></code> and <code class="docutils literal notranslate"><span class="pre">b</span></code> are not restricted to be scalars, they are allowed to
938 be themselves polynomial variables or even polynomial expressions.</p>
939 <blockquote>
940 <div><p>To compute <code class="docutils literal notranslate"><span class="pre">\int_{x-1}^x</span> <span class="pre">P(t)dt</span></code> it is more efficient to use
941 <code class="docutils literal notranslate"><span class="pre">intfrom(x-1)</span></code>.</p>
942 <p>Similary to compute <code class="docutils literal notranslate"><span class="pre">\int_x^{x+1}</span> <span class="pre">P(t)dt</span></code>, use <code class="docutils literal notranslate"><span class="pre">-intfrom(x+1)</span></code>.</p>
943 <p><strong>UNSTABLE</strong></p>
944 <p>Am I right to allow general polynomials <code class="docutils literal notranslate"><span class="pre">a</span></code> and <code class="docutils literal notranslate"><span class="pre">b</span></code> hence add
945 overhead to the pure scalar case ?</p>
946 </div></blockquote>
947 </div></blockquote>
948 </section>
949 </section>
950 <section id="non-expandable-macros">
951 <h2>Non-expandable macros</h2>
952 <div class="admonition note">
953 <p class="admonition-title">Note</p>
954 <p>At <code class="docutils literal notranslate"><span class="pre">0.8</span></code> <code class="docutils literal notranslate"><span class="pre">polexpr</span></code> is usable with Plain TeX and not only with
955 LaTeX. Some examples given in this section may be using LaTeX syntax
956 such as <code class="docutils literal notranslate"><span class="pre">\renewcommand</span></code>.</p>
957 </div>
958 <section id="poldef-polname-letter-expression-using-the-letter-as-indeterminate">
959 <span id="poldef"></span><h3><code class="docutils literal notranslate"><span class="pre">\poldef</span> <span class="pre">polname(letter):=</span> <span class="pre">expression</span> <span class="pre">using</span> <span class="pre">the</span> <span class="pre">letter</span> <span class="pre">as</span> <span class="pre">indeterminate;</span></code></h3>
960 <blockquote>
961 <div><p>This evaluates the <em>polynomial expression</em> and stores the
962 coefficients in a private structure accessible later via other
963 package macros, used with argument <code class="docutils literal notranslate"><span class="pre">polname</span></code>. Of course the
964 <em>expression</em> can make use of previously defined polynomials.</p>
965 <p>Polynomial names must start with a letter and are constituted of
966 letters, digits, underscores, the <code class="docutils literal notranslate"><span class="pre">&#64;</span></code> (see <a class="reference internal" href="#technicalities">Technicalities</a>) and
967 the right tick <code class="docutils literal notranslate"><span class="pre">'</span></code>.</p>
968 <p>The whole <a class="reference external" href="https://www.ctan.org/pkg/xintexpr">xintexpr</a> syntax is authorized, as long as the final
969 result is of polynomial type:</p>
970 <div class="highlight-latex notranslate"><div class="highlight"><pre><span></span><span class="k">\poldef</span> polname(z) := add((-1)<span class="nb">^</span>i z<span class="nb">^</span>(2i+1)/(2i+1)!, i = 0..10);
971 </pre></div>
972 </div>
973 <p>With fractional coefficients, beware the <a class="reference internal" href="#warningtacit">tacit multiplication issue</a>.</p>
974 <p>Furthermore:</p>
975 <ul class="simple">
976 <li><p>a variable <code class="docutils literal notranslate"><span class="pre">polname</span></code> is defined which can be used in <code class="docutils literal notranslate"><span class="pre">\poldef</span></code>
977 as well as in <code class="docutils literal notranslate"><span class="pre">\xinteval</span></code> for algebraic computations or as
978 argument to polynomial aware functions,</p></li>
979 <li><p>a function <code class="docutils literal notranslate"><span class="pre">polname()</span></code> is defined which can be used in <code class="docutils literal notranslate"><span class="pre">\poldef</span></code>
980 as well as in <code class="docutils literal notranslate"><span class="pre">\xinteval</span></code>. It accepts there as argument scalars
981 and also other polynomials (via their names, thanks to previous
982 item).</p></li>
983 </ul>
984 <p>Any function defined via <code class="docutils literal notranslate"><span class="pre">\xintdeffunc</span></code> and only algebraic
985 operations, as well as ople indexing or slicing operations, should
986 work fine in <code class="docutils literal notranslate"><span class="pre">\xintexpr/\xinteval</span></code> with such polynomial names as
987 argument.</p>
988 <p>In the case of a constant polynomial, the <a class="reference external" href="https://www.ctan.org/pkg/xintexpr">xintexpr</a> <em>variable</em> (not
989 the internal data structure on which the package macros operate)
990 associated to it is indistinguishable from a scalar, it is actually
991 a scalar and has lost all traces from its origins as a polynomial
992 (so for example can be used as argument to the <code class="docutils literal notranslate"><span class="pre">cos()</span></code> function).
993 The <em>function</em> on the other hand remains a one-argument function,
994 which simply has a constant value.</p>
995 <div class="admonition attention">
996 <p class="admonition-title">Attention</p>
997 <p>The function <code class="docutils literal notranslate"><span class="pre">polname()</span></code> is defined <strong>only</strong> for
998 <code class="docutils literal notranslate"><span class="pre">\xintexpr/\xinteval</span></code>
999 context. It will be unknown to <code class="docutils literal notranslate"><span class="pre">\xintfloateval</span></code>.</p>
1000 <p>Worse, a
1001 previously existing floating point function of the same name will
1002 be made undefined again, to avoid hard to debug mismatches between
1003 exact and floating point polynomials. This also applies when the
1004 polynomial is produced not via <code class="docutils literal notranslate"><span class="pre">\poldef</span></code> or <code class="docutils literal notranslate"><span class="pre">\PolDef</span></code> but
1005 as result of usage of the other package macros.</p>
1006 <p>See <a class="reference internal" href="#polgenfloatvariant"><span class="std std-ref">\PolGenFloatVariant{&lt;polname&gt;}</span></a> to generate a <strong>function</strong>
1007 usable in <code class="docutils literal notranslate"><span class="pre">\xintfloateval</span></code>.</p>
1008 </div>
1009 <div class="admonition attention">
1010 <p class="admonition-title">Attention</p>
1011 <p>Using the <strong>variable</strong> <code class="docutils literal notranslate"><span class="pre">mypol</span></code> inside <code class="docutils literal notranslate"><span class="pre">\xintfloateval</span></code> will
1012 generate low-level errors because the infix operators there are
1013 not polynomial-aware, and the polynomial specific functions such
1014 as <code class="docutils literal notranslate"><span class="pre">deg()</span></code> are only defined for usage inside <code class="docutils literal notranslate"><span class="pre">\xintexpr</span></code>.</p>
1015 <p>In short, currently polynomials defined via <code class="docutils literal notranslate"><span class="pre">polexpr</span></code> can
1016 be used in floating point context only for numerical evaluations,
1017 via <strong>functions</strong> obtained from <a class="reference internal" href="#polgenfloatvariant"><span class="std std-ref">\PolGenFloatVariant{&lt;polname&gt;}</span></a>
1018 usage.</p>
1019 <p>Changes to the original polynomial via package macros are not
1020 automatically mapped to the numerical floating point evaluator
1021 which must be manually updated as necessary when the original
1022 rational coefficient polynomial is modified.</p>
1023 </div>
1024 <p>The original expression is lost after parsing, and in particular the
1025 package provides no way to typeset it (of course the package
1026 provides macros to typeset the computed polynomial). Typesetting
1027 the original expression has to be done manually, if needed.</p>
1028 </div></blockquote>
1029 </section>
1030 <section id="poldef-letter-polname-expr-using-the-letter-as-indeterminate">
1031 <span id="id5"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolDef[&lt;letter&gt;]{&lt;polname&gt;}{&lt;expr.</span> <span class="pre">using</span> <span class="pre">the</span> <span class="pre">letter</span> <span class="pre">as</span> <span class="pre">indeterminate&gt;}</span></code></h3>
1032 <blockquote>
1033 <div><p>Does the same as <a class="reference internal" href="#poldef">\poldef</a> in an undelimited macro
1034 format, the main interest is to avoid potential problems with the
1035 catcode of the semi-colon in presence of some packages. In absence
1036 of a <code class="docutils literal notranslate"><span class="pre">[&lt;letter&gt;]</span></code> optional argument, the variable is assumed to be
1037 <code class="docutils literal notranslate"><span class="pre">x</span></code>.</p>
1038 </div></blockquote>
1039 </section>
1040 <section id="polgenfloatvariant">
1041 <span id="id6"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolGenFloatVariant{}</span></code></h3>
1042 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolGenFloatVariant{&lt;polname&gt;}</span></code></p>
1043 <blockquote>
1044 <div><p>Makes the polynomial also usable in the
1045 <code class="docutils literal notranslate"><span class="pre">\xintfloatexpr/\xintfloateval</span></code> parser. It will therein evaluates
1046 via an Horner scheme using polynomial coefficients already
1047 pre-rounded to the float precision.</p>
1048 <p>See also <a class="reference internal" href="#poltofloatexpr"><span class="std std-ref">\PolToFloatExpr{&lt;pol. expr.&gt;}</span></a>.</p>
1049 <div class="admonition attention">
1050 <p class="admonition-title">Attention</p>
1051 <p>Any operation, for example generating the derivative polynomial,
1052 or dividing two polynomials or using the <code class="docutils literal notranslate"><span class="pre">\PolLet</span></code>, must be
1053 followed by explicit usage of <code class="docutils literal notranslate"><span class="pre">\PolGenFloatVariant{&lt;polname&gt;}</span></code> if
1054 the new polynomial is to be used in <code class="docutils literal notranslate"><span class="pre">\xintfloateval</span></code>.</p>
1055 </div>
1056 </div></blockquote>
1057 </section>
1058 <section id="poltypeset">
1059 <span id="id7"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolTypeset[]{}</span></code></h3>
1060 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolTypeset[&lt;letter&gt;]{&lt;pol.</span> <span class="pre">expr.&gt;}</span></code></p>
1061 <blockquote>
1062 <div><p>Typesets in descending powers, switching to math mode if in text
1063 mode, after evaluating the polynomial expression:</p>
1064 <div class="highlight-latex notranslate"><div class="highlight"><pre><span></span><span class="k">\PolTypeset</span><span class="nb">{</span>mul(x-i,i=1..5)<span class="nb">}</span><span class="c">% possible since polexpr 0.8</span>
1065 </pre></div>
1066 </div>
1067 <p>The letter used in the input is by default assumed to be <code class="docutils literal notranslate"><span class="pre">x</span></code>,
1068 but can be modified by a redefinition of <a class="reference internal" href="#id68">\PolToExprInVar</a>.</p>
1069 <p>The letter used in the output is also by default <code class="docutils literal notranslate"><span class="pre">x</span></code>. This one
1070 can be changed on-the-fly via the optional <code class="docutils literal notranslate"><span class="pre">&lt;letter&gt;</span></code>:</p>
1071 <div class="highlight-latex notranslate"><div class="highlight"><pre><span></span><span class="k">\PolTypeset</span><span class="na">[z]</span><span class="nb">{</span>polname or polynomial expression<span class="nb">}</span>
1072 </pre></div>
1073 </div>
1074 <p>By default zero coefficients are skipped (use <code class="docutils literal notranslate"><span class="pre">\poltypesetalltrue</span></code>
1075 to get all of them in output).</p>
1076 <p>The following macros (whose meanings will be found in the package code)
1077 can be re-defined for customization. Their default definitions are
1078 expandable, but this is not a requirement.</p>
1079 </div></blockquote>
1080 <section id="poltypesetcmd">
1081 <span id="id8"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolTypesetCmd{}</span></code></h4>
1082 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolTypesetCmd{&lt;raw_coeff&gt;}</span></code></p>
1083 <blockquote>
1084 <div><p>Its package definition checks if the coefficient is <code class="docutils literal notranslate"><span class="pre">1</span></code> or <code class="docutils literal notranslate"><span class="pre">-1</span></code>
1085 and then skips printing the <code class="docutils literal notranslate"><span class="pre">1</span></code>, except for the coefficient of
1086 degree zero. Also it sets the conditional deciding behaviour of
1087 <a class="reference internal" href="#polifcoeffisplusorminusone"><span class="std std-ref">\PolIfCoeffIsPlusOrMinusOne{T}{F}</span></a>.</p>
1088 <p>The actual printing of the coefficients, when not equal to plus or
1089 minus one, is handled by <a class="reference internal" href="#poltypesetone"><span class="std std-ref">\PolTypesetOne{&lt;raw_coeff&gt;}</span></a>.</p>
1090 </div></blockquote>
1091 <section id="polifcoeffisplusorminusone">
1092 <span id="id9"></span><h5><code class="docutils literal notranslate"><span class="pre">\PolIfCoeffIsPlusOrMinusOne{}{}</span></code></h5>
1093 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolIfCoeffIsPlusOrMinusOne{T}{F}</span></code></p>
1094 <blockquote>
1095 <div><p>This macro is a priori undefined.</p>
1096 <p>It is defined via the default <a class="reference internal" href="#poltypesetcmd"><span class="std std-ref">\PolTypesetCmd{&lt;raw_coeff&gt;}</span></a> to be
1097 used if needed in the execution of <a class="reference internal" href="#id11">\PolTypesetMonomialCmd</a>,
1098 e.g. to insert a <code class="docutils literal notranslate"><span class="pre">\cdot</span></code> in front of <code class="docutils literal notranslate"><span class="pre">\PolVar^{\PolIndex}</span></code> if
1099 the coefficient is not plus or minus one.</p>
1100 <p>The macro will execute <code class="docutils literal notranslate"><span class="pre">T</span></code> if the coefficient has been found to be
1101 plus or minus one, and <code class="docutils literal notranslate"><span class="pre">F</span></code> if not. It chooses expandably between
1102 <code class="docutils literal notranslate"><span class="pre">T</span></code> and <code class="docutils literal notranslate"><span class="pre">F</span></code>.</p>
1103 </div></blockquote>
1104 </section>
1105 </section>
1106 <section id="poltypesetone">
1107 <span id="id10"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolTypesetOne{}</span></code></h4>
1108 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolTypesetOne{&lt;raw_coeff&gt;}</span></code></p>
1109 <blockquote>
1110 <div><p>Defaults to <code class="docutils literal notranslate"><span class="pre">\xintTeXsignedFrac</span></code> (LaTeX) or <code class="docutils literal notranslate"><span class="pre">\xintTeXsignedOver</span></code>
1111 (else). But these <a class="reference external" href="https://www.ctan.org/pkg/xint">xintfrac</a> old legacy macros are a bit
1112 annoying as they insist in exhibiting a power of ten rather than
1113 using simpler decimal notation.</p>
1114 <p>As alternative, one can do definitions such as:</p>
1115 <div class="highlight-latex notranslate"><div class="highlight"><pre><span></span><span class="k">\def\PolTypesetOne</span>#1<span class="nb">{</span><span class="k">\xintDecToString</span><span class="nb">{</span><span class="k">\xintREZ</span><span class="nb">{</span>#1<span class="nb">}}}</span>
1116 <span class="c">% or with LaTeX+siunitx for example</span>
1117 <span class="k">\renewcommand\PolTypesetOne</span><span class="na">[1]</span><span class="nb">{</span><span class="k">\num</span><span class="nb">{</span><span class="k">\xintPFloat</span><span class="na">[5]</span><span class="nb">{</span>#1<span class="nb">}}}</span>
1118 <span class="c">% (as \num of siunitx understands floating point notation)</span>
1119 <span class="k">\renewcommand\PolTypesetOne</span><span class="na">[1]</span><span class="nb">{</span><span class="k">\num</span><span class="nb">{</span><span class="k">\xintRound</span><span class="nb">{</span>4<span class="nb">}{</span>#1<span class="nb">}}}</span>
1120 </pre></div>
1121 </div>
1122 </div></blockquote>
1123 </section>
1124 <section id="poltypesetmonomialcmd">
1125 <span id="id11"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolTypesetMonomialCmd</span></code></h4>
1126 <blockquote>
1127 <div><p>This decides how a monomial (in variable <code class="docutils literal notranslate"><span class="pre">\PolVar</span></code> and with
1128 exponent <code class="docutils literal notranslate"><span class="pre">\PolIndex</span></code>) is to be printed. The default does nothing
1129 for the constant term, <code class="docutils literal notranslate"><span class="pre">\PolVar</span></code> for the first degree and
1130 <code class="docutils literal notranslate"><span class="pre">\PolVar^{\PolIndex}</span></code> for higher degrees monomials. Beware that
1131 <code class="docutils literal notranslate"><span class="pre">\PolIndex</span></code> expands to digit tokens and needs termination in
1132 <code class="docutils literal notranslate"><span class="pre">\ifnum</span></code> tests.</p>
1133 </div></blockquote>
1134 </section>
1135 <section id="poltypesetcmdprefix">
1136 <span id="id12"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolTypesetCmdPrefix{}</span></code></h4>
1137 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolTypesetCmdPrefix{&lt;raw_coeff&gt;}</span></code></p>
1138 <blockquote>
1139 <div><p>Expands to a <code class="docutils literal notranslate"><span class="pre">+</span></code> if the <code class="docutils literal notranslate"><span class="pre">raw_coeff</span></code> is zero or positive, and to
1140 nothing if <code class="docutils literal notranslate"><span class="pre">raw_coeff</span></code> is negative, as in latter case the
1141 <code class="docutils literal notranslate"><span class="pre">\xintTeXsignedFrac</span></code> (or <code class="docutils literal notranslate"><span class="pre">\xintTeXsignedOver</span></code>) used by
1142 <a class="reference internal" href="#poltypesetcmd"><span class="std std-ref">\PolTypesetCmd{&lt;raw_coeff&gt;}</span></a> will put the <code class="docutils literal notranslate"><span class="pre">-</span></code> sign in front of
1143 the fraction (if it is a fraction) and this will thus serve as
1144 separator in the typeset formula. Not used for the first term.</p>
1145 </div></blockquote>
1146 </section>
1147 </section>
1148 <section id="id13">
1149 <span id="id14"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolTypeset*[]{}</span></code></h3>
1150 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolTypeset*[&lt;letter&gt;]{&lt;pol.</span> <span class="pre">expr.&gt;}</span></code></p>
1151 <blockquote>
1152 <div><p>Typesets in ascending powers. The <code class="docutils literal notranslate"><span class="pre">&lt;letter&gt;</span></code> optional argument
1153 (after the <code class="docutils literal notranslate"><span class="pre">*</span></code>) declares the letter to use in the <em>output</em>.
1154 As for <a class="reference external" href="PolTypeset">\PolTypeset</a>, it defaults to <code class="docutils literal notranslate"><span class="pre">x</span></code>.</p>
1155 <p>To modify the expected <code class="docutils literal notranslate"><span class="pre">x</span></code> in the <em>input</em>, see <a class="reference internal" href="#id68">\PolToExprInVar</a>.</p>
1156 <p>Extended at <code class="docutils literal notranslate"><span class="pre">0.8</span></code> to accept general expressions and not only
1157 polynomial names.</p>
1158 </div></blockquote>
1159 </section>
1160 <section id="pollet">
1161 <span id="id16"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolLet{}={}</span></code></h3>
1162 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolLet{&lt;polname_2&gt;}={&lt;polname_1&gt;}</span></code></p>
1163 <blockquote>
1164 <div><p>Makes a copy of the already defined polynomial <code class="docutils literal notranslate"><span class="pre">polname_1</span></code> to a
1165 new one <code class="docutils literal notranslate"><span class="pre">polname_2</span></code>. This has the same effect as
1166 <code class="docutils literal notranslate"><span class="pre">\PolDef{&lt;polname_2&gt;}{&lt;polname_1&gt;(x)}</span></code> or (better)
1167 <code class="docutils literal notranslate"><span class="pre">\PolDef{&lt;polname_2&gt;}{&lt;polname_1&gt;}</span></code> but with less overhead. The
1168 <code class="docutils literal notranslate"><span class="pre">=</span></code> is optional.</p>
1169 </div></blockquote>
1170 </section>
1171 <section id="polgloballet">
1172 <span id="id17"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolGlobalLet{}={}</span></code></h3>
1173 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolGlobalLet{&lt;polname_2&gt;}={&lt;polname_1&gt;}</span></code></p>
1174 <blockquote>
1175 <div><p>Acts globally.</p>
1176 </div></blockquote>
1177 </section>
1178 <section id="polassign-toarray">
1179 <span id="polassign"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolAssign{}\toarray{}</span></code></h3>
1180 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolAssign{&lt;polname&gt;}\toarray{&lt;\macro&gt;}</span></code></p>
1181 <blockquote>
1182 <div><p>Defines a one-argument expandable macro <code class="docutils literal notranslate"><span class="pre">\macro{#1}</span></code> which expands
1183 to the (raw) #1th polynomial coefficient.</p>
1184 <ul class="simple">
1185 <li><p>Attention, coefficients here are indexed starting at 1. This is
1186 an unfortunate legacy situation related to the original indexing
1187 convention in <a class="reference external" href="https://www.ctan.org/pkg/xint">xinttools</a> arrays.</p></li>
1188 <li><p>With #1=-1, -2, …, <code class="docutils literal notranslate"><span class="pre">\macro{#1}</span></code> returns leading coefficients.</p></li>
1189 <li><p>With #1=0, returns the number of coefficients, i.e. <code class="docutils literal notranslate"><span class="pre">1</span> <span class="pre">+</span> <span class="pre">deg</span> <span class="pre">f</span></code>
1190 for non-zero polynomials.</p></li>
1191 <li><p>Out-of-range #1’s return <code class="docutils literal notranslate"><span class="pre">0/1[0]</span></code>.</p></li>
1192 </ul>
1193 <p>See also <a class="reference internal" href="#polnthcoeff"><span class="std std-ref">\PolNthCoeff{&lt;polname&gt;}{&lt;index&gt;}</span></a>.</p>
1194 </div></blockquote>
1195 </section>
1196 <section id="polget-fromarray">
1197 <span id="polget"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolGet{}\fromarray{}</span></code></h3>
1198 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolGet{&lt;polname&gt;}\fromarray{&lt;\macro&gt;}</span></code></p>
1199 <blockquote>
1200 <div><p>Does the converse operation to
1201 <code class="docutils literal notranslate"><span class="pre">\PolAssign{&lt;polname&gt;}\toarray\macro</span></code>. Each individual
1202 <code class="docutils literal notranslate"><span class="pre">\macro{&lt;value&gt;}</span></code> gets expanded in an <code class="docutils literal notranslate"><span class="pre">\edef</span></code> and then normalized
1203 via <a class="reference external" href="https://www.ctan.org/pkg/xint">xintfrac</a>‘s macro <code class="docutils literal notranslate"><span class="pre">\xintRaw</span></code>.</p>
1204 <p>The leading zeros are removed from the polynomial.</p>
1205 <p>(contrived) Example:</p>
1206 <div class="highlight-latex notranslate"><div class="highlight"><pre><span></span><span class="k">\xintAssignArray</span><span class="nb">{</span>1<span class="nb">}{</span>-2<span class="nb">}{</span>5<span class="nb">}{</span>-3<span class="nb">}</span><span class="k">\to\foo</span>
1207 <span class="k">\PolGet</span><span class="nb">{</span>f<span class="nb">}</span><span class="k">\fromarray\foo</span>
1208 </pre></div>
1209 </div>
1210 <p>This will define <code class="docutils literal notranslate"><span class="pre">f</span></code> as would have <code class="docutils literal notranslate"><span class="pre">\poldef</span> <span class="pre">f(x):=1-2x+5x^2-3x^3;</span></code>.</p>
1211 </div></blockquote>
1212 </section>
1213 <section id="polfromcsv">
1214 <span id="id18"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolFromCSV{}{}</span></code></h3>
1215 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolFromCSV{&lt;polname&gt;}{&lt;csv&gt;}</span></code></p>
1216 <blockquote>
1217 <div><p>Defines a polynomial directly from the comma separated list of values
1218 (or a macro expanding to such a list) of its coefficients, the <em>first
1219 item</em> gives the constant term, the <em>last item</em> gives the leading
1220 coefficient, except if zero, then it is dropped (iteratively). List
1221 items are each expanded in an <code class="docutils literal notranslate"><span class="pre">\edef</span></code> and then put into normalized
1222 form via <a class="reference external" href="https://www.ctan.org/pkg/xint">xintfrac</a>‘s macro <code class="docutils literal notranslate"><span class="pre">\xintRaw</span></code>.</p>
1223 <p>As leading zero coefficients are removed:</p>
1224 <div class="highlight-latex notranslate"><div class="highlight"><pre><span></span><span class="k">\PolFromCSV</span><span class="nb">{</span>f<span class="nb">}{</span>0, 0, 0, 0, 0, 0, 0, 0, 0, 0<span class="nb">}</span>
1225 </pre></div>
1226 </div>
1227 <p>defines the zero polynomial, which holds only one coefficient.</p>
1228 <p>See also expandable macro <a class="reference internal" href="#poltocsv"><span class="std std-ref">\PolToCSV{&lt;polname&gt;}</span></a>.</p>
1229 </div></blockquote>
1230 </section>
1231 <section id="polmapcoeffs">
1232 <span id="id19"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolMapCoeffs{}{}</span></code></h3>
1233 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolMapCoeffs{\macro}{&lt;polname&gt;}</span></code></p>
1234 <blockquote>
1235 <div><p>It modifies (‘in-place’: original coefficients get lost) each
1236 coefficient of the defined polynomial via the <em>expandable</em> macro
1237 <code class="docutils literal notranslate"><span class="pre">\macro</span></code>. The degree is adjusted as necessary if some leading
1238 coefficients vanish after the operation.</p>
1239 <p>In the replacement text of <code class="docutils literal notranslate"><span class="pre">\macro</span></code>, <code class="docutils literal notranslate"><span class="pre">\index</span></code> expands to the
1240 coefficient index (starting at zero for the constant term).</p>
1241 <p>Notice that <code class="docutils literal notranslate"><span class="pre">\macro</span></code> will have to handle inputs in the <a class="reference external" href="https://www.ctan.org/pkg/xint">xintfrac</a>
1242 internal format. This means that it probably will have to be
1243 expressed in terms of macros from the <a class="reference external" href="https://www.ctan.org/pkg/xint">xintfrac</a> package.</p>
1244 <p>Example:</p>
1245 <div class="highlight-latex notranslate"><div class="highlight"><pre><span></span><span class="k">\def\foo</span>#1<span class="nb">{</span><span class="k">\xintMul</span><span class="nb">{</span>#1<span class="nb">}{</span><span class="k">\the\numexpr\index*\index\relax</span><span class="nb">}}</span>
1246 </pre></div>
1247 </div>
1248 <p>(or with <code class="docutils literal notranslate"><span class="pre">\xintSqr{\index}</span></code>) to replace <code class="docutils literal notranslate"><span class="pre">n</span></code>-th coefficient
1249 <code class="docutils literal notranslate"><span class="pre">f_n</span></code> by <code class="docutils literal notranslate"><span class="pre">f_n*n^2</span></code>.</p>
1250 </div></blockquote>
1251 </section>
1252 <section id="polreducecoeffs">
1253 <span id="id20"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolReduceCoeffs{}</span></code></h3>
1254 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolReduceCoeffs{&lt;polname&gt;}</span></code></p>
1255 <blockquote>
1256 <div><p>Reduces the internal representations of the coefficients to
1257 their lowest terms.</p>
1258 </div></blockquote>
1259 </section>
1260 <section id="id21">
1261 <span id="id22"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolReduceCoeffs*{}</span></code></h3>
1262 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolReduceCoeffs*{&lt;polname&gt;}</span></code></p>
1263 <blockquote>
1264 <div><p>Reduces the internal representations of the coefficients to their
1265 lowest terms, but ignoring a possible separated “power of ten part”.</p>
1266 <p>For example, <a class="reference external" href="https://www.ctan.org/pkg/xint">xintfrac</a> stores an <code class="docutils literal notranslate"><span class="pre">30e2/50</span></code> input as <code class="docutils literal notranslate"><span class="pre">30/50</span></code> with
1267 a separate <code class="docutils literal notranslate"><span class="pre">10^2</span></code> part. This will thus get replaced by <code class="docutils literal notranslate"><span class="pre">3e^2/5</span></code>
1268 (or rather whatever <a class="reference external" href="https://www.ctan.org/pkg/xint">xintfrac</a> uses for internal representation), and
1269 not by <code class="docutils literal notranslate"><span class="pre">60</span></code> as would result from complete reduction.</p>
1270 <p>Evaluations with polynomials treated by this can be much faster than
1271 with those handled by the non-starred variant
1272 <a class="reference internal" href="#polreducecoeffs"><span class="std std-ref">\PolReduceCoeffs{&lt;polname&gt;}</span></a>: as the numerators and denominators
1273 remain generally smaller.</p>
1274 </div></blockquote>
1275 </section>
1276 <section id="polmakemonic">
1277 <span id="id23"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolMakeMonic{}</span></code></h3>
1278 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolMakeMonic{&lt;polname&gt;}</span></code></p>
1279 <blockquote>
1280 <div><p>Divides by the leading coefficient. It is recommended to execute
1281 <a class="reference internal" href="#id21"><span class="std std-ref">\PolReduceCoeffs*{&lt;polname&gt;}</span></a> immediately afterwards. This is not
1282 done automatically, in case the original polynomial had integer
1283 coefficients and the user wants to keep the leading one as common
1284 denominator for typesetting purposes.</p>
1285 </div></blockquote>
1286 </section>
1287 <section id="polmakeprimitive">
1288 <span id="id24"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolMakePrimitive{}</span></code></h3>
1289 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolMakePrimitive{&lt;polname&gt;}</span></code></p>
1290 <blockquote>
1291 <div><p>Divides by the integer content see (<a class="reference internal" href="#policontent">\PolIContent</a>).
1292 This thus produces a polynomial with integer
1293 coefficients having no common factor. The sign of the leading
1294 coefficient is not modified.</p>
1295 </div></blockquote>
1296 </section>
1297 <section id="poldiff">
1298 <span id="id25"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolDiff{}{}</span></code></h3>
1299 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolDiff{&lt;polname_1&gt;}{&lt;polname_2&gt;}</span></code></p>
1300 <blockquote>
1301 <div><p>This sets <code class="docutils literal notranslate"><span class="pre">polname_2</span></code> to the first derivative of <code class="docutils literal notranslate"><span class="pre">polname_1</span></code>. It
1302 is allowed to issue <code class="docutils literal notranslate"><span class="pre">\PolDiff{f}{f}</span></code>, effectively replacing <code class="docutils literal notranslate"><span class="pre">f</span></code>
1303 by <code class="docutils literal notranslate"><span class="pre">f'</span></code>.</p>
1304 <p>Coefficients of the result <code class="docutils literal notranslate"><span class="pre">polname_2</span></code> are irreducible fractions
1305 (see <a class="reference internal" href="#technicalities">Technicalities</a> for the whole story.)</p>
1306 </div></blockquote>
1307 </section>
1308 <section id="id26">
1309 <span id="id27"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolDiff[]{}{}</span></code></h3>
1310 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolDiff[N]{&lt;polname_1&gt;}{&lt;polname_2&gt;}</span></code></p>
1311 <blockquote>
1312 <div><p>This sets <code class="docutils literal notranslate"><span class="pre">polname_2</span></code> to the <code class="docutils literal notranslate"><span class="pre">N</span></code>-th derivative of <code class="docutils literal notranslate"><span class="pre">polname_1</span></code>.
1313 Identical arguments is allowed. With <code class="docutils literal notranslate"><span class="pre">N=0</span></code>, same effect as
1314 <code class="docutils literal notranslate"><span class="pre">\PolLet{&lt;polname_2&gt;}={&lt;polname_1&gt;}</span></code>. With negative <code class="docutils literal notranslate"><span class="pre">N</span></code>, switches to
1315 using <code class="docutils literal notranslate"><span class="pre">\PolAntiDiff</span></code>.</p>
1316 </div></blockquote>
1317 </section>
1318 <section id="polantidiff">
1319 <span id="id28"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolAntiDiff{}{}</span></code></h3>
1320 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolAntiDiff{&lt;polname_1&gt;}{&lt;polname_2&gt;}</span></code></p>
1321 <blockquote>
1322 <div><p>This sets <code class="docutils literal notranslate"><span class="pre">polname_2</span></code> to the primitive of <code class="docutils literal notranslate"><span class="pre">polname_1</span></code> vanishing
1323 at zero.</p>
1324 <p>Coefficients of the result <code class="docutils literal notranslate"><span class="pre">polname_2</span></code> are irreducible fractions
1325 (see <a class="reference internal" href="#technicalities">Technicalities</a> for the whole story.)</p>
1326 </div></blockquote>
1327 </section>
1328 <section id="id29">
1329 <span id="id30"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolAntiDiff[]{}{}</span></code></h3>
1330 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolAntiDiff[N]{&lt;polname_1&gt;}{&lt;polname_2&gt;}</span></code></p>
1331 <blockquote>
1332 <div><p>This sets <code class="docutils literal notranslate"><span class="pre">polname_2</span></code> to the result of <code class="docutils literal notranslate"><span class="pre">N</span></code> successive integrations on
1333 <code class="docutils literal notranslate"><span class="pre">polname_1</span></code>. With negative <code class="docutils literal notranslate"><span class="pre">N</span></code>, it switches to using <code class="docutils literal notranslate"><span class="pre">\PolDiff</span></code>.</p>
1334 </div></blockquote>
1335 </section>
1336 <section id="poldivide">
1337 <span id="id31"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolDivide{}{}{}{}</span></code></h3>
1338 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolDivide{&lt;polname_1&gt;}{&lt;polname_2&gt;}{&lt;polname_Q&gt;}{&lt;polname_R&gt;}</span></code></p>
1339 <blockquote>
1340 <div><p>This sets <code class="docutils literal notranslate"><span class="pre">polname_Q</span></code> and <code class="docutils literal notranslate"><span class="pre">polname_R</span></code> to be the quotient and
1341 remainder in the Euclidean division of <code class="docutils literal notranslate"><span class="pre">polname_1</span></code> by
1342 <code class="docutils literal notranslate"><span class="pre">polname_2</span></code>.</p>
1343 </div></blockquote>
1344 </section>
1345 <section id="polquo">
1346 <span id="id32"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolQuo{}{}{}</span></code></h3>
1347 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolQuo{&lt;polname_1&gt;}{&lt;polname_2&gt;}{&lt;polname_Q&gt;}</span></code></p>
1348 <blockquote>
1349 <div><p>This sets <code class="docutils literal notranslate"><span class="pre">polname_Q</span></code> to be the quotient in the Euclidean division
1350 of <code class="docutils literal notranslate"><span class="pre">polname_1</span></code> by <code class="docutils literal notranslate"><span class="pre">polname_2</span></code>.</p>
1351 </div></blockquote>
1352 </section>
1353 <section id="polrem">
1354 <span id="id33"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolRem{}{}{}</span></code></h3>
1355 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolRem{&lt;polname_1&gt;}{&lt;polname_2&gt;}{&lt;polname_R&gt;}</span></code></p>
1356 <blockquote>
1357 <div><p>This sets <code class="docutils literal notranslate"><span class="pre">polname_R</span></code> to be the remainder in the Euclidean division
1358 of <code class="docutils literal notranslate"><span class="pre">polname_1</span></code> by <code class="docutils literal notranslate"><span class="pre">polname_2</span></code>.</p>
1359 </div></blockquote>
1360 </section>
1361 <section id="polgcd">
1362 <span id="id34"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolGCD{}{}{}</span></code></h3>
1363 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolGCD{&lt;polname_1&gt;}{&lt;polname_2&gt;}{&lt;polname_GCD&gt;}</span></code></p>
1364 <blockquote>
1365 <div><p>This sets <code class="docutils literal notranslate"><span class="pre">polname_GCD</span></code> to be the (monic) GCD of <code class="docutils literal notranslate"><span class="pre">polname_1</span></code>
1366 and <code class="docutils literal notranslate"><span class="pre">polname_2</span></code>. It is a unitary polynomial except if both
1367 <code class="docutils literal notranslate"><span class="pre">polname_1</span></code> and <code class="docutils literal notranslate"><span class="pre">polname_2</span></code> vanish, then <code class="docutils literal notranslate"><span class="pre">polname_GCD</span></code> is the
1368 zero polynomial.</p>
1369 </div></blockquote>
1370 </section>
1371 <section id="root-localization-routines-via-the-sturm-theorem">
1372 <h3>Root localization routines via the <a class="reference external" href="https://en.wikipedia.org/wiki/Sturm%27s_theorem">Sturm Theorem</a></h3>
1373 <p>As <a class="reference internal" href="#poltosturm"><span class="std std-ref">\PolToSturm{&lt;polname&gt;}{&lt;sturmname&gt;}</span></a> and
1374 <a class="reference internal" href="#polsturmisolatezeros"><span class="std std-ref">\PolSturmIsolateZeros{&lt;sturmname&gt;}</span></a> and variants declare
1375 additional polynomial or scalar variables with names based on <code class="docutils literal notranslate"><span class="pre">&lt;sturmname&gt;</span></code> as
1376 prefix, it is advisable to keep the <code class="docutils literal notranslate"><span class="pre">&lt;sturmname&gt;</span></code> namespace separate from
1377 the one applying to <code class="docutils literal notranslate"><span class="pre">\xintexpr</span></code> variables generally, or to polynomials.</p>
1378 <section id="poltosturm">
1379 <span id="id35"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolToSturm{}{}</span></code></h4>
1380 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolToSturm{&lt;polname&gt;}{&lt;sturmname&gt;}</span></code></p>
1381 <blockquote>
1382 <div><p>With <code class="docutils literal notranslate"><span class="pre">&lt;polname&gt;</span></code> being for example <code class="docutils literal notranslate"><span class="pre">P</span></code>, and <code class="docutils literal notranslate"><span class="pre">&lt;sturmname&gt;</span></code> being
1383 for example <code class="docutils literal notranslate"><span class="pre">S</span></code>, the macro starts by computing the derivative
1384 <code class="docutils literal notranslate"><span class="pre">P'</span></code>, then computes the opposite of the remainder in the euclidean
1385 division of <code class="docutils literal notranslate"><span class="pre">P</span></code> by <code class="docutils literal notranslate"><span class="pre">P'</span></code>, then the opposite of the remainder in
1386 the euclidean division of <code class="docutils literal notranslate"><span class="pre">P'</span></code> by the first obtained polynomial,
1387 etc… Up to signs following the <code class="docutils literal notranslate"><span class="pre">--++--++...</span></code> pattern, these are
1388 the same remainders as in the Euclide algorithm applied to the
1389 computation of the GCD of <code class="docutils literal notranslate"><span class="pre">P</span></code> and <code class="docutils literal notranslate"><span class="pre">P'</span></code>.</p>
1390 <p>The precise process differs from the above description: the
1391 algorithm first sets <code class="docutils literal notranslate"><span class="pre">S_0_</span></code> to be the <em>primitive part</em> of <code class="docutils literal notranslate"><span class="pre">P</span></code>
1392 and <code class="docutils literal notranslate"><span class="pre">S_1_</span></code> to be the <em>primitive part</em> of <code class="docutils literal notranslate"><span class="pre">P'</span></code> (see
1393 <a class="reference internal" href="#policontent"><span class="std std-ref">\PolIContent{&lt;polname&gt;}</span></a>), then at each step
1394 the remainder is made primitive and stored for internal reference as
1395 <code class="docutils literal notranslate"><span class="pre">S_k_</span></code>, so only integer-coefficients polynomials are manipulated.</p>
1396 <div class="admonition warning">
1397 <p class="admonition-title">Warning</p>
1398 <p>This exact procedure will perhaps in future be replaced by a
1399 <em>sub-resultant algorithm</em>, which may bring some speed gain in
1400 obtaining a pseudo-Sturm sequence, but some experimenting is
1401 needed, in the context of realistically realizable computations
1402 by the package; primitive polynomials although a bit costly
1403 have the smallest coefficients hence are the best for the kind of
1404 computations done for root localization, after having computed a
1405 Sturm sequence.</p>
1406 </div>
1407 <p>The last non-zero primitivized remainder <code class="docutils literal notranslate"><span class="pre">S_N_</span></code> is, up to sign,
1408 the primitive part of the GCD of <code class="docutils literal notranslate"><span class="pre">P</span></code> and <code class="docutils literal notranslate"><span class="pre">P'</span></code>. Its roots (real
1409 and complex) are the multiple roots of the original <code class="docutils literal notranslate"><span class="pre">P</span></code>. The
1410 original <code class="docutils literal notranslate"><span class="pre">P</span></code> was “square-free” (i.e. did not have multiple real
1411 or complex roots) if and only if <code class="docutils literal notranslate"><span class="pre">S_N_</span></code> is a constant, which is
1412 then <code class="docutils literal notranslate"><span class="pre">+1</span></code> or <code class="docutils literal notranslate"><span class="pre">-1</span></code> (its value before primitivization is lost).</p>
1413 <p>The macro then divides each <code class="docutils literal notranslate"><span class="pre">S_k_</span></code> by <code class="docutils literal notranslate"><span class="pre">S_N_</span></code> and declares the
1414 quotients <code class="docutils literal notranslate"><span class="pre">S_k</span></code> as user polynomials for future use. By Gauss
1415 theorem about the contents of integer-coefficients polynomials,
1416 these <code class="docutils literal notranslate"><span class="pre">S_k</span></code> also are primitive integer-coefficients polynomials.</p>
1417 <p>This step will be referred to as <em>normalization</em>, and in this
1418 documentation the obtained polynomials are said to constitute the
1419 “Sturm chain” (or “Sturm sequence”), i.e. by convention the “Sturm
1420 chain polynomials” are square-free and primitive. The possibly
1421 non-square-free ones are referred to as <em>non-normalized</em>.</p>
1422 <p>As an exception to the rule, if the original <code class="docutils literal notranslate"><span class="pre">P</span></code> was “square-free”
1423 (i.e. did not have multiple real or complex roots) then
1424 normalization is skipped (in that case <code class="docutils literal notranslate"><span class="pre">S_N_</span></code> is either <code class="docutils literal notranslate"><span class="pre">+1</span></code> or
1425 <code class="docutils literal notranslate"><span class="pre">-1</span></code>), so <code class="docutils literal notranslate"><span class="pre">S_0_</span></code> is exactly the primitive part of starting
1426 polynomial <code class="docutils literal notranslate"><span class="pre">P</span></code>, in the “square-free” case.</p>
1427 <p>The next logical step is to execute <a class="reference internal" href="#polsturmisolatezeros">\PolSturmIsolateZeros{S}</a> or one of its variants. Be careful not to
1428 use the names <code class="docutils literal notranslate"><span class="pre">sturmname_0</span></code>, <code class="docutils literal notranslate"><span class="pre">sturmname_1</span></code>, etc… for defining
1429 other polynomials after having done
1430 <code class="docutils literal notranslate"><span class="pre">\PolToSturm{&lt;polname&gt;}{&lt;sturmname&gt;}</span></code> and before executing
1431 <code class="docutils literal notranslate"><span class="pre">\PolSturmIsolateZeros{&lt;sturmname&gt;}</span></code> or its variants else the
1432 latter will behave erroneously.</p>
1433 <div class="admonition note">
1434 <p class="admonition-title">Note</p>
1435 <p>The declaration of the <code class="docutils literal notranslate"><span class="pre">S_k</span></code>‘s will overwrite with no warning
1436 previously declared polynomials with identical names <code class="docutils literal notranslate"><span class="pre">S_k</span></code>,
1437 i.e. <code class="docutils literal notranslate"><span class="pre">&lt;sturmname&gt;_k</span></code>. This is why the macro was designed
1438 to expect two names: <code class="docutils literal notranslate"><span class="pre">&lt;polname&gt;</span></code> and <code class="docutils literal notranslate"><span class="pre">&lt;sturmname&gt;</span></code>.</p>
1439 <p>It is allowed to use the polynomial name <code class="docutils literal notranslate"><span class="pre">P</span></code> as Sturm chain
1440 name <code class="docutils literal notranslate"><span class="pre">S</span></code>: <code class="docutils literal notranslate"><span class="pre">\PolToSturm{P}{P}</span></code>, but this is considered bad
1441 practice for the reason mentioned in the previous paragraph.</p>
1442 <p>Furthermore, <a class="reference internal" href="#polsturmisolatezeros">\PolSturmIsolateZeros</a>
1443 creates <a class="reference external" href="https://www.ctan.org/pkg/xintexpr">xintexpr</a> variables whose names start with
1444 <code class="docutils literal notranslate"><span class="pre">&lt;sturmname&gt;L_</span></code>, <code class="docutils literal notranslate"><span class="pre">&lt;sturmname&gt;R_</span></code>, and <code class="docutils literal notranslate"><span class="pre">&lt;sturmname&gt;Z_</span></code>, also
1445 <code class="docutils literal notranslate"><span class="pre">&lt;sturmname&gt;M_</span></code> for holding the multiplicities, and this may
1446 overwrite pre-existing user-defined <a class="reference external" href="https://www.ctan.org/pkg/xintexpr">xintexpr</a> variables.</p>
1447 </div>
1448 <div class="admonition warning">
1449 <p class="admonition-title">Warning</p>
1450 <p>The reason why the <code class="docutils literal notranslate"><span class="pre">S_k</span></code>‘s are declared as polynomials is
1451 that the associated polynomial functions are needed to compute
1452 the sign changes in the Sturm sequence evaluated at a given
1453 location, as this is the basis mechanism of <a class="reference internal" href="#polsturmisolatezeros">\PolSturmIsolateZeros</a> (on the basis of the <a class="reference external" href="https://en.wikipedia.org/wiki/Sturm%27s_theorem">Sturm theorem</a>).</p>
1454 <p>It is possible that in future the package will only internally
1455 construct such polynomial functions and only the starred variant
1456 will make the normalized (i.e. square-free) Sturm sequence public.</p>
1457 </div>
1458 <p>The integer <code class="docutils literal notranslate"><span class="pre">N</span></code> giving the length of the Sturm chain <code class="docutils literal notranslate"><span class="pre">S_0</span></code>,
1459 <code class="docutils literal notranslate"><span class="pre">S_1</span></code>, …, <code class="docutils literal notranslate"><span class="pre">S_N</span></code> is available as
1460 <a class="reference internal" href="#polsturmchainlength"><span class="std std-ref">\PolSturmChainLength{&lt;sturmname&gt;}</span></a>. If all roots of original <code class="docutils literal notranslate"><span class="pre">P</span></code>
1461 are real, then <code class="docutils literal notranslate"><span class="pre">N</span></code> is both the number of distinct real roots and
1462 the degree of <code class="docutils literal notranslate"><span class="pre">S_0</span></code>. In the case of existence of complex roots,
1463 the number of distinct real roots is at most <code class="docutils literal notranslate"><span class="pre">N</span></code> and <code class="docutils literal notranslate"><span class="pre">N</span></code> is at
1464 most the degree of <code class="docutils literal notranslate"><span class="pre">S_0</span></code>.</p>
1465 </div></blockquote>
1466 </section>
1467 <section id="id36">
1468 <span id="id37"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolToSturm*{}{}</span></code></h4>
1469 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolToSturm*{&lt;polname&gt;}{&lt;sturmname&gt;}</span></code></p>
1470 <blockquote>
1471 <div><p>Does the same as <a class="reference internal" href="#poltosturm">un-starred version</a> and additionally it
1472 keeps for user usage the memory of the <em>un-normalized</em> (but still
1473 made primitive) Sturm chain
1474 polynomials <code class="docutils literal notranslate"><span class="pre">sturmname_k_</span></code>, <code class="docutils literal notranslate"><span class="pre">k=0,1,</span> <span class="pre">...,</span> <span class="pre">N</span></code>, with
1475 <code class="docutils literal notranslate"><span class="pre">N</span></code> being <a class="reference internal" href="#polsturmchainlength"><span class="std std-ref">\PolSturmChainLength{&lt;sturmname&gt;}</span></a>.</p>
1476 </div></blockquote>
1477 </section>
1478 <section id="polsturmisolatezeros">
1479 <span id="id38"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolSturmIsolateZeros{}</span></code></h4>
1480 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolSturmIsolateZeros{&lt;sturmname&gt;}</span></code></p>
1481 <blockquote>
1482 <div><p>The macro locates, using the <a class="reference external" href="https://en.wikipedia.org/wiki/Sturm%27s_theorem">Sturm Theorem</a>, as many disjoint
1483 intervals as there are distinct real roots.</p>
1484 <div class="admonition important">
1485 <p class="admonition-title">Important</p>
1486 <p>The Sturm chain must have been produced by an earlier
1487 <a class="reference internal" href="#poltosturm"><span class="std std-ref">\PolToSturm{&lt;polname&gt;}{&lt;sturmname&gt;}</span></a>.</p>
1488 </div>
1489 <p>After its execution they are two types of such intervals (stored in
1490 memory and accessible via macros or <a class="reference external" href="https://www.ctan.org/pkg/xintexpr">xintexpr</a> variables, see below):</p>
1491 <ul class="simple">
1492 <li><p>singleton <code class="docutils literal notranslate"><span class="pre">{a}</span></code>: then <code class="docutils literal notranslate"><span class="pre">a</span></code> is a root, (necessarily a decimal
1493 number, but not all such decimal numbers are exactly identified yet).</p></li>
1494 <li><p>open intervals <code class="docutils literal notranslate"><span class="pre">(a,b)</span></code>: then there is exactly one root <code class="docutils literal notranslate"><span class="pre">z</span></code>
1495 such that <code class="docutils literal notranslate"><span class="pre">a</span> <span class="pre">&lt;</span> <span class="pre">z</span> <span class="pre">&lt;</span> <span class="pre">b</span></code>, and the end points are guaranteed to not
1496 be roots.</p></li>
1497 </ul>
1498 <p>The interval boundaries are decimal numbers, originating
1499 in iterated decimal subdivision from initial intervals
1500 <code class="docutils literal notranslate"><span class="pre">(-10^E,</span> <span class="pre">0)</span></code> and <code class="docutils literal notranslate"><span class="pre">(0,</span> <span class="pre">10^E)</span></code> with <code class="docutils literal notranslate"><span class="pre">E</span></code> chosen initially large
1501 enough so that all roots are enclosed; if zero is a root it is always
1502 identified as such. The non-singleton intervals are of the
1503 type <code class="docutils literal notranslate"><span class="pre">(a/10^f,</span> <span class="pre">(a+1)/10^f)</span></code> with <code class="docutils literal notranslate"><span class="pre">a</span></code> an integer, which is
1504 neither <code class="docutils literal notranslate"><span class="pre">0</span></code> nor <code class="docutils literal notranslate"><span class="pre">-1</span></code>. Hence either <code class="docutils literal notranslate"><span class="pre">a</span></code> and <code class="docutils literal notranslate"><span class="pre">a+1</span></code> are both positive
1505 or they are both negative.</p>
1506 <p>One does not <em>a priori</em> know what will be the lengths of these
1507 intervals (except that they are always powers of ten), they
1508 vary depending on how many digits two successive roots have in
1509 common in their respective decimal expansions.</p>
1510 <div class="admonition important">
1511 <p class="admonition-title">Important</p>
1512 <p>If some two consecutive intervals share an end-point, no
1513 information is yet gained about the separation between the two
1514 roots which could at this stage be arbitrarily small.</p>
1515 <p>See <a class="reference internal" href="#polrefineinterval"><span class="std std-ref">\PolRefineInterval*{&lt;sturmname&gt;}{&lt;index&gt;}</span></a> which addresses
1516 this issue.</p>
1517 </div>
1518 <p>Let us suppose <code class="docutils literal notranslate"><span class="pre">&lt;sturmname&gt;</span></code> is <code class="docutils literal notranslate"><span class="pre">S</span></code>.</p>
1519 <p>The interval boundaries (and exactly found roots) are made available
1520 for future computations in <code class="docutils literal notranslate"><span class="pre">\xintexpr/xinteval</span></code> or <code class="docutils literal notranslate"><span class="pre">\poldef</span></code> as
1521 variables <code class="docutils literal notranslate"><span class="pre">SL_1</span></code>, <code class="docutils literal notranslate"><span class="pre">SL_2</span></code>, etc…, for the left end-points and
1522 <code class="docutils literal notranslate"><span class="pre">SR_1</span></code>, <code class="docutils literal notranslate"><span class="pre">SR_2</span></code>, …, for the right end-points.</p>
1523 <p>Additionally, <a class="reference external" href="https://www.ctan.org/pkg/xintexpr">xintexpr</a> variable <code class="docutils literal notranslate"><span class="pre">SZ_1_isknown</span></code> will have value
1524 <code class="docutils literal notranslate"><span class="pre">1</span></code> if the root in the first interval is known, and <code class="docutils literal notranslate"><span class="pre">0</span></code>
1525 otherwise. And similarly for the other intervals.</p>
1526 <div class="admonition important">
1527 <p class="admonition-title">Important</p>
1528 <p>The variable declarations are done with no check of existence of
1529 previously existing variables with identical names.</p>
1530 </div>
1531 <p>Also, macros <a class="reference internal" href="#polsturmisolatedzeroleft"><span class="std std-ref">\PolSturmIsolatedZeroLeft{&lt;sturmname&gt;}{&lt;index&gt;}</span></a> and
1532 <a class="reference internal" href="#polsturmisolatedzeroright"><span class="std std-ref">\PolSturmIsolatedZeroRight{&lt;sturmname&gt;}{&lt;index&gt;}</span></a> are provided which
1533 expand to these same values, written in decimal notation (i.e.
1534 pre-processed by <a class="reference internal" href="#poldectostring">\PolDecToString</a>.) And there
1535 is also <a class="reference internal" href="#polsturmifzeroexactlyknown"><span class="std std-ref">\PolSturmIfZeroExactlyKnown{&lt;sturmname&gt;}{&lt;index&gt;}{T}{F}</span></a>.</p>
1536 <div class="admonition important">
1537 <p class="admonition-title">Important</p>
1538 <p>Trailing zeroes in the stored decimal numbers accessible via the
1539 macros are significant: they are also present in the decimal
1540 expansion of the exact root, so as to be able for example to
1541 print out bounds of real roots with as many digits as is
1542 significant, even if the digits are zeros.</p>
1543 </div>
1544 <p>The start of the decimal expansion of the <code class="docutils literal notranslate"><span class="pre">&lt;index&gt;</span></code>-th root is given by
1545 <a class="reference internal" href="#polsturmisolatedzeroleft">\PolSturmIsolatedZeroLeft{&lt;sturmname&gt;}{&lt;index&gt;}</a> if the root is positive, and by
1546 <a class="reference internal" href="#polsturmisolatedzeroright">PolSturmIsolatedZeroRight{&lt;sturmname&gt;}{&lt;index&gt;}</a> if the root is neagtive. These two
1547 decimal numbers are either both zero or both of the same sign.</p>
1548 <p>The number of distinct roots is obtainable expandably as
1549 <a class="reference internal" href="#polsturmnbofisolatedzeros"><span class="std std-ref">\PolSturmNbOfIsolatedZeros{&lt;sturmname&gt;}</span></a>.</p>
1550 <p>Furthermore
1551 <a class="reference internal" href="#polsturmnbofrootsoflessthanorequalto"><span class="std std-ref">\PolSturmNbOfRootsOf{&lt;sturmname&gt;}\LessThanOrEqualTo{&lt;value&gt;}</span></a> and
1552 <a class="reference internal" href="#polsturmnbofrootsoflessthanorequaltoexpr"><span class="std std-ref">\PolSturmNbOfRootsOf{&lt;sturmname&gt;}\LessThanOrEqualToExpr{&lt;num. expr.&gt;}</span></a>.
1553 will expandably compute respectively the number of real roots at
1554 most equal to <code class="docutils literal notranslate"><span class="pre">value</span></code> or <code class="docutils literal notranslate"><span class="pre">expression</span></code>, and the same but with
1555 multiplicities.</p>
1556 <p>These variables and macros are automatically updated in case of
1557 subsequent usage of <a class="reference internal" href="#polrefineinterval"><span class="std std-ref">\PolRefineInterval*{&lt;sturmname&gt;}{&lt;index&gt;}</span></a> or
1558 other localization improving macros.</p>
1559 <div class="admonition note">
1560 <p class="admonition-title">Note</p>
1561 <p>The current polexpr implementation defines the <a class="reference external" href="https://www.ctan.org/pkg/xintexpr">xintexpr</a> variables
1562 and <a class="reference external" href="https://www.ctan.org/pkg/xint">xinttools</a> arrays as described above with global scope. On the
1563 other hand the Sturm sequence polynomials obey the current scope.</p>
1564 <p>This is perhaps a bit inconsistent and may change in future.</p>
1565 </div>
1566 <div class="admonition note">
1567 <p class="admonition-title">Note</p>
1568 <p>The results are exact
1569 bounds for the mathematically exact real roots.</p>
1570 <p>Future releases will perhaps also provide macros based on Newton
1571 or Regula Falsi methods. Exact computations with such methods
1572 lead however quickly to very big fractions, and this forces usage
1573 of some rounding scheme for the abscissas if computation times
1574 are to remain reasonable. This raises issues of its own, which
1575 are studied in numerical mathematics.</p>
1576 </div>
1577 </div></blockquote>
1578 </section>
1579 <section id="id39">
1580 <span id="id40"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolSturmIsolateZeros*{}</span></code></h4>
1581 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolSturmIsolateZeros*{&lt;sturmname&gt;}</span></code></p>
1582 <blockquote>
1583 <div><p>The macro does the same as <a class="reference internal" href="#polsturmisolatezeros"><span class="std std-ref">\PolSturmIsolateZeros{&lt;sturmname&gt;}</span></a> and
1584 then in addition it does the extra work to determine all
1585 multiplicities of the real roots.</p>
1586 <p>After execution,
1587 <a class="reference internal" href="#polsturmisolatedzeromultiplicity"><span class="std std-ref">\PolSturmIsolatedZeroMultiplicity{&lt;sturmname&gt;}{&lt;index&gt;}</span></a> expands
1588 to the multiplicity of the root located in the <code class="docutils literal notranslate"><span class="pre">index</span></code>-th
1589 interval (intervals are enumerated from left to right, with index
1590 starting at <code class="docutils literal notranslate"><span class="pre">1</span></code>).</p>
1591 <p>Furthermore, if for example the <code class="docutils literal notranslate"><span class="pre">&lt;sturmname&gt;</span></code> is <code class="docutils literal notranslate"><span class="pre">S</span></code>, <a class="reference external" href="https://www.ctan.org/pkg/xintexpr">xintexpr</a>
1592 variables <code class="docutils literal notranslate"><span class="pre">SM_1</span></code>, <code class="docutils literal notranslate"><span class="pre">SM_2</span></code>… hold the multiplicities thus
1593 computed.</p>
1594 <div class="admonition note">
1595 <p class="admonition-title">Note</p>
1596 <p>Somewhat counter-intuitively, it is not necessary to have
1597 executed the <a class="reference internal" href="#id36"><span class="std std-ref">\PolToSturm*</span></a>
1598 starred variant: during its
1599 execution, <a class="reference internal" href="#poltosturm"><span class="std std-ref">\PolToSturm</span></a>,
1600 even though it does not declare the
1601 non-square-free Sturm chain polynomials as user-level genuine
1602 polynomials, stores their data in private macros.</p>
1603 </div>
1604 <p>See <code class="docutils literal notranslate"><span class="pre">The</span> <span class="pre">degree</span> <span class="pre">nine</span> <span class="pre">polynomial</span> <span class="pre">with</span> <span class="pre">0.99,</span> <span class="pre">0.999,</span> <span class="pre">0.9999</span> <span class="pre">as</span> <span class="pre">triple</span>
1605 <span class="pre">roots</span></code> example in <code class="docutils literal notranslate"><span class="pre">polexpr-examples.pdf</span></code>.</p>
1606 </div></blockquote>
1607 <section id="polsturmisolatezerosandgetmultiplicities">
1608 <span id="id41"></span><h5><code class="docutils literal notranslate"><span class="pre">\PolSturmIsolateZerosAndGetMultiplicities{}</span></code></h5>
1609 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolSturmIsolateZerosAndGetMultiplicities{&lt;sturmname&gt;}</span></code></p>
1610 <blockquote>
1611 <div><p>This is another name for <a class="reference internal" href="#id39"><span class="std std-ref">\PolSturmIsolateZeros*{&lt;sturmname&gt;}</span></a>.</p>
1612 </div></blockquote>
1613 </section>
1614 </section>
1615 <section id="id42">
1616 <span id="id43"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolSturmIsolateZeros**{}</span></code></h4>
1617 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolSturmIsolateZeros**{&lt;sturmname&gt;}</span></code></p>
1618 <blockquote>
1619 <div><p>The macro does the same as <a class="reference internal" href="#id39"><span class="std std-ref">\PolSturmIsolateZeros*{&lt;sturmname&gt;}</span></a> and
1620 in addition it does the extra work to determine all the <em>rational</em>
1621 roots.</p>
1622 <div class="admonition note">
1623 <p class="admonition-title">Note</p>
1624 <p>After execution of this macro, a root is “known” if and only if
1625 it is rational.</p>
1626 </div>
1627 <p>Furthermore, primitive polynomial <code class="docutils literal notranslate"><span class="pre">sturmname_sqf_norr</span></code> is created
1628 to match the (square-free) <code class="docutils literal notranslate"><span class="pre">sturmname_0</span></code> from which all rational
1629 roots have been removed. The number of distinct rational roots is
1630 thus the difference between the degrees of these two polynomials
1631 (see also <a class="reference internal" href="#polsturmnbofrationalroots"><span class="std std-ref">\PolSturmNbOfRationalRoots{&lt;sturmname&gt;}</span></a>).</p>
1632 <p>And <code class="docutils literal notranslate"><span class="pre">sturmname_norr</span></code> is <code class="docutils literal notranslate"><span class="pre">sturmname_0_</span></code> from which all rational
1633 roots have been removed, i.e. it contains the irrational roots of
1634 the original polynomial, with the same multiplicities.</p>
1635 <p>See <code class="docutils literal notranslate"><span class="pre">A</span> <span class="pre">degree</span> <span class="pre">five</span> <span class="pre">polynomial</span> <span class="pre">with</span> <span class="pre">three</span> <span class="pre">rational</span>
1636 <span class="pre">roots</span></code> in <code class="docutils literal notranslate"><span class="pre">polexpr-examples.pdf</span></code>.</p>
1637 </div></blockquote>
1638 <section id="polsturmisolatezerosgetmultiplicitiesandrationalroots">
1639 <span id="id44"></span><h5><code class="docutils literal notranslate"><span class="pre">\PolSturmIsolateZerosGetMultiplicitiesAndRationalRoots</span></code></h5>
1640 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolSturmIsolateZerosGetMultiplicitiesAndRationalRoots</span></code></p>
1641 <blockquote>
1642 <div><p>This is another name for <a class="reference internal" href="#id42"><span class="std std-ref">\PolSturmIsolateZeros**{&lt;sturmname&gt;}</span></a>.</p>
1643 </div></blockquote>
1644 </section>
1645 </section>
1646 <section id="polsturmisolatezerosandfindrationalroots">
1647 <span id="id45"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolSturmIsolateZerosAndFindRationalRoots{}</span></code></h4>
1648 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolSturmIsolateZerosAndFindRationalRoots{&lt;sturmname&gt;}</span></code></p>
1649 <blockquote>
1650 <div><p>This works exactly like <a class="reference internal" href="#id42"><span class="std std-ref">\PolSturmIsolateZeros**{&lt;sturmname&gt;}</span></a>
1651 (inclusive of declaring the polynomials <code class="docutils literal notranslate"><span class="pre">sturmname_sqf_norr</span></code> and
1652 <code class="docutils literal notranslate"><span class="pre">sturmname_norr</span></code> with no rational roots) except that it does <em>not</em>
1653 compute the multiplicities of the <em>non-rational</em> roots.</p>
1654 <div class="admonition note">
1655 <p class="admonition-title">Note</p>
1656 <p>There is no macro to find the rational roots but not compute
1657 their multiplicities at the same time.</p>
1658 </div>
1659 <div class="admonition attention">
1660 <p class="admonition-title">Attention</p>
1661 <p>This macro does <em>not</em> define <a class="reference external" href="https://www.ctan.org/pkg/xintexpr">xintexpr</a> variables
1662 <code class="docutils literal notranslate"><span class="pre">sturmnameM_1</span></code>, <code class="docutils literal notranslate"><span class="pre">sturmnameM_2</span></code>, … holding the
1663 multiplicities and it leaves the multiplicity array (whose accessor
1664 is <a class="reference internal" href="#polsturmisolatedzeromultiplicity"><span class="std std-ref">\PolSturmIsolatedZeroMultiplicity{&lt;sturmname&gt;}{&lt;index&gt;}</span></a>) into
1665 a broken state, as all non-rational roots will supposedly have
1666 multiplicity one. This means that the output of
1667 <a class="reference internal" href="#id62">\PolPrintIntervals*</a> will be
1668 erroneous regarding the multiplicities of irrational roots.</p>
1669 <p>I decided to document it because finding multiplicities of the
1670 non rational roots is somewhat costly, and one may be interested
1671 only into finding the rational roots (of course random
1672 polynomials with integer coefficients will not have <em>any</em>
1673 rational root anyhow).</p>
1674 </div>
1675 </div></blockquote>
1676 </section>
1677 <section id="polrefineinterval">
1678 <span id="id46"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolRefineInterval*{}{}</span></code></h4>
1679 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolRefineInterval*{&lt;sturmname&gt;}{&lt;index&gt;}</span></code></p>
1680 <blockquote>
1681 <div><p>The <code class="docutils literal notranslate"><span class="pre">index</span></code>-th interval (starting indexing at one) is further
1682 subdivided as many times as is necessary in order for the newer
1683 interval to have both its end-points distinct from the end-points of
1684 the original interval. As a consequence, the <code class="docutils literal notranslate"><span class="pre">k</span></code>th root is then
1685 strictly separated from the other roots.</p>
1686 </div></blockquote>
1687 </section>
1688 <section id="id47">
1689 <span id="id48"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolRefineInterval[]{}{}</span></code></h4>
1690 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolRefineInterval[N]{&lt;sturmname&gt;}{&lt;index&gt;}</span></code></p>
1691 <blockquote>
1692 <div><p>The <code class="docutils literal notranslate"><span class="pre">index</span></code>-th interval (starting count at one) is further
1693 subdivided once, reducing its length by a factor of 10. This is done
1694 <code class="docutils literal notranslate"><span class="pre">N</span></code> times if the optional argument <code class="docutils literal notranslate"><span class="pre">[N]</span></code> is present.</p>
1695 </div></blockquote>
1696 </section>
1697 <section id="polensureintervallength">
1698 <span id="id49"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolEnsureIntervalLength{}{}{}</span></code></h4>
1699 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolEnsureIntervalLength{&lt;sturmname&gt;}{&lt;index&gt;}{&lt;exponent&gt;}</span></code></p>
1700 <blockquote>
1701 <div><p>The <code class="docutils literal notranslate"><span class="pre">index</span></code>-th interval is subdivided until its length becomes at
1702 most <code class="docutils literal notranslate"><span class="pre">10^E</span></code>. This means (for <code class="docutils literal notranslate"><span class="pre">E&lt;0</span></code>) that the first <code class="docutils literal notranslate"><span class="pre">-E</span></code> digits
1703 after decimal mark of the <code class="docutils literal notranslate"><span class="pre">k</span></code>th root will then be known exactly.</p>
1704 </div></blockquote>
1705 </section>
1706 <section id="polensureintervallengths">
1707 <span id="id50"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolEnsureIntervalLengths{}{}</span></code></h4>
1708 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolEnsureIntervalLengths{&lt;sturmname&gt;}{&lt;exponent&gt;}</span></code></p>
1709 <blockquote>
1710 <div><p>The intervals as obtained from <code class="docutils literal notranslate"><span class="pre">\PolSturmIsolateZeros</span></code> are (if
1711 necessary) subdivided further by (base 10) dichotomy in order for
1712 each of them to have length at most <code class="docutils literal notranslate"><span class="pre">10^E</span></code>.</p>
1713 <p>This means that decimal expansions of all roots will be known with
1714 <code class="docutils literal notranslate"><span class="pre">-E</span></code> digits (for <code class="docutils literal notranslate"><span class="pre">E&lt;0</span></code>) after decimal mark.</p>
1715 </div></blockquote>
1716 </section>
1717 <section id="polsettosturmchainsignchangesat">
1718 <span id="id51"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolSetToSturmChainSignChangesAt{}{}{}</span></code></h4>
1719 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolSetToSturmChainSignChangesAt{\foo}{&lt;sturmname&gt;}{&lt;value&gt;}</span></code></p>
1720 <blockquote>
1721 <div><p>Sets macro <code class="docutils literal notranslate"><span class="pre">\foo</span></code> to store the number of sign changes in the
1722 already computed normalized Sturm chain with name prefix
1723 <code class="docutils literal notranslate"><span class="pre">&lt;sturmname&gt;</span></code>, at location <code class="docutils literal notranslate"><span class="pre">&lt;value&gt;</span></code> (which must be in format as
1724 acceptable by the <a class="reference external" href="https://www.ctan.org/pkg/xint">xintfrac</a> macros.)</p>
1725 <p>The definition is made with global scope. For local scope, use
1726 <code class="docutils literal notranslate"><span class="pre">[\empty]</span></code> as extra optional argument.</p>
1727 <p>One can use this immediately after creation of the Sturm chain.</p>
1728 </div></blockquote>
1729 </section>
1730 <section id="polsettonbofzeroswithin">
1731 <span id="id52"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolSetToNbOfZerosWithin{}{}{}{}</span></code></h4>
1732 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolSetToNbOfZerosWithin{\foo}{&lt;sturmname&gt;}{&lt;value_left&gt;}{&lt;value_right&gt;}</span></code></p>
1733 <blockquote>
1734 <div><p>Sets, assuming the normalized Sturm chain has been already computed,
1735 macro <code class="docutils literal notranslate"><span class="pre">\foo</span></code> to store the number of roots of <code class="docutils literal notranslate"><span class="pre">sturmname_0</span></code> in
1736 the interval <code class="docutils literal notranslate"><span class="pre">(value_left,</span> <span class="pre">value_right]</span></code>. The macro first
1737 re-orders end-points if necessary for <code class="docutils literal notranslate"><span class="pre">value_left</span> <span class="pre">&lt;=</span> <span class="pre">value_right</span></code>
1738 to hold.</p>
1739 <p>In accordance to <a class="reference external" href="https://en.wikipedia.org/wiki/Sturm%27s_theorem">Sturm Theorem</a> this is computed as the difference
1740 between the number of sign changes of the Sturm chain at <code class="docutils literal notranslate"><span class="pre">value_right</span></code>
1741 and the one at <code class="docutils literal notranslate"><span class="pre">value_left</span></code>.</p>
1742 <p>The definition is made with global scope. For local scope, use
1743 <code class="docutils literal notranslate"><span class="pre">[\empty]</span></code> as extra optional argument.</p>
1744 <p>One can use this immediately after creation of a Sturm chain.</p>
1745 <p>See also the expandable
1746 <a class="reference internal" href="#polsturmnbofrootsoflessthanorequalto"><span class="std std-ref">\PolSturmNbOfRootsOf{&lt;sturmname&gt;}\LessThanOrEqualTo{value}</span></a>,
1747 which however requires prior execution of <a class="reference internal" href="#polsturmisolatezeros">\PolSturmIsolateZeros</a>.</p>
1748 <p>See also the expandable
1749 <a class="reference internal" href="#polsturmnbwithmultofrootsoflessthanorequalto"><span class="std std-ref">\PolSturmNbWithMultOfRootsOf{&lt;sturmname&gt;}\LessThanOrEqualTo{value}</span></a>
1750 which requires prior execution of
1751 <a class="reference internal" href="#id39">\PolSturmIsolateZeros*</a>.</p>
1752 </div></blockquote>
1753 </section>
1754 </section>
1755 <section id="displaying-the-found-roots-polprintintervals-varname">
1756 <span id="polprintintervals"></span><h3>Displaying the found roots: <code class="docutils literal notranslate"><span class="pre">\PolPrintIntervals[&lt;varname&gt;]{}</span></code></h3>
1757 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolPrintIntervals[&lt;varname&gt;]{&lt;sturmname&gt;}</span></code></p>
1758 <blockquote>
1759 <div><p>This is a convenience macro which prints the bounds for the roots
1760 <code class="docutils literal notranslate"><span class="pre">Z_1</span></code>, <code class="docutils literal notranslate"><span class="pre">Z_2</span></code>, … (the optional argument <code class="docutils literal notranslate"><span class="pre">varname</span></code> allows to
1761 specify a replacement for the default <code class="docutils literal notranslate"><span class="pre">Z</span></code>). This will be done (by
1762 default) in a
1763 math mode <code class="docutils literal notranslate"><span class="pre">array</span></code>, one interval per row, and pattern <code class="docutils literal notranslate"><span class="pre">rcccl</span></code>,
1764 where the second and fourth column hold the <code class="docutils literal notranslate"><span class="pre">&lt;</span></code> sign, except when
1765 the interval reduces to a singleton, which means the root is known
1766 exactly.</p>
1767 <div class="admonition note">
1768 <p class="admonition-title">Note</p>
1769 <p>The explanations here and in this section are for LaTeX. With
1770 other TeX macro formats, the LaTeX syntax such as for example
1771 <code class="docutils literal notranslate"><span class="pre">\begin{array}{rcccl}</span></code> which appears in the documentation here
1772 is actually replaced with quasi-equivalent direct use of TeX
1773 primitives.</p>
1774 </div>
1775 <p>The next macros which govern its output.</p>
1776 </div></blockquote>
1777 <section id="polprintintervalsnorealroots">
1778 <span id="id53"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervalsNoRealRoots</span></code></h4>
1779 <blockquote>
1780 <div><p>Executed in place of an <code class="docutils literal notranslate"><span class="pre">array</span></code> environment, when there are no
1781 real roots. Default definition:</p>
1782 <div class="highlight-latex notranslate"><div class="highlight"><pre><span></span><span class="k">\newcommand\PolPrintIntervalsNoRealRoots</span><span class="nb">{}</span>
1783 </pre></div>
1784 </div>
1785 </div></blockquote>
1786 </section>
1787 <section id="polprintintervalsbeginenv">
1788 <span id="id54"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervalsBeginEnv</span></code></h4>
1789 <blockquote>
1790 <div><p>Default definition (given here for LaTeX, Plain has a variant):</p>
1791 <div class="highlight-latex notranslate"><div class="highlight"><pre><span></span><span class="k">\newcommand\PolPrintIntervalsBeginEnv</span><span class="nb">{</span><span class="sb">\[</span><span class="nv">\begin</span><span class="nb">{array}{rcccl}}</span>
1792 </pre></div>
1793 </div>
1794 <p>A simpler <code class="docutils literal notranslate"><span class="pre">center</span></code> environment provides a straightforward way to
1795 obtain a display allowing pagebreaks. Of course redefinitions must
1796 at any rate be kept in sync with <a class="reference internal" href="#id57">\PolPrintIntervalsKnownRoot</a> and
1797 <a class="reference internal" href="#id58">\PolPrintIntervalsUnknownRoot</a>.</p>
1798 <p>Prior to <code class="docutils literal notranslate"><span class="pre">0.8.6</span></code> it was not possible to use here for example
1799 <code class="docutils literal notranslate"><span class="pre">\begin{align}</span></code> due to the latter executing twice in contents.</p>
1800 </div></blockquote>
1801 </section>
1802 <section id="polprintintervalsendenv">
1803 <span id="id55"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervalsEndEnv</span></code></h4>
1804 <blockquote>
1805 <div><p>Default definition:</p>
1806 <div class="highlight-latex notranslate"><div class="highlight"><pre><span></span><span class="k">\newcommand\PolPrintIntervalsEndEnv</span><span class="nb">{</span><span class="k">\end</span><span class="nb">{</span>array<span class="nb">}</span><span class="k">\]</span><span class="nb">}</span>
1807 </pre></div>
1808 </div>
1809 </div></blockquote>
1810 </section>
1811 <section id="polprintintervalsrowseparator">
1812 <span id="id56"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervalsRowSeparator</span></code></h4>
1813 <blockquote>
1814 <div><p>Expands by default to <code class="docutils literal notranslate"><span class="pre">\\</span></code> with LaTeX and to <code class="docutils literal notranslate"><span class="pre">\cr</span></code> with Plain</p>
1815 <p>Added at <code class="docutils literal notranslate"><span class="pre">0.8.6</span></code>.</p>
1816 </div></blockquote>
1817 </section>
1818 <section id="polprintintervalsknownroot">
1819 <span id="id57"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervalsKnownRoot</span></code></h4>
1820 <blockquote>
1821 <div><p>Default definition:</p>
1822 <div class="highlight-latex notranslate"><div class="highlight"><pre><span></span><span class="k">\newcommand\PolPrintIntervalsKnownRoot</span><span class="nb">{</span><span class="c">%</span>
1823 <span class="nb">&amp;&amp;</span><span class="k">\PolPrintIntervalsTheVar</span><span class="nb">_{</span><span class="k">\PolPrintIntervalsTheIndex</span><span class="nb">}</span><span class="c">%</span>
1824 <span class="nb">&amp;</span>=<span class="nb">&amp;</span><span class="k">\PolPrintIntervalsPrintExactZero</span>
1825 <span class="nb">}</span>
1826 </pre></div>
1827 </div>
1828 </div></blockquote>
1829 </section>
1830 <section id="polprintintervalsunknownroot">
1831 <span id="id58"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervalsUnknownRoot</span></code></h4>
1832 <blockquote>
1833 <div><p>Default definition:</p>
1834 <div class="highlight-latex notranslate"><div class="highlight"><pre><span></span><span class="k">\newcommand\PolPrintIntervalsUnknownRoot</span><span class="nb">{</span><span class="c">%</span>
1835 <span class="k">\PolPrintIntervalsPrintLeftEndPoint</span><span class="nb">&amp;</span>&lt;<span class="nb">&amp;</span><span class="c">%</span>
1836 <span class="k">\PolPrintIntervalsTheVar</span><span class="nb">_{</span><span class="k">\PolPrintIntervalsTheIndex</span><span class="nb">}&amp;</span>&lt;<span class="nb">&amp;</span><span class="c">%</span>
1837 <span class="k">\PolPrintIntervalsPrintRightEndPoint</span>
1838 <span class="nb">}</span>
1839 </pre></div>
1840 </div>
1841 </div></blockquote>
1842 </section>
1843 <section id="polprintintervalsprintexactzero">
1844 <span id="id59"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervalsPrintExactZero</span></code></h4>
1845 <blockquote>
1846 <div><p>Default definition:</p>
1847 <div class="highlight-latex notranslate"><div class="highlight"><pre><span></span><span class="k">\newcommand\PolPrintIntervalsPrintExactZero</span><span class="nb">{</span><span class="k">\PolPrintIntervalsTheLeftEndPoint</span><span class="nb">}</span>
1848 </pre></div>
1849 </div>
1850 </div></blockquote>
1851 </section>
1852 <section id="polprintintervalsprintleftendpoint">
1853 <span id="id60"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervalsPrintLeftEndPoint</span></code></h4>
1854 <blockquote>
1855 <div><p>Default definition:</p>
1856 <div class="highlight-latex notranslate"><div class="highlight"><pre><span></span><span class="k">\newcommand\PolPrintIntervalsPrintLeftEndPoint</span><span class="nb">{</span><span class="k">\PolPrintIntervalsTheLeftEndPoint</span><span class="nb">}</span>
1857 </pre></div>
1858 </div>
1859 </div></blockquote>
1860 </section>
1861 <section id="polprintintervalsprintrightendpoint">
1862 <span id="id61"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervalsPrintRightEndPoint</span></code></h4>
1863 <blockquote>
1864 <div><p>Default definition is:</p>
1865 <div class="highlight-latex notranslate"><div class="highlight"><pre><span></span><span class="k">\newcommand\PolPrintIntervalsPrintRightEndPoint</span><span class="nb">{</span><span class="k">\PolPrintIntervalsTheRightEndPoint</span><span class="nb">}</span>
1866 </pre></div>
1867 </div>
1868 </div></blockquote>
1869 </section>
1870 <section id="polprintintervals-varname">
1871 <span id="id62"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervals*[&lt;varname&gt;]{}</span></code></h4>
1872 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolPrintIntervals*[&lt;varname&gt;]{&lt;sturmname&gt;}</span></code></p>
1873 <blockquote>
1874 <div><p>This starred variant produces an alternative output (which
1875 displays the root multiplicity), and is provided as an
1876 example of customization.</p>
1877 <p>As replacement for <a class="reference internal" href="#id57">\PolPrintIntervalsKnownRoot</a>,
1878 <a class="reference internal" href="#id59">\PolPrintIntervalsPrintExactZero</a>,
1879 <a class="reference internal" href="#id58">\PolPrintIntervalsUnknownRoot</a> it uses its own
1880 <code class="docutils literal notranslate"><span class="pre">\POL&#64;&#64;PrintIntervals...</span></code> macros. We only reproduce here one
1881 definition:</p>
1882 <div class="highlight-latex notranslate"><div class="highlight"><pre><span></span><span class="k">\newcommand\POL</span>@@PrintIntervalsPrintExactZero<span class="nb">{</span><span class="c">%</span>
1883 <span class="k">\displaystyle</span>
1884 <span class="k">\xintTeXsignedFrac</span><span class="nb">{</span><span class="k">\PolPrintIntervalsTheLeftEndPoint</span><span class="nb">}</span><span class="c">%</span>
1885 <span class="nb">}</span><span class="c">%</span>
1886 </pre></div>
1887 </div>
1888 <p>Multiplicities are printed using this auxiliary macro:</p>
1889 </div></blockquote>
1890 <section id="polprintintervalsprintmultiplicity">
1891 <span id="id63"></span><h5><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervalsPrintMultiplicity</span></code></h5>
1892 <blockquote>
1893 <div><p>whose default definition is:</p>
1894 <div class="highlight-latex notranslate"><div class="highlight"><pre><span></span><span class="k">\newcommand\PolPrintIntervalsPrintMultiplicity</span><span class="nb">{</span>(<span class="k">\mbox</span><span class="nb">{</span>mult. <span class="nb">}</span><span class="k">\PolPrintIntervalsTheMultiplicity</span>)<span class="nb">}</span>
1895 </pre></div>
1896 </div>
1897 </div></blockquote>
1898 </section>
1899 </section>
1900 </section>
1901 </section>
1902 <section id="expandable-macros">
1903 <h2>Expandable macros</h2>
1904 <div class="admonition note">
1905 <p class="admonition-title">Note</p>
1906 <p>At <code class="docutils literal notranslate"><span class="pre">0.8</span></code> <code class="docutils literal notranslate"><span class="pre">polexpr</span></code> is usable with Plain TeX and not only with
1907 LaTeX. Some examples given in this section may be using LaTeX syntax
1908 such as <code class="docutils literal notranslate"><span class="pre">\renewcommand</span></code>. Convert to TeX primitives as appropriate
1909 if testing with a non LaTeX macro format.</p>
1910 </div>
1911 <p>These macros expand completely in two steps except <code class="docutils literal notranslate"><span class="pre">\PolToExpr</span></code> and
1912 <code class="docutils literal notranslate"><span class="pre">\PolToFloatExpr</span></code> which need a <code class="docutils literal notranslate"><span class="pre">\write</span></code>, <code class="docutils literal notranslate"><span class="pre">\edef</span></code> or a
1913 <code class="docutils literal notranslate"><span class="pre">\csname...\endcsname</span></code> context.</p>
1914 <section id="poltoexpr">
1915 <span id="id64"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolToExpr{}</span></code></h3>
1916 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolToExpr{&lt;pol.</span> <span class="pre">expr.&gt;}</span></code></p>
1917 <blockquote>
1918 <div><p>Produces expandably <a class="footnote-reference brackets" href="#id66" id="id65" role="doc-noteref"><span class="fn-bracket">[</span>3<span class="fn-bracket">]</span></a> the string <code class="docutils literal notranslate"><span class="pre">coeff_N*x^N+...</span></code>, i.e. the
1919 polynomial is using descending powers.</p>
1920 <aside class="footnote brackets" id="id66" role="note">
1921 <span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#id65">3</a><span class="fn-bracket">]</span></span>
1922 <p>requires exhaustive expansion, for example as triggered by
1923 <code class="docutils literal notranslate"><span class="pre">\write</span></code> or <code class="docutils literal notranslate"><span class="pre">\edef</span></code>.</p>
1924 </aside>
1925 <p>Since <code class="docutils literal notranslate"><span class="pre">0.8</span></code> the input is not restricted to be a polynomial name but
1926 is allowed to be an arbitrary expression. Then <code class="docutils literal notranslate"><span class="pre">x</span></code> is expected as
1927 indeterminate but this can be customized via <a class="reference internal" href="#id68">\PolToExprInVar</a>.</p>
1928 <p>The output uses the letter <code class="docutils literal notranslate"><span class="pre">x</span></code> by default, this is customizable
1929 via <a class="reference internal" href="#poltoexprvar">\PolToExprVar</a>. The default output is compatible both with</p>
1930 <ul class="simple">
1931 <li><p>the Maple’s input format,</p></li>
1932 <li><p>and the PSTricks <code class="docutils literal notranslate"><span class="pre">\psplot[algebraic]</span></code> input format.</p></li>
1933 </ul>
1934 <p>Attention that it is not compatible with Python, see further
1935 <a class="reference internal" href="#id70">\PolToExprCaret</a> in this context.</p>
1936 <p>The following applies:</p>
1937 <ul class="simple">
1938 <li><p>vanishing coefficients are skipped (issue <code class="docutils literal notranslate"><span class="pre">\poltoexpralltrue</span></code> to
1939 override this and produce output such as <code class="docutils literal notranslate"><span class="pre">x^3+0*x^2+0*x^1+0</span></code>),</p></li>
1940 <li><p>negative coefficients are not prefixed by a <code class="docutils literal notranslate"><span class="pre">+</span></code> sign (else,
1941 Maple would not be happy),</p></li>
1942 <li><p>coefficients numerically equal to <code class="docutils literal notranslate"><span class="pre">1</span></code> (or <code class="docutils literal notranslate"><span class="pre">-1</span></code>) are present
1943 only via their sign,</p></li>
1944 <li><p>the letter <code class="docutils literal notranslate"><span class="pre">x</span></code> is used and the degree one monomial is output as
1945 <code class="docutils literal notranslate"><span class="pre">x</span></code>, not as <code class="docutils literal notranslate"><span class="pre">x^1</span></code>.</p></li>
1946 <li><p>(<code class="docutils literal notranslate"><span class="pre">0.8</span></code>) the caret <code class="docutils literal notranslate"><span class="pre">^</span></code> is of catcode 12. This means that one
1947 can for convenience typeset in regular text mode, for example
1948 using <code class="docutils literal notranslate"><span class="pre">\texttt</span></code> (in LaTeX). But TeX will not know how to break
1949 the expression across end-of-lines anyhow. Formerly <code class="docutils literal notranslate"><span class="pre">^</span></code> was
1950 suitable for math mode but as the exponent is not braced this
1951 worked only for polynomials of degrees at most 9. Anyhow this
1952 is not supposed to be a typesetting macro.</p></li>
1953 </ul>
1954 <p>Complete customization is possible, see the next macros. Any user
1955 redefinition must maintain the expandability property.</p>
1956 </div></blockquote>
1957 <section id="poltoexprvar">
1958 <span id="id67"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolToExprVar</span></code></h4>
1959 <blockquote>
1960 <div><p>Defaults to <code class="docutils literal notranslate"><span class="pre">x</span></code>. The letter used in the macro output.</p>
1961 </div></blockquote>
1962 </section>
1963 <section id="poltoexprinvar">
1964 <span id="id68"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolToExprInVar</span></code></h4>
1965 <blockquote>
1966 <div><p>Defaults to <code class="docutils literal notranslate"><span class="pre">x</span></code>: the letter used as the polynomial indeterminate
1967 in the macro input:</p>
1968 <div class="highlight-latex notranslate"><div class="highlight"><pre><span></span><span class="k">\def\PolToExprInVar</span><span class="nb">{</span>x<span class="nb">}</span><span class="c">% (default)</span>
1969 </pre></div>
1970 </div>
1971 <p>Recall that declared polynomials are more efficiently used in
1972 algebraic expressions without the <code class="docutils literal notranslate"><span class="pre">(x)</span></code>, i.e. <code class="docutils literal notranslate"><span class="pre">P*Q</span></code> is better
1973 than <code class="docutils literal notranslate"><span class="pre">P(x)*Q(x)</span></code>. Thus the input, even if an expression, does not
1974 have to contain any <code class="docutils literal notranslate"><span class="pre">x</span></code>.</p>
1975 <p>(new with <code class="docutils literal notranslate"><span class="pre">0.8</span></code>)</p>
1976 </div></blockquote>
1977 </section>
1978 <section id="poltoexprtimes">
1979 <span id="id69"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolToExprTimes</span></code></h4>
1980 <blockquote>
1981 <div><p>Defaults to <code class="docutils literal notranslate"><span class="pre">*</span></code>.</p>
1982 </div></blockquote>
1983 </section>
1984 <section id="poltoexprcaret">
1985 <span id="id70"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolToExprCaret</span></code></h4>
1986 <blockquote>
1987 <div><p>Defaults to <code class="docutils literal notranslate"><span class="pre">^</span></code> of catcode 12. Set it to
1988 expand to <code class="docutils literal notranslate"><span class="pre">**</span></code> for Python compatible output.</p>
1989 <p>(new with <code class="docutils literal notranslate"><span class="pre">0.8</span></code>)</p>
1990 </div></blockquote>
1991 </section>
1992 <section id="poltoexprcmd">
1993 <span id="id71"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolToExprCmd{}</span></code></h4>
1994 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolToExprCmd{&lt;raw_coeff&gt;}</span></code></p>
1995 <blockquote>
1996 <div><p>Defaults to <code class="docutils literal notranslate"><span class="pre">\xintPRaw{\xintRawWithZeros{#1}}</span></code>.</p>
1997 <p>This means that the coefficient value is printed-out as a fraction
1998 <code class="docutils literal notranslate"><span class="pre">a/b</span></code>, skipping the <code class="docutils literal notranslate"><span class="pre">/b</span></code> part if <code class="docutils literal notranslate"><span class="pre">b</span></code> turns out to be one.</p>
1999 <p>Configure it to be <code class="docutils literal notranslate"><span class="pre">\xintPRaw{\xintIrr{#1}}</span></code> if the fractions
2000 must be in irreducible terms.</p>
2001 <p>An alternative is <code class="docutils literal notranslate"><span class="pre">\xintDecToString{\xintREZ{#1}}</span></code> which uses
2002 integer or decimal fixed point format such as <code class="docutils literal notranslate"><span class="pre">23.0071</span></code> if the
2003 internal representation of the number only has a power of ten as
2004 denominator (the effect of <code class="docutils literal notranslate"><span class="pre">\xintREZ</span></code> here is to remove trailing
2005 decimal zeros). The behaviour of <code class="docutils literal notranslate"><span class="pre">\xintDecToString</span></code> is not yet
2006 stable for other cases, and for example at time of writing no
2007 attempt is made to identify inputs having a finite decimal expansion
2008 so for example <code class="docutils literal notranslate"><span class="pre">23.007/2</span></code> or <code class="docutils literal notranslate"><span class="pre">23.007/25</span></code> can appear in output
2009 and not their finite decimal expansion with no denominator.</p>
2010 </div></blockquote>
2011 </section>
2012 <section id="poltoexproneterm">
2013 <span id="id72"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolToExprOneTerm{}{}</span></code></h4>
2014 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolToExprOneTerm{&lt;raw_coeff&gt;}{&lt;exponent&gt;}</span></code></p>
2015 <blockquote>
2016 <div><p>This is the macro which from the coefficient and the exponent
2017 produces the corresponding term in output, such as <code class="docutils literal notranslate"><span class="pre">2/3*x^7</span></code>.</p>
2018 <p>For its default definition, see the source code. It uses
2019 <a class="reference internal" href="#poltoexprcmd">\PolToExprCmd</a>, <a class="reference internal" href="#poltoexprtimes">\PolToExprTimes</a>, <a class="reference internal" href="#poltoexprvar">\PolToExprVar</a> and
2020 <a class="reference internal" href="#id70">\PolToExprCaret</a>.</p>
2021 </div></blockquote>
2022 </section>
2023 <section id="poltoexpronetermstylea">
2024 <span id="id73"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolToExprOneTermStyleA{}{}</span></code></h4>
2025 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolToExprOneTermStyleA{&lt;raw_coeff&gt;}{&lt;exponent&gt;}</span></code></p>
2026 <blockquote>
2027 <div><p>This holds the default package meaning of <code class="docutils literal notranslate"><span class="pre">\PolToExprOneTerm</span></code>.</p>
2028 </div></blockquote>
2029 </section>
2030 <section id="poltoexpronetermstyleb">
2031 <span id="id74"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolToExprOneTermStyleB{}{}</span></code></h4>
2032 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolToExprOneTermStyleB{&lt;raw_coeff&gt;}{&lt;exponent&gt;}</span></code></p>
2033 <blockquote>
2034 <div><p>This holds an alternative meaning, which puts the fractional part of
2035 a coefficient after the monomial, i.e. like this:</p>
2036 <div class="highlight-latex notranslate"><div class="highlight"><pre><span></span>2*x<span class="nb">^</span>11/3+3*x<span class="nb">^</span>8/7-x<span class="nb">^</span>5-x<span class="nb">^</span>4/4-x<span class="nb">^</span>3-x<span class="nb">^</span>2/2-2*x+1
2037 </pre></div>
2038 </div>
2039 <p><a class="reference internal" href="#poltoexprcmd">\PolToExprCmd</a> isn’t used at all in this style. But
2040 <a class="reference internal" href="#poltoexprtimes">\PolToExprTimes</a>, <a class="reference internal" href="#poltoexprvar">\PolToExprVar</a> and <a class="reference internal" href="#id70">\PolToExprCaret</a> are obeyed.</p>
2041 <p>To activate it use <code class="docutils literal notranslate"><span class="pre">\let\PolToExprOneTerm\PolToExprOneTermStyleB</span></code>.
2042 To revert to the package default behaviour, issue
2043 <code class="docutils literal notranslate"><span class="pre">\let\PolToExprOneTerm\PolToExprOneTermStyleA</span></code>.</p>
2044 </div></blockquote>
2045 </section>
2046 <section id="poltoexprtermprefix">
2047 <span id="id75"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolToExprTermPrefix{}</span></code></h4>
2048 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolToExprTermPrefix{&lt;raw_coeff&gt;}</span></code></p>
2049 <blockquote>
2050 <div><p>It receives as argument the coefficient. Its default behaviour is
2051 to produce a <code class="docutils literal notranslate"><span class="pre">+</span></code> if the coefficient is positive, which will thus
2052 serve to separate the monomials in the output. This is to match
2053 the default for <a class="reference internal" href="#poltoexprcmd"><span class="std std-ref">\PolToExprCmd{&lt;raw_coeff&gt;}</span></a> which in case of a
2054 positive coefficient does not output an explicit <code class="docutils literal notranslate"><span class="pre">+</span></code> prefix.</p>
2055 </div></blockquote>
2056 </section>
2057 </section>
2058 <section id="poltofloatexpr">
2059 <span id="id76"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolToFloatExpr{}</span></code></h3>
2060 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolToFloatExpr{&lt;pol.</span> <span class="pre">expr.&gt;}</span></code></p>
2061 <blockquote>
2062 <div><p>Similar to <a class="reference internal" href="#poltoexpr"><span class="std std-ref">\PolToExpr{&lt;pol. expr.&gt;}</span></a> but using
2063 <a class="reference internal" href="#poltofloatexprcmd"><span class="std std-ref">\PolToFloatExprCmd{&lt;raw_coeff&gt;}</span></a> which by default rounds and
2064 converts the coefficients to floating point format.</p>
2065 <div class="admonition note">
2066 <p class="admonition-title">Note</p>
2067 <p>This is unrelated to <a class="reference internal" href="#polgenfloatvariant"><span class="std std-ref">\PolGenFloatVariant{&lt;polname&gt;}</span></a>:
2068 <a class="reference internal" href="#poltofloatexprcmd"><span class="std std-ref">\PolToFloatExprCmd{&lt;raw_coeff&gt;}</span></a> operates on the <em>exact</em>
2069 coefficients anew (and may thus produce something else than
2070 the coefficients of the polynomial function acting
2071 in <code class="docutils literal notranslate"><span class="pre">\xintfloateval</span></code> if the floating point precision was changed
2072 in between).</p>
2073 </div>
2074 <p>Extended at <code class="docutils literal notranslate"><span class="pre">0.8</span></code> to accept general expressions as input.</p>
2075 </div></blockquote>
2076 <section id="poltofloatexproneterm">
2077 <span id="id77"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolToFloatExprOneTerm{}{}</span></code></h4>
2078 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolToFloatExprOneTerm{&lt;raw_coeff&gt;}{&lt;exponent&gt;}</span></code></p>
2079 <blockquote>
2080 <div><p>Similar to <a class="reference internal" href="#poltoexproneterm"><span class="std std-ref">\PolToExprOneTerm{&lt;raw_coeff&gt;}{&lt;exponent&gt;}</span></a>. But does not treat
2081 especially coefficients equal to plus or minus one.</p>
2082 </div></blockquote>
2083 </section>
2084 <section id="poltofloatexprcmd">
2085 <span id="id78"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolToFloatExprCmd{}</span></code></h4>
2086 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolToFloatExprCmd{&lt;raw_coeff&gt;}</span></code></p>
2087 <blockquote>
2088 <div><p>The one-argument macro used by <code class="docutils literal notranslate"><span class="pre">\PolToFloatExprOneTerm</span></code>.
2089 It defaults to <code class="docutils literal notranslate"><span class="pre">\xintPFloat{#1}</span></code>, which trims trailing
2090 zeroes.</p>
2091 <p><em>changed at 0.8.2</em> Formerly it was using <code class="docutils literal notranslate"><span class="pre">\xintFloat</span></code>.</p>
2092 </div></blockquote>
2093 </section>
2094 </section>
2095 <section id="id79">
2096 <span id="id80"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolToExpr*{}</span></code></h3>
2097 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolToExpr*{&lt;pol.</span> <span class="pre">expr.&gt;}</span></code></p>
2098 <blockquote>
2099 <div><p>Ascending powers: <code class="docutils literal notranslate"><span class="pre">coeff_0+coeff_1*x+coeff_2*x^2+...</span></code>.</p>
2100 <p>Extended at <code class="docutils literal notranslate"><span class="pre">0.8</span></code> to accept general expressions as input.</p>
2101 <p>Customizable with the same macros as for
2102 <a class="reference internal" href="#poltoexpr"><span class="std std-ref">\PolToExpr{&lt;pol. expr.&gt;}</span></a>.</p>
2103 </div></blockquote>
2104 </section>
2105 <section id="id81">
2106 <span id="id82"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolToFloatExpr*{}</span></code></h3>
2107 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolToFloatExpr*{&lt;pol.</span> <span class="pre">expr.&gt;}</span></code></p>
2108 <blockquote>
2109 <div><p>Ascending powers.</p>
2110 <p>Extended at <code class="docutils literal notranslate"><span class="pre">0.8</span></code> to accept general expressions as input.</p>
2111 </div></blockquote>
2112 </section>
2113 <section id="polnthcoeff">
2114 <span id="id83"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolNthCoeff{}{}</span></code></h3>
2115 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolNthCoeff{&lt;polname&gt;}{&lt;index&gt;}</span></code></p>
2116 <blockquote>
2117 <div><p>It expands to the raw <code class="docutils literal notranslate"><span class="pre">N</span></code>-th coefficient (<code class="docutils literal notranslate"><span class="pre">N=0</span></code> corresponds to
2118 the constant coefficient). If <code class="docutils literal notranslate"><span class="pre">N</span></code> is out of range, zero (in its
2119 default <a class="reference external" href="https://www.ctan.org/pkg/xint">xintfrac</a> format <code class="docutils literal notranslate"><span class="pre">0/1[0]</span></code>) is returned.</p>
2120 <p>Negative indices <code class="docutils literal notranslate"><span class="pre">N=-1</span></code>, <code class="docutils literal notranslate"><span class="pre">-2</span></code>, … return the leading
2121 coefficient, sub-leading coefficient, …, and finally <code class="docutils literal notranslate"><span class="pre">0/1[0]</span></code>
2122 for <code class="docutils literal notranslate"><span class="pre">N&lt;-1-degree</span></code>.</p>
2123 </div></blockquote>
2124 </section>
2125 <section id="polleadingcoeff">
2126 <span id="id84"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolLeadingCoeff{}</span></code></h3>
2127 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolLeadingCoeff{&lt;polname&gt;}</span></code></p>
2128 <blockquote>
2129 <div><p>Expands to the leading coefficient.</p>
2130 </div></blockquote>
2131 </section>
2132 <section id="poldegree">
2133 <span id="id85"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolDegree{}</span></code></h3>
2134 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolDegree{&lt;polname&gt;}</span></code></p>
2135 <blockquote>
2136 <div><p>It expands to the degree. This is <code class="docutils literal notranslate"><span class="pre">-1</span></code> if zero polynomial but this
2137 may change in future. Should it then expand to <code class="docutils literal notranslate"><span class="pre">-\infty</span></code> ?</p>
2138 </div></blockquote>
2139 </section>
2140 <section id="policontent">
2141 <span id="id86"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolIContent{}</span></code></h3>
2142 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolIContent{&lt;polname&gt;}</span></code></p>
2143 <blockquote>
2144 <div><p>It expands to the contents of the polynomial, i.e. to the positive
2145 fraction such that dividing by this fraction produces a polynomial
2146 with integer coefficients having no common prime divisor.</p>
2147 <p>See <a class="reference internal" href="#polmakeprimitive">\PolMakePrimitive</a>.</p>
2148 </div></blockquote>
2149 </section>
2150 <section id="poltolist">
2151 <span id="id87"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolToList{}</span></code></h3>
2152 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolToList{&lt;polname&gt;}</span></code></p>
2153 <blockquote>
2154 <div><p>Expands to <code class="docutils literal notranslate"><span class="pre">{coeff_0}{coeff_1}...{coeff_N}</span></code> with <code class="docutils literal notranslate"><span class="pre">N</span></code> = degree, and
2155 <code class="docutils literal notranslate"><span class="pre">coeff_N</span></code> the leading coefficient
2156 (the zero polynomial does give <code class="docutils literal notranslate"><span class="pre">{0/1[0]}</span></code> and not an
2157 empty output.)</p>
2158 </div></blockquote>
2159 </section>
2160 <section id="poltocsv">
2161 <span id="id88"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolToCSV{}</span></code></h3>
2162 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolToCSV{&lt;polname&gt;}</span></code></p>
2163 <blockquote>
2164 <div><p>Expands to <code class="docutils literal notranslate"><span class="pre">coeff_0,</span> <span class="pre">coeff_1,</span> <span class="pre">coeff_2,</span> <span class="pre">.....,</span> <span class="pre">coeff_N</span></code>, starting
2165 with constant term and ending with leading coefficient. Converse
2166 to <a class="reference internal" href="#polfromcsv"><span class="std std-ref">\PolFromCSV{&lt;polname&gt;}{&lt;csv&gt;}</span></a>.</p>
2167 </div></blockquote>
2168 </section>
2169 <section id="poleval-atexpr">
2170 <span id="polevalatexpr"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolEval{}\AtExpr{}</span></code></h3>
2171 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolEval{&lt;polname&gt;}\AtExpr{&lt;num.</span> <span class="pre">expr.&gt;}</span></code></p>
2172 <blockquote>
2173 <div><p>Same output as
2174 <code class="docutils literal notranslate"><span class="pre">\xinteval{polname(numerical</span> <span class="pre">expression)}</span></code>.</p>
2175 </div></blockquote>
2176 </section>
2177 <section id="poleval-at">
2178 <span id="polevalat"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolEval{}\At{}</span></code></h3>
2179 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolEval{&lt;polname&gt;}\At{&lt;value&gt;}</span></code></p>
2180 <blockquote>
2181 <div><p>Evaluates the polynomial at the given value which must be in (or
2182 expand to) a format acceptable to the <a class="reference external" href="https://www.ctan.org/pkg/xint">xintfrac</a> macros.</p>
2183 </div></blockquote>
2184 </section>
2185 <section id="polevalreduced-atexpr">
2186 <span id="polevalreducedatexpr"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolEvalReduced{}\AtExpr{}</span></code></h3>
2187 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolEvalReduced{&lt;polname&gt;}\AtExpr{&lt;num.</span> <span class="pre">expr.&gt;}</span></code></p>
2188 <blockquote>
2189 <div><p>Same output as <code class="docutils literal notranslate"><span class="pre">\xinteval{reduce(polname(numerical</span> <span class="pre">expression))}</span></code>.</p>
2190 </div></blockquote>
2191 </section>
2192 <section id="polevalreduced-at">
2193 <span id="polevalreducedat"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolEvalReduced{}\At{}</span></code></h3>
2194 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolEvalReduced{&lt;polname&gt;}\At{&lt;value&gt;}</span></code></p>
2195 <blockquote>
2196 <div><p>Evaluates the polynomial at the value which must be in (or expand
2197 to) a format acceptable to the <a class="reference external" href="https://www.ctan.org/pkg/xint">xintfrac</a> macros, and outputs an
2198 irreducible fraction.</p>
2199 </div></blockquote>
2200 </section>
2201 <section id="polfloateval-atexpr">
2202 <span id="polfloatevalatexpr"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolFloatEval{}\AtExpr{}</span></code></h3>
2203 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolFloatEval{&lt;polname&gt;}\AtExpr{&lt;num.</span> <span class="pre">expr.&gt;}</span></code></p>
2204 <blockquote>
2205 <div><p>Same output as <code class="docutils literal notranslate"><span class="pre">\xintfloateval{polname(numerical</span> <span class="pre">expression)}</span></code>.</p>
2206 <div class="admonition attention">
2207 <p class="admonition-title">Attention</p>
2208 <p><a class="reference internal" href="#polgenfloatvariant">\PolGenFloatVariant</a> must have
2209 been issued before.</p>
2210 </div>
2211 <p>To use the <em>exact coefficients</em> with <em>exactly executed</em> additions
2212 and multiplications and do the rounding only as the final last step,
2213 the following syntax can be used: <a class="footnote-reference brackets" href="#id90" id="id89" role="doc-noteref"><span class="fn-bracket">[</span>4<span class="fn-bracket">]</span></a></p>
2214 <div class="highlight-latex notranslate"><div class="highlight"><pre><span></span><span class="k">\xintfloateval</span><span class="nb">{</span>3.27*<span class="k">\xintexpr</span> f(2.53)<span class="k">\relax</span><span class="nb">^</span>2<span class="nb">}</span>
2215 </pre></div>
2216 </div>
2217 <aside class="footnote brackets" id="id90" role="note">
2218 <span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#id89">4</a><span class="fn-bracket">]</span></span>
2219 <p>Cf. <a class="reference external" href="https://www.ctan.org/pkg/xintexpr">xintexpr</a> documentation about nested expressions.</p>
2220 </aside>
2221 </div></blockquote>
2222 </section>
2223 <section id="polfloateval-at">
2224 <span id="polfloatevalat"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolFloatEval{}\At{}</span></code></h3>
2225 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolFloatEval{&lt;polname&gt;}\At{&lt;value&gt;}</span></code></p>
2226 <blockquote>
2227 <div><p>Evaluates the polynomial at the value which must be in (or expand
2228 to) a format acceptable to the <a class="reference external" href="https://www.ctan.org/pkg/xint">xintfrac</a> macros.</p>
2229 </div></blockquote>
2230 </section>
2231 <section id="expandable-macros-in-relation-to-root-localization-via-sturm-theorem">
2232 <h3>Expandable macros in relation to root localization via <a class="reference external" href="https://en.wikipedia.org/wiki/Sturm%27s_theorem">Sturm Theorem</a></h3>
2233 <section id="polsturmchainlength">
2234 <span id="id91"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolSturmChainLength{}</span></code></h4>
2235 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolSturmChainLength{&lt;sturmname&gt;}</span></code></p>
2236 <blockquote>
2237 <div><p>Returns the integer <code class="docutils literal notranslate"><span class="pre">N</span></code> such that <code class="docutils literal notranslate"><span class="pre">sturmname_N</span></code> is the last one
2238 in the Sturm chain <code class="docutils literal notranslate"><span class="pre">sturmname_0</span></code>, <code class="docutils literal notranslate"><span class="pre">sturmname_1</span></code>, …</p>
2239 <p>See <a class="reference internal" href="#poltosturm"><span class="std std-ref">\PolToSturm{&lt;polname&gt;}{&lt;sturmname&gt;}</span></a>.</p>
2240 </div></blockquote>
2241 </section>
2242 <section id="polsturmifzeroexactlyknown">
2243 <span id="id92"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolSturmIfZeroExactlyKnown{}{}{}{}</span></code></h4>
2244 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolSturmIfZeroExactlyKnown{&lt;sturmname&gt;}{&lt;index&gt;}{T}{F}</span></code></p>
2245 <blockquote>
2246 <div><p>Executes <code class="docutils literal notranslate"><span class="pre">T</span></code> if the <code class="docutils literal notranslate"><span class="pre">index</span></code>-th interval reduces to a singleton,
2247 i.e. the root is known exactly, else <code class="docutils literal notranslate"><span class="pre">F</span></code>.</p>
2248 </div></blockquote>
2249 </section>
2250 <section id="polsturmisolatedzeroleft">
2251 <span id="id93"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolSturmIsolatedZeroLeft{}{}</span></code></h4>
2252 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolSturmIsolatedZeroLeft{&lt;sturmname&gt;}{&lt;index&gt;}</span></code></p>
2253 <blockquote>
2254 <div><p>Expands to the left end-point for the <code class="docutils literal notranslate"><span class="pre">index</span></code>-th interval, as
2255 computed by some earlier <a class="reference internal" href="#polsturmisolatezeros"><span class="std std-ref">\PolSturmIsolateZeros{&lt;sturmname&gt;}</span></a>.</p>
2256 <div class="admonition note">
2257 <p class="admonition-title">Note</p>
2258 <p>Execution of this macro after some
2259 <a class="reference internal" href="#id47">\PolRefineInterval{&lt;sturmname&gt;}{&lt;index&gt;}</a>
2260 will take into account the now known tighter bounds.</p>
2261 </div>
2262 <p>The value is pre-formatted using <a class="reference internal" href="#poldectostring">\PolDecTostring</a>.</p>
2263 </div></blockquote>
2264 </section>
2265 <section id="polsturmisolatedzeroright">
2266 <span id="id94"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolSturmIsolatedZeroRight{}{}</span></code></h4>
2267 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolSturmIsolatedZeroRight{&lt;sturmname&gt;}{&lt;index&gt;}</span></code></p>
2268 <blockquote>
2269 <div><p>Expands to the right end-point for the <code class="docutils literal notranslate"><span class="pre">index</span></code>-th interval as
2270 computed by some earlier <a class="reference internal" href="#polsturmisolatezeros"><span class="std std-ref">\PolSturmIsolateZeros{&lt;sturmname&gt;}</span></a> and
2271 possibly refined afterwards.</p>
2272 <p>The value is pre-formatted using <a class="reference internal" href="#poldectostring">\PolDecTostring</a>.</p>
2273 </div></blockquote>
2274 </section>
2275 <section id="polsturmisolatedzeromultiplicity">
2276 <span id="id95"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolSturmIsolatedZeroMultiplicity{}{}</span></code></h4>
2277 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolSturmIsolatedZeroMultiplicity{&lt;sturmname&gt;}{&lt;index&gt;}</span></code></p>
2278 <blockquote>
2279 <div><p>Expands to the multiplicity of the unique root contained in the
2280 <code class="docutils literal notranslate"><span class="pre">index</span></code>-th interval.</p>
2281 <div class="admonition attention">
2282 <p class="admonition-title">Attention</p>
2283 <p>A prior execution of <a class="reference internal" href="#id39"><span class="std std-ref">\PolSturmIsolateZeros*{&lt;sturmname&gt;}</span></a> is mandatory.</p>
2284 </div>
2285 <p>See <code class="docutils literal notranslate"><span class="pre">The</span> <span class="pre">degree</span> <span class="pre">nine</span> <span class="pre">polynomial</span> <span class="pre">with</span> <span class="pre">0.99,</span> <span class="pre">0.999,</span> <span class="pre">0.9999</span> <span class="pre">as</span> <span class="pre">triple</span>
2286 <span class="pre">roots</span></code> in <code class="docutils literal notranslate"><span class="pre">polexpr-examples.pdf</span></code>.</p>
2287 </div></blockquote>
2288 </section>
2289 <section id="polsturmnbofisolatedzeros">
2290 <span id="id96"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolSturmNbOfIsolatedZeros{}</span></code></h4>
2291 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolSturmNbOfIsolatedZeros{&lt;sturmname&gt;}</span></code></p>
2292 <blockquote>
2293 <div><p>Expands to the number of real roots of the polynomial
2294 <code class="docutils literal notranslate"><span class="pre">&lt;sturmname&gt;_0</span></code>, i.e. the number of distinct real roots of the
2295 polynomial originally used to create the Sturm chain via
2296 <a class="reference internal" href="#poltosturm"><span class="std std-ref">\PolToSturm{&lt;polname&gt;}{&lt;sturmname&gt;}</span></a>.</p>
2297 </div></blockquote>
2298 <div class="admonition warning">
2299 <p class="admonition-title">Warning</p>
2300 <p>The next few macros counting roots, with or without multiplicities,
2301 less than or equal to some value, are under evaluation and may be
2302 removed from the package if their utility is judged to be not high
2303 enough. They can be re-coded at user level on the basis of the other
2304 documented package macros anyway.</p>
2305 </div>
2306 </section>
2307 <section id="polsturmnbofrootsof-lessthanorequalto">
2308 <span id="polsturmnbofrootsoflessthanorequalto"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolSturmNbOfRootsOf{}\LessThanOrEqualTo{}</span></code></h4>
2309 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolSturmNbOfRootsOf{&lt;sturmname&gt;}\LessThanOrEqualTo{&lt;value&gt;}</span></code></p>
2310 <blockquote>
2311 <div><p>Expands to the number of distinct roots (of the polynomial used to
2312 create the Sturm chain) less than or equal to the <code class="docutils literal notranslate"><span class="pre">value</span></code> (i.e. a
2313 number of fraction recognizable by the <a class="reference external" href="https://www.ctan.org/pkg/xint">xintfrac</a> macros).</p>
2314 <div class="admonition attention">
2315 <p class="admonition-title">Attention</p>
2316 <p><a class="reference internal" href="#polsturmisolatezeros"><span class="std std-ref">\PolSturmIsolateZeros{&lt;sturmname&gt;}</span></a> must have been executed
2317 beforehand.</p>
2318 <p>And the argument is a <code class="docutils literal notranslate"><span class="pre">&lt;sturmname&gt;</span></code>, not a <code class="docutils literal notranslate"><span class="pre">&lt;polname&gt;</span></code> (this is
2319 why the macro contains Sturm in its name), simply to be reminded
2320 of the above constraint.</p>
2321 </div>
2322 </div></blockquote>
2323 </section>
2324 <section id="polsturmnbofrootsof-lessthanorequaltoexpr">
2325 <span id="polsturmnbofrootsoflessthanorequaltoexpr"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolSturmNbOfRootsOf{}\LessThanOrEqualToExpr{}</span></code></h4>
2326 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolSturmNbOfRootsOf{&lt;sturmname&gt;}\LessThanOrEqualToExpr{&lt;num.</span> <span class="pre">expr.&gt;}</span></code></p>
2327 <blockquote>
2328 <div><p>Expands to the number of distinct roots (of the polynomial
2329 used to create the Sturm chain) which are less than or equal to the
2330 given numerical expression.</p>
2331 <div class="admonition attention">
2332 <p class="admonition-title">Attention</p>
2333 <p><a class="reference internal" href="#polsturmisolatezeros"><span class="std std-ref">\PolSturmIsolateZeros{&lt;sturmname&gt;}</span></a> must have been executed
2334 beforehand.</p>
2335 </div>
2336 </div></blockquote>
2337 </section>
2338 <section id="polsturmnbwithmultofrootsof-lessthanorequalto">
2339 <span id="polsturmnbwithmultofrootsoflessthanorequalto"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolSturmNbWithMultOfRootsOf{}\LessThanOrEqualTo{}</span></code></h4>
2340 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolSturmNbWithMultOfRootsOf{&lt;sturmname&gt;}\LessThanOrEqualTo{&lt;value&gt;}</span></code></p>
2341 <blockquote>
2342 <div><p>Expands to the number counted with multiplicities of the roots (of
2343 the polynomial used to create the Sturm chain) which are less than
2344 or equal to the given <code class="docutils literal notranslate"><span class="pre">value</span></code>.</p>
2345 <div class="admonition attention">
2346 <p class="admonition-title">Attention</p>
2347 <p><a class="reference internal" href="#id39"><span class="std std-ref">\PolSturmIsolateZeros*{&lt;sturmname&gt;}</span></a> (or the double starred
2348 variant) must have been executed beforehand.</p>
2349 </div>
2350 </div></blockquote>
2351 </section>
2352 <section id="polsturmnbwithmultofrootsof-lessthanorequaltoexpr">
2353 <span id="polsturmnbwithmultofrootsoflessthanorequaltoexpr"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolSturmNbWithMultOfRootsOf{}\LessThanOrEqualToExpr{}</span></code></h4>
2354 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolSturmNbWithMultOfRootsOf{&lt;sturmname&gt;}\LessThanOrEqualToExpr{&lt;num.</span> <span class="pre">expr.&gt;}</span></code></p>
2355 <blockquote>
2356 <div><p>Expands to the total number of roots (counted with multiplicities)
2357 which are less than or equal to the given <code class="docutils literal notranslate"><span class="pre">expression</span></code>.</p>
2358 <div class="admonition attention">
2359 <p class="admonition-title">Attention</p>
2360 <p><a class="reference internal" href="#id39"><span class="std std-ref">\PolSturmIsolateZeros*{&lt;sturmname&gt;}</span></a> (or the double starred
2361 variant) must have been executed beforehand.</p>
2362 </div>
2363 </div></blockquote>
2364 </section>
2365 <section id="polsturmnbofrationalroots">
2366 <span id="id97"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolSturmNbOfRationalRoots{}</span></code></h4>
2367 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolSturmNbOfRationalRoots{&lt;sturmname&gt;}</span></code></p>
2368 <blockquote>
2369 <div><p>Expands to the number of rational roots (without multiplicities).</p>
2370 <div class="admonition attention">
2371 <p class="admonition-title">Attention</p>
2372 <p><a class="reference internal" href="#id42"><span class="std std-ref">\PolSturmIsolateZeros**{&lt;sturmname&gt;}</span></a> must have been executed
2373 beforehand.</p>
2374 </div>
2375 </div></blockquote>
2376 </section>
2377 <section id="polsturmnbofrationalrootswithmultiplicities">
2378 <span id="id98"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolSturmNbOfRationalRootsWithMultiplicities{}</span></code></h4>
2379 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolSturmNbOfRationalRootsWithMultiplicities{&lt;sturmname&gt;}</span></code></p>
2380 <blockquote>
2381 <div><p>Expands to the number of rational roots (counted with multiplicities).</p>
2382 <div class="admonition attention">
2383 <p class="admonition-title">Attention</p>
2384 <p><a class="reference internal" href="#id42"><span class="std std-ref">\PolSturmIsolateZeros**{&lt;sturmname&gt;}</span></a> must have been executed
2385 beforehand.</p>
2386 </div>
2387 </div></blockquote>
2388 </section>
2389 <section id="polsturmrationalroot">
2390 <span id="id99"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolSturmRationalRoot{}{}</span></code></h4>
2391 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolSturmRationalRoot{&lt;sturmname&gt;}{&lt;k&gt;}</span></code></p>
2392 <blockquote>
2393 <div><p>Expands to the k-th rational root. They are enumerated from left to
2394 right starting at index value <code class="docutils literal notranslate"><span class="pre">1</span></code>.</p>
2395 <div class="admonition attention">
2396 <p class="admonition-title">Attention</p>
2397 <p><a class="reference internal" href="#id42"><span class="std std-ref">\PolSturmIsolateZeros**{&lt;sturmname&gt;}</span></a> must have been executed
2398 beforehand.</p>
2399 </div>
2400 </div></blockquote>
2401 </section>
2402 <section id="polsturmrationalrootindex">
2403 <span id="id100"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolSturmRationalRootIndex{}{}</span></code></h4>
2404 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolSturmRationalRootIndex{&lt;sturmname&gt;}{&lt;k&gt;}</span></code></p>
2405 <blockquote>
2406 <div><p>Expands to the index of the <code class="docutils literal notranslate"><span class="pre">k</span></code>th rational root as part of the
2407 ordered real roots (counted without multiplicities). So
2408 <a class="reference internal" href="#polsturmrationalroot"><span class="std std-ref">\PolSturmRationalRoot{&lt;sturmname&gt;}{&lt;k&gt;}</span></a> is equivalent to
2409 this nested call:</p>
2410 <div class="highlight-latex notranslate"><div class="highlight"><pre><span></span><span class="k">\PolSturmIsolatedZeroLeft</span><span class="nb">{</span>&lt;sturmname&gt;<span class="nb">}{</span><span class="k">\PolSturmRationalRootIndex</span><span class="nb">{</span>&lt;sturmname&gt;<span class="nb">}{</span>&lt;k&gt;<span class="nb">}}</span>
2411 </pre></div>
2412 </div>
2413 <div class="admonition attention">
2414 <p class="admonition-title">Attention</p>
2415 <p><a class="reference internal" href="#id42"><span class="std std-ref">\PolSturmIsolateZeros**{&lt;sturmname&gt;}</span></a> must have been executed
2416 beforehand.</p>
2417 </div>
2418 </div></blockquote>
2419 </section>
2420 <section id="polsturmrationalrootmultiplicity">
2421 <span id="id101"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolSturmRationalRootMultiplicity{}{}</span></code></h4>
2422 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolSturmRationalRootMultiplicity{&lt;sturmname&gt;}{&lt;k&gt;}</span></code></p>
2423 <blockquote>
2424 <div><p>Expands to the multiplicity of the <code class="docutils literal notranslate"><span class="pre">k</span></code>th rational root.</p>
2425 <div class="admonition attention">
2426 <p class="admonition-title">Attention</p>
2427 <p><a class="reference internal" href="#id42"><span class="std std-ref">\PolSturmIsolateZeros**{&lt;sturmname&gt;}</span></a> must have been executed
2428 beforehand.</p>
2429 </div>
2430 </div></blockquote>
2431 </section>
2432 <section id="polintervalwidth">
2433 <span id="id102"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolIntervalWidth{}{}</span></code></h4>
2434 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolIntervalWidth{&lt;sturmname&gt;}{&lt;index&gt;}</span></code></p>
2435 <blockquote>
2436 <div><p>The <code class="docutils literal notranslate"><span class="pre">10^E</span></code> width of the current <code class="docutils literal notranslate"><span class="pre">index</span></code>-th root localization
2437 interval. Output is in <a class="reference external" href="https://www.ctan.org/pkg/xint">xintfrac</a> raw <code class="docutils literal notranslate"><span class="pre">1/1[E]</span></code> format (if not zero).</p>
2438 </div></blockquote>
2439 </section>
2440 </section>
2441 <section id="expandable-macros-for-use-within-execution-of-polprintintervals">
2442 <h3>Expandable macros for use within execution of <code class="docutils literal notranslate"><span class="pre">\PolPrintIntervals</span></code></h3>
2443 <p>These macros are for usage within custom user redefinitions of
2444 <a class="reference internal" href="#id57">\PolPrintIntervalsKnownRoot</a>, <a class="reference internal" href="#id58">\PolPrintIntervalsUnknownRoot</a>, or
2445 in redefinitions of <a class="reference internal" href="#polprintintervalsprintexactzero">PolPrintIntervalsPrintExactZero</a> (used in the
2446 default for the former) and of <a class="reference internal" href="#id60">\PolPrintIntervalsPrintLeftEndPoint</a>,
2447 <a class="reference internal" href="#id61">\PolPrintIntervalsPrintRightEndPoint</a> (used in the default for the
2448 latter).</p>
2449 <section id="polprintintervalsthevar">
2450 <span id="id103"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervalsTheVar</span></code></h4>
2451 <blockquote>
2452 <div><p>Expands to the name (default <code class="docutils literal notranslate"><span class="pre">Z</span></code>) used for representing the roots,
2453 which was passed as optional argument <code class="docutils literal notranslate"><span class="pre">varname</span></code> to
2454 <a class="reference internal" href="#polprintintervals"><span class="std std-ref">\PolPrintIntervals[varname]{&lt;sturmname&gt;}</span></a>.</p>
2455 </div></blockquote>
2456 </section>
2457 <section id="polprintintervalstheindex">
2458 <span id="id104"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervalsTheIndex</span></code></h4>
2459 <blockquote>
2460 <div><p>Expands to the index of the considered interval (indexing starting
2461 at 1 for the leftmost interval).</p>
2462 </div></blockquote>
2463 </section>
2464 <section id="polprintintervalsthesturmname">
2465 <span id="id105"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervalsTheSturmName</span></code></h4>
2466 <blockquote>
2467 <div><p>Expands to the argument which was passed as <code class="docutils literal notranslate"><span class="pre">&lt;sturmname&gt;</span></code> to
2468 <a class="reference internal" href="#polprintintervals"><span class="std std-ref">\PolPrintIntervals[varname]{&lt;sturmname&gt;}</span></a>.</p>
2469 </div></blockquote>
2470 </section>
2471 <section id="polprintintervalstheleftendpoint">
2472 <span id="id106"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervalsTheLeftEndPoint</span></code></h4>
2473 <blockquote>
2474 <div><p>The left end point of the interval, as would be produced by
2475 <a class="reference internal" href="#polsturmisolatedzeroleft">\PolSturmIsolatedZeroLeft</a> if it was
2476 used with arguments the Sturm chain name and interval index returned
2477 by <a class="reference internal" href="#id105">\PolPrintIntervalsTheSturmName</a> and
2478 <a class="reference internal" href="#id104">\PolPrintIntervalsTheIndex</a>.</p>
2479 </div></blockquote>
2480 </section>
2481 <section id="polprintintervalstherightendpoint">
2482 <span id="id107"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervalsTheRightEndPoint</span></code></h4>
2483 <blockquote>
2484 <div><p>The right end point of the interval, as would be produced by
2485 <a class="reference internal" href="#polsturmisolatedzeroright">\PolSturmIsolatedZeroRight</a> for
2486 this Sturm chain name and index.</p>
2487 </div></blockquote>
2488 </section>
2489 <section id="polprintintervalsthemultiplicity">
2490 <span id="id108"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervalsTheMultiplicity</span></code></h4>
2491 <blockquote>
2492 <div><p>The multiplicity of the unique root within the interval of index
2493 <a class="reference internal" href="#id104">\PolPrintIntervalsTheIndex</a>. Makes sense only if the starred (or
2494 double-starred) variant of <a class="reference internal" href="#polsturmisolatezeros">\PolSturmIsolateZeros</a> was used earlier.</p>
2495 </div></blockquote>
2496 </section>
2497 </section>
2498 </section>
2499 <section id="tex-booleans-with-names-enacting-their-defaults">
2500 <h2>TeX Booleans (with names enacting their defaults)</h2>
2501 <section id="xintverbosefalse">
2502 <span id="id109"></span><h3><code class="docutils literal notranslate"><span class="pre">\xintverbosefalse</span></code></h3>
2503 <blockquote>
2504 <div><p>This is actually an <a class="reference external" href="https://www.ctan.org/pkg/xintexpr">xintexpr</a> configuration. Setting it to
2505 <code class="docutils literal notranslate"><span class="pre">true</span></code> triggers the writing of information to the log when new
2506 polynomial or scalar variables are defined.</p>
2507 <div class="admonition caution">
2508 <p class="admonition-title">Caution</p>
2509 <p>The macro and variable meanings as written to the log are to be
2510 considered unstable and undocumented internal structures.</p>
2511 </div>
2512 </div></blockquote>
2513 </section>
2514 <section id="polnewpolverbosefalse">
2515 <span id="id110"></span><h3><code class="docutils literal notranslate"><span class="pre">\polnewpolverbosefalse</span></code></h3>
2516 <blockquote>
2517 <div><p>When <code class="docutils literal notranslate"><span class="pre">\poldef</span></code> is used, both a variable and a function are
2518 defined. The default <code class="docutils literal notranslate"><span class="pre">\polnewpolverbosefalse</span></code> setting suppresses
2519 the print-out to the log and terminal of the function macro meaning,
2520 as it only duplicates the information contained in the variable
2521 which is already printed out to the log and terminal.</p>
2522 <p>However <a class="reference internal" href="#polgenfloatvariant"><span class="std std-ref">\PolGenFloatVariant{&lt;polname&gt;}</span></a>
2523 does still print out the information relative to the polynomial
2524 function it defines for use in <code class="docutils literal notranslate"><span class="pre">\xintfloateval{}</span></code> as there is no
2525 float polynomial variable, only the</p>
2526 <p>function, and it is the only way to see its rounded coefficients
2527 (<code class="docutils literal notranslate"><span class="pre">\xintverbosefalse</span></code> suppresses also that info).</p>
2528 <p>If set to <code class="docutils literal notranslate"><span class="pre">true</span></code>, it overrides in both cases
2529 <code class="docutils literal notranslate"><span class="pre">\xintverbosefalse</span></code>. The setting only affects polynomial
2530 declarations. Scalar variables such as those holding information on
2531 roots obey only the <code class="docutils literal notranslate"><span class="pre">\xintverbose...</span></code> setting.</p>
2532 <p>(new with <code class="docutils literal notranslate"><span class="pre">0.8</span></code>)</p>
2533 </div></blockquote>
2534 </section>
2535 <section id="poltypesetallfalse">
2536 <span id="id111"></span><h3><code class="docutils literal notranslate"><span class="pre">\poltypesetallfalse</span></code></h3>
2537 <blockquote>
2538 <div><p>If <code class="docutils literal notranslate"><span class="pre">true</span></code>, <a class="reference internal" href="#poltypeset">\PolTypeset</a> will also typeset the vanishing
2539 coefficients.</p>
2540 </div></blockquote>
2541 </section>
2542 <section id="poltoexprallfalse">
2543 <span id="id112"></span><h3><code class="docutils literal notranslate"><span class="pre">\poltoexprallfalse</span></code></h3>
2544 <blockquote>
2545 <div><p>If <code class="docutils literal notranslate"><span class="pre">true</span></code>, <a class="reference internal" href="#poltoexpr"><span class="std std-ref">\PolToExpr{&lt;pol. expr.&gt;}</span></a> and
2546 <a class="reference internal" href="#poltofloatexpr"><span class="std std-ref">\PolToFloatExpr{&lt;pol. expr.&gt;}</span></a> will also
2547 include the vanishing coefficients in their outputs.</p>
2548 </div></blockquote>
2549 </section>
2550 </section>
2551 <section id="utilities">
2552 <h2>Utilities</h2>
2553 <section id="poldectostring">
2554 <span id="id113"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolDecToString{}</span></code></h3>
2555 <p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolDecToString{decimal</span> <span class="pre">number}</span></code></p>
2556 <blockquote>
2557 <div><p>This is a utility macro to print decimal numbers. It is an alias
2558 for <code class="docutils literal notranslate"><span class="pre">\xintDecToString</span></code>.</p>
2559 </div></blockquote>
2560 <blockquote>
2561 <div><p>For example
2562 <code class="docutils literal notranslate"><span class="pre">\PolDecToString{123.456e-8}</span></code> will expand to <code class="docutils literal notranslate"><span class="pre">0.00000123456</span></code>
2563 and <code class="docutils literal notranslate"><span class="pre">\PolDecToString{123.450e-8}</span></code> to <code class="docutils literal notranslate"><span class="pre">0.00000123450</span></code> which
2564 illustrates that trailing zeros are not trimmed.</p>
2565 <p>To trim trailing zeroes, one can use
2566 <code class="docutils literal notranslate"><span class="pre">\PolDecToString{\xintREZ{#1}}</span></code>.</p>
2567 <p>Attention that a.t.t.o.w. if the argument is for example <code class="docutils literal notranslate"><span class="pre">1/5</span></code>, the
2568 macro does not identify that this is in fact a number with a finite
2569 decimal expansion and it outputs <code class="docutils literal notranslate"><span class="pre">1/5</span></code>. See current <a class="reference external" href="https://www.ctan.org/pkg/xint">xintfrac</a>
2570 documentation.</p>
2571 </div></blockquote>
2572 </section>
2573 <section id="polexprsetup-key-val">
2574 <span id="polexprsetup"></span><h3><code class="docutils literal notranslate"><span class="pre">\polexprsetup{key=val,...}</span></code></h3>
2575 <blockquote>
2576 <div><p>Serves to customize the package. Currently only two keys are
2577 recognized:</p>
2578 <ul class="simple">
2579 <li><p><code class="docutils literal notranslate"><span class="pre">norr</span></code>: the postfix that <a class="reference internal" href="#id42"><span class="std std-ref">\PolSturmIsolateZeros**{&lt;sturmname&gt;}</span></a>
2580 should append to <code class="docutils literal notranslate"><span class="pre">&lt;sturmname&gt;</span></code> to declare the primitive polynomial
2581 obtained from original one after removal of all rational roots.
2582 The default value is <code class="docutils literal notranslate"><span class="pre">_norr</span></code> (standing for “no rational roots”).</p></li>
2583 <li><p><code class="docutils literal notranslate"><span class="pre">sqfnorr</span></code>: the postfix that <a class="reference internal" href="#id42"><span class="std std-ref">\PolSturmIsolateZeros**{&lt;sturmname&gt;}</span></a>
2584 should append to <code class="docutils literal notranslate"><span class="pre">&lt;sturmname&gt;</span></code> to declare the primitive polynomial
2585 obtained from original one after removal of all rational roots and
2586 suppression of all multiplicities.
2587 The default value is <code class="docutils literal notranslate"><span class="pre">_sqf_norr</span></code> (standing for “square-free with
2588 no rational roots”).</p></li>
2589 </ul>
2590 <p>The package executes <code class="docutils literal notranslate"><span class="pre">\polexprsetup{norr=_norr,</span>
2591 <span class="pre">sqfnorr=_sqf_norr}</span></code> as default.</p>
2592 </div></blockquote>
2593 </section>
2594 </section>
2595 <section id="technicalities">
2596 <h2>Technicalities</h2>
2597 <ul>
2598 <li><p>Do not use the underscore <code class="docutils literal notranslate"><span class="pre">_</span></code> as the <em>first character</em> of a
2599 polynomial name, even if of catcode letter. This may cause an
2600 infinite loop.</p></li>
2601 <li><p>The <code class="docutils literal notranslate"><span class="pre">&#64;</span></code> is allowed in the names of polynomials, independently of
2602 whether it is of catcode letter or other. In defining macros which
2603 will use <code class="docutils literal notranslate"><span class="pre">\poldef</span></code> to create polynomials it seems reasonable to
2604 adopt the convention that <code class="docutils literal notranslate"><span class="pre">&#64;</span></code> as <em>first</em> character in polynomial
2605 names is to be reserved to temporary auxiliary polynomials.</p>
2606 <div class="admonition attention">
2607 <p class="admonition-title">Attention</p>
2608 <p>Do not use <code class="docutils literal notranslate"><span class="pre">&#64;_</span></code> at start of polynomial names. This is reserved for
2609 internal usage by the package.</p>
2610 </div>
2611 </li>
2612 <li><p>Catcodes are set temporarily by <a class="reference internal" href="#poldef">\poldef</a> macro to safe
2613 values prior to grab the polynomial expression up to the terminator
2614 <code class="docutils literal notranslate"><span class="pre">;</span></code>, and also by <a class="reference internal" href="#id5">\PolDef</a> prior to grab the
2615 brace-enclosed polynomial expression. This gives a layer of
2616 protection in case some package (for example the <code class="docutils literal notranslate"><span class="pre">babel-french</span></code> module)
2617 has made some characters active. It will fail though if the whole
2618 thing is located inside some definition of a macro done at a time the
2619 characters are active.</p></li>
2620 <li><div class="admonition attention">
2621 <p class="admonition-title">Attention</p>
2622 <p>Contrarily to <code class="docutils literal notranslate"><span class="pre">\xintdefvar</span></code> and <code class="docutils literal notranslate"><span class="pre">\xintdeffunc</span></code> from <a class="reference external" href="https://www.ctan.org/pkg/xintexpr">xintexpr</a>,
2623 <code class="docutils literal notranslate"><span class="pre">\poldef</span></code> uses a naive delimited macro to fetch up to the
2624 expression terminator <code class="docutils literal notranslate"><span class="pre">&quot;;&quot;</span></code>, hence it will be fooled if some
2625 <code class="docutils literal notranslate"><span class="pre">;</span></code> is used inside the expression (which is possible as it
2626 appears in some <a class="reference external" href="https://www.ctan.org/pkg/xintexpr">xintexpr</a> constructs). Work-around is to use curly
2627 braces around the inner semi-colons, or simpler to use
2628 <code class="docutils literal notranslate"><span class="pre">\PolDef</span></code>.</p>
2629 </div>
2630 </li>
2631 <li><p>As a consequence of <a class="reference external" href="https://www.ctan.org/pkg/xint">xintfrac</a> addition and subtraction always using
2632 least common multiples for the denominators, user-chosen common
2633 denominators (currently) survive additions and multiplications. For
2634 example, this:</p>
2635 <div class="highlight-latex notranslate"><div class="highlight"><pre><span></span><span class="k">\poldef</span> P(x):= 1/2 + 2/2*x + 3/2*x<span class="nb">^</span>3 + 4/2*x<span class="nb">^</span>4;
2636 <span class="k">\poldef</span> Q(x):= 1/3 + (2/3)x + (3/3)x<span class="nb">^</span>3 + (4/3)x<span class="nb">^</span>4;
2637 <span class="k">\poldef</span> PQ(x):= P*Q;
2638 </pre></div>
2639 </div>
2640 <p>gives internally the polynomial:</p>
2641 <div class="highlight-latex notranslate"><div class="highlight"><pre><span></span>1/6+4/6*x<span class="nb">^</span>1+4/6*x<span class="nb">^</span>2+6/6*x<span class="nb">^</span>3+20/6*x<span class="nb">^</span>4+16/6*x<span class="nb">^</span>5+9/6*x<span class="nb">^</span>6+24/6*x<span class="nb">^</span>7+16/6*x<span class="nb">^</span>8
2642 </pre></div>
2643 </div>
2644 <p>where all coefficients have the same denominator 6. Notice though that
2645 <code class="docutils literal notranslate"><span class="pre">\PolToExpr{PQ}</span></code> outputs the <code class="docutils literal notranslate"><span class="pre">6/6*x^3</span></code> as <code class="docutils literal notranslate"><span class="pre">x^3</span></code> because (by
2646 default) it recognizes and filters out coefficients equal to one or
2647 minus one. One can use for example
2648 <code class="docutils literal notranslate"><span class="pre">\PolToCSV{PQ}</span></code> to see the internally stored coefficients.</p>
2649 </li>
2650 <li><p><a class="reference internal" href="#poldiff"><span class="std std-ref">\PolDiff{&lt;polname_1&gt;}{&lt;polname_2&gt;}</span></a> always applies <code class="docutils literal notranslate"><span class="pre">\xintPIrr</span></code> to the
2651 resulting coefficients, which means that fractions are reduced to
2652 lowest terms but ignoring an already separated <em>power of ten</em> part <code class="docutils literal notranslate"><span class="pre">[N]</span></code>
2653 present in the internal representation. This is tentative and may change.</p>
2654 <p>Same remark for <a class="reference internal" href="#polantidiff"><span class="std std-ref">\PolAntiDiff{&lt;polname_1&gt;}{&lt;polname_2&gt;}</span></a>.</p>
2655 </li>
2656 <li><p>Currently, the package stores all coefficients from index <code class="docutils literal notranslate"><span class="pre">0</span></code> to
2657 index equal to the polynomial degree inside a single macro, as a list.
2658 This data structure is obviously very inefficient for polynomials of
2659 high degree and few coefficients (as an example with <code class="docutils literal notranslate"><span class="pre">\poldef</span>
2660 <span class="pre">f(x):=x^1000</span> <span class="pre">+</span> <span class="pre">x^500;</span></code> the subsequent definition <code class="docutils literal notranslate"><span class="pre">\poldef</span> <span class="pre">g(x):=</span>
2661 <span class="pre">f(x)^2;</span></code> will do of the order of 1,000,000 multiplications and
2662 additions involvings only zeroes… which does take time). This
2663 may change in the future.</p></li>
2664 <li><p>As is to be expected internal structures of the package are barely
2665 documented and unstable. Don’t use them.</p></li>
2666 </ul>
2667 </section>
2668 </section>
2669
2670
2671 <div class="clearer"></div>
2672 </div>
2673 </div>
2674 </div>
2675 <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
2676 <div class="sphinxsidebarwrapper"><h3>Contents of this page</h3>
2677 <ul>
2678 <li><a class="reference internal" href="#">polexpr reference</a><ul>
2679 <li><a class="reference internal" href="#syntax-overview-via-examples">Syntax overview via examples</a></li>
2680 <li><a class="reference internal" href="#using-defined-polynomials-in-floating-point-context">Using defined polynomials in floating point context</a></li>
2681 <li><a class="reference internal" href="#the-polexpr-0-8-extensions-to-the-xintexpr-syntax">The polexpr <code class="docutils literal notranslate"><span class="pre">0.8</span></code> extensions to the <code class="docutils literal notranslate"><span class="pre">\xintexpr</span></code> syntax</a><ul>
2682 <li><a class="reference internal" href="#warning-about-unstability-of-the-new-syntax">Warning about unstability of the new syntax</a></li>
2683 <li><a class="reference internal" href="#infix-operators">Infix operators <code class="docutils literal notranslate"><span class="pre">+,</span> <span class="pre">-,</span> <span class="pre">*,</span> <span class="pre">/,</span> <span class="pre">**,</span> <span class="pre">^</span></code></a></li>
2684 <li><a class="reference internal" href="#experimental-infix-operators">Experimental infix operators <code class="docutils literal notranslate"><span class="pre">//,</span> <span class="pre">/:</span></code></a></li>
2685 <li><a class="reference internal" href="#comparison-operators">Comparison operators <code class="docutils literal notranslate"><span class="pre">&lt;,</span> <span class="pre">&gt;,</span> <span class="pre">&lt;=,</span> <span class="pre">&gt;=,</span> <span class="pre">==,</span> <span class="pre">!=</span></code></a></li>
2686 <li><a class="reference internal" href="#pol-nutple-expression"><code class="docutils literal notranslate"><span class="pre">pol(&lt;nutple</span> <span class="pre">expression&gt;)</span></code></a></li>
2687 <li><a class="reference internal" href="#lpol-nutple-expression"><code class="docutils literal notranslate"><span class="pre">lpol(&lt;nutple</span> <span class="pre">expression&gt;)</span></code></a></li>
2688 <li><a class="reference internal" href="#xinteval-pol-expr"><code class="docutils literal notranslate"><span class="pre">\xinteval{&lt;pol.</span> <span class="pre">expr.&gt;}</span></code></a></li>
2689 <li><a class="reference internal" href="#evalp-pol-expr-pol-expr"><code class="docutils literal notranslate"><span class="pre">evalp(&lt;pol.</span> <span class="pre">expr.&gt;,</span> <span class="pre">&lt;pol.</span> <span class="pre">expr&gt;)</span></code></a></li>
2690 <li><a class="reference internal" href="#deg-pol-expr"><code class="docutils literal notranslate"><span class="pre">deg(&lt;pol.</span> <span class="pre">expr.&gt;)</span></code></a></li>
2691 <li><a class="reference internal" href="#coeffs-pol-expr"><code class="docutils literal notranslate"><span class="pre">coeffs(&lt;pol.</span> <span class="pre">expr.&gt;)</span></code></a></li>
2692 <li><a class="reference internal" href="#lcoeffs-pol-expr"><code class="docutils literal notranslate"><span class="pre">lcoeffs(&lt;pol.</span> <span class="pre">expr.&gt;)</span></code></a></li>
2693 <li><a class="reference internal" href="#coeff-pol-expr-num-expr"><code class="docutils literal notranslate"><span class="pre">coeff(&lt;pol.</span> <span class="pre">expr.&gt;,</span> <span class="pre">&lt;num.</span> <span class="pre">expr.&gt;)</span></code></a></li>
2694 <li><a class="reference internal" href="#lc-pol-expr"><code class="docutils literal notranslate"><span class="pre">lc(&lt;pol.</span> <span class="pre">expr.&gt;)</span></code></a></li>
2695 <li><a class="reference internal" href="#monicpart-pol-expr"><code class="docutils literal notranslate"><span class="pre">monicpart(&lt;pol.</span> <span class="pre">expr.&gt;)</span></code></a></li>
2696 <li><a class="reference internal" href="#cont-pol-expr"><code class="docutils literal notranslate"><span class="pre">cont(&lt;pol.</span> <span class="pre">expr.&gt;)</span></code></a></li>
2697 <li><a class="reference internal" href="#primpart-pol-expr"><code class="docutils literal notranslate"><span class="pre">primpart(&lt;pol.</span> <span class="pre">expr.&gt;)</span></code></a></li>
2698 <li><a class="reference internal" href="#quorem-pol-expr-pol-expr"><code class="docutils literal notranslate"><span class="pre">quorem(&lt;pol.</span> <span class="pre">expr.&gt;,</span> <span class="pre">&lt;pol.</span> <span class="pre">expr.&gt;)</span></code></a></li>
2699 <li><a class="reference internal" href="#quo-pol-expr-pol-expr"><code class="docutils literal notranslate"><span class="pre">quo(&lt;pol.</span> <span class="pre">expr.&gt;,</span> <span class="pre">&lt;pol.</span> <span class="pre">expr.&gt;)</span></code></a></li>
2700 <li><a class="reference internal" href="#rem-pol-expr-pol-expr"><code class="docutils literal notranslate"><span class="pre">rem(&lt;pol.</span> <span class="pre">expr.&gt;,</span> <span class="pre">&lt;pol.</span> <span class="pre">expr.&gt;)</span></code></a></li>
2701 <li><a class="reference internal" href="#prem-pol-expr-1-pol-expr-2"><code class="docutils literal notranslate"><span class="pre">prem(&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">1&gt;,</span> <span class="pre">&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">2&gt;)</span></code></a></li>
2702 <li><a class="reference internal" href="#divmod-pol-expr-1-pol-expr-2"><code class="docutils literal notranslate"><span class="pre">divmod(&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">1&gt;,</span> <span class="pre">&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">2&gt;)</span></code></a></li>
2703 <li><a class="reference internal" href="#mod-pol-expr-1-pol-expr-2"><code class="docutils literal notranslate"><span class="pre">mod(&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">1&gt;,</span> <span class="pre">&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">2&gt;)</span></code></a></li>
2704 <li><a class="reference internal" href="#polgcd-pol-expr-1-pol-expr-2"><code class="docutils literal notranslate"><span class="pre">polgcd(&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">1&gt;,</span> <span class="pre">&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">2&gt;,</span> <span class="pre">...)</span></code></a></li>
2705 <li><a class="reference internal" href="#resultant-pol-expr-1-pol-expr-2"><code class="docutils literal notranslate"><span class="pre">resultant(&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">1&gt;,</span> <span class="pre">&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">2&gt;)</span></code></a></li>
2706 <li><a class="reference internal" href="#disc-pol-expr"><code class="docutils literal notranslate"><span class="pre">disc(&lt;pol.</span> <span class="pre">expr.&gt;)</span></code></a></li>
2707 <li><a class="reference internal" href="#polpowmod-pol-expr-1-num-expr-pol-expr-2"><code class="docutils literal notranslate"><span class="pre">polpowmod(&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">1&gt;,</span> <span class="pre">&lt;num.</span> <span class="pre">expr.&gt;,</span> <span class="pre">&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">2&gt;)</span></code></a></li>
2708 <li><a class="reference internal" href="#rdcoeffs-pol-expr"><code class="docutils literal notranslate"><span class="pre">rdcoeffs(&lt;pol.</span> <span class="pre">expr.&gt;)</span></code></a></li>
2709 <li><a class="reference internal" href="#rdzcoeffs-pol-expr"><code class="docutils literal notranslate"><span class="pre">rdzcoeffs(&lt;pol.</span> <span class="pre">expr.&gt;)</span></code></a></li>
2710 <li><a class="reference internal" href="#diff1-pol-expr"><code class="docutils literal notranslate"><span class="pre">diff1(&lt;pol.</span> <span class="pre">expr.&gt;)</span></code></a></li>
2711 <li><a class="reference internal" href="#diff2-pol-expr"><code class="docutils literal notranslate"><span class="pre">diff2(&lt;pol.</span> <span class="pre">expr.&gt;)</span></code></a></li>
2712 <li><a class="reference internal" href="#diffn-pol-expr-p-num-expr-n"><code class="docutils literal notranslate"><span class="pre">diffn(&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">P&gt;,</span> <span class="pre">&lt;num.</span> <span class="pre">expr.</span> <span class="pre">n&gt;)</span></code></a></li>
2713 <li><a class="reference internal" href="#antider-pol-expr-p"><code class="docutils literal notranslate"><span class="pre">antider(&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">P&gt;)</span></code></a></li>
2714 <li><a class="reference internal" href="#intfrom-pol-expr-p-pol-expr-c"><code class="docutils literal notranslate"><span class="pre">intfrom(&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">P&gt;,</span> <span class="pre">&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">c&gt;)</span></code></a></li>
2715 <li><a class="reference internal" href="#integral-pol-expr-p-pol-expr-a-pol-expr-b"><code class="docutils literal notranslate"><span class="pre">integral(&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">P&gt;,</span> <span class="pre">[&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">a&gt;,</span> <span class="pre">&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">b&gt;])</span></code></a></li>
2716 </ul>
2717 </li>
2718 <li><a class="reference internal" href="#non-expandable-macros">Non-expandable macros</a><ul>
2719 <li><a class="reference internal" href="#poldef-polname-letter-expression-using-the-letter-as-indeterminate"><code class="docutils literal notranslate"><span class="pre">\poldef</span> <span class="pre">polname(letter):=</span> <span class="pre">expression</span> <span class="pre">using</span> <span class="pre">the</span> <span class="pre">letter</span> <span class="pre">as</span> <span class="pre">indeterminate;</span></code></a></li>
2720 <li><a class="reference internal" href="#poldef-letter-polname-expr-using-the-letter-as-indeterminate"><code class="docutils literal notranslate"><span class="pre">\PolDef[&lt;letter&gt;]{&lt;polname&gt;}{&lt;expr.</span> <span class="pre">using</span> <span class="pre">the</span> <span class="pre">letter</span> <span class="pre">as</span> <span class="pre">indeterminate&gt;}</span></code></a></li>
2721 <li><a class="reference internal" href="#polgenfloatvariant"><code class="docutils literal notranslate"><span class="pre">\PolGenFloatVariant{}</span></code></a></li>
2722 <li><a class="reference internal" href="#poltypeset"><code class="docutils literal notranslate"><span class="pre">\PolTypeset[]{}</span></code></a><ul>
2723 <li><a class="reference internal" href="#poltypesetcmd"><code class="docutils literal notranslate"><span class="pre">\PolTypesetCmd{}</span></code></a><ul>
2724 <li><a class="reference internal" href="#polifcoeffisplusorminusone"><code class="docutils literal notranslate"><span class="pre">\PolIfCoeffIsPlusOrMinusOne{}{}</span></code></a></li>
2725 </ul>
2726 </li>
2727 <li><a class="reference internal" href="#poltypesetone"><code class="docutils literal notranslate"><span class="pre">\PolTypesetOne{}</span></code></a></li>
2728 <li><a class="reference internal" href="#poltypesetmonomialcmd"><code class="docutils literal notranslate"><span class="pre">\PolTypesetMonomialCmd</span></code></a></li>
2729 <li><a class="reference internal" href="#poltypesetcmdprefix"><code class="docutils literal notranslate"><span class="pre">\PolTypesetCmdPrefix{}</span></code></a></li>
2730 </ul>
2731 </li>
2732 <li><a class="reference internal" href="#id13"><code class="docutils literal notranslate"><span class="pre">\PolTypeset*[]{}</span></code></a></li>
2733 <li><a class="reference internal" href="#pollet"><code class="docutils literal notranslate"><span class="pre">\PolLet{}={}</span></code></a></li>
2734 <li><a class="reference internal" href="#polgloballet"><code class="docutils literal notranslate"><span class="pre">\PolGlobalLet{}={}</span></code></a></li>
2735 <li><a class="reference internal" href="#polassign-toarray"><code class="docutils literal notranslate"><span class="pre">\PolAssign{}\toarray{}</span></code></a></li>
2736 <li><a class="reference internal" href="#polget-fromarray"><code class="docutils literal notranslate"><span class="pre">\PolGet{}\fromarray{}</span></code></a></li>
2737 <li><a class="reference internal" href="#polfromcsv"><code class="docutils literal notranslate"><span class="pre">\PolFromCSV{}{}</span></code></a></li>
2738 <li><a class="reference internal" href="#polmapcoeffs"><code class="docutils literal notranslate"><span class="pre">\PolMapCoeffs{}{}</span></code></a></li>
2739 <li><a class="reference internal" href="#polreducecoeffs"><code class="docutils literal notranslate"><span class="pre">\PolReduceCoeffs{}</span></code></a></li>
2740 <li><a class="reference internal" href="#id21"><code class="docutils literal notranslate"><span class="pre">\PolReduceCoeffs*{}</span></code></a></li>
2741 <li><a class="reference internal" href="#polmakemonic"><code class="docutils literal notranslate"><span class="pre">\PolMakeMonic{}</span></code></a></li>
2742 <li><a class="reference internal" href="#polmakeprimitive"><code class="docutils literal notranslate"><span class="pre">\PolMakePrimitive{}</span></code></a></li>
2743 <li><a class="reference internal" href="#poldiff"><code class="docutils literal notranslate"><span class="pre">\PolDiff{}{}</span></code></a></li>
2744 <li><a class="reference internal" href="#id26"><code class="docutils literal notranslate"><span class="pre">\PolDiff[]{}{}</span></code></a></li>
2745 <li><a class="reference internal" href="#polantidiff"><code class="docutils literal notranslate"><span class="pre">\PolAntiDiff{}{}</span></code></a></li>
2746 <li><a class="reference internal" href="#id29"><code class="docutils literal notranslate"><span class="pre">\PolAntiDiff[]{}{}</span></code></a></li>
2747 <li><a class="reference internal" href="#poldivide"><code class="docutils literal notranslate"><span class="pre">\PolDivide{}{}{}{}</span></code></a></li>
2748 <li><a class="reference internal" href="#polquo"><code class="docutils literal notranslate"><span class="pre">\PolQuo{}{}{}</span></code></a></li>
2749 <li><a class="reference internal" href="#polrem"><code class="docutils literal notranslate"><span class="pre">\PolRem{}{}{}</span></code></a></li>
2750 <li><a class="reference internal" href="#polgcd"><code class="docutils literal notranslate"><span class="pre">\PolGCD{}{}{}</span></code></a></li>
2751 <li><a class="reference internal" href="#root-localization-routines-via-the-sturm-theorem">Root localization routines via the Sturm Theorem</a><ul>
2752 <li><a class="reference internal" href="#poltosturm"><code class="docutils literal notranslate"><span class="pre">\PolToSturm{}{}</span></code></a></li>
2753 <li><a class="reference internal" href="#id36"><code class="docutils literal notranslate"><span class="pre">\PolToSturm*{}{}</span></code></a></li>
2754 <li><a class="reference internal" href="#polsturmisolatezeros"><code class="docutils literal notranslate"><span class="pre">\PolSturmIsolateZeros{}</span></code></a></li>
2755 <li><a class="reference internal" href="#id39"><code class="docutils literal notranslate"><span class="pre">\PolSturmIsolateZeros*{}</span></code></a><ul>
2756 <li><a class="reference internal" href="#polsturmisolatezerosandgetmultiplicities"><code class="docutils literal notranslate"><span class="pre">\PolSturmIsolateZerosAndGetMultiplicities{}</span></code></a></li>
2757 </ul>
2758 </li>
2759 <li><a class="reference internal" href="#id42"><code class="docutils literal notranslate"><span class="pre">\PolSturmIsolateZeros**{}</span></code></a><ul>
2760 <li><a class="reference internal" href="#polsturmisolatezerosgetmultiplicitiesandrationalroots"><code class="docutils literal notranslate"><span class="pre">\PolSturmIsolateZerosGetMultiplicitiesAndRationalRoots</span></code></a></li>
2761 </ul>
2762 </li>
2763 <li><a class="reference internal" href="#polsturmisolatezerosandfindrationalroots"><code class="docutils literal notranslate"><span class="pre">\PolSturmIsolateZerosAndFindRationalRoots{}</span></code></a></li>
2764 <li><a class="reference internal" href="#polrefineinterval"><code class="docutils literal notranslate"><span class="pre">\PolRefineInterval*{}{}</span></code></a></li>
2765 <li><a class="reference internal" href="#id47"><code class="docutils literal notranslate"><span class="pre">\PolRefineInterval[]{}{}</span></code></a></li>
2766 <li><a class="reference internal" href="#polensureintervallength"><code class="docutils literal notranslate"><span class="pre">\PolEnsureIntervalLength{}{}{}</span></code></a></li>
2767 <li><a class="reference internal" href="#polensureintervallengths"><code class="docutils literal notranslate"><span class="pre">\PolEnsureIntervalLengths{}{}</span></code></a></li>
2768 <li><a class="reference internal" href="#polsettosturmchainsignchangesat"><code class="docutils literal notranslate"><span class="pre">\PolSetToSturmChainSignChangesAt{}{}{}</span></code></a></li>
2769 <li><a class="reference internal" href="#polsettonbofzeroswithin"><code class="docutils literal notranslate"><span class="pre">\PolSetToNbOfZerosWithin{}{}{}{}</span></code></a></li>
2770 </ul>
2771 </li>
2772 <li><a class="reference internal" href="#displaying-the-found-roots-polprintintervals-varname">Displaying the found roots: <code class="docutils literal notranslate"><span class="pre">\PolPrintIntervals[&lt;varname&gt;]{}</span></code></a><ul>
2773 <li><a class="reference internal" href="#polprintintervalsnorealroots"><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervalsNoRealRoots</span></code></a></li>
2774 <li><a class="reference internal" href="#polprintintervalsbeginenv"><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervalsBeginEnv</span></code></a></li>
2775 <li><a class="reference internal" href="#polprintintervalsendenv"><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervalsEndEnv</span></code></a></li>
2776 <li><a class="reference internal" href="#polprintintervalsrowseparator"><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervalsRowSeparator</span></code></a></li>
2777 <li><a class="reference internal" href="#polprintintervalsknownroot"><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervalsKnownRoot</span></code></a></li>
2778 <li><a class="reference internal" href="#polprintintervalsunknownroot"><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervalsUnknownRoot</span></code></a></li>
2779 <li><a class="reference internal" href="#polprintintervalsprintexactzero"><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervalsPrintExactZero</span></code></a></li>
2780 <li><a class="reference internal" href="#polprintintervalsprintleftendpoint"><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervalsPrintLeftEndPoint</span></code></a></li>
2781 <li><a class="reference internal" href="#polprintintervalsprintrightendpoint"><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervalsPrintRightEndPoint</span></code></a></li>
2782 <li><a class="reference internal" href="#polprintintervals-varname"><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervals*[&lt;varname&gt;]{}</span></code></a><ul>
2783 <li><a class="reference internal" href="#polprintintervalsprintmultiplicity"><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervalsPrintMultiplicity</span></code></a></li>
2784 </ul>
2785 </li>
2786 </ul>
2787 </li>
2788 </ul>
2789 </li>
2790 <li><a class="reference internal" href="#expandable-macros">Expandable macros</a><ul>
2791 <li><a class="reference internal" href="#poltoexpr"><code class="docutils literal notranslate"><span class="pre">\PolToExpr{}</span></code></a><ul>
2792 <li><a class="reference internal" href="#poltoexprvar"><code class="docutils literal notranslate"><span class="pre">\PolToExprVar</span></code></a></li>
2793 <li><a class="reference internal" href="#poltoexprinvar"><code class="docutils literal notranslate"><span class="pre">\PolToExprInVar</span></code></a></li>
2794 <li><a class="reference internal" href="#poltoexprtimes"><code class="docutils literal notranslate"><span class="pre">\PolToExprTimes</span></code></a></li>
2795 <li><a class="reference internal" href="#poltoexprcaret"><code class="docutils literal notranslate"><span class="pre">\PolToExprCaret</span></code></a></li>
2796 <li><a class="reference internal" href="#poltoexprcmd"><code class="docutils literal notranslate"><span class="pre">\PolToExprCmd{}</span></code></a></li>
2797 <li><a class="reference internal" href="#poltoexproneterm"><code class="docutils literal notranslate"><span class="pre">\PolToExprOneTerm{}{}</span></code></a></li>
2798 <li><a class="reference internal" href="#poltoexpronetermstylea"><code class="docutils literal notranslate"><span class="pre">\PolToExprOneTermStyleA{}{}</span></code></a></li>
2799 <li><a class="reference internal" href="#poltoexpronetermstyleb"><code class="docutils literal notranslate"><span class="pre">\PolToExprOneTermStyleB{}{}</span></code></a></li>
2800 <li><a class="reference internal" href="#poltoexprtermprefix"><code class="docutils literal notranslate"><span class="pre">\PolToExprTermPrefix{}</span></code></a></li>
2801 </ul>
2802 </li>
2803 <li><a class="reference internal" href="#poltofloatexpr"><code class="docutils literal notranslate"><span class="pre">\PolToFloatExpr{}</span></code></a><ul>
2804 <li><a class="reference internal" href="#poltofloatexproneterm"><code class="docutils literal notranslate"><span class="pre">\PolToFloatExprOneTerm{}{}</span></code></a></li>
2805 <li><a class="reference internal" href="#poltofloatexprcmd"><code class="docutils literal notranslate"><span class="pre">\PolToFloatExprCmd{}</span></code></a></li>
2806 </ul>
2807 </li>
2808 <li><a class="reference internal" href="#id79"><code class="docutils literal notranslate"><span class="pre">\PolToExpr*{}</span></code></a></li>
2809 <li><a class="reference internal" href="#id81"><code class="docutils literal notranslate"><span class="pre">\PolToFloatExpr*{}</span></code></a></li>
2810 <li><a class="reference internal" href="#polnthcoeff"><code class="docutils literal notranslate"><span class="pre">\PolNthCoeff{}{}</span></code></a></li>
2811 <li><a class="reference internal" href="#polleadingcoeff"><code class="docutils literal notranslate"><span class="pre">\PolLeadingCoeff{}</span></code></a></li>
2812 <li><a class="reference internal" href="#poldegree"><code class="docutils literal notranslate"><span class="pre">\PolDegree{}</span></code></a></li>
2813 <li><a class="reference internal" href="#policontent"><code class="docutils literal notranslate"><span class="pre">\PolIContent{}</span></code></a></li>
2814 <li><a class="reference internal" href="#poltolist"><code class="docutils literal notranslate"><span class="pre">\PolToList{}</span></code></a></li>
2815 <li><a class="reference internal" href="#poltocsv"><code class="docutils literal notranslate"><span class="pre">\PolToCSV{}</span></code></a></li>
2816 <li><a class="reference internal" href="#poleval-atexpr"><code class="docutils literal notranslate"><span class="pre">\PolEval{}\AtExpr{}</span></code></a></li>
2817 <li><a class="reference internal" href="#poleval-at"><code class="docutils literal notranslate"><span class="pre">\PolEval{}\At{}</span></code></a></li>
2818 <li><a class="reference internal" href="#polevalreduced-atexpr"><code class="docutils literal notranslate"><span class="pre">\PolEvalReduced{}\AtExpr{}</span></code></a></li>
2819 <li><a class="reference internal" href="#polevalreduced-at"><code class="docutils literal notranslate"><span class="pre">\PolEvalReduced{}\At{}</span></code></a></li>
2820 <li><a class="reference internal" href="#polfloateval-atexpr"><code class="docutils literal notranslate"><span class="pre">\PolFloatEval{}\AtExpr{}</span></code></a></li>
2821 <li><a class="reference internal" href="#polfloateval-at"><code class="docutils literal notranslate"><span class="pre">\PolFloatEval{}\At{}</span></code></a></li>
2822 <li><a class="reference internal" href="#expandable-macros-in-relation-to-root-localization-via-sturm-theorem">Expandable macros in relation to root localization via Sturm Theorem</a><ul>
2823 <li><a class="reference internal" href="#polsturmchainlength"><code class="docutils literal notranslate"><span class="pre">\PolSturmChainLength{}</span></code></a></li>
2824 <li><a class="reference internal" href="#polsturmifzeroexactlyknown"><code class="docutils literal notranslate"><span class="pre">\PolSturmIfZeroExactlyKnown{}{}{}{}</span></code></a></li>
2825 <li><a class="reference internal" href="#polsturmisolatedzeroleft"><code class="docutils literal notranslate"><span class="pre">\PolSturmIsolatedZeroLeft{}{}</span></code></a></li>
2826 <li><a class="reference internal" href="#polsturmisolatedzeroright"><code class="docutils literal notranslate"><span class="pre">\PolSturmIsolatedZeroRight{}{}</span></code></a></li>
2827 <li><a class="reference internal" href="#polsturmisolatedzeromultiplicity"><code class="docutils literal notranslate"><span class="pre">\PolSturmIsolatedZeroMultiplicity{}{}</span></code></a></li>
2828 <li><a class="reference internal" href="#polsturmnbofisolatedzeros"><code class="docutils literal notranslate"><span class="pre">\PolSturmNbOfIsolatedZeros{}</span></code></a></li>
2829 <li><a class="reference internal" href="#polsturmnbofrootsof-lessthanorequalto"><code class="docutils literal notranslate"><span class="pre">\PolSturmNbOfRootsOf{}\LessThanOrEqualTo{}</span></code></a></li>
2830 <li><a class="reference internal" href="#polsturmnbofrootsof-lessthanorequaltoexpr"><code class="docutils literal notranslate"><span class="pre">\PolSturmNbOfRootsOf{}\LessThanOrEqualToExpr{}</span></code></a></li>
2831 <li><a class="reference internal" href="#polsturmnbwithmultofrootsof-lessthanorequalto"><code class="docutils literal notranslate"><span class="pre">\PolSturmNbWithMultOfRootsOf{}\LessThanOrEqualTo{}</span></code></a></li>
2832 <li><a class="reference internal" href="#polsturmnbwithmultofrootsof-lessthanorequaltoexpr"><code class="docutils literal notranslate"><span class="pre">\PolSturmNbWithMultOfRootsOf{}\LessThanOrEqualToExpr{}</span></code></a></li>
2833 <li><a class="reference internal" href="#polsturmnbofrationalroots"><code class="docutils literal notranslate"><span class="pre">\PolSturmNbOfRationalRoots{}</span></code></a></li>
2834 <li><a class="reference internal" href="#polsturmnbofrationalrootswithmultiplicities"><code class="docutils literal notranslate"><span class="pre">\PolSturmNbOfRationalRootsWithMultiplicities{}</span></code></a></li>
2835 <li><a class="reference internal" href="#polsturmrationalroot"><code class="docutils literal notranslate"><span class="pre">\PolSturmRationalRoot{}{}</span></code></a></li>
2836 <li><a class="reference internal" href="#polsturmrationalrootindex"><code class="docutils literal notranslate"><span class="pre">\PolSturmRationalRootIndex{}{}</span></code></a></li>
2837 <li><a class="reference internal" href="#polsturmrationalrootmultiplicity"><code class="docutils literal notranslate"><span class="pre">\PolSturmRationalRootMultiplicity{}{}</span></code></a></li>
2838 <li><a class="reference internal" href="#polintervalwidth"><code class="docutils literal notranslate"><span class="pre">\PolIntervalWidth{}{}</span></code></a></li>
2839 </ul>
2840 </li>
2841 <li><a class="reference internal" href="#expandable-macros-for-use-within-execution-of-polprintintervals">Expandable macros for use within execution of <code class="docutils literal notranslate"><span class="pre">\PolPrintIntervals</span></code></a><ul>
2842 <li><a class="reference internal" href="#polprintintervalsthevar"><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervalsTheVar</span></code></a></li>
2843 <li><a class="reference internal" href="#polprintintervalstheindex"><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervalsTheIndex</span></code></a></li>
2844 <li><a class="reference internal" href="#polprintintervalsthesturmname"><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervalsTheSturmName</span></code></a></li>
2845 <li><a class="reference internal" href="#polprintintervalstheleftendpoint"><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervalsTheLeftEndPoint</span></code></a></li>
2846 <li><a class="reference internal" href="#polprintintervalstherightendpoint"><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervalsTheRightEndPoint</span></code></a></li>
2847 <li><a class="reference internal" href="#polprintintervalsthemultiplicity"><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervalsTheMultiplicity</span></code></a></li>
2848 </ul>
2849 </li>
2850 </ul>
2851 </li>
2852 <li><a class="reference internal" href="#tex-booleans-with-names-enacting-their-defaults">TeX Booleans (with names enacting their defaults)</a><ul>
2853 <li><a class="reference internal" href="#xintverbosefalse"><code class="docutils literal notranslate"><span class="pre">\xintverbosefalse</span></code></a></li>
2854 <li><a class="reference internal" href="#polnewpolverbosefalse"><code class="docutils literal notranslate"><span class="pre">\polnewpolverbosefalse</span></code></a></li>
2855 <li><a class="reference internal" href="#poltypesetallfalse"><code class="docutils literal notranslate"><span class="pre">\poltypesetallfalse</span></code></a></li>
2856 <li><a class="reference internal" href="#poltoexprallfalse"><code class="docutils literal notranslate"><span class="pre">\poltoexprallfalse</span></code></a></li>
2857 </ul>
2858 </li>
2859 <li><a class="reference internal" href="#utilities">Utilities</a><ul>
2860 <li><a class="reference internal" href="#poldectostring"><code class="docutils literal notranslate"><span class="pre">\PolDecToString{}</span></code></a></li>
2861 <li><a class="reference internal" href="#polexprsetup-key-val"><code class="docutils literal notranslate"><span class="pre">\polexprsetup{key=val,...}</span></code></a></li>
2862 </ul>
2863 </li>
2864 <li><a class="reference internal" href="#technicalities">Technicalities</a></li>
2865 </ul>
2866 </li>
2867 </ul>
2868
2869 <div role="note" aria-label="source link">
2870 <h3>This Page</h3>
2871 <ul class="this-page-menu">
2872 <li><a href="polexpr-ref.rst.txt"
2873 rel="nofollow">Show Source</a></li>
2874 </ul>
2875 </div>
2876 <div>
2877 <h4>Previous topic</h4>
2878 <p class="topless"><a href="polexpr.html"
2879 title="previous chapter">Introduction to polexpr</a></p>
2880 </div>
2881 <div>
2882 <h4>Next topic</h4>
2883 <p class="topless"><a href="polexpr-changes.html"
2884 title="next chapter">CHANGES</a></p>
2885 </div>
2886 </div>
2887 </div>
2888 <div class="clearer"></div>
2889 </div>
2890 <div class="related" role="navigation" aria-label="related navigation">
2891 <h3>Navigation</h3>
2892 <ul>
2893 <li class="right" style="margin-right: 10px">
2894 <a href="polexpr-changes.html" title="CHANGES"
2895 >next</a></li>
2896 <li class="right" >
2897 <a href="polexpr.html" title="Introduction to polexpr"
2898 >previous</a> |</li>
2899 <li class="nav-item nav-item-0"><a href="polexpr.html">polexpr 0.8.7a documentation</a> &#187;</li>
2900 <li class="nav-item nav-item-this"><a href="">polexpr reference</a></li>
2901 </ul>
2902 </div>
2903 <div class="footer" role="contentinfo">
2904 &#169; Copyright 2022, Jean-François Burnol.
2905 Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 5.0.0+/f58771c09.
2906 </div>
2907 </body>
2908 </html>