diff options
Diffstat (limited to 'macros/generic/polexpr/polexpr-ref.html')
-rw-r--r-- | macros/generic/polexpr/polexpr-ref.html | 2898 |
1 files changed, 2898 insertions, 0 deletions
diff --git a/macros/generic/polexpr/polexpr-ref.html b/macros/generic/polexpr/polexpr-ref.html new file mode 100644 index 0000000000..9f3767c48d --- /dev/null +++ b/macros/generic/polexpr/polexpr-ref.html @@ -0,0 +1,2898 @@ + +<!DOCTYPE html> + +<html lang="en"> + <head> + <meta charset="utf-8" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.18.1: http://docutils.sourceforge.net/" /> + + <title>polexpr reference — polexpr 0.8.7 documentation</title> + <link rel="stylesheet" type="text/css" href="polexpr.css" /> + <link rel="next" title="CHANGES" href="polexpr-changes.html" /> + <link rel="prev" title="Introduction to polexpr" href="polexpr.html" /> + </head><body> + <div class="related" role="navigation" aria-label="related navigation"> + <h3>Navigation</h3> + <ul> + <li class="right" style="margin-right: 10px"> + <a href="polexpr-changes.html" title="CHANGES" + accesskey="N">next</a></li> + <li class="right" > + <a href="polexpr.html" title="Introduction to polexpr" + accesskey="P">previous</a> |</li> + <li class="nav-item nav-item-0"><a href="polexpr.html">polexpr 0.8.7 documentation</a> »</li> + <li class="nav-item nav-item-this"><a href="">polexpr reference</a></li> + </ul> + </div> + + <div class="document"> + <div class="documentwrapper"> + <div class="bodywrapper"> + <div class="body" role="main"> + + <section id="polexpr-reference"> +<h1>polexpr reference</h1> +<section id="syntax-overview-via-examples"> +<span id="quick"></span><h2>Syntax overview via examples</h2> +<p>The syntax to define a new polynomial is:</p> +<div class="highlight-latex notranslate"><div class="highlight"><pre><span></span><span class="k">\poldef</span> polname(x):= expression in variable x; +</pre></div> +</div> +<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 +polynomial aware functions added to its syntax; they are described in +detail <a class="reference internal" href="#polexpr08"><span class="std std-ref">below</span></a>. The parser accepts and will handle +exactly arbitrarily big integers or fractions.</p> +<div class="admonition note"> +<p class="admonition-title">Note</p> +<p><a class="reference external" href="https://www.ctan.org/pkg/xintexpr">xintexpr</a> does not automatically reduce fractions to lowest terms, +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>. +See <a class="reference internal" href="#rdcoeffs"><span class="std std-ref">rdcoeffs()</span></a> and the macro +<a class="reference internal" href="#polreducecoeffs"><span class="std std-ref">\PolReduceCoeffs</span></a>.</p> +</div> +<ul class="simple"> +<li><p>In place of <code class="docutils literal notranslate"><span class="pre">x</span></code> an arbitrary <em>dummy variable</em> is authorized, +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 +under Unicode engines).</p></li> +<li><p><code class="docutils literal notranslate"><span class="pre">polname</span></code> consists of <em>letters</em>, <em>digits</em>, and also the <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 name <strong>must</strong> start with +a letter: do not use the underscore <code class="docutils literal notranslate"><span class="pre">_</span></code> as <em>first character</em> of a +polynomial name (even if of catcode letter). No warning is emitted +but dire consequences will ensue. The <code class="docutils literal notranslate"><span class="pre">@</span></code> is also allowed +(independently of its catcode “letter” or “other”, which does not +matter). It is recommended to avoid using it as first character, +except for temporary polynomial variables.</p></li> +<li><p>The colon before the equality sign is optional and its (reasonable) +catcode does not matter.</p></li> +<li><p>The semi-colon at the end of the expression is mandatory. It is not +allowed to arise from expansion (despite the fact that the expression +itself will be parsed using only expansion), it must be “visible” +immediately.</p></li> +</ul> +<p>There are some potential problems (refer to the <a class="reference internal" href="#technicalities">Technicalities</a> section at +bottom of this page) with the semi-colon as expression terminator, so an +alternative syntax is provided, which avoids it altogether:</p> +<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><polname><span class="nb">}{</span><expr. using letter as indeterminate><span class="nb">}</span> +</pre></div> +</div> +<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 +used as the indeterminate in the expression.</p> +<p>Examples:</p> +<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> +<dl> +<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 +expression, and they create internally macros serving to +incarnate the polynomial, its coefficients, and the associated +polynomial function.</p> +<p>The polynomial can then be used in further polynomial definitions, +be served as argument to package macros, or appear as a variable in +various functions <a class="reference internal" href="#polexpr08">described later</a>.</p> +<div class="admonition warning"> +<p class="admonition-title">Warning</p> +<p>Both the function <code class="docutils literal notranslate"><span class="pre">quo()</span></code> (as shown in the example above), and +the infix operator <code class="docutils literal notranslate"><span class="pre">/</span></code> are mapped to the Euclidean quotient.</p> +<p>This usage of <code class="docutils literal notranslate"><span class="pre">/</span></code> to stand for the Euclidean quotient is +<strong>deprecated</strong> and reserved for a (somewhat improbable) possible +extension of the package to handle rational functions as well.</p> +</div> +<div class="admonition attention" id="warningtacit"> +<p class="admonition-title">Attention</p> +<p>Tacit multiplication rules let the parser when encountering +<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>. +But then it gives zero, because <cite>/</cite> stands for the Euclidean +quotient operation here.</p> +<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 +<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 +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> +<span class="pre">x^3/3</span> <span class="pre">-</span> <span class="pre">...</span></code>.</p> +<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: +<a class="reference external" href="https://www.ctan.org/pkg/xintexpr">xintexpr</a>‘s tacit multiplication always “ties more”, hence this +gets interpreted as <code class="docutils literal notranslate"><span class="pre">1/(2*(x-1)*(x-2))</span></code> not as +<code class="docutils literal notranslate"><span class="pre">(1/2)*(x-1)*(x-2)</span></code> and then gives zero by +polynomial division. Thus, in such cases, use one of +<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> +</div> +<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>, +which can be used inside <code class="docutils literal notranslate"><span class="pre">\xinteval</span></code>, as:</p> +<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> +</pre></div> +</div> +<p>or even as:</p> +<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> +</pre></div> +</div> +<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, +if not a scalar, will then be printed as <code class="docutils literal notranslate"><span class="pre">pol([c0,c1,...])</span></code> which +stands for a polynomial variable having the listed coefficients; see +<a class="reference internal" href="#pol"><span class="std std-ref">pol()</span></a>.</p> +<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 +a <em>variable of polynomial type</em>, which serves as argument to +polynomial specific functions such as <a class="reference internal" href="#deg"><span class="std std-ref">deg()</span></a> or +<a class="reference internal" href="#polgcd"><span class="std std-ref">polgcd()</span></a>, or as argument to other polynomials (as +above), or even simply stands for its own in algebraic expressions +such as:</p> +<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; +</pre></div> +</div> +<p>Notice that in the above, the <code class="docutils literal notranslate"><span class="pre">(z)</span></code> part is mandatory, as it informs +<code class="docutils literal notranslate"><span class="pre">\poldef</span></code> of the letter used for the indeterminate. In the above +<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 +more efficient.</p> +<p>One needs to acquire a good understanding of when the symbol <code class="docutils literal notranslate"><span class="pre">P</span></code> +will stand for a function and when it will stand for a variable.</p> +<ul> +<li><p>If <code class="docutils literal notranslate"><span class="pre">P</span></code> and +<code class="docutils literal notranslate"><span class="pre">Q</span></code> are both declared polynomials then:</p> +<div class="highlight-latex notranslate"><div class="highlight"><pre><span></span>(P+Q)(3)<span class="c">% <--- attention, does (P+Q)*3, not P(3)+Q(3)</span> +</pre></div> +</div> +<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 +known as a <em>function</em>, but <em>only as a variable of polynomial +type</em>. Note that <a class="reference internal" href="#evalp"><span class="std std-ref">evalp(P+Q,3)</span></a> gives as expected +the same as <code class="docutils literal notranslate"><span class="pre">P(3)+Q(3)</span></code>.</p> +</li> +<li><p>Also:</p> +<div class="highlight-latex notranslate"><div class="highlight"><pre><span></span>(P)(3)<span class="c">% <--- attention, does P*3, not P(3)</span> +</pre></div> +</div> +<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 +enclose a function name in parentheses: consequently it is the variable +which is used here.</p> +</li> +</ul> +<p>There is a <em>meager possibility</em> that in future some internal changes +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 +<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 +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 +interpretation, looking more intuitive. Anyway, do not rely too +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 +is what is intended.</p> +</dd> +<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> +<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> +<span class="pre">g(w):=f(w);</span></code>.</p> +</dd> +<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 +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 +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> +<p>It may look strange that an indeterminate variable is used on +left-hand-side even though it may be absent of right-hand-side, as +it seems to define <code class="docutils literal notranslate"><span class="pre">f</span></code> always as a polynomial function.</p> +<p>This is a legacy of pre-<code class="docutils literal notranslate"><span class="pre">0.8</span></code> context.</p> +<div class="admonition important"> +<p class="admonition-title">Important</p> +<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 +perhaps unexpected result: first <code class="docutils literal notranslate"><span class="pre">f^2</span></code> is computed, then the +opening parenthesis is seen which inserts a tacit multiplication +<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>. +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 +computed as a polynomial <em>variable</em> and ceases being a function.</p> +</div> +</dd> +<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 +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> +</dd> +<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… +And <code class="docutils literal notranslate"><span class="pre">f-sqr(g(sqr(g)))</span></code> computes the same thing.</p> +<p>We can check this in a typeset document like this:</p> +<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> +<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> +<span class="k">\poldef</span> f(z):= f<span class="nb">^</span>2;<span class="c">%</span> +<span class="k">\poldef</span> f(T):= f(f);<span class="c">%</span> +<span class="k">\poldef</span> k(w):= f-sqr(g(sqr(g)));<span class="c">%</span> +<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> +<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> +<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> +<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> +</pre></div> +</div> +</dd> +<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> +</dd> +<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 +of <code class="docutils literal notranslate"><span class="pre">f</span></code>.</p> +<div class="admonition important"> +<p class="admonition-title">Important</p> +<p>This is not done automatically. If some new definition needs to use +the derivative of some available polynomial, that derivative +polynomial must have been previously defined: something such as +<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> +<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 +permanent declaration, so here <code class="docutils literal notranslate"><span class="pre">evalp(diff1(f),3)^2</span></code>. And +<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 +to be the derived polynomial.</p> +<p>Notice that the name <code class="docutils literal notranslate"><span class="pre">diff1()</span></code> is experimental and may change. Use +<code class="docutils literal notranslate"><span class="pre">\PolDiff{f}{f'}</span></code> as the stable interface.</p> +</div> +</dd> +<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> +<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> +<span class="k">\PolDiff</span><span class="nb">{</span>f<span class="nb">}{</span>f'<span class="nb">}</span><span class="k">\PolDiff</span><span class="nb">{</span>f'<span class="nb">}{</span>f''<span class="nb">}</span><span class="k">\PolDiff</span><span class="nb">{</span>f''<span class="nb">}{</span>f'''<span class="nb">}</span><span class="c">%</span> +<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> +<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> +<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> +<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="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> +</pre></div> +</div> +<p>See <a class="reference internal" href="#poltypeset">its documentation</a> for the configurability +via macros.</p> +<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 +expression, it does not have to be a pre-declared polynomial name:</p> +<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> +</pre></div> +</div> +</dd> +<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>) +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 +coefficient. The <code class="docutils literal notranslate"><span class="pre">+</span></code> signs are omitted if followed by negative +coefficients.</p> +<p>This is useful for console or file output. This syntax is Maple and +PSTricks <code class="docutils literal notranslate"><span class="pre">\psplot[algebraic]</span></code> compatible; and also it is +compatible with <code class="docutils literal notranslate"><span class="pre">\poldef</span></code> input syntax, of course. See +<a class="reference internal" href="#id69">\PolToExprCaret</a> for configuration of the <code class="docutils literal notranslate"><span class="pre">^</span></code>, for example to +use rather <code class="docutils literal notranslate"><span class="pre">**</span></code> for Python syntax compliance.</p> +<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 +so in a draft document one can use <code class="docutils literal notranslate"><span class="pre">\PolToExpr{P}</span></code> inside the +typesetting flow (without requiring math mode, where the <code class="docutils literal notranslate"><span class="pre">*</span></code> would +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; +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 +for math, except sometimes in monospace typeface, and anyhow TeX is +unable to break the expression across lines, barring special help).</p> +<p>See <a class="reference internal" href="#poltoexpr"><span class="std std-ref">\PolToExpr{<pol. expr.>}</span></a> and related macros for customization.</p> +<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 +polynomial variable but more generally any polynomial expression.</p> +</dd> +</dl> +</section> +<section id="using-defined-polynomials-in-floating-point-context"> +<h2>Using defined polynomials in floating point context</h2> +<p>Exact manipulations with fractional coefficients may quickly lead to +very large denominators. For numerical evaluations, it is advisable +to a use a floating point context. But for the polynomial to be +usable as a function in floating point context, an extra step beyond +<code class="docutils literal notranslate"><span class="pre">\poldef</span></code> is required: see <a class="reference internal" href="#polgenfloatvariant">\PolGenFloatVariant</a>. Then the +<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 +as a genuine function (with already float-rounded coefficients, and +using a Horner scheme).</p> +<p>But <a class="reference internal" href="#polgenfloatvariant">\PolGenFloatVariant</a> must be used each time the polynomial gets +redefined or a new polynomial is created out of it. Functions such as +for example <a class="reference internal" href="#deg"><span class="std std-ref">deg()</span></a> which handle the polynomial as an entity +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 +<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 +serve as a numerical function (and only after declaration via +<a class="reference internal" href="#polgenfloatvariant">\PolGenFloatVariant</a>), and not as a variable.</p> +<p>In some cases one may wish to replace a polynomial having acquired +very big fractional coefficients with a new one whose coefficients +have been float-rounded. See <a class="reference internal" href="#polmapcoeffs"><span class="std std-ref">\PolMapCoeffs</span></a> +which can be used for example with the <code class="docutils literal notranslate"><span class="pre">\xintFloat</span></code> macro from the +<a class="reference external" href="https://www.ctan.org/pkg/xint">xintfrac</a> package to achieve this.</p> +</section> +<section id="the-polexpr-0-8-extensions-to-the-xintexpr-syntax"> +<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> +<p>All the syntax elements described in this section can be used in the +<code class="docutils literal notranslate"><span class="pre">\xintexpr/\xinteval</span></code> context (where polynomials can be obtained from +the <code class="docutils literal notranslate"><span class="pre">pol([])</span></code> constructor, once polexpr is loaded): their usage is +not limited to only <code class="docutils literal notranslate"><span class="pre">\poldef</span></code> context.</p> +<div class="admonition note"> +<p class="admonition-title">Note</p> +<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 +to be a polynomial, the difference with those declared via <code class="docutils literal notranslate"><span class="pre">\poldef</span></code> +will be:</p> +<ol class="arabic"> +<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. +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 +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> +<li><p><code class="docutils literal notranslate"><span class="pre">myPol</span></code> is not known to the polexpr package, hence for example the +macros to achieve localization of its roots are unavailable.</p> +<p>In a parallel universe I perhaps have implemented this expandably +which means it could then be accessible with syntax such as +<code class="docutils literal notranslate"><span class="pre">rightmostroot(pol([42,1,34,2,-8,1]))</span></code> but…</p> +</li> +</ol> +</div> +<section id="warning-about-unstability-of-the-new-syntax"> +<h3>Warning about unstability of the new syntax</h3> +<div class="admonition warning"> +<p class="admonition-title">Warning</p> +<p>Consider the entirety of this section as <strong>UNSTABLE</strong> and +<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> +<p>And this applies even to items not explicitly flagged with one of +<strong>unstable</strong>, <strong>Unstable</strong>, or <strong>UNSTABLE</strong> which only reflect that +documentation was written over a period of time exceeding one minute, +enough for the author mood changes to kick in.</p> +<p>It is hard to find good names at the start of a life-long extension +program of functionalities, and perhaps in future it will be +preferred to rename everything or give to some functions other +meanings. Such quasi-complete renamings happened already a few times +during the week devoted to development.</p> +</div> +</section> +<section id="infix-operators"> +<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> +<blockquote> +<div><p>As has been explained in the <a class="reference internal" href="#syntax-overview-via-examples">Syntax overview via examples</a> +section these infix operators have been made polynomial aware, not +only in the <code class="docutils literal notranslate"><span class="pre">\poldef</span></code> context, but generally in any +<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> +<p>Conversely functions declared via <code class="docutils literal notranslate"><span class="pre">\xintdeffunc</span></code> and making use of +these operators will automatically be able to accept polynomials +declared from <code class="docutils literal notranslate"><span class="pre">\poldef</span></code> as variables.</p> +<p>Usage of <code class="docutils literal notranslate"><span class="pre">/</span></code> for euclidean division of polynomials is <strong>deprecated</strong>. +Only in case of a scalar denominator is it to be considered stable. +Please use rather <code class="docutils literal notranslate"><span class="pre">quo()</span></code>.</p> +</div></blockquote> +</section> +<section id="experimental-infix-operators"> +<h3>Experimental infix operators <code class="docutils literal notranslate"><span class="pre">//,</span> <span class="pre">/:</span></code></h3> +<blockquote> +<div><p>Here is the tentative behaviour of <code class="docutils literal notranslate"><span class="pre">A//B</span></code> according to types:</p> +<ul class="simple"> +<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> +<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> +<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> +<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 +coefficient floored division.</p></li> +</ul> +<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> +from <code class="docutils literal notranslate"><span class="pre">\xintexpr</span></code>.</p> +<p>The behaviour in the last case, but not only, is to be considerd +<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> +scalar to act as <code class="docutils literal notranslate"><span class="pre">quo(A,B)</span></code>. But, we have currently chosen to let +<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. +Beware that it thus means it can be employed with the idea of doing +euclidean division only by checking that <code class="docutils literal notranslate"><span class="pre">B</span></code> is non-scalar.</p> +<p>The <code class="docutils literal notranslate"><span class="pre">/:</span></code> operator provides the associated remainder so always +<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> +<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 +<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, +or is active, but note that <code class="docutils literal notranslate"><span class="pre">/:</span></code> is fine and needs no precaution if +<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 +problematic, like for all other characters possibly used in an +expression).</p> +<blockquote> +<div><p><strong>UNSTABLE</strong></p> +<p>As explained above, there are (among other things) hesitations +about behaviour with <code class="docutils literal notranslate"><span class="pre">pol2</span></code> a scalar.</p> +</div></blockquote> +</div></blockquote> +</section> +<section id="comparison-operators"> +<h3>Comparison 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> +<blockquote> +<div><p><strong>NOT YET IMPLEMENTED</strong></p> +<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 +fractions does not currently require them to be in reduced terms, +such operations would be a bit costly as they could not benefit from +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 +it yet anywhere, even for normalized pure integers, although it could +speed up signifcantly certain aspects of core arithmetic.</p> +<p>Equality of polynomials can currently be tested by computing the +difference, which is a bit costly. And of course the <code class="docutils literal notranslate"><span class="pre">deg()</span></code> +function allows comparing degrees. In this context note the +following syntax:</p> +<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> +</pre></div> +</div> +<p>for branching.</p> +</div></blockquote> +</section> +<section id="pol-nutple-expression"> +<span id="pol"></span><h3><code class="docutils literal notranslate"><span class="pre">pol(<nutple</span> <span class="pre">expression>)</span></code></h3> +<blockquote> +<div><p>This converts a nutple <code class="docutils literal notranslate"><span class="pre">[c0,c1,...,cN]</span></code> into the polynomial +variable having these coefficients. Attention that the square +brackets are <strong>mandatory</strong>, except of course if the argument is +actually an expression producing such a “nutple”.</p> +<blockquote> +<div><p>Currently, this process will not normalize the coefficients (such +as reducing to lowest terms), it only trims out the leading zero +coefficients.</p> +</div></blockquote> +<p>Inside <code class="docutils literal notranslate"><span class="pre">\xintexpr</span></code>, this is the only (allowed) way to create ex +nihilo a polynomial variable; inside <code class="docutils literal notranslate"><span class="pre">\poldef</span></code> it is an alternative +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> +<span class="pre">x^2</span> <span class="pre">+</span> <span class="pre">...</span></code>.</p> +</div></blockquote> +<div class="admonition important"> +<p class="admonition-title">Important</p> +<p>Whenever an expression with polynomials collapses to a constant, it +becomes a scalar. There is currently no distinction during the +parsing of expressions by <code class="docutils literal notranslate"><span class="pre">\poldef</span></code> +or <code class="docutils literal notranslate"><span class="pre">\xintexpr</span></code> between constant polynomial variables and scalar +variables.</p> +<p>Naturally, <code class="docutils literal notranslate"><span class="pre">\poldef</span></code> can be used to declare a constant polynomial +<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 +independent of argument, but as a variable, it is non-distinguishable +from a scalar (of course functions such as <code class="docutils literal notranslate"><span class="pre">deg()</span></code> tacitly +consider scalars to be constant polynomials).</p> +<p>Notice that we tend to use the vocable “variable” to refer to +arbitrary expressions used as function arguments, without implying +that we are actually referring to pre-declared variables in the sense +of <code class="docutils literal notranslate"><span class="pre">\xintdefvar</span></code>.</p> +</div> +</section> +<section id="lpol-nutple-expression"> +<span id="lpol"></span><h3><code class="docutils literal notranslate"><span class="pre">lpol(<nutple</span> <span class="pre">expression>)</span></code></h3> +<blockquote> +<div><p>This converts a nutple <code class="docutils literal notranslate"><span class="pre">[cN,...,c1,c0]</span></code> into the polynomial +variable having these coefficients, with leading coefficients coming +first in the input. Attention that the square brackets are +<strong>mandatory</strong>, except of course if the argument is actually an +expression producing such a “nutple”.</p> +<blockquote> +<div><p>Currently, this process will not normalize the coefficients (such +as reducing to lowest terms), it only trims out the leading zero +coefficients.</p> +<p><strong>NAME UNSTABLE</strong></p> +</div></blockquote> +<p>It can be used in <code class="docutils literal notranslate"><span class="pre">\poldef</span></code> as an alternative input syntax, which +is more efficient than using the algebraic notation with monomials.</p> +<p>(new with <code class="docutils literal notranslate"><span class="pre">0.8.1</span></code>, an empty nutple will cause breakage)</p> +</div></blockquote> +</section> +<section id="xinteval-pol-expr"> +<span id="xintevalpolexpr"></span><h3><code class="docutils literal notranslate"><span class="pre">\xinteval{<pol.</span> <span class="pre">expr.>}</span></code></h3> +<blockquote> +<div><p>This is documented here for lack of a better place: it evaluates the +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> +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> +<p>The “pol” word uses letter catcodes, which is actually mandatory for +this output to be usable as input, but it does not make sense to use +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 +executing <code class="docutils literal notranslate"><span class="pre">pol(coeffs(..expression..))</span></code> which is but a convoluted +way to obtain the same result as <code class="docutils literal notranslate"><span class="pre">(..expression..)</span></code> (the +parentheses delimiting the polynomial expression).</p> +<p>For example, <code class="docutils literal notranslate"><span class="pre">\xinteval{(1+pol([0,1]))^10}</span></code> expands (in two steps) +to:</p> +<div class="highlight-latex notranslate"><div class="highlight"><pre><span></span>pol([1, 10, 45, 120, 210, 252, 210, 120, 45, 10, 1]) +</pre></div> +</div> +<p>You do need loading polexpr for this, else of course <code class="docutils literal notranslate"><span class="pre">pol([])</span></code> +remains unknown to <code class="docutils literal notranslate"><span class="pre">\xinteval{}</span></code> as well as the polynomial algebra ! +This example can also be done as +<code class="docutils literal notranslate"><span class="pre">\xinteval{subs((1+x)^10,x=pol([0,1]))}</span></code>.</p> +<p>I hesitated using as output the polynomial notation as produced by +<a class="reference internal" href="#poltoexpr">\PolToExpr{}</a>, but finally opted for this.</p> +</div></blockquote> +</section> +<section id="evalp-pol-expr-pol-expr"> +<span id="evalp"></span><h3><code class="docutils literal notranslate"><span class="pre">evalp(<pol.</span> <span class="pre">expr.>,</span> <span class="pre"><pol.</span> <span class="pre">expr>)</span></code></h3> +<blockquote> +<div><p>Evaluates the first argument as a polynomial function of the +second. Usually the second argument will be scalar, but this is not +required:</p> +<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); +</pre></div> +</div> +<p>If the first argument is an already declared polynomial <code class="docutils literal notranslate"><span class="pre">P</span></code>, use +rather the functional form <code class="docutils literal notranslate"><span class="pre">P()</span></code> (which can accept a numerical as +well as polynomial argument) as it is more efficient.</p> +<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> +<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); +</pre></div> +</div> +<p>but the <code class="docutils literal notranslate"><span class="pre">evalp()</span></code> will use a Horner evaluation scheme which is +usually more efficient.</p> +<aside class="footnote brackets" id="id2" role="note"> +<span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#id1">1</a><span class="fn-bracket">]</span></span> +<p>by the way Maple uses the opposite, hence wrong, order +<code class="docutils literal notranslate"><span class="pre">subs(x=...,</span> <span class="pre">P)</span></code> but was written before computer science +reached the <a class="reference external" href="https://www.ctan.org/pkg/xintexpr">xintexpr</a> heights. However it makes validating +Maple results by polexpr sometimes cumbersome, but perhaps +they will update it at some point.</p> +</aside> +<blockquote> +<div><p><strong>name unstable</strong></p> +<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>? +<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> +<p>Life is so complicated when one asks questions. Not everybody does, +though, as is amply demonstrated these days.</p> +<p><strong>syntax unstable</strong></p> +<p>I am hesitating about permuting the order of the arguments.</p> +</div></blockquote> +</div></blockquote> +</section> +<section id="deg-pol-expr"> +<span id="deg"></span><h3><code class="docutils literal notranslate"><span class="pre">deg(<pol.</span> <span class="pre">expr.>)</span></code></h3> +<blockquote> +<div><p>Computes the degree.</p> +</div></blockquote> +<div class="admonition important"> +<p class="admonition-title">Important</p> +<p>As <code class="docutils literal notranslate"><span class="pre">\xintexpr</span></code> does not yet support infinities, the degree of +the zero polynomial is <code class="docutils literal notranslate"><span class="pre">-1</span></code>. Beware that this breaks additivity +of degrees, but <code class="docutils literal notranslate"><span class="pre">deg(P)<0</span></code> correctly detects the zero polynomial, +and <code class="docutils literal notranslate"><span class="pre">deg(P)<=0</span></code> detects scalars.</p> +</div> +</section> +<section id="coeffs-pol-expr"> +<h3><code class="docutils literal notranslate"><span class="pre">coeffs(<pol.</span> <span class="pre">expr.>)</span></code></h3> +<blockquote> +<div><p>Produces the nutple <code class="docutils literal notranslate"><span class="pre">[c0,c1,...,cN]</span></code> of coefficients. The highest +degree coefficient is always non zero (except for the zero +polynomial…).</p> +<blockquote> +<div><p><strong>name unstable</strong></p> +<p>I am considering in particular using <code class="docutils literal notranslate"><span class="pre">polcoeffs()</span></code> to avoid +having to overload <code class="docutils literal notranslate"><span class="pre">coeffs()</span></code> in future when matrix type +will be added to <a class="reference external" href="https://www.ctan.org/pkg/xintexpr">xintexpr</a>.</p> +</div></blockquote> +</div></blockquote> +</section> +<section id="lcoeffs-pol-expr"> +<span id="lcoeffs"></span><h3><code class="docutils literal notranslate"><span class="pre">lcoeffs(<pol.</span> <span class="pre">expr.>)</span></code></h3> +<blockquote> +<div><p>Produces the nutple <code class="docutils literal notranslate"><span class="pre">[cN,....,c1,c0]</span></code> of coefficients, starting +with the highest degree coefficient.</p> +<p>(new with <code class="docutils literal notranslate"><span class="pre">0.8.1</span></code>)</p> +</div></blockquote> +</section> +<section id="coeff-pol-expr-num-expr"> +<h3><code class="docutils literal notranslate"><span class="pre">coeff(<pol.</span> <span class="pre">expr.>,</span> <span class="pre"><num.</span> <span class="pre">expr.>)</span></code></h3> +<blockquote> +<div><p>As expected. Produces zero if the numerical index is negative or +higher than the degree.</p> +<blockquote> +<div><p><strong>name, syntax and output unstable</strong></p> +<p>I am hesitating with <code class="docutils literal notranslate"><span class="pre">coeff(n,pol)</span></code> syntax and also perhaps using +<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> +when matrix type will be added to <a class="reference external" href="https://www.ctan.org/pkg/xintexpr">xintexpr</a>.</p> +<p>The current behaviour is at odds with legacy +<a class="reference internal" href="#polnthcoeff"><span class="std std-ref">\PolNthCoeff{<polname>}{<index>}</span></a> regarding negative indices. +Accessing leading or sub-leading coefficients can be done with +other syntax, see <a class="reference internal" href="#lc-pol-expr">lc(<pol. expr.>)</a>, and in some contexts it +is useful to be able to rely on the fact that coefficients with +negative indices do vanish, so I am for time being maintaining this.</p> +</div></blockquote> +</div></blockquote> +</section> +<section id="lc-pol-expr"> +<span id="lc"></span><h3><code class="docutils literal notranslate"><span class="pre">lc(<pol.</span> <span class="pre">expr.>)</span></code></h3> +<blockquote> +<div><p>The leading coefficient. The same result can be obtained from +<code class="docutils literal notranslate"><span class="pre">coeffs(pol)[-1]</span></code>, which shows also how to generalize to access +sub-leading coefficients. See the <a class="reference external" href="https://www.ctan.org/pkg/xintexpr">xintexpr</a> documentation for +Python-like indexing syntax.</p> +</div></blockquote> +</section> +<section id="monicpart-pol-expr"> +<h3><code class="docutils literal notranslate"><span class="pre">monicpart(<pol.</span> <span class="pre">expr.>)</span></code></h3> +<blockquote> +<div><p>Divides by the leading coefficient, except that <code class="docutils literal notranslate"><span class="pre">monicpart(0)==0</span></code>.</p> +<blockquote> +<div><p><strong>unstable</strong></p> +<p>Currently the coefficients are reduced to lowest terms (contrarily +to legacy behaviour of <a class="reference internal" href="#polmakemonic">\PolMakeMonic</a>), and +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 +extracts powers of ten from numerator or denominator and stores +them internally separately. This is generally beneficial to +efficiency of multiplication.</p> +</div></blockquote> +</div></blockquote> +</section> +<section id="cont-pol-expr"> +<span id="cont"></span><h3><code class="docutils literal notranslate"><span class="pre">cont(<pol.</span> <span class="pre">expr.>)</span></code></h3> +<blockquote> +<div><p>The (fractional) greatest common divisor of the polynomial +coefficients. It is always produced as an irreducible (non-negative) +fraction. According to Gauss theorem the content of a product is the +product of the contents.</p> +<blockquote> +<div><p><strong>name and syntax unstable</strong></p> +<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 +macro <a class="reference internal" href="#policontent">\PolIContent</a>, whose name in 2018 was +chosen in relation to Maple’s function <code class="docutils literal notranslate"><span class="pre">icontent()</span></code>, possibly +because at that time I had not seen that Maple also had a +<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> +<p>It will change syntax if in future multivariate polynomials are +supported, and <code class="docutils literal notranslate"><span class="pre">icontent()</span></code> will then make a come-back.</p> +</div></blockquote> +</div></blockquote> +</section> +<section id="primpart-pol-expr"> +<h3><code class="docutils literal notranslate"><span class="pre">primpart(<pol.</span> <span class="pre">expr.>)</span></code></h3> +<blockquote> +<div><p>The quotient (except for the zero polynomial) by +<code class="docutils literal notranslate"><span class="pre">cont(<pol.</span> <span class="pre">expr.>)</span></code>. This is thus a polynomial with +integer coefficients having <code class="docutils literal notranslate"><span class="pre">1</span></code> as greatest common divisor. The +sign of the leading coefficient is the same as in the original.</p> +<p>And <code class="docutils literal notranslate"><span class="pre">primpart(0)==0</span></code>.</p> +<p>The trailing zeros of the integer coefficients are extracted +into a power of ten exponent part, in the internal representation.</p> +</div></blockquote> +</section> +<section id="quorem-pol-expr-pol-expr"> +<h3><code class="docutils literal notranslate"><span class="pre">quorem(<pol.</span> <span class="pre">expr.>,</span> <span class="pre"><pol.</span> <span class="pre">expr.>)</span></code></h3> +<blockquote> +<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 +<code class="docutils literal notranslate"><span class="pre">R</span></code> the remainder.</p> +<blockquote> +<div><p><strong>name unstable</strong></p> +<p><code class="docutils literal notranslate"><span class="pre">poldiv()</span></code>?</p> +</div></blockquote> +</div></blockquote> +</section> +<section id="quo-pol-expr-pol-expr"> +<h3><code class="docutils literal notranslate"><span class="pre">quo(<pol.</span> <span class="pre">expr.>,</span> <span class="pre"><pol.</span> <span class="pre">expr.>)</span></code></h3> +<blockquote> +<div><p>The euclidean quotient.</p> +<p>The deprecated <code class="docutils literal notranslate"><span class="pre">pol1/pol2</span></code> syntax computes the same polynomial.</p> +</div></blockquote> +</section> +<section id="rem-pol-expr-pol-expr"> +<h3><code class="docutils literal notranslate"><span class="pre">rem(<pol.</span> <span class="pre">expr.>,</span> <span class="pre"><pol.</span> <span class="pre">expr.>)</span></code></h3> +<blockquote> +<div><p>The euclidean remainder. If <code class="docutils literal notranslate"><span class="pre">pol2</span></code> is a (non-zero) scalar, this is +zero.</p> +<p>There is no infix operator associated to this, for lack of evident +notation. Please advise.</p> +<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 +degree at least one. But read the warning about it being unstable +even in that case.</p> +</div></blockquote> +</section> +<section id="prem-pol-expr-1-pol-expr-2"> +<span id="prem"></span><h3><code class="docutils literal notranslate"><span class="pre">prem(<pol.</span> <span class="pre">expr.</span> <span class="pre">1>,</span> <span class="pre"><pol.</span> <span class="pre">expr.</span> <span class="pre">2>)</span></code></h3> +<blockquote> +<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 +Euclidean remainder. Its description is:</p> +<ul> +<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> +<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 +leading coefficient of <code class="docutils literal notranslate"><span class="pre">pol2</span></code>,</p></li> +<li><p><code class="docutils literal notranslate"><span class="pre">f</span></code> is the number of non-zero coefficients in the euclidean +quotient, if <code class="docutils literal notranslate"><span class="pre">deg(pol2)>0</span></code> (even if the remainder vanishes).</p> +<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> +</li> +</ul> +<p>With these definitions one can show that if both <code class="docutils literal notranslate"><span class="pre">pol1</span></code> and +<code class="docutils literal notranslate"><span class="pre">pol2</span></code> have integer coefficients, then this is also the case of +<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 +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)>0</span></code>). +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 +coefficients polynomials.</p> +<div class="admonition hint"> +<p class="admonition-title">Hint</p> +<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> +(which may be faster, even with non integer coefficients) use +<code class="docutils literal notranslate"><span class="pre">subs(last(x)/first(x),x=prem(P,Q))</span></code> syntax as it avoids +computing <code class="docutils literal notranslate"><span class="pre">prem(P,Q)</span></code> twice. This does the trick both in +<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> +<p>However, as is explained in the <a class="reference external" href="https://www.ctan.org/pkg/xintexpr">xintexpr</a> documentation, using +such syntax in an <code class="docutils literal notranslate"><span class="pre">\xintdeffunc</span></code> is (a.t.t.o.w) illusory, due to +technicalities of how <code class="docutils literal notranslate"><span class="pre">subs()</span></code> gets converted into nested +expandable macros. One needs an auxiliary function like this:</p> +<div class="highlight-latex notranslate"><div class="highlight"><pre><span></span><span class="k">\xintdeffunc</span> lastoverfirst(x):=last(x)/first(x); +<span class="k">\xintdeffunc</span> myR(x)=lastoverfirst(prem(x)); +</pre></div> +</div> +<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 +once and compute a polynomial identical to the euclidean +remainder (internal representations of coefficients may differ).</p> +</div> +<p>In this case of integer coefficients polynomials, the polexpr +internal representation of the integer coefficients in the pseudo +remainder will be with unit denominators only if that was already the +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 +lowest terms is made prior or after computation).</p> +<p>Pay attention here that <code class="docutils literal notranslate"><span class="pre">b</span></code> is the <strong>absolute value</strong> of the +leading coefficient of <code class="docutils literal notranslate"><span class="pre">pol2</span></code>. Thus the coefficients of the +pseudo-remainder have the same signs as those of the standard +remainder. This diverges from Maple’s function with the same name.</p> +</div></blockquote> +</section> +<section id="divmod-pol-expr-1-pol-expr-2"> +<h3><code class="docutils literal notranslate"><span class="pre">divmod(<pol.</span> <span class="pre">expr.</span> <span class="pre">1>,</span> <span class="pre"><pol.</span> <span class="pre">expr.</span> <span class="pre">2>)</span></code></h3> +<blockquote> +<div><p>Overloads the scalar <code class="docutils literal notranslate"><span class="pre">divmod()</span></code> and associates it with the +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> +<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 +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> +non constant polynomials, this is the same as <code class="docutils literal notranslate"><span class="pre">quorem()</span></code>.</p> +<blockquote> +<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> +</div></blockquote> +</div></blockquote> +</section> +<section id="mod-pol-expr-1-pol-expr-2"> +<h3><code class="docutils literal notranslate"><span class="pre">mod(<pol.</span> <span class="pre">expr.</span> <span class="pre">1>,</span> <span class="pre"><pol.</span> <span class="pre">expr.</span> <span class="pre">2>)</span></code></h3> +<blockquote> +<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> +when the second argument <code class="docutils literal notranslate"><span class="pre">pol2</span></code> is of degree at least one.</p> +<blockquote> +<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> +</div></blockquote> +</div></blockquote> +</section> +<section id="polgcd-pol-expr-1-pol-expr-2"> +<h3><code class="docutils literal notranslate"><span class="pre">polgcd(<pol.</span> <span class="pre">expr.</span> <span class="pre">1>,</span> <span class="pre"><pol.</span> <span class="pre">expr.</span> <span class="pre">2>,</span> <span class="pre">...)</span></code></h3> +<blockquote> +<div><p>Evaluates to the greatest common polynomial divisor of all the +polynomial inputs. The output is a <strong>primitive</strong> (in particular, +with integer coefficients) polynomial. It is zero if and only if all +inputs vanish.</p> +<p>Attention, there must be either at least two polynomial variables, or +alternatively, only one argument which then must be a bracketed list +or some expression or variable evaluating to such a “nutple” whose +items are polynomials (see the documentation of the scalar <code class="docutils literal notranslate"><span class="pre">gcd()</span></code> +in <a class="reference external" href="https://www.ctan.org/pkg/xintexpr">xintexpr</a>).</p> +<blockquote> +<div><p>The two variable case could (and was, during development) have been +defined at user level like this:</p> +<div class="highlight-latex notranslate"><div class="highlight"><pre><span></span><span class="k">\xintdeffunc</span> polgcd<span class="nb">_</span>(P,Q):= + (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>; +<span class="k">\xintdeffunc</span> polgcd(P,Q):=polgcd<span class="nb">_</span>(primpart(P),primpart(Q));<span class="c">%</span> +</pre></div> +</div> +<p>This is basically what is done internally for two polynomials, up +to some internal optimizations.</p> +</div></blockquote> +<p><strong>UNSTABLE</strong></p> +<p>I hesitate between returning a <em>primitive</em> or a <em>monic</em> polynomial. +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 +coefficients, else it returns a monic polynomial, but this is +complicated technically for us to add such a check and would add +serious overhead.</p> +<p>Internally, computations are done using primitive +integer-coefficients polynomials (as can be seen in the function +template above). So I decided finally to output a primitive +polynomial, as one can always apply <code class="docutils literal notranslate"><span class="pre">monicpart()</span></code> to it.</p> +<p>Attention that this is at odds with behaviour of the legacy +<a class="reference internal" href="#polgcd">\PolGCD</a> (non expandable) macro.</p> +<aside class="footnote brackets" id="id4" role="note"> +<span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#id3">2</a><span class="fn-bracket">]</span></span> +<p>actually, only two polynomial arguments are allowed by Maple’s +<code class="docutils literal notranslate"><span class="pre">gcd()</span></code> as far as I know.</p> +</aside> +</div></blockquote> +</section> +<section id="resultant-pol-expr-1-pol-expr-2"> +<h3><code class="docutils literal notranslate"><span class="pre">resultant(<pol.</span> <span class="pre">expr.</span> <span class="pre">1>,</span> <span class="pre"><pol.</span> <span class="pre">expr.</span> <span class="pre">2>)</span></code></h3> +<blockquote> +<div><p>The resultant.</p> +<blockquote> +<div><p><strong>NOT YET IMPLEMENTED</strong></p> +</div></blockquote> +</div></blockquote> +</section> +<section id="disc-pol-expr"> +<h3><code class="docutils literal notranslate"><span class="pre">disc(<pol.</span> <span class="pre">expr.>)</span></code></h3> +<blockquote> +<div><p>The discriminant.</p> +<blockquote> +<div><p><strong>NOT YET IMPLEMENTED</strong></p> +</div></blockquote> +</div></blockquote> +</section> +<section id="polpowmod-pol-expr-1-num-expr-pol-expr-2"> +<h3><code class="docutils literal notranslate"><span class="pre">polpowmod(<pol.</span> <span class="pre">expr.</span> <span class="pre">1>,</span> <span class="pre"><num.</span> <span class="pre">expr.>,</span> <span class="pre"><pol.</span> <span class="pre">expr.</span> <span class="pre">2>)</span></code></h3> +<blockquote> +<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 +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> +<p>Attention that this is using the <code class="docutils literal notranslate"><span class="pre">mod()</span></code> operation, whose current +experimental status is as follows:</p> +<ul class="simple"> +<li><p>if <code class="docutils literal notranslate"><span class="pre">deg(pol2)>0</span></code>, the euclidean remainder operation,</p></li> +<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> +</ul> +<p><strong>UNSTABLE</strong></p> +<blockquote> +<div><p>This is currently implemented at high level via <code class="docutils literal notranslate"><span class="pre">\xintdeffunc</span></code> and +recursive definitions, which were copied over from a scalar example +in the <a class="reference external" href="https://www.ctan.org/pkg/xintexpr">xintexpr</a> manual:</p> +<div class="highlight-latex notranslate"><div class="highlight"><pre><span></span><span class="k">\xintdeffunc</span> polpowmod<span class="nb">_</span>(P, m, Q) := + isone(m)? + <span class="c">% m=1: return P modulo Q</span> + <span class="nb">{</span> mod(P,Q) <span class="nb">}</span> + <span class="c">% m > 1: test if odd or even and do recursive call</span> + <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> + <span class="nb">{</span> mod( sqr(polpowmod<span class="nb">_</span>(P, m//2, Q)), Q) <span class="nb">}</span> + <span class="nb">}</span> + ;<span class="c">%</span> +<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> +</pre></div> +</div> +<p>Negative exponents are not currently implemented.</p> +<p>For example:</p> +<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> +<span class="k">\xinteval</span><span class="nb">{</span>subs(polpowmod(1+x,20,10), x=pol([0,1]))<span class="nb">}</span> +</pre></div> +</div> +<p>produce respectively:</p> +<div class="highlight-latex notranslate"><div class="highlight"><pre><span></span>pol([1, 100, 4950, 161700, 3921225, 75287520, 1192052400]) +pol([1, 0, 0, 0, 5, 4, 0, 0, 0, 0, 6, 0, 0, 0, 0, 4, 5, 0, 0, 0, 1]) +</pre></div> +</div> +</div></blockquote> +</div></blockquote> +</section> +<section id="rdcoeffs-pol-expr"> +<span id="rdcoeffs"></span><h3><code class="docutils literal notranslate"><span class="pre">rdcoeffs(<pol.</span> <span class="pre">expr.>)</span></code></h3> +<blockquote> +<div><p>This operates on the internal representation of the coefficients, +reducing them to lowest terms.</p> +<blockquote> +<div><p><strong>name HIGHLY undecided</strong></p> +</div></blockquote> +</div></blockquote> +</section> +<section id="rdzcoeffs-pol-expr"> +<h3><code class="docutils literal notranslate"><span class="pre">rdzcoeffs(<pol.</span> <span class="pre">expr.>)</span></code></h3> +<blockquote> +<div><p>This operates on the internal representation of the coefficients, +reducing them to lowest terms then extracting from numerator +or denominator the maximal power of ten to store as a decimal +exponent.</p> +<p>This is sometimes favourable to more efficient polynomial algebra +computations.</p> +<blockquote> +<div><p><strong>name HIGHLY undecided</strong></p> +</div></blockquote> +</div></blockquote> +</section> +<section id="diff1-pol-expr"> +<h3><code class="docutils literal notranslate"><span class="pre">diff1(<pol.</span> <span class="pre">expr.>)</span></code></h3> +<blockquote> +<div><p>The first derivative.</p> +<blockquote> +<div><p><strong>name UNSTABLE</strong></p> +<p>This name may be used in future to be the partial derivative with +respect to a first variable.</p> +</div></blockquote> +</div></blockquote> +</section> +<section id="diff2-pol-expr"> +<h3><code class="docutils literal notranslate"><span class="pre">diff2(<pol.</span> <span class="pre">expr.>)</span></code></h3> +<blockquote> +<div><p>The second derivative.</p> +<blockquote> +<div><p><strong>name UNSTABLE</strong></p> +<p>This name may be used in future to be the partial derivative with +respect to a second variable.</p> +</div></blockquote> +</div></blockquote> +</section> +<section id="diffn-pol-expr-p-num-expr-n"> +<h3><code class="docutils literal notranslate"><span class="pre">diffn(<pol.</span> <span class="pre">expr.</span> <span class="pre">P>,</span> <span class="pre"><num.</span> <span class="pre">expr.</span> <span class="pre">n>)</span></code></h3> +<blockquote> +<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<0</span></code> computes iterated primitives +vanishing at the origin.</p> +<p>The coefficients are not reduced to lowest terms.</p> +<blockquote> +<div><p><strong>name and syntax UNSTABLE</strong></p> +<p>I am also considering reversing the order of the arguments.</p> +</div></blockquote> +</div></blockquote> +</section> +<section id="antider-pol-expr-p"> +<h3><code class="docutils literal notranslate"><span class="pre">antider(<pol.</span> <span class="pre">expr.</span> <span class="pre">P>)</span></code></h3> +<blockquote> +<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> +</div></blockquote> +</section> +<section id="intfrom-pol-expr-p-pol-expr-c"> +<h3><code class="docutils literal notranslate"><span class="pre">intfrom(<pol.</span> <span class="pre">expr.</span> <span class="pre">P>,</span> <span class="pre"><pol.</span> <span class="pre">expr.</span> <span class="pre">c>)</span></code></h3> +<blockquote> +<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> +<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> +this will give zero!</p> +<blockquote> +<div><p><strong>UNSTABLE</strong></p> +<p>Allowing general polynomial variable for <code class="docutils literal notranslate"><span class="pre">c</span></code> adds a bit of +overhead to the case of a pure scalar. So I am hesitating +maintaining this feature whose interest appears dubious.</p> +</div></blockquote> +<div class="admonition attention"> +<p class="admonition-title">Attention</p> +<p>As the two arguments are both allowed to be polynomials, if by +inadvertance one exchanges the two, there is no error but the +meaning of <code class="docutils literal notranslate"><span class="pre">intfrom(c,P)</span></code> is completely otherwise, as it +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> +<div class="highlight-latex notranslate"><div class="highlight"><pre><span></span>>>> <span class="nb">&</span>pol +pol mode (i.e. function definitions use <span class="k">\poldef</span>) +>>> P(x):=1+x<span class="nb">^</span>2; +P = x<span class="nb">^</span>2+1 + --> <span class="nb">&</span>GenFloat(P) lets P become usable as function in fp mode + --> <span class="nb">&</span>ROOTS(P) (resp. <span class="nb">&</span>ROOTS(P,N)) finds all rational roots exactly and + all irrational roots with at least 10 (resp. N) fractional digits +>>> intfrom(P,1); +@<span class="nb">_</span>1 pol([-4/3, 1, 0, 1/3]) +>>> intfrom(1,P); +@<span class="nb">_</span>2 pol([-1, 1, -1]) +>>> <span class="nb">&</span>bye +</pre></div> +</div> +</div> +</div></blockquote> +</section> +<section id="integral-pol-expr-p-pol-expr-a-pol-expr-b"> +<h3><code class="docutils literal notranslate"><span class="pre">integral(<pol.</span> <span class="pre">expr.</span> <span class="pre">P>,</span> <span class="pre">[<pol.</span> <span class="pre">expr.</span> <span class="pre">a>,</span> <span class="pre"><pol.</span> <span class="pre">expr.</span> <span class="pre">b>])</span></code></h3> +<blockquote> +<div><p><code class="docutils literal notranslate"><span class="pre">\int_a^b</span> <span class="pre">P(t)dt</span></code>.</p> +<div class="admonition warning"> +<p class="admonition-title">Warning</p> +<p>The brackets here are not denoting an optional argument but a +<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 +recoverable-from error check is done on the input syntax. The +input can be an <a class="reference external" href="https://www.ctan.org/pkg/xintexpr">xintexpr</a> variable which happens to be a nutple +with two items, or any expression which evaluates to such a +nutple.</p> +</div> +<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 +be themselves polynomial variables or even polynomial expressions.</p> +<blockquote> +<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 +<code class="docutils literal notranslate"><span class="pre">intfrom(x-1)</span></code>.</p> +<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> +<p><strong>UNSTABLE</strong></p> +<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 +overhead to the pure scalar case ?</p> +</div></blockquote> +</div></blockquote> +</section> +</section> +<section id="non-expandable-macros"> +<h2>Non-expandable macros</h2> +<div class="admonition note"> +<p class="admonition-title">Note</p> +<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 +LaTeX. Some examples given in this section may be using LaTeX syntax +such as <code class="docutils literal notranslate"><span class="pre">\renewcommand</span></code>.</p> +</div> +<section id="poldef-polname-letter-expression-using-the-letter-as-indeterminate"> +<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> +<blockquote> +<div><p>This evaluates the <em>polynomial expression</em> and stores the +coefficients in a private structure accessible later via other +package macros, used with argument <code class="docutils literal notranslate"><span class="pre">polname</span></code>. Of course the +<em>expression</em> can make use of previously defined polynomials.</p> +<p>Polynomial names must start with a letter and are constituted of +letters, digits, underscores and the right tick <code class="docutils literal notranslate"><span class="pre">'</span></code>.</p> +<p>The whole <a class="reference external" href="https://www.ctan.org/pkg/xintexpr">xintexpr</a> syntax is authorized, as long as the final +result is of polynomial type:</p> +<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); +</pre></div> +</div> +<p>With fractional coefficients, beware the <a class="reference internal" href="#warningtacit">tacit multiplication issue</a>.</p> +<p>Furthermore:</p> +<ul class="simple"> +<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> +as well as in <code class="docutils literal notranslate"><span class="pre">\xinteval</span></code> for algebraic computations or as +argument to polynomial aware functions,</p></li> +<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> +as well as in <code class="docutils literal notranslate"><span class="pre">\xinteval</span></code>. It accepts there as argument scalars +and also other polynomials (via their names, thanks to previous +item).</p></li> +</ul> +<p>Notice that any function defined via <code class="docutils literal notranslate"><span class="pre">\xintdeffunc</span></code> and using +only algebraic operations (and ople indexing or slicing operations) +should work fine in <code class="docutils literal notranslate"><span class="pre">\xintexpr/\xinteval</span></code> with such polynomial +names as argument.</p> +<p>In the case of a constant polynomial, the <a class="reference external" href="https://www.ctan.org/pkg/xintexpr">xintexpr</a> variable (not the +internal data structure on which the package macros operate) +associated to it is indistinguishable from a scalar, it is actually +a scalar and has lost all traces from its origins as a polynomial +(so for example can be used as argument to the <code class="docutils literal notranslate"><span class="pre">cos()</span></code> function).</p> +<p>The <em>function</em> on the other hand remains a one-argument function, +which simply has a constant value.</p> +<div class="admonition attention"> +<p class="admonition-title">Attention</p> +<p>The function <code class="docutils literal notranslate"><span class="pre">polname()</span></code> is defined <strong>only</strong> for +<code class="docutils literal notranslate"><span class="pre">\xintexpr/\xinteval</span></code> +context. It will be unknown to <code class="docutils literal notranslate"><span class="pre">\xintfloateval</span></code>.</p> +<p>Worse, a +previously existing floating point function of the same name will +be let undefined again, to avoid hard to debug mismatches between +exact and floating point polynomials. This also applies when the +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 +as result of usage of the other package macros.</p> +<p>See <a class="reference internal" href="#polgenfloatvariant"><span class="std std-ref">\PolGenFloatVariant{<polname>}</span></a> to generate a <strong>function</strong> +usable in <code class="docutils literal notranslate"><span class="pre">\xintfloateval</span></code>.</p> +</div> +<div class="admonition attention"> +<p class="admonition-title">Attention</p> +<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 +generate low-level errors because the infix operators there are +not polynomial-aware, and the polynomial specific functions such +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> +<p>In short, currently polynomials defined via <code class="docutils literal notranslate"><span class="pre">polexpr</span></code> can +be used in floating point context only for numerical evaluations, +via <strong>functions</strong> obtained from <a class="reference internal" href="#polgenfloatvariant"><span class="std std-ref">\PolGenFloatVariant{<polname>}</span></a> +usage.</p> +<p>Changes to the original polynomial via package macros are not +automatically mapped to the numerical floating point evaluator +which must be manually updated as necessary when the original +rational coefficient polynomial is modified.</p> +</div> +<p>The original expression is lost after parsing, and in particular the +package provides no way to typeset it (of course the package +provides macros to typeset the computed polynomial). Typesetting +the original expression has to be done manually, if needed.</p> +</div></blockquote> +</section> +<section id="poldef-letter-polname-expr-using-the-letter-as-indeterminate"> +<span id="id5"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolDef[<letter>]{<polname>}{<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>}</span></code></h3> +<blockquote> +<div><p>Does the same as <a class="reference internal" href="#poldef">\poldef</a> in an undelimited macro +format, the main interest is to avoid potential problems with the +catcode of the semi-colon in presence of some packages. In absence +of a <code class="docutils literal notranslate"><span class="pre">[<letter>]</span></code> optional argument, the variable is assumed to be +<code class="docutils literal notranslate"><span class="pre">x</span></code>.</p> +</div></blockquote> +</section> +<section id="polgenfloatvariant"> +<span id="id6"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolGenFloatVariant{}</span></code></h3> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolGenFloatVariant{<polname>}</span></code></p> +<blockquote> +<div><p>Makes the polynomial also usable in the +<code class="docutils literal notranslate"><span class="pre">\xintfloatexpr/\xintfloateval</span></code> parser. It will therein evaluates +via an Horner scheme using polynomial coefficients already +pre-rounded to the float precision.</p> +<p>See also <a class="reference internal" href="#poltofloatexpr"><span class="std std-ref">\PolToFloatExpr{<pol. expr.>}</span></a>.</p> +<div class="admonition attention"> +<p class="admonition-title">Attention</p> +<p>Any operation, for example generating the derivative polynomial, +or dividing two polynomials or using the <code class="docutils literal notranslate"><span class="pre">\PolLet</span></code>, must be +followed by explicit usage of <code class="docutils literal notranslate"><span class="pre">\PolGenFloatVariant{<polname>}</span></code> if +the new polynomial is to be used in <code class="docutils literal notranslate"><span class="pre">\xintfloateval</span></code>.</p> +</div> +</div></blockquote> +</section> +<section id="poltypeset"> +<span id="id7"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolTypeset{}</span></code></h3> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolTypeset{<pol.</span> <span class="pre">expr.>}</span></code></p> +<blockquote> +<div><p>Typesets in descending powers, switching to math mode if in text +mode, after evaluating the polynomial expression:</p> +<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> +</pre></div> +</div> +<p>The letter used in the input expression is by default <code class="docutils literal notranslate"><span class="pre">x</span></code>, +but can be modified by a redefinition of <a class="reference internal" href="#id67">\PolToExprInVar</a>.</p> +<p>It uses also by default the letter <code class="docutils literal notranslate"><span class="pre">x</span></code> on output but this one can +be changed via an optional argument:</p> +<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> +</pre></div> +</div> +<p>By default zero coefficients are skipped (use <code class="docutils literal notranslate"><span class="pre">\poltypesetalltrue</span></code> +to get all of them in output).</p> +<p>The following macros (whose meanings will be found in the package code) +can be re-defined for customization. Their default definitions are +expandable, but this is not a requirement.</p> +</div></blockquote> +<section id="poltypesetcmd"> +<span id="id8"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolTypesetCmd{}</span></code></h4> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolTypesetCmd{<raw_coeff>}</span></code></p> +<blockquote> +<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> +and then skips printing the <code class="docutils literal notranslate"><span class="pre">1</span></code>, except for the coefficient of +degree zero. Also it sets the conditional deciding behaviour of +<a class="reference internal" href="#polifcoeffisplusorminusone"><span class="std std-ref">\PolIfCoeffIsPlusOrMinusOne{T}{F}</span></a>.</p> +<p>The actual printing of the coefficients, when not equal to plus or +minus one, is handled by <a class="reference internal" href="#poltypesetone"><span class="std std-ref">\PolTypesetOne{<raw_coeff>}</span></a>.</p> +</div></blockquote> +<section id="polifcoeffisplusorminusone"> +<span id="id9"></span><h5><code class="docutils literal notranslate"><span class="pre">\PolIfCoeffIsPlusOrMinusOne{}{}</span></code></h5> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolIfCoeffIsPlusOrMinusOne{T}{F}</span></code></p> +<blockquote> +<div><p>This macro is a priori undefined.</p> +<p>It is defined via the default <a class="reference internal" href="#poltypesetcmd"><span class="std std-ref">\PolTypesetCmd{<raw_coeff>}</span></a> to be +used if needed in the execution of <a class="reference internal" href="#id11">\PolTypesetMonomialCmd</a>, +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 +the coefficient is not plus or minus one.</p> +<p>The macro will execute <code class="docutils literal notranslate"><span class="pre">T</span></code> if the coefficient has been found to be +plus or minus one, and <code class="docutils literal notranslate"><span class="pre">F</span></code> if not. It chooses expandably between +<code class="docutils literal notranslate"><span class="pre">T</span></code> and <code class="docutils literal notranslate"><span class="pre">F</span></code>.</p> +</div></blockquote> +</section> +</section> +<section id="poltypesetone"> +<span id="id10"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolTypesetOne{}</span></code></h4> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolTypesetOne{<raw_coeff>}</span></code></p> +<blockquote> +<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> +(else). But these <a class="reference external" href="https://www.ctan.org/pkg/xint">xintfrac</a> old legacy macros are a bit +annoying as they insist in exhibiting a power of ten rather than +using simpler decimal notation.</p> +<p>As alternative, one can do definitions such as:</p> +<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> +<span class="c">% or with LaTeX+siunitx for example</span> +<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> +<span class="c">% (as \num of siunitx understands floating point notation)</span> +<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> +</pre></div> +</div> +</div></blockquote> +</section> +<section id="poltypesetmonomialcmd"> +<span id="id11"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolTypesetMonomialCmd</span></code></h4> +<blockquote> +<div><p>This decides how a monomial (in variable <code class="docutils literal notranslate"><span class="pre">\PolVar</span></code> and with +exponent <code class="docutils literal notranslate"><span class="pre">\PolIndex</span></code>) is to be printed. The default does nothing +for the constant term, <code class="docutils literal notranslate"><span class="pre">\PolVar</span></code> for the first degree and +<code class="docutils literal notranslate"><span class="pre">\PolVar^{\PolIndex}</span></code> for higher degrees monomials. Beware that +<code class="docutils literal notranslate"><span class="pre">\PolIndex</span></code> expands to digit tokens and needs termination in +<code class="docutils literal notranslate"><span class="pre">\ifnum</span></code> tests.</p> +</div></blockquote> +</section> +<section id="poltypesetcmdprefix"> +<span id="id12"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolTypesetCmdPrefix{}</span></code></h4> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolTypesetCmdPrefix{<raw_coeff>}</span></code></p> +<blockquote> +<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 +nothing if <code class="docutils literal notranslate"><span class="pre">raw_coeff</span></code> is negative, as in latter case the +<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 +<a class="reference internal" href="#poltypesetcmd"><span class="std std-ref">\PolTypesetCmd{<raw_coeff>}</span></a> will put the <code class="docutils literal notranslate"><span class="pre">-</span></code> sign in front of +the fraction (if it is a fraction) and this will thus serve as +separator in the typeset formula. Not used for the first term.</p> +</div></blockquote> +</section> +</section> +<section id="id13"> +<span id="id14"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolTypeset*{}</span></code></h3> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolTypeset*{<pol.</span> <span class="pre">expr.>}</span></code></p> +<blockquote> +<div><p>Typesets in ascending powers. Use <code class="docutils literal notranslate"><span class="pre">[<letter>]</span></code> optional argument +(after the <code class="docutils literal notranslate"><span class="pre">*</span></code>) to use another letter than <code class="docutils literal notranslate"><span class="pre">x</span></code>.</p> +<p>Extended at <code class="docutils literal notranslate"><span class="pre">0.8</span></code> to accept general expressions and not only +polynomial names. Redefine <a class="reference internal" href="#id67">\PolToExprInVar</a> to use in the +expression another letter than default <code class="docutils literal notranslate"><span class="pre">x</span></code>.</p> +</div></blockquote> +</section> +<section id="pollet"> +<span id="id15"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolLet{}={}</span></code></h3> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolLet{<polname_2>}={<polname_1>}</span></code></p> +<blockquote> +<div><p>Makes a copy of the already defined polynomial <code class="docutils literal notranslate"><span class="pre">polname_1</span></code> to a +new one <code class="docutils literal notranslate"><span class="pre">polname_2</span></code>. This has the same effect as +<code class="docutils literal notranslate"><span class="pre">\PolDef{<polname_2>}{<polname_1>(x)}</span></code> or (better) +<code class="docutils literal notranslate"><span class="pre">\PolDef{<polname_2>}{<polname_1>}</span></code> but with less overhead. The +<code class="docutils literal notranslate"><span class="pre">=</span></code> is optional.</p> +</div></blockquote> +</section> +<section id="polgloballet"> +<span id="id16"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolGlobalLet{}={}</span></code></h3> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolGlobalLet{<polname_2>}={<polname_1>}</span></code></p> +<blockquote> +<div><p>Acts globally.</p> +</div></blockquote> +</section> +<section id="polassign-toarray"> +<span id="polassign"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolAssign{}\toarray{}</span></code></h3> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolAssign{<polname>}\toarray{<\macro>}</span></code></p> +<blockquote> +<div><p>Defines a one-argument expandable macro <code class="docutils literal notranslate"><span class="pre">\macro{#1}</span></code> which expands +to the (raw) #1th polynomial coefficient.</p> +<ul class="simple"> +<li><p>Attention, coefficients here are indexed starting at 1. This is +an unfortunate legacy situation related to the original indexing +convention in <a class="reference external" href="https://www.ctan.org/pkg/xint">xinttools</a> arrays.</p></li> +<li><p>With #1=-1, -2, …, <code class="docutils literal notranslate"><span class="pre">\macro{#1}</span></code> returns leading coefficients.</p></li> +<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> +for non-zero polynomials.</p></li> +<li><p>Out-of-range #1’s return <code class="docutils literal notranslate"><span class="pre">0/1[0]</span></code>.</p></li> +</ul> +<p>See also <a class="reference internal" href="#polnthcoeff"><span class="std std-ref">\PolNthCoeff{<polname>}{<index>}</span></a>.</p> +</div></blockquote> +</section> +<section id="polget-fromarray"> +<span id="polget"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolGet{}\fromarray{}</span></code></h3> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolGet{<polname>}\fromarray{<\macro>}</span></code></p> +<blockquote> +<div><p>Does the converse operation to +<code class="docutils literal notranslate"><span class="pre">\PolAssign{<polname>}\toarray\macro</span></code>. Each individual +<code class="docutils literal notranslate"><span class="pre">\macro{<value>}</span></code> gets expanded in an <code class="docutils literal notranslate"><span class="pre">\edef</span></code> and then normalized +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> +<p>The leading zeros are removed from the polynomial.</p> +<p>(contrived) Example:</p> +<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> +<span class="k">\PolGet</span><span class="nb">{</span>f<span class="nb">}</span><span class="k">\fromarray\foo</span> +</pre></div> +</div> +<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> +</div></blockquote> +</section> +<section id="polfromcsv"> +<span id="id17"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolFromCSV{}{}</span></code></h3> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolFromCSV{<polname>}{<csv>}</span></code></p> +<blockquote> +<div><p>Defines a polynomial directly from the comma separated list of values +(or a macro expanding to such a list) of its coefficients, the <em>first +item</em> gives the constant term, the <em>last item</em> gives the leading +coefficient, except if zero, then it is dropped (iteratively). List +items are each expanded in an <code class="docutils literal notranslate"><span class="pre">\edef</span></code> and then put into normalized +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> +<p>As leading zero coefficients are removed:</p> +<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> +</pre></div> +</div> +<p>defines the zero polynomial, which holds only one coefficient.</p> +<p>See also expandable macro <a class="reference internal" href="#poltocsv"><span class="std std-ref">\PolToCSV{<polname>}</span></a>.</p> +</div></blockquote> +</section> +<section id="polmapcoeffs"> +<span id="id18"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolMapCoeffs{}{}</span></code></h3> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolMapCoeffs{\macro}{<polname>}</span></code></p> +<blockquote> +<div><p>It modifies (‘in-place’: original coefficients get lost) each +coefficient of the defined polynomial via the <em>expandable</em> macro +<code class="docutils literal notranslate"><span class="pre">\macro</span></code>. The degree is adjusted as necessary if some leading +coefficients vanish after the operation.</p> +<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 +coefficient index (starting at zero for the constant term).</p> +<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> +internal format. This means that it probably will have to be +expressed in terms of macros from the <a class="reference external" href="https://www.ctan.org/pkg/xint">xintfrac</a> package.</p> +<p>Example:</p> +<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> +</pre></div> +</div> +<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 +<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> +</div></blockquote> +</section> +<section id="polreducecoeffs"> +<span id="id19"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolReduceCoeffs{}</span></code></h3> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolReduceCoeffs{<polname>}</span></code></p> +<blockquote> +<div><p>Reduces the internal representations of the coefficients to +their lowest terms.</p> +</div></blockquote> +</section> +<section id="id20"> +<span id="id21"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolReduceCoeffs*{}</span></code></h3> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolReduceCoeffs*{<polname>}</span></code></p> +<blockquote> +<div><p>Reduces the internal representations of the coefficients to their +lowest terms, but ignoring a possible separated “power of ten part”.</p> +<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 +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> +(or rather whatever <a class="reference external" href="https://www.ctan.org/pkg/xint">xintfrac</a> uses for internal representation), and +not by <code class="docutils literal notranslate"><span class="pre">60</span></code> as would result from complete reduction.</p> +<p>Evaluations with polynomials treated by this can be much faster than +with those handled by the non-starred variant +<a class="reference internal" href="#polreducecoeffs"><span class="std std-ref">\PolReduceCoeffs{<polname>}</span></a>: as the numerators and denominators +remain generally smaller.</p> +</div></blockquote> +</section> +<section id="polmakemonic"> +<span id="id22"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolMakeMonic{}</span></code></h3> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolMakeMonic{<polname>}</span></code></p> +<blockquote> +<div><p>Divides by the leading coefficient. It is recommended to execute +<a class="reference internal" href="#id20"><span class="std std-ref">\PolReduceCoeffs*{<polname>}</span></a> immediately afterwards. This is not +done automatically, in case the original polynomial had integer +coefficients and the user wants to keep the leading one as common +denominator for typesetting purposes.</p> +</div></blockquote> +</section> +<section id="polmakeprimitive"> +<span id="id23"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolMakePrimitive{}</span></code></h3> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolMakePrimitive{<polname>}</span></code></p> +<blockquote> +<div><p>Divides by the integer content see (<a class="reference internal" href="#policontent">\PolIContent</a>). +This thus produces a polynomial with integer +coefficients having no common factor. The sign of the leading +coefficient is not modified.</p> +</div></blockquote> +</section> +<section id="poldiff"> +<span id="id24"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolDiff{}{}</span></code></h3> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolDiff{<polname_1>}{<polname_2>}</span></code></p> +<blockquote> +<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 +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> +by <code class="docutils literal notranslate"><span class="pre">f'</span></code>.</p> +<p>Coefficients of the result <code class="docutils literal notranslate"><span class="pre">polname_2</span></code> are irreducible fractions +(see <a class="reference internal" href="#technicalities">Technicalities</a> for the whole story.)</p> +</div></blockquote> +</section> +<section id="id25"> +<span id="id26"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolDiff[]{}{}</span></code></h3> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolDiff[N]{<polname_1>}{<polname_2>}</span></code></p> +<blockquote> +<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>. +Identical arguments is allowed. With <code class="docutils literal notranslate"><span class="pre">N=0</span></code>, same effect as +<code class="docutils literal notranslate"><span class="pre">\PolLet{<polname_2>}={<polname_1>}</span></code>. With negative <code class="docutils literal notranslate"><span class="pre">N</span></code>, switches to +using <code class="docutils literal notranslate"><span class="pre">\PolAntiDiff</span></code>.</p> +</div></blockquote> +</section> +<section id="polantidiff"> +<span id="id27"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolAntiDiff{}{}</span></code></h3> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolAntiDiff{<polname_1>}{<polname_2>}</span></code></p> +<blockquote> +<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 +at zero.</p> +<p>Coefficients of the result <code class="docutils literal notranslate"><span class="pre">polname_2</span></code> are irreducible fractions +(see <a class="reference internal" href="#technicalities">Technicalities</a> for the whole story.)</p> +</div></blockquote> +</section> +<section id="id28"> +<span id="id29"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolAntiDiff[]{}{}</span></code></h3> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolAntiDiff[N]{<polname_1>}{<polname_2>}</span></code></p> +<blockquote> +<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 +<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> +</div></blockquote> +</section> +<section id="poldivide"> +<span id="id30"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolDivide{}{}{}{}</span></code></h3> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolDivide{<polname_1>}{<polname_2>}{<polname_Q>}{<polname_R>}</span></code></p> +<blockquote> +<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 +remainder in the Euclidean division 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> +</div></blockquote> +</section> +<section id="polquo"> +<span id="id31"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolQuo{}{}{}</span></code></h3> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolQuo{<polname_1>}{<polname_2>}{<polname_Q>}</span></code></p> +<blockquote> +<div><p>This sets <code class="docutils literal notranslate"><span class="pre">polname_Q</span></code> to be the quotient in the Euclidean division +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> +</div></blockquote> +</section> +<section id="polrem"> +<span id="id32"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolRem{}{}{}</span></code></h3> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolRem{<polname_1>}{<polname_2>}{<polname_R>}</span></code></p> +<blockquote> +<div><p>This sets <code class="docutils literal notranslate"><span class="pre">polname_R</span></code> to be the remainder in the Euclidean division +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> +</div></blockquote> +</section> +<section id="polgcd"> +<span id="id33"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolGCD{}{}{}</span></code></h3> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolGCD{<polname_1>}{<polname_2>}{<polname_GCD>}</span></code></p> +<blockquote> +<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> +and <code class="docutils literal notranslate"><span class="pre">polname_2</span></code>. It is a unitary polynomial except if both +<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 +zero polynomial.</p> +</div></blockquote> +</section> +<section id="root-localization-routines-via-the-sturm-theorem"> +<h3>Root localization routines via the <a class="reference external" href="https://en.wikipedia.org/wiki/Sturm%27s_theorem">Sturm Theorem</a></h3> +<p>As <a class="reference internal" href="#poltosturm"><span class="std std-ref">\PolToSturm{<polname>}{<sturmname>}</span></a> and +<a class="reference internal" href="#polsturmisolatezeros"><span class="std std-ref">\PolSturmIsolateZeros{<sturmname>}</span></a> and variants declare +additional polynomial or scalar variables with names based on <code class="docutils literal notranslate"><span class="pre"><sturmname></span></code> as +prefix, it is advisable to keep the <code class="docutils literal notranslate"><span class="pre"><sturmname></span></code> namespace separate from +the one applying to <code class="docutils literal notranslate"><span class="pre">\xintexpr</span></code> variables generally, or to polynomials.</p> +<section id="poltosturm"> +<span id="id34"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolToSturm{}{}</span></code></h4> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolToSturm{<polname>}{<sturmname>}</span></code></p> +<blockquote> +<div><p>With <code class="docutils literal notranslate"><span class="pre"><polname></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"><sturmname></span></code> being +for example <code class="docutils literal notranslate"><span class="pre">S</span></code>, the macro starts by computing the derivative +<code class="docutils literal notranslate"><span class="pre">P'</span></code>, then computes the opposite of the remainder in the euclidean +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 +the euclidean division of <code class="docutils literal notranslate"><span class="pre">P'</span></code> by the first obtained polynomial, +etc… Up to signs following the <code class="docutils literal notranslate"><span class="pre">--++--++...</span></code> pattern, these are +the same remainders as in the Euclide algorithm applied to the +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> +<p>The precise process differs from the above description: the +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> +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 +<a class="reference internal" href="#policontent"><span class="std std-ref">\PolIContent{<polname>}</span></a>), then at each step +the remainder is made primitive and stored for internal reference as +<code class="docutils literal notranslate"><span class="pre">S_k_</span></code>, so only integer-coefficients polynomials are manipulated.</p> +<div class="admonition warning"> +<p class="admonition-title">Warning</p> +<p>This exact procedure will perhaps in future be replaced by a +<em>sub-resultant algorithm</em>, which may bring some speed gain in +obtaining a pseudo-Sturm sequence, but some experimenting is +needed, in the context of realistically realizable computations +by the package; primitive polynomials although a bit costly +have the smallest coefficients hence are the best for the kind of +computations done for root localization, after having computed a +Sturm sequence.</p> +</div> +<p>The last non-zero primitivized remainder <code class="docutils literal notranslate"><span class="pre">S_N_</span></code> is, up to sign, +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 +and complex) are the multiple roots of the original <code class="docutils literal notranslate"><span class="pre">P</span></code>. The +original <code class="docutils literal notranslate"><span class="pre">P</span></code> was “square-free” (i.e. did not have multiple real +or complex roots) if and only if <code class="docutils literal notranslate"><span class="pre">S_N_</span></code> is a constant, which is +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> +<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 +quotients <code class="docutils literal notranslate"><span class="pre">S_k</span></code> as user polynomials for future use. By Gauss +theorem about the contents of integer-coefficients polynomials, +these <code class="docutils literal notranslate"><span class="pre">S_k</span></code> also are primitive integer-coefficients polynomials.</p> +<p>This step will be referred to as <em>normalization</em>, and in this +documentation the obtained polynomials are said to constitute the +“Sturm chain” (or “Sturm sequence”), i.e. by convention the “Sturm +chain polynomials” are square-free and primitive. The possibly +non-square-free ones are referred to as <em>non-normalized</em>.</p> +<p>As an exception to the rule, if the original <code class="docutils literal notranslate"><span class="pre">P</span></code> was “square-free” +(i.e. did not have multiple real or complex roots) then +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 +<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 +polynomial <code class="docutils literal notranslate"><span class="pre">P</span></code>, in the “square-free” case.</p> +<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 +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 +other polynomials after having done +<code class="docutils literal notranslate"><span class="pre">\PolToSturm{<polname>}{<sturmname>}</span></code> and before executing +<code class="docutils literal notranslate"><span class="pre">\PolSturmIsolateZeros{<sturmname>}</span></code> or its variants else the +latter will behave erroneously.</p> +<div class="admonition note"> +<p class="admonition-title">Note</p> +<p>The declaration of the <code class="docutils literal notranslate"><span class="pre">S_k</span></code>‘s will overwrite +with no warning previously declared polynomials with identical +names <code class="docutils literal notranslate"><span class="pre">S_k</span></code>. This is original reason why the macro expects two +names: <code class="docutils literal notranslate"><span class="pre"><polname></span></code> and <code class="docutils literal notranslate"><span class="pre"><sturmname></span></code>.</p> +<p>It is allowed to use the polynomial name <code class="docutils literal notranslate"><span class="pre">P</span></code> as Sturm chain +name <code class="docutils literal notranslate"><span class="pre">S</span></code>: <code class="docutils literal notranslate"><span class="pre">\PolToSturm{f}(f}</span></code>, but of course fusing the +namespaces is slightly dangerous. And, also <a class="reference internal" href="#polsturmisolatezeros">\PolSturmIsolateZeros</a> creates variables sharing +the <code class="docutils literal notranslate"><span class="pre"><sturmname></span></code> prefix, which must be taken into account to +avoid name clashes.</p> +</div> +<div class="admonition warning"> +<p class="admonition-title">Warning</p> +<p>The reason why the <code class="docutils literal notranslate"><span class="pre">S_k</span></code>‘s are declared as polynomials is +that the associated polynomial functions are needed to compute +the sign changes in the Sturm sequence evaluated at a given +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> +<p>It is possible that in future the package will only internally +construct such polynomial functions and only the starred variant +will make the normalized (i.e. square-free) Sturm sequence public.</p> +</div> +<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>, +<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 +<a class="reference internal" href="#polsturmchainlength"><span class="std std-ref">\PolSturmChainLength{<sturmname>}</span></a>. If all roots of original <code class="docutils literal notranslate"><span class="pre">P</span></code> +are real, then <code class="docutils literal notranslate"><span class="pre">N</span></code> is both the number of distinct real roots and +the degree of <code class="docutils literal notranslate"><span class="pre">S_0</span></code>. In the case of existence of complex roots, +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 +most the degree of <code class="docutils literal notranslate"><span class="pre">S_0</span></code>.</p> +</div></blockquote> +</section> +<section id="id35"> +<span id="id36"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolToSturm*{}{}</span></code></h4> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolToSturm*{<polname>}{<sturmname>}</span></code></p> +<blockquote> +<div><p>Does the same as <a class="reference internal" href="#poltosturm">un-starred version</a> and additionally it +keeps for user usage the memory of the <em>un-normalized</em> (but still +made primitive) Sturm chain +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 +<code class="docutils literal notranslate"><span class="pre">N</span></code> being <a class="reference internal" href="#polsturmchainlength"><span class="std std-ref">\PolSturmChainLength{<sturmname>}</span></a>.</p> +</div></blockquote> +</section> +<section id="polsturmisolatezeros"> +<span id="id37"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolSturmIsolateZeros{}</span></code></h4> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolSturmIsolateZeros{<sturmname>}</span></code></p> +<blockquote> +<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 +intervals as there are distinct real roots.</p> +<div class="admonition important"> +<p class="admonition-title">Important</p> +<p>The Sturm chain must have been produced by an earlier +<a class="reference internal" href="#poltosturm"><span class="std std-ref">\PolToSturm{<polname>}{<sturmname>}</span></a>.</p> +</div> +<p>After its execution they are two types of such intervals (stored in +memory and accessible via macros or <a class="reference external" href="https://www.ctan.org/pkg/xintexpr">xintexpr</a> variables, see below):</p> +<ul class="simple"> +<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 +number, but not all such decimal numbers are exactly identified yet).</p></li> +<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> +such that <code class="docutils literal notranslate"><span class="pre">a</span> <span class="pre"><</span> <span class="pre">z</span> <span class="pre"><</span> <span class="pre">b</span></code>, and the end points are guaranteed to not +be roots.</p></li> +</ul> +<p>The interval boundaries are decimal numbers, originating +in iterated decimal subdivision from initial intervals +<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 +enough so that all roots are enclosed; if zero is a root it is always +identified as such. The non-singleton intervals are of the +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 +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 +or they are both negative.</p> +<p>One does not <em>a priori</em> know what will be the lengths of these +intervals (except that they are always powers of ten), they +vary depending on how many digits two successive roots have in +common in their respective decimal expansions.</p> +<div class="admonition important"> +<p class="admonition-title">Important</p> +<p>If some two consecutive intervals share an end-point, no +information is yet gained about the separation between the two +roots which could at this stage be arbitrarily small.</p> +<p>See <a class="reference internal" href="#polrefineinterval"><span class="std std-ref">\PolRefineInterval*{<sturmname>}{<index>}</span></a> which addresses +this issue.</p> +</div> +<p>Let us suppose <code class="docutils literal notranslate"><span class="pre"><sturmname></span></code> is <code class="docutils literal notranslate"><span class="pre">S</span></code>.</p> +<p>The interval boundaries (and exactly found roots) are made available +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 +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 +<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> +<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 +<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> +otherwise. And similarly for the other intervals.</p> +<div class="admonition important"> +<p class="admonition-title">Important</p> +<p>The variable declarations are done with no check of existence of +previously existing variables with identical names.</p> +</div> +<p>Also, macros <a class="reference internal" href="#polsturmisolatedzeroleft"><span class="std std-ref">\PolSturmIsolatedZeroLeft{<sturmname>}{<index>}</span></a> and +<a class="reference internal" href="#polsturmisolatedzeroright"><span class="std std-ref">\PolSturmIsolatedZeroRight{<sturmname>}{<index>}</span></a> are provided which +expand to these same values, written in decimal notation (i.e. +pre-processed by <a class="reference internal" href="#poldectostring">\PolDecToString</a>.) And there +is also <a class="reference internal" href="#polsturmifzeroexactlyknown"><span class="std std-ref">\PolSturmIfZeroExactlyKnown{<sturmname>}{<index>}{T}{F}</span></a>.</p> +<div class="admonition important"> +<p class="admonition-title">Important</p> +<p>Trailing zeroes in the stored decimal numbers accessible via the +macros are significant: they are also present in the decimal +expansion of the exact root, so as to be able for example to +print out bounds of real roots with as many digits as is +significant, even if the digits are zeros.</p> +</div> +<p>The start of the decimal expansion of the <code class="docutils literal notranslate"><span class="pre"><index></span></code>-th root is given by +<a class="reference internal" href="#polsturmisolatedzeroleft">\PolSturmIsolatedZeroLeft{<sturmname>}{<index>}</a> if the root is positive, and by +<a class="reference internal" href="#polsturmisolatedzeroright">PolSturmIsolatedZeroRight{<sturmname>}{<index>}</a> if the root is neagtive. These two +decimal numbers are either both zero or both of the same sign.</p> +<p>The number of distinct roots is obtainable expandably as +<a class="reference internal" href="#polsturmnbofisolatedzeros"><span class="std std-ref">\PolSturmNbOfIsolatedZeros{<sturmname>}</span></a>.</p> +<p>Furthermore +<a class="reference internal" href="#polsturmnbofrootsoflessthanorequalto"><span class="std std-ref">\PolSturmNbOfRootsOf{<sturmname>}\LessThanOrEqualTo{<value>}</span></a> and +<a class="reference internal" href="#polsturmnbofrootsoflessthanorequaltoexpr"><span class="std std-ref">\PolSturmNbOfRootsOf{<sturmname>}\LessThanOrEqualToExpr{<num. expr.>}</span></a>. +will expandably compute respectively the number of real roots at +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 +multiplicities.</p> +<p>These variables and macros are automatically updated in case of +subsequent usage of <a class="reference internal" href="#polrefineinterval"><span class="std std-ref">\PolRefineInterval*{<sturmname>}{<index>}</span></a> or +other localization improving macros.</p> +<div class="admonition note"> +<p class="admonition-title">Note</p> +<p>The current polexpr implementation defines the <a class="reference external" href="https://www.ctan.org/pkg/xintexpr">xintexpr</a> variables +and <a class="reference external" href="https://www.ctan.org/pkg/xint">xinttools</a> arrays as described above with global scope. On the +other hand the Sturm sequence polynomials obey the current scope.</p> +<p>This is perhaps a bit inconsistent and may change in future.</p> +</div> +<div class="admonition note"> +<p class="admonition-title">Note</p> +<p>The results are exact +bounds for the mathematically exact real roots.</p> +<p>Future releases will perhaps also provide macros based on Newton +or Regula Falsi methods. Exact computations with such methods +lead however quickly to very big fractions, and this forces usage +of some rounding scheme for the abscissas if computation times +are to remain reasonable. This raises issues of its own, which +are studied in numerical mathematics.</p> +</div> +</div></blockquote> +</section> +<section id="id38"> +<span id="id39"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolSturmIsolateZeros*{}</span></code></h4> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolSturmIsolateZeros*{<sturmname>}</span></code></p> +<blockquote> +<div><p>The macro does the same as <a class="reference internal" href="#polsturmisolatezeros"><span class="std std-ref">\PolSturmIsolateZeros{<sturmname>}</span></a> and +then in addition it does the extra work to determine all +multiplicities of the real roots.</p> +<p>After execution, +<a class="reference internal" href="#polsturmisolatedzeromultiplicity"><span class="std std-ref">\PolSturmIsolatedZeroMultiplicity{<sturmname>}{<index>}</span></a> expands +to the multiplicity of the root located in the <code class="docutils literal notranslate"><span class="pre">index</span></code>-th +interval (intervals are enumerated from left to right, with index +starting at <code class="docutils literal notranslate"><span class="pre">1</span></code>).</p> +<p>Furthermore, if for example the <code class="docutils literal notranslate"><span class="pre"><sturmname></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> +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 +computed.</p> +<div class="admonition note"> +<p class="admonition-title">Note</p> +<p>Somewhat counter-intuitively, it is not necessary to have +executed the <a class="reference internal" href="#id35"><span class="std std-ref">\PolToSturm*</span></a> +starred variant: during its +execution, <a class="reference internal" href="#poltosturm"><span class="std std-ref">\PolToSturm</span></a>, +even though it does not declare the +non-square-free Sturm chain polynomials as user-level genuine +polynomials, stores their data in private macros.</p> +</div> +<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> +<span class="pre">roots</span></code> example in <code class="docutils literal notranslate"><span class="pre">polexpr-examples.pdf</span></code>.</p> +</div></blockquote> +<section id="polsturmisolatezerosandgetmultiplicities"> +<span id="id40"></span><h5><code class="docutils literal notranslate"><span class="pre">\PolSturmIsolateZerosAndGetMultiplicities{}</span></code></h5> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolSturmIsolateZerosAndGetMultiplicities{<sturmname>}</span></code></p> +<blockquote> +<div><p>This is another name for <a class="reference internal" href="#id38"><span class="std std-ref">\PolSturmIsolateZeros*{<sturmname>}</span></a>.</p> +</div></blockquote> +</section> +</section> +<section id="id41"> +<span id="id42"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolSturmIsolateZeros**{}</span></code></h4> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolSturmIsolateZeros**{<sturmname>}</span></code></p> +<blockquote> +<div><p>The macro does the same as <a class="reference internal" href="#id38"><span class="std std-ref">\PolSturmIsolateZeros*{<sturmname>}</span></a> and +in addition it does the extra work to determine all the <em>rational</em> +roots.</p> +<div class="admonition note"> +<p class="admonition-title">Note</p> +<p>After execution of this macro, a root is “known” if and only if +it is rational.</p> +</div> +<p>Furthermore, primitive polynomial <code class="docutils literal notranslate"><span class="pre">sturmname_sqf_norr</span></code> is created +to match the (square-free) <code class="docutils literal notranslate"><span class="pre">sturmname_0</span></code> from which all rational +roots have been removed. The number of distinct rational roots is +thus the difference between the degrees of these two polynomials +(see also <a class="reference internal" href="#polsturmnbofrationalroots"><span class="std std-ref">\PolSturmNbOfRationalRoots{<sturmname>}</span></a>).</p> +<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 +roots have been removed, i.e. it contains the irrational roots of +the original polynomial, with the same multiplicities.</p> +<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> +<span class="pre">roots</span></code> in <code class="docutils literal notranslate"><span class="pre">polexpr-examples.pdf</span></code>.</p> +</div></blockquote> +<section id="polsturmisolatezerosgetmultiplicitiesandrationalroots"> +<span id="id43"></span><h5><code class="docutils literal notranslate"><span class="pre">\PolSturmIsolateZerosGetMultiplicitiesAndRationalRoots</span></code></h5> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolSturmIsolateZerosGetMultiplicitiesAndRationalRoots</span></code></p> +<blockquote> +<div><p>This is another name for <a class="reference internal" href="#id41"><span class="std std-ref">\PolSturmIsolateZeros**{<sturmname>}</span></a>.</p> +</div></blockquote> +</section> +</section> +<section id="polsturmisolatezerosandfindrationalroots"> +<span id="id44"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolSturmIsolateZerosAndFindRationalRoots{}</span></code></h4> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolSturmIsolateZerosAndFindRationalRoots{<sturmname>}</span></code></p> +<blockquote> +<div><p>This works exactly like <a class="reference internal" href="#id41"><span class="std std-ref">\PolSturmIsolateZeros**{<sturmname>}</span></a> +(inclusive of declaring the polynomials <code class="docutils literal notranslate"><span class="pre">sturmname_sqf_norr</span></code> and +<code class="docutils literal notranslate"><span class="pre">sturmname_norr</span></code> with no rational roots) except that it does <em>not</em> +compute the multiplicities of the <em>non-rational</em> roots.</p> +<div class="admonition note"> +<p class="admonition-title">Note</p> +<p>There is no macro to find the rational roots but not compute +their multiplicities at the same time.</p> +</div> +<div class="admonition attention"> +<p class="admonition-title">Attention</p> +<p>This macro does <em>not</em> define <a class="reference external" href="https://www.ctan.org/pkg/xintexpr">xintexpr</a> variables +<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 +multiplicities and it leaves the multiplicity array (whose accessor +is <a class="reference internal" href="#polsturmisolatedzeromultiplicity"><span class="std std-ref">\PolSturmIsolatedZeroMultiplicity{<sturmname>}{<index>}</span></a>) into +a broken state, as all non-rational roots will supposedly have +multiplicity one. This means that the output of +<a class="reference internal" href="#id61">\PolPrintIntervals*</a> will be +erroneous regarding the multiplicities of irrational roots.</p> +<p>I decided to document it because finding multiplicities of the +non rational roots is somewhat costly, and one may be interested +only into finding the rational roots (of course random +polynomials with integer coefficients will not have <em>any</em> +rational root anyhow).</p> +</div> +</div></blockquote> +</section> +<section id="polrefineinterval"> +<span id="id45"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolRefineInterval*{}{}</span></code></h4> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolRefineInterval*{<sturmname>}{<index>}</span></code></p> +<blockquote> +<div><p>The <code class="docutils literal notranslate"><span class="pre">index</span></code>-th interval (starting indexing at one) is further +subdivided as many times as is necessary in order for the newer +interval to have both its end-points distinct from the end-points of +the original interval. As a consequence, the <code class="docutils literal notranslate"><span class="pre">k</span></code>th root is then +strictly separated from the other roots.</p> +</div></blockquote> +</section> +<section id="id46"> +<span id="id47"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolRefineInterval[]{}{}</span></code></h4> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolRefineInterval[N]{<sturmname>}{<index>}</span></code></p> +<blockquote> +<div><p>The <code class="docutils literal notranslate"><span class="pre">index</span></code>-th interval (starting count at one) is further +subdivided once, reducing its length by a factor of 10. This is done +<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> +</div></blockquote> +</section> +<section id="polensureintervallength"> +<span id="id48"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolEnsureIntervalLength{}{}{}</span></code></h4> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolEnsureIntervalLength{<sturmname>}{<index>}{<exponent>}</span></code></p> +<blockquote> +<div><p>The <code class="docutils literal notranslate"><span class="pre">index</span></code>-th interval is subdivided until its length becomes at +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<0</span></code>) that the first <code class="docutils literal notranslate"><span class="pre">-E</span></code> digits +after decimal mark of the <code class="docutils literal notranslate"><span class="pre">k</span></code>th root will then be known exactly.</p> +</div></blockquote> +</section> +<section id="polensureintervallengths"> +<span id="id49"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolEnsureIntervalLengths{}{}</span></code></h4> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolEnsureIntervalLengths{<sturmname>}{<exponent>}</span></code></p> +<blockquote> +<div><p>The intervals as obtained from <code class="docutils literal notranslate"><span class="pre">\PolSturmIsolateZeros</span></code> are (if +necessary) subdivided further by (base 10) dichotomy in order for +each of them to have length at most <code class="docutils literal notranslate"><span class="pre">10^E</span></code>.</p> +<p>This means that decimal expansions of all roots will be known with +<code class="docutils literal notranslate"><span class="pre">-E</span></code> digits (for <code class="docutils literal notranslate"><span class="pre">E<0</span></code>) after decimal mark.</p> +</div></blockquote> +</section> +<section id="polsettosturmchainsignchangesat"> +<span id="id50"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolSetToSturmChainSignChangesAt{}{}{}</span></code></h4> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolSetToSturmChainSignChangesAt{\foo}{<sturmname>}{<value>}</span></code></p> +<blockquote> +<div><p>Sets macro <code class="docutils literal notranslate"><span class="pre">\foo</span></code> to store the number of sign changes in the +already computed normalized Sturm chain with name prefix +<code class="docutils literal notranslate"><span class="pre"><sturmname></span></code>, at location <code class="docutils literal notranslate"><span class="pre"><value></span></code> (which must be in format as +acceptable by the <a class="reference external" href="https://www.ctan.org/pkg/xint">xintfrac</a> macros.)</p> +<p>The definition is made with global scope. For local scope, use +<code class="docutils literal notranslate"><span class="pre">[\empty]</span></code> as extra optional argument.</p> +<p>One can use this immediately after creation of the Sturm chain.</p> +</div></blockquote> +</section> +<section id="polsettonbofzeroswithin"> +<span id="id51"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolSetToNbOfZerosWithin{}{}{}{}</span></code></h4> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolSetToNbOfZerosWithin{\foo}{<sturmname>}{<value_left>}{<value_right>}</span></code></p> +<blockquote> +<div><p>Sets, assuming the normalized Sturm chain has been already computed, +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 +the interval <code class="docutils literal notranslate"><span class="pre">(value_left,</span> <span class="pre">value_right]</span></code>. The macro first +re-orders end-points if necessary for <code class="docutils literal notranslate"><span class="pre">value_left</span> <span class="pre"><=</span> <span class="pre">value_right</span></code> +to hold.</p> +<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 +between the number of sign changes of the Sturm chain at <code class="docutils literal notranslate"><span class="pre">value_right</span></code> +and the one at <code class="docutils literal notranslate"><span class="pre">value_left</span></code>.</p> +<p>The definition is made with global scope. For local scope, use +<code class="docutils literal notranslate"><span class="pre">[\empty]</span></code> as extra optional argument.</p> +<p>One can use this immediately after creation of a Sturm chain.</p> +<p>See also the expandable +<a class="reference internal" href="#polsturmnbofrootsoflessthanorequalto"><span class="std std-ref">\PolSturmNbOfRootsOf{<sturmname>}\LessThanOrEqualTo{value}</span></a>, +which however requires prior execution of <a class="reference internal" href="#polsturmisolatezeros">\PolSturmIsolateZeros</a>.</p> +<p>See also the expandable +<a class="reference internal" href="#polsturmnbwithmultofrootsoflessthanorequalto"><span class="std std-ref">\PolSturmNbWithMultOfRootsOf{<sturmname>}\LessThanOrEqualTo{value}</span></a> +which requires prior execution of +<a class="reference internal" href="#id38">\PolSturmIsolateZeros*</a>.</p> +</div></blockquote> +</section> +</section> +<section id="displaying-the-found-roots-polprintintervals-varname"> +<span id="polprintintervals"></span><h3>Displaying the found roots: <code class="docutils literal notranslate"><span class="pre">\PolPrintIntervals[<varname>]{}</span></code></h3> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolPrintIntervals[<varname>]{<sturmname>}</span></code></p> +<blockquote> +<div><p>This is a convenience macro which prints the bounds for the roots +<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 +specify a replacement for the default <code class="docutils literal notranslate"><span class="pre">Z</span></code>). This will be done (by +default) in a +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>, +where the second and fourth column hold the <code class="docutils literal notranslate"><span class="pre"><</span></code> sign, except when +the interval reduces to a singleton, which means the root is known +exactly.</p> +<div class="admonition note"> +<p class="admonition-title">Note</p> +<p>The explanations here and in this section are for LaTeX. With +other TeX macro formats, the LaTeX syntax such as for example +<code class="docutils literal notranslate"><span class="pre">\begin{array}{rcccl}</span></code> which appears in the documentation here +is actually replaced with quasi-equivalent direct use of TeX +primitives.</p> +</div> +<p>The next macros which govern its output.</p> +</div></blockquote> +<section id="polprintintervalsnorealroots"> +<span id="id52"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervalsNoRealRoots</span></code></h4> +<blockquote> +<div><p>Executed in place of an <code class="docutils literal notranslate"><span class="pre">array</span></code> environment, when there are no +real roots. Default definition:</p> +<div class="highlight-latex notranslate"><div class="highlight"><pre><span></span><span class="k">\newcommand\PolPrintIntervalsNoRealRoots</span><span class="nb">{}</span> +</pre></div> +</div> +</div></blockquote> +</section> +<section id="polprintintervalsbeginenv"> +<span id="id53"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervalsBeginEnv</span></code></h4> +<blockquote> +<div><p>Default definition (given here for LaTeX, Plain has a variant):</p> +<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> +</pre></div> +</div> +<p>A simpler <code class="docutils literal notranslate"><span class="pre">center</span></code> environment provides a straightforward way to +obtain a display allowing pagebreaks. Of course redefinitions must +at any rate be kept in sync with <a class="reference internal" href="#id56">\PolPrintIntervalsKnownRoot</a> and +<a class="reference internal" href="#id57">\PolPrintIntervalsUnknownRoot</a>.</p> +<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 +<code class="docutils literal notranslate"><span class="pre">\begin{align}</span></code> due to the latter executing twice in contents.</p> +</div></blockquote> +</section> +<section id="polprintintervalsendenv"> +<span id="id54"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervalsEndEnv</span></code></h4> +<blockquote> +<div><p>Default definition:</p> +<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> +</pre></div> +</div> +</div></blockquote> +</section> +<section id="polprintintervalsrowseparator"> +<span id="id55"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervalsRowSeparator</span></code></h4> +<blockquote> +<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> +<p>Added at <code class="docutils literal notranslate"><span class="pre">0.8.6</span></code>.</p> +</div></blockquote> +</section> +<section id="polprintintervalsknownroot"> +<span id="id56"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervalsKnownRoot</span></code></h4> +<blockquote> +<div><p>Default definition:</p> +<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> + <span class="nb">&&</span><span class="k">\PolPrintIntervalsTheVar</span><span class="nb">_{</span><span class="k">\PolPrintIntervalsTheIndex</span><span class="nb">}</span><span class="c">%</span> + <span class="nb">&</span>=<span class="nb">&</span><span class="k">\PolPrintIntervalsPrintExactZero</span> +<span class="nb">}</span> +</pre></div> +</div> +</div></blockquote> +</section> +<section id="polprintintervalsunknownroot"> +<span id="id57"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervalsUnknownRoot</span></code></h4> +<blockquote> +<div><p>Default definition:</p> +<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> + <span class="k">\PolPrintIntervalsPrintLeftEndPoint</span><span class="nb">&</span><<span class="nb">&</span><span class="c">%</span> + <span class="k">\PolPrintIntervalsTheVar</span><span class="nb">_{</span><span class="k">\PolPrintIntervalsTheIndex</span><span class="nb">}&</span><<span class="nb">&</span><span class="c">%</span> + <span class="k">\PolPrintIntervalsPrintRightEndPoint</span> +<span class="nb">}</span> +</pre></div> +</div> +</div></blockquote> +</section> +<section id="polprintintervalsprintexactzero"> +<span id="id58"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervalsPrintExactZero</span></code></h4> +<blockquote> +<div><p>Default definition:</p> +<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> +</pre></div> +</div> +</div></blockquote> +</section> +<section id="polprintintervalsprintleftendpoint"> +<span id="id59"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervalsPrintLeftEndPoint</span></code></h4> +<blockquote> +<div><p>Default definition:</p> +<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> +</pre></div> +</div> +</div></blockquote> +</section> +<section id="polprintintervalsprintrightendpoint"> +<span id="id60"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervalsPrintRightEndPoint</span></code></h4> +<blockquote> +<div><p>Default definition is:</p> +<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> +</pre></div> +</div> +</div></blockquote> +</section> +<section id="polprintintervals-varname"> +<span id="id61"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervals*[<varname>]{}</span></code></h4> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolPrintIntervals*[<varname>]{<sturmname>}</span></code></p> +<blockquote> +<div><p>This starred variant produces an alternative output (which +displays the root multiplicity), and is provided as an +example of customization.</p> +<p>As replacement for <a class="reference internal" href="#id56">\PolPrintIntervalsKnownRoot</a>, +<a class="reference internal" href="#id58">\PolPrintIntervalsPrintExactZero</a>, +<a class="reference internal" href="#id57">\PolPrintIntervalsUnknownRoot</a> it uses its own +<code class="docutils literal notranslate"><span class="pre">\POL@@PrintIntervals...</span></code> macros. We only reproduce here one +definition:</p> +<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> + <span class="k">\displaystyle</span> + <span class="k">\xintTeXsignedFrac</span><span class="nb">{</span><span class="k">\PolPrintIntervalsTheLeftEndPoint</span><span class="nb">}</span><span class="c">%</span> +<span class="nb">}</span><span class="c">%</span> +</pre></div> +</div> +<p>Multiplicities are printed using this auxiliary macro:</p> +</div></blockquote> +<section id="polprintintervalsprintmultiplicity"> +<span id="id62"></span><h5><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervalsPrintMultiplicity</span></code></h5> +<blockquote> +<div><p>whose default definition is:</p> +<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> +</pre></div> +</div> +</div></blockquote> +</section> +</section> +</section> +</section> +<section id="expandable-macros"> +<h2>Expandable macros</h2> +<div class="admonition note"> +<p class="admonition-title">Note</p> +<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 +LaTeX. Some examples given in this section may be using LaTeX syntax +such as <code class="docutils literal notranslate"><span class="pre">\renewcommand</span></code>. Convert to TeX primitives as appropriate +if testing with a non LaTeX macro format.</p> +</div> +<p>These macros expand completely in two steps except <code class="docutils literal notranslate"><span class="pre">\PolToExpr</span></code> and +<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 +<code class="docutils literal notranslate"><span class="pre">\csname...\endcsname</span></code> context.</p> +<section id="poltoexpr"> +<span id="id63"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolToExpr{}</span></code></h3> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolToExpr{<pol.</span> <span class="pre">expr.>}</span></code></p> +<blockquote> +<div><p>Produces expandably <a class="footnote-reference brackets" href="#id65" id="id64" 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 +polynomial is using descending powers.</p> +<aside class="footnote brackets" id="id65" role="note"> +<span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#id64">3</a><span class="fn-bracket">]</span></span> +<p>requires exhaustive expansion, for example as triggered by +<code class="docutils literal notranslate"><span class="pre">\write</span></code> or <code class="docutils literal notranslate"><span class="pre">\edef</span></code>.</p> +</aside> +<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 +is allowed to be an arbitrary expression. Then <code class="docutils literal notranslate"><span class="pre">x</span></code> is expected as +indeterminate but this can be customized via <a class="reference internal" href="#id67">\PolToExprInVar</a>.</p> +<p>The output uses the letter <code class="docutils literal notranslate"><span class="pre">x</span></code> by default, this is customizable +via <a class="reference internal" href="#poltoexprvar">\PolToExprVar</a>. The default output is compatible both with</p> +<ul class="simple"> +<li><p>the Maple’s input format,</p></li> +<li><p>and the PSTricks <code class="docutils literal notranslate"><span class="pre">\psplot[algebraic]</span></code> input format.</p></li> +</ul> +<p>Attention that it is not compatible with Python, see further +<a class="reference internal" href="#id69">\PolToExprCaret</a> in this context.</p> +<p>The following applies:</p> +<ul class="simple"> +<li><p>vanishing coefficients are skipped (issue <code class="docutils literal notranslate"><span class="pre">\poltoexpralltrue</span></code> to +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> +<li><p>negative coefficients are not prefixed by a <code class="docutils literal notranslate"><span class="pre">+</span></code> sign (else, +Maple would not be happy),</p></li> +<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 +only via their sign,</p></li> +<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 +<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> +<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 +can for convenience typeset in regular text mode, for example +using <code class="docutils literal notranslate"><span class="pre">\texttt</span></code> (in LaTeX). But TeX will not know how to break +the expression across end-of-lines anyhow. Formerly <code class="docutils literal notranslate"><span class="pre">^</span></code> was +suitable for math mode but as the exponent is not braced this +worked only for polynomials of degrees at most 9. Anyhow this +is not supposed to be a typesetting macro.</p></li> +</ul> +<p>Complete customization is possible, see the next macros. Any user +redefinition must maintain the expandability property.</p> +</div></blockquote> +<section id="poltoexprvar"> +<span id="id66"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolToExprVar</span></code></h4> +<blockquote> +<div><p>Defaults to <code class="docutils literal notranslate"><span class="pre">x</span></code>. The letter used in the macro output.</p> +</div></blockquote> +</section> +<section id="poltoexprinvar"> +<span id="id67"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolToExprInVar</span></code></h4> +<blockquote> +<div><p>Defaults to <code class="docutils literal notranslate"><span class="pre">x</span></code>: the letter used as the polynomial indeterminate +in the macro input.</p> +<p>Recall that declared polynomials are more efficiently used in +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 +than <code class="docutils literal notranslate"><span class="pre">P(x)*Q(x)</span></code>. Thus the input, even if an expression, does not +have to contain any <code class="docutils literal notranslate"><span class="pre">x</span></code>.</p> +<p>(new with <code class="docutils literal notranslate"><span class="pre">0.8</span></code>)</p> +</div></blockquote> +</section> +<section id="poltoexprtimes"> +<span id="id68"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolToExprTimes</span></code></h4> +<blockquote> +<div><p>Defaults to <code class="docutils literal notranslate"><span class="pre">*</span></code>.</p> +</div></blockquote> +</section> +<section id="poltoexprcaret"> +<span id="id69"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolToExprCaret</span></code></h4> +<blockquote> +<div><p>Defaults to <code class="docutils literal notranslate"><span class="pre">^</span></code> of catcode 12. Set it to +expand to <code class="docutils literal notranslate"><span class="pre">**</span></code> for Python compatible output.</p> +<p>(new with <code class="docutils literal notranslate"><span class="pre">0.8</span></code>)</p> +</div></blockquote> +</section> +<section id="poltoexprcmd"> +<span id="id70"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolToExprCmd{}</span></code></h4> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolToExprCmd{<raw_coeff>}</span></code></p> +<blockquote> +<div><p>Defaults to <code class="docutils literal notranslate"><span class="pre">\xintPRaw{\xintRawWithZeros{#1}}</span></code>.</p> +<p>This means that the coefficient value is printed-out as a fraction +<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> +<p>Configure it to be <code class="docutils literal notranslate"><span class="pre">\xintPRaw{\xintIrr{#1}}</span></code> if the fractions +must be in irreducible terms.</p> +<p>An alternative is <code class="docutils literal notranslate"><span class="pre">\xintDecToString{\xintREZ{#1}}</span></code> which uses +integer or decimal fixed point format such as <code class="docutils literal notranslate"><span class="pre">23.0071</span></code> if the +internal representation of the number only has a power of ten as +denominator (the effect of <code class="docutils literal notranslate"><span class="pre">\xintREZ</span></code> here is to remove trailing +decimal zeros). The behaviour of <code class="docutils literal notranslate"><span class="pre">\xintDecToString</span></code> is not yet +stable for other cases, and for example at time of writing no +attempt is made to identify inputs having a finite decimal expansion +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 +and not their finite decimal expansion with no denominator.</p> +</div></blockquote> +</section> +<section id="poltoexproneterm"> +<span id="id71"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolToExprOneTerm{}{}</span></code></h4> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolToExprOneTerm{<raw_coeff>}{<exponent>}</span></code></p> +<blockquote> +<div><p>This is the macro which from the coefficient and the exponent +produces the corresponding term in output, such as <code class="docutils literal notranslate"><span class="pre">2/3*x^7</span></code>.</p> +<p>For its default definition, see the source code. It uses +<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 +<a class="reference internal" href="#id69">\PolToExprCaret</a>.</p> +</div></blockquote> +</section> +<section id="poltoexpronetermstylea"> +<span id="id72"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolToExprOneTermStyleA{}{}</span></code></h4> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolToExprOneTermStyleA{<raw_coeff>}{<exponent>}</span></code></p> +<blockquote> +<div><p>This holds the default package meaning of <code class="docutils literal notranslate"><span class="pre">\PolToExprOneTerm</span></code>.</p> +</div></blockquote> +</section> +<section id="poltoexpronetermstyleb"> +<span id="id73"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolToExprOneTermStyleB{}{}</span></code></h4> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolToExprOneTermStyleB{<raw_coeff>}{<exponent>}</span></code></p> +<blockquote> +<div><p>This holds an alternative meaning, which puts the fractional part of +a coefficient after the monomial, i.e. like this:</p> +<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 +</pre></div> +</div> +<p><a class="reference internal" href="#poltoexprcmd">\PolToExprCmd</a> isn’t used at all in this style. But +<a class="reference internal" href="#poltoexprtimes">\PolToExprTimes</a>, <a class="reference internal" href="#poltoexprvar">\PolToExprVar</a> and <a class="reference internal" href="#id69">\PolToExprCaret</a> are obeyed.</p> +<p>To activate it use <code class="docutils literal notranslate"><span class="pre">\let\PolToExprOneTerm\PolToExprOneTermStyleB</span></code>. +To revert to the package default behaviour, issue +<code class="docutils literal notranslate"><span class="pre">\let\PolToExprOneTerm\PolToExprOneTermStyleA</span></code>.</p> +</div></blockquote> +</section> +<section id="poltoexprtermprefix"> +<span id="id74"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolToExprTermPrefix{}</span></code></h4> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolToExprTermPrefix{<raw_coeff>}</span></code></p> +<blockquote> +<div><p>It receives as argument the coefficient. Its default behaviour is +to produce a <code class="docutils literal notranslate"><span class="pre">+</span></code> if the coefficient is positive, which will thus +serve to separate the monomials in the output. This is to match +the default for <a class="reference internal" href="#poltoexprcmd"><span class="std std-ref">\PolToExprCmd{<raw_coeff>}</span></a> which in case of a +positive coefficient does not output an explicit <code class="docutils literal notranslate"><span class="pre">+</span></code> prefix.</p> +</div></blockquote> +</section> +</section> +<section id="poltofloatexpr"> +<span id="id75"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolToFloatExpr{}</span></code></h3> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolToFloatExpr{<pol.</span> <span class="pre">expr.>}</span></code></p> +<blockquote> +<div><p>Similar to <a class="reference internal" href="#poltoexpr"><span class="std std-ref">\PolToExpr{<pol. expr.>}</span></a> but using +<a class="reference internal" href="#poltofloatexprcmd"><span class="std std-ref">\PolToFloatExprCmd{<raw_coeff>}</span></a> which by default rounds and +converts the coefficients to floating point format.</p> +<div class="admonition note"> +<p class="admonition-title">Note</p> +<p>This is unrelated to <a class="reference internal" href="#polgenfloatvariant"><span class="std std-ref">\PolGenFloatVariant{<polname>}</span></a>: +<a class="reference internal" href="#poltofloatexprcmd"><span class="std std-ref">\PolToFloatExprCmd{<raw_coeff>}</span></a> operates on the <em>exact</em> +coefficients anew (and may thus produce something else than +the coefficients of the polynomial function acting +in <code class="docutils literal notranslate"><span class="pre">\xintfloateval</span></code> if the floating point precision was changed +in between).</p> +</div> +<p>Extended at <code class="docutils literal notranslate"><span class="pre">0.8</span></code> to accept general expressions as input.</p> +</div></blockquote> +<section id="poltofloatexproneterm"> +<span id="id76"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolToFloatExprOneTerm{}{}</span></code></h4> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolToFloatExprOneTerm{<raw_coeff>}{<exponent>}</span></code></p> +<blockquote> +<div><p>Similar to <a class="reference internal" href="#poltoexproneterm"><span class="std std-ref">\PolToExprOneTerm{<raw_coeff>}{<exponent>}</span></a>. But does not treat +especially coefficients equal to plus or minus one.</p> +</div></blockquote> +</section> +<section id="poltofloatexprcmd"> +<span id="id77"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolToFloatExprCmd{}</span></code></h4> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolToFloatExprCmd{<raw_coeff>}</span></code></p> +<blockquote> +<div><p>The one-argument macro used by <code class="docutils literal notranslate"><span class="pre">\PolToFloatExprOneTerm</span></code>. +It defaults to <code class="docutils literal notranslate"><span class="pre">\xintPFloat{#1}</span></code>, which trims trailing +zeroes.</p> +<p><em>changed at 0.8.2</em> Formerly it was using <code class="docutils literal notranslate"><span class="pre">\xintFloat</span></code>.</p> +</div></blockquote> +</section> +</section> +<section id="id78"> +<span id="id79"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolToExpr*{}</span></code></h3> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolToExpr*{<pol.</span> <span class="pre">expr.>}</span></code></p> +<blockquote> +<div><p>Ascending powers: <code class="docutils literal notranslate"><span class="pre">coeff_0+coeff_1*x+coeff_2*x^2+...</span></code>.</p> +<p>Extended at <code class="docutils literal notranslate"><span class="pre">0.8</span></code> to accept general expressions as input.</p> +<p>Customizable with the same macros as for +<a class="reference internal" href="#poltoexpr"><span class="std std-ref">\PolToExpr{<pol. expr.>}</span></a>.</p> +</div></blockquote> +</section> +<section id="id80"> +<span id="id81"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolToFloatExpr*{}</span></code></h3> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolToFloatExpr*{<pol.</span> <span class="pre">expr.>}</span></code></p> +<blockquote> +<div><p>Ascending powers.</p> +<p>Extended at <code class="docutils literal notranslate"><span class="pre">0.8</span></code> to accept general expressions as input.</p> +</div></blockquote> +</section> +<section id="polnthcoeff"> +<span id="id82"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolNthCoeff{}{}</span></code></h3> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolNthCoeff{<polname>}{<index>}</span></code></p> +<blockquote> +<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 +the constant coefficient). If <code class="docutils literal notranslate"><span class="pre">N</span></code> is out of range, zero (in its +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> +<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 +coefficient, sub-leading coefficient, …, and finally <code class="docutils literal notranslate"><span class="pre">0/1[0]</span></code> +for <code class="docutils literal notranslate"><span class="pre">N<-1-degree</span></code>.</p> +</div></blockquote> +</section> +<section id="polleadingcoeff"> +<span id="id83"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolLeadingCoeff{}</span></code></h3> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolLeadingCoeff{<polname>}</span></code></p> +<blockquote> +<div><p>Expands to the leading coefficient.</p> +</div></blockquote> +</section> +<section id="poldegree"> +<span id="id84"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolDegree{}</span></code></h3> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolDegree{<polname>}</span></code></p> +<blockquote> +<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 +may change in future. Should it then expand to <code class="docutils literal notranslate"><span class="pre">-\infty</span></code> ?</p> +</div></blockquote> +</section> +<section id="policontent"> +<span id="id85"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolIContent{}</span></code></h3> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolIContent{<polname>}</span></code></p> +<blockquote> +<div><p>It expands to the contents of the polynomial, i.e. to the positive +fraction such that dividing by this fraction produces a polynomial +with integer coefficients having no common prime divisor.</p> +<p>See <a class="reference internal" href="#polmakeprimitive">\PolMakePrimitive</a>.</p> +</div></blockquote> +</section> +<section id="poltolist"> +<span id="id86"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolToList{}</span></code></h3> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolToList{<polname>}</span></code></p> +<blockquote> +<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 +<code class="docutils literal notranslate"><span class="pre">coeff_N</span></code> the leading coefficient +(the zero polynomial does give <code class="docutils literal notranslate"><span class="pre">{0/1[0]}</span></code> and not an +empty output.)</p> +</div></blockquote> +</section> +<section id="poltocsv"> +<span id="id87"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolToCSV{}</span></code></h3> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolToCSV{<polname>}</span></code></p> +<blockquote> +<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 +with constant term and ending with leading coefficient. Converse +to <a class="reference internal" href="#polfromcsv"><span class="std std-ref">\PolFromCSV{<polname>}{<csv>}</span></a>.</p> +</div></blockquote> +</section> +<section id="poleval-atexpr"> +<span id="polevalatexpr"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolEval{}\AtExpr{}</span></code></h3> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolEval{<polname>}\AtExpr{<num.</span> <span class="pre">expr.>}</span></code></p> +<blockquote> +<div><p>Same output as +<code class="docutils literal notranslate"><span class="pre">\xinteval{polname(numerical</span> <span class="pre">expression)}</span></code>.</p> +</div></blockquote> +</section> +<section id="poleval-at"> +<span id="polevalat"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolEval{}\At{}</span></code></h3> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolEval{<polname>}\At{<value>}</span></code></p> +<blockquote> +<div><p>Evaluates the polynomial at the given value which must be in (or +expand to) a format acceptable to the <a class="reference external" href="https://www.ctan.org/pkg/xint">xintfrac</a> macros.</p> +</div></blockquote> +</section> +<section id="polevalreduced-atexpr"> +<span id="polevalreducedatexpr"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolEvalReduced{}\AtExpr{}</span></code></h3> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolEvalReduced{<polname>}\AtExpr{<num.</span> <span class="pre">expr.>}</span></code></p> +<blockquote> +<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> +</div></blockquote> +</section> +<section id="polevalreduced-at"> +<span id="polevalreducedat"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolEvalReduced{}\At{}</span></code></h3> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolEvalReduced{<polname>}\At{<value>}</span></code></p> +<blockquote> +<div><p>Evaluates the polynomial at the value which must be in (or expand +to) a format acceptable to the <a class="reference external" href="https://www.ctan.org/pkg/xint">xintfrac</a> macros, and outputs an +irreducible fraction.</p> +</div></blockquote> +</section> +<section id="polfloateval-atexpr"> +<span id="polfloatevalatexpr"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolFloatEval{}\AtExpr{}</span></code></h3> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolFloatEval{<polname>}\AtExpr{<num.</span> <span class="pre">expr.>}</span></code></p> +<blockquote> +<div><p>Same output as <code class="docutils literal notranslate"><span class="pre">\xintfloateval{polname(numerical</span> <span class="pre">expression)}</span></code>.</p> +<div class="admonition attention"> +<p class="admonition-title">Attention</p> +<p><a class="reference internal" href="#polgenfloatvariant">\PolGenFloatVariant</a> must have +been issued before.</p> +</div> +<p>To use the <em>exact coefficients</em> with <em>exactly executed</em> additions +and multiplications and do the rounding only as the final last step, +the following syntax can be used: <a class="footnote-reference brackets" href="#id89" id="id88" role="doc-noteref"><span class="fn-bracket">[</span>4<span class="fn-bracket">]</span></a></p> +<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> +</pre></div> +</div> +<aside class="footnote brackets" id="id89" role="note"> +<span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#id88">4</a><span class="fn-bracket">]</span></span> +<p>Cf. <a class="reference external" href="https://www.ctan.org/pkg/xintexpr">xintexpr</a> documentation about nested expressions.</p> +</aside> +</div></blockquote> +</section> +<section id="polfloateval-at"> +<span id="polfloatevalat"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolFloatEval{}\At{}</span></code></h3> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolFloatEval{<polname>}\At{<value>}</span></code></p> +<blockquote> +<div><p>Evaluates the polynomial at the value which must be in (or expand +to) a format acceptable to the <a class="reference external" href="https://www.ctan.org/pkg/xint">xintfrac</a> macros.</p> +</div></blockquote> +</section> +<section id="expandable-macros-in-relation-to-root-localization-via-sturm-theorem"> +<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> +<section id="polsturmchainlength"> +<span id="id90"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolSturmChainLength{}</span></code></h4> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolSturmChainLength{<sturmname>}</span></code></p> +<blockquote> +<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 +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> +<p>See <a class="reference internal" href="#poltosturm"><span class="std std-ref">\PolToSturm{<polname>}{<sturmname>}</span></a>.</p> +</div></blockquote> +</section> +<section id="polsturmifzeroexactlyknown"> +<span id="id91"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolSturmIfZeroExactlyKnown{}{}{}{}</span></code></h4> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolSturmIfZeroExactlyKnown{<sturmname>}{<index>}{T}{F}</span></code></p> +<blockquote> +<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, +i.e. the root is known exactly, else <code class="docutils literal notranslate"><span class="pre">F</span></code>.</p> +</div></blockquote> +</section> +<section id="polsturmisolatedzeroleft"> +<span id="id92"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolSturmIsolatedZeroLeft{}{}</span></code></h4> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolSturmIsolatedZeroLeft{<sturmname>}{<index>}</span></code></p> +<blockquote> +<div><p>Expands to the left end-point for the <code class="docutils literal notranslate"><span class="pre">index</span></code>-th interval, as +computed by some earlier <a class="reference internal" href="#polsturmisolatezeros"><span class="std std-ref">\PolSturmIsolateZeros{<sturmname>}</span></a>.</p> +<div class="admonition note"> +<p class="admonition-title">Note</p> +<p>Execution of this macro after some +<a class="reference internal" href="#id46">\PolRefineInterval{<sturmname>}{<index>}</a> +will take into account the now known tighter bounds.</p> +</div> +<p>The value is pre-formatted using <a class="reference internal" href="#poldectostring">\PolDecTostring</a>.</p> +</div></blockquote> +</section> +<section id="polsturmisolatedzeroright"> +<span id="id93"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolSturmIsolatedZeroRight{}{}</span></code></h4> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolSturmIsolatedZeroRight{<sturmname>}{<index>}</span></code></p> +<blockquote> +<div><p>Expands to the right end-point for the <code class="docutils literal notranslate"><span class="pre">index</span></code>-th interval as +computed by some earlier <a class="reference internal" href="#polsturmisolatezeros"><span class="std std-ref">\PolSturmIsolateZeros{<sturmname>}</span></a> and +possibly refined afterwards.</p> +<p>The value is pre-formatted using <a class="reference internal" href="#poldectostring">\PolDecTostring</a>.</p> +</div></blockquote> +</section> +<section id="polsturmisolatedzeromultiplicity"> +<span id="id94"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolSturmIsolatedZeroMultiplicity{}{}</span></code></h4> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolSturmIsolatedZeroMultiplicity{<sturmname>}{<index>}</span></code></p> +<blockquote> +<div><p>Expands to the multiplicity of the unique root contained in the +<code class="docutils literal notranslate"><span class="pre">index</span></code>-th interval.</p> +<div class="admonition attention"> +<p class="admonition-title">Attention</p> +<p>A prior execution of <a class="reference internal" href="#id38"><span class="std std-ref">\PolSturmIsolateZeros*{<sturmname>}</span></a> is mandatory.</p> +</div> +<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> +<span class="pre">roots</span></code> in <code class="docutils literal notranslate"><span class="pre">polexpr-examples.pdf</span></code>.</p> +</div></blockquote> +</section> +<section id="polsturmnbofisolatedzeros"> +<span id="id95"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolSturmNbOfIsolatedZeros{}</span></code></h4> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolSturmNbOfIsolatedZeros{<sturmname>}</span></code></p> +<blockquote> +<div><p>Expands to the number of real roots of the polynomial +<code class="docutils literal notranslate"><span class="pre"><sturmname>_0</span></code>, i.e. the number of distinct real roots of the +polynomial originally used to create the Sturm chain via +<a class="reference internal" href="#poltosturm"><span class="std std-ref">\PolToSturm{<polname>}{<sturmname>}</span></a>.</p> +</div></blockquote> +<div class="admonition warning"> +<p class="admonition-title">Warning</p> +<p>The next few macros counting roots, with or without multiplicities, +less than or equal to some value, are under evaluation and may be +removed from the package if their utility is judged to be not high +enough. They can be re-coded at user level on the basis of the other +documented package macros anyway.</p> +</div> +</section> +<section id="polsturmnbofrootsof-lessthanorequalto"> +<span id="polsturmnbofrootsoflessthanorequalto"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolSturmNbOfRootsOf{}\LessThanOrEqualTo{}</span></code></h4> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolSturmNbOfRootsOf{<sturmname>}\LessThanOrEqualTo{<value>}</span></code></p> +<blockquote> +<div><p>Expands to the number of distinct roots (of the polynomial used to +create the Sturm chain) less than or equal to the <code class="docutils literal notranslate"><span class="pre">value</span></code> (i.e. a +number of fraction recognizable by the <a class="reference external" href="https://www.ctan.org/pkg/xint">xintfrac</a> macros).</p> +<div class="admonition attention"> +<p class="admonition-title">Attention</p> +<p><a class="reference internal" href="#polsturmisolatezeros"><span class="std std-ref">\PolSturmIsolateZeros{<sturmname>}</span></a> must have been executed +beforehand.</p> +<p>And the argument is a <code class="docutils literal notranslate"><span class="pre"><sturmname></span></code>, not a <code class="docutils literal notranslate"><span class="pre"><polname></span></code> (this is +why the macro contains Sturm in its name), simply to be reminded +of the above constraint.</p> +</div> +</div></blockquote> +</section> +<section id="polsturmnbofrootsof-lessthanorequaltoexpr"> +<span id="polsturmnbofrootsoflessthanorequaltoexpr"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolSturmNbOfRootsOf{}\LessThanOrEqualToExpr{}</span></code></h4> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolSturmNbOfRootsOf{<sturmname>}\LessThanOrEqualToExpr{<num.</span> <span class="pre">expr.>}</span></code></p> +<blockquote> +<div><p>Expands to the number of distinct roots (of the polynomial +used to create the Sturm chain) which are less than or equal to the +given numerical expression.</p> +<div class="admonition attention"> +<p class="admonition-title">Attention</p> +<p><a class="reference internal" href="#polsturmisolatezeros"><span class="std std-ref">\PolSturmIsolateZeros{<sturmname>}</span></a> must have been executed +beforehand.</p> +</div> +</div></blockquote> +</section> +<section id="polsturmnbwithmultofrootsof-lessthanorequalto"> +<span id="polsturmnbwithmultofrootsoflessthanorequalto"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolSturmNbWithMultOfRootsOf{}\LessThanOrEqualTo{}</span></code></h4> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolSturmNbWithMultOfRootsOf{<sturmname>}\LessThanOrEqualTo{<value>}</span></code></p> +<blockquote> +<div><p>Expands to the number counted with multiplicities of the roots (of +the polynomial used to create the Sturm chain) which are less than +or equal to the given <code class="docutils literal notranslate"><span class="pre">value</span></code>.</p> +<div class="admonition attention"> +<p class="admonition-title">Attention</p> +<p><a class="reference internal" href="#id38"><span class="std std-ref">\PolSturmIsolateZeros*{<sturmname>}</span></a> (or the double starred +variant) must have been executed beforehand.</p> +</div> +</div></blockquote> +</section> +<section id="polsturmnbwithmultofrootsof-lessthanorequaltoexpr"> +<span id="polsturmnbwithmultofrootsoflessthanorequaltoexpr"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolSturmNbWithMultOfRootsOf{}\LessThanOrEqualToExpr{}</span></code></h4> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolSturmNbWithMultOfRootsOf{<sturmname>}\LessThanOrEqualToExpr{<num.</span> <span class="pre">expr.>}</span></code></p> +<blockquote> +<div><p>Expands to the total number of roots (counted with multiplicities) +which are less than or equal to the given <code class="docutils literal notranslate"><span class="pre">expression</span></code>.</p> +<div class="admonition attention"> +<p class="admonition-title">Attention</p> +<p><a class="reference internal" href="#id38"><span class="std std-ref">\PolSturmIsolateZeros*{<sturmname>}</span></a> (or the double starred +variant) must have been executed beforehand.</p> +</div> +</div></blockquote> +</section> +<section id="polsturmnbofrationalroots"> +<span id="id96"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolSturmNbOfRationalRoots{}</span></code></h4> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolSturmNbOfRationalRoots{<sturmname>}</span></code></p> +<blockquote> +<div><p>Expands to the number of rational roots (without multiplicities).</p> +<div class="admonition attention"> +<p class="admonition-title">Attention</p> +<p><a class="reference internal" href="#id41"><span class="std std-ref">\PolSturmIsolateZeros**{<sturmname>}</span></a> must have been executed +beforehand.</p> +</div> +</div></blockquote> +</section> +<section id="polsturmnbofrationalrootswithmultiplicities"> +<span id="id97"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolSturmNbOfRationalRootsWithMultiplicities{}</span></code></h4> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolSturmNbOfRationalRootsWithMultiplicities{<sturmname>}</span></code></p> +<blockquote> +<div><p>Expands to the number of rational roots (counted with multiplicities).</p> +<div class="admonition attention"> +<p class="admonition-title">Attention</p> +<p><a class="reference internal" href="#id41"><span class="std std-ref">\PolSturmIsolateZeros**{<sturmname>}</span></a> must have been executed +beforehand.</p> +</div> +</div></blockquote> +</section> +<section id="polsturmrationalroot"> +<span id="id98"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolSturmRationalRoot{}{}</span></code></h4> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolSturmRationalRoot{<sturmname>}{<k>}</span></code></p> +<blockquote> +<div><p>Expands to the k-th rational root. They are enumerated from left to +right starting at index value <code class="docutils literal notranslate"><span class="pre">1</span></code>.</p> +<div class="admonition attention"> +<p class="admonition-title">Attention</p> +<p><a class="reference internal" href="#id41"><span class="std std-ref">\PolSturmIsolateZeros**{<sturmname>}</span></a> must have been executed +beforehand.</p> +</div> +</div></blockquote> +</section> +<section id="polsturmrationalrootindex"> +<span id="id99"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolSturmRationalRootIndex{}{}</span></code></h4> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolSturmRationalRootIndex{<sturmname>}{<k>}</span></code></p> +<blockquote> +<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 +ordered real roots (counted without multiplicities). So +<a class="reference internal" href="#polsturmrationalroot"><span class="std std-ref">\PolSturmRationalRoot{<sturmname>}{<k>}</span></a> is equivalent to +this nested call:</p> +<div class="highlight-latex notranslate"><div class="highlight"><pre><span></span><span class="k">\PolSturmIsolatedZeroLeft</span><span class="nb">{</span><sturmname><span class="nb">}{</span><span class="k">\PolSturmRationalRootIndex</span><span class="nb">{</span><sturmname><span class="nb">}{</span><k><span class="nb">}}</span> +</pre></div> +</div> +<div class="admonition attention"> +<p class="admonition-title">Attention</p> +<p><a class="reference internal" href="#id41"><span class="std std-ref">\PolSturmIsolateZeros**{<sturmname>}</span></a> must have been executed +beforehand.</p> +</div> +</div></blockquote> +</section> +<section id="polsturmrationalrootmultiplicity"> +<span id="id100"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolSturmRationalRootMultiplicity{}{}</span></code></h4> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolSturmRationalRootMultiplicity{<sturmname>}{<k>}</span></code></p> +<blockquote> +<div><p>Expands to the multiplicity of the <code class="docutils literal notranslate"><span class="pre">k</span></code>th rational root.</p> +<div class="admonition attention"> +<p class="admonition-title">Attention</p> +<p><a class="reference internal" href="#id41"><span class="std std-ref">\PolSturmIsolateZeros**{<sturmname>}</span></a> must have been executed +beforehand.</p> +</div> +</div></blockquote> +</section> +<section id="polintervalwidth"> +<span id="id101"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolIntervalWidth{}{}</span></code></h4> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolIntervalWidth{<sturmname>}{<index>}</span></code></p> +<blockquote> +<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 +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> +</div></blockquote> +</section> +</section> +<section id="expandable-macros-for-use-within-execution-of-polprintintervals"> +<h3>Expandable macros for use within execution of <code class="docutils literal notranslate"><span class="pre">\PolPrintIntervals</span></code></h3> +<p>These macros are for usage within custom user redefinitions of +<a class="reference internal" href="#id56">\PolPrintIntervalsKnownRoot</a>, <a class="reference internal" href="#id57">\PolPrintIntervalsUnknownRoot</a>, or +in redefinitions of <a class="reference internal" href="#polprintintervalsprintexactzero">PolPrintIntervalsPrintExactZero</a> (used in the +default for the former) and of <a class="reference internal" href="#id59">\PolPrintIntervalsPrintLeftEndPoint</a>, +<a class="reference internal" href="#id60">\PolPrintIntervalsPrintRightEndPoint</a> (used in the default for the +latter).</p> +<section id="polprintintervalsthevar"> +<span id="id102"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervalsTheVar</span></code></h4> +<blockquote> +<div><p>Expands to the name (default <code class="docutils literal notranslate"><span class="pre">Z</span></code>) used for representing the roots, +which was passed as optional argument <code class="docutils literal notranslate"><span class="pre">varname</span></code> to +<a class="reference internal" href="#polprintintervals"><span class="std std-ref">\PolPrintIntervals[varname]{<sturmname>}</span></a>.</p> +</div></blockquote> +</section> +<section id="polprintintervalstheindex"> +<span id="id103"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervalsTheIndex</span></code></h4> +<blockquote> +<div><p>Expands to the index of the considered interval (indexing starting +at 1 for the leftmost interval).</p> +</div></blockquote> +</section> +<section id="polprintintervalsthesturmname"> +<span id="id104"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervalsTheSturmName</span></code></h4> +<blockquote> +<div><p>Expands to the argument which was passed as <code class="docutils literal notranslate"><span class="pre"><sturmname></span></code> to +<a class="reference internal" href="#polprintintervals"><span class="std std-ref">\PolPrintIntervals[varname]{<sturmname>}</span></a>.</p> +</div></blockquote> +</section> +<section id="polprintintervalstheleftendpoint"> +<span id="id105"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervalsTheLeftEndPoint</span></code></h4> +<blockquote> +<div><p>The left end point of the interval, as would be produced by +<a class="reference internal" href="#polsturmisolatedzeroleft">\PolSturmIsolatedZeroLeft</a> if it was +used with arguments the Sturm chain name and interval index returned +by <a class="reference internal" href="#id104">\PolPrintIntervalsTheSturmName</a> and +<a class="reference internal" href="#id103">\PolPrintIntervalsTheIndex</a>.</p> +</div></blockquote> +</section> +<section id="polprintintervalstherightendpoint"> +<span id="id106"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervalsTheRightEndPoint</span></code></h4> +<blockquote> +<div><p>The right end point of the interval, as would be produced by +<a class="reference internal" href="#polsturmisolatedzeroright">\PolSturmIsolatedZeroRight</a> for +this Sturm chain name and index.</p> +</div></blockquote> +</section> +<section id="polprintintervalsthemultiplicity"> +<span id="id107"></span><h4><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervalsTheMultiplicity</span></code></h4> +<blockquote> +<div><p>The multiplicity of the unique root within the interval of index +<a class="reference internal" href="#id103">\PolPrintIntervalsTheIndex</a>. Makes sense only if the starred (or +double-starred) variant of <a class="reference internal" href="#polsturmisolatezeros">\PolSturmIsolateZeros</a> was used earlier.</p> +</div></blockquote> +</section> +</section> +</section> +<section id="tex-booleans-with-names-enacting-their-defaults"> +<h2>TeX Booleans (with names enacting their defaults)</h2> +<section id="xintverbosefalse"> +<span id="id108"></span><h3><code class="docutils literal notranslate"><span class="pre">\xintverbosefalse</span></code></h3> +<blockquote> +<div><p>This is actually an <a class="reference external" href="https://www.ctan.org/pkg/xintexpr">xintexpr</a> configuration. Setting it to +<code class="docutils literal notranslate"><span class="pre">true</span></code> triggers the writing of information to the log when new +polynomial or scalar variables are defined.</p> +<div class="admonition caution"> +<p class="admonition-title">Caution</p> +<p>The macro and variable meanings as written to the log are to be +considered unstable and undocumented internal structures.</p> +</div> +</div></blockquote> +</section> +<section id="polnewpolverbosefalse"> +<span id="id109"></span><h3><code class="docutils literal notranslate"><span class="pre">\polnewpolverbosefalse</span></code></h3> +<blockquote> +<div><p>When <code class="docutils literal notranslate"><span class="pre">\poldef</span></code> is used, both a variable and a function are +defined. The default <code class="docutils literal notranslate"><span class="pre">\polnewpolverbosefalse</span></code> setting suppresses +the print-out to the log and terminal of the function macro meaning, +as it only duplicates the information contained in the variable +which is already printed out to the log and terminal.</p> +<p>However <a class="reference internal" href="#polgenfloatvariant"><span class="std std-ref">\PolGenFloatVariant{<polname>}</span></a> +does still print out the information relative to the polynomial +function it defines for use in <code class="docutils literal notranslate"><span class="pre">\xintfloateval{}</span></code> as there is no +float polynomial variable, only the</p> +<p>function, and it is the only way to see its rounded coefficients +(<code class="docutils literal notranslate"><span class="pre">\xintverbosefalse</span></code> suppresses also that info).</p> +<p>If set to <code class="docutils literal notranslate"><span class="pre">true</span></code>, it overrides in both cases +<code class="docutils literal notranslate"><span class="pre">\xintverbosefalse</span></code>. The setting only affects polynomial +declarations. Scalar variables such as those holding information on +roots obey only the <code class="docutils literal notranslate"><span class="pre">\xintverbose...</span></code> setting.</p> +<p>(new with <code class="docutils literal notranslate"><span class="pre">0.8</span></code>)</p> +</div></blockquote> +</section> +<section id="poltypesetallfalse"> +<span id="id110"></span><h3><code class="docutils literal notranslate"><span class="pre">\poltypesetallfalse</span></code></h3> +<blockquote> +<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 +coefficients.</p> +</div></blockquote> +</section> +<section id="poltoexprallfalse"> +<span id="id111"></span><h3><code class="docutils literal notranslate"><span class="pre">\poltoexprallfalse</span></code></h3> +<blockquote> +<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{<pol. expr.>}</span></a> and +<a class="reference internal" href="#poltofloatexpr"><span class="std std-ref">\PolToFloatExpr{<pol. expr.>}</span></a> will also +include the vanishing coefficients in their outputs.</p> +</div></blockquote> +</section> +</section> +<section id="utilities"> +<h2>Utilities</h2> +<section id="poldectostring"> +<span id="id112"></span><h3><code class="docutils literal notranslate"><span class="pre">\PolDecToString{}</span></code></h3> +<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolDecToString{decimal</span> <span class="pre">number}</span></code></p> +<blockquote> +<div><p>This is a utility macro to print decimal numbers. It is an alias +for <code class="docutils literal notranslate"><span class="pre">\xintDecToString</span></code>.</p> +</div></blockquote> +<blockquote> +<div><p>For example +<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> +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 +illustrates that trailing zeros are not trimmed.</p> +<p>To trim trailing zeroes, one can use +<code class="docutils literal notranslate"><span class="pre">\PolDecToString{\xintREZ{#1}}</span></code>.</p> +<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 +macro does not identify that this is in fact a number with a finite +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> +documentation.</p> +</div></blockquote> +</section> +<section id="polexprsetup-key-val"> +<span id="polexprsetup"></span><h3><code class="docutils literal notranslate"><span class="pre">\polexprsetup{key=val,...}</span></code></h3> +<blockquote> +<div><p>Serves to customize the package. Currently only two keys are +recognized:</p> +<ul class="simple"> +<li><p><code class="docutils literal notranslate"><span class="pre">norr</span></code>: the postfix that <a class="reference internal" href="#id41"><span class="std std-ref">\PolSturmIsolateZeros**{<sturmname>}</span></a> +should append to <code class="docutils literal notranslate"><span class="pre"><sturmname></span></code> to declare the primitive polynomial +obtained from original one after removal of all rational roots. +The default value is <code class="docutils literal notranslate"><span class="pre">_norr</span></code> (standing for “no rational roots”).</p></li> +<li><p><code class="docutils literal notranslate"><span class="pre">sqfnorr</span></code>: the postfix that <a class="reference internal" href="#id41"><span class="std std-ref">\PolSturmIsolateZeros**{<sturmname>}</span></a> +should append to <code class="docutils literal notranslate"><span class="pre"><sturmname></span></code> to declare the primitive polynomial +obtained from original one after removal of all rational roots and +suppression of all multiplicities. +The default value is <code class="docutils literal notranslate"><span class="pre">_sqf_norr</span></code> (standing for “square-free with +no rational roots”).</p></li> +</ul> +<p>The package executes <code class="docutils literal notranslate"><span class="pre">\polexprsetup{norr=_norr,</span> +<span class="pre">sqfnorr=_sqf_norr}</span></code> as default.</p> +</div></blockquote> +</section> +</section> +<section id="technicalities"> +<h2>Technicalities</h2> +<ul> +<li><p>The <code class="docutils literal notranslate"><span class="pre">@</span></code> is allowed in the name of a polynomial (independently of +whether it is of catcode letter or other.) This has always been the +case, but was not documented by polexpr prior to <code class="docutils literal notranslate"><span class="pre">0.8</span></code>, as the +author has never found the time to provide some official guidelines on +how to name temporary variables and the <code class="docutils literal notranslate"><span class="pre">@</span></code> is used already as such +internally; time has still not yet been found to review the situation +but it seems reasonable to recommend at any rate to restrict usage of +<code class="docutils literal notranslate"><span class="pre">@</span></code> to scratch variables of defined macros and to avoid using it to +name document variable.</p></li> +<li><p>Catcodes are set temporarily by <a class="reference internal" href="#poldef">\poldef</a> macro to safe +values prior to grab the polynomial expression up to the terminator +<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 +brace-enclosed polynomial expression. This gives a layer of +protection in case some package (for example the <code class="docutils literal notranslate"><span class="pre">babel-french</span></code> module) +has made some characters active. It will fail though if the whole +thing is located inside some definition of a macro done at a time the +characters are active.</p></li> +<li><div class="admonition attention"> +<p class="admonition-title">Attention</p> +<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>, +<code class="docutils literal notranslate"><span class="pre">\poldef</span></code> uses a naive delimited macro to fetch up to the +expression terminator <code class="docutils literal notranslate"><span class="pre">";"</span></code>, hence it will be fooled if some +<code class="docutils literal notranslate"><span class="pre">;</span></code> is used inside the expression (which is possible as it +appears in some <a class="reference external" href="https://www.ctan.org/pkg/xintexpr">xintexpr</a> constructs). Work-around is to use curly +braces around the inner semi-colons, or simpler to use +<code class="docutils literal notranslate"><span class="pre">\PolDef</span></code>.</p> +</div> +</li> +<li><p>As a consequence of <a class="reference external" href="https://www.ctan.org/pkg/xint">xintfrac</a> addition and subtraction always using +least common multiples for the denominators, user-chosen common +denominators (currently) survive additions and multiplications. For +example, this:</p> +<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; +<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; +<span class="k">\poldef</span> PQ(x):= P*Q; +</pre></div> +</div> +<p>gives internally the polynomial:</p> +<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 +</pre></div> +</div> +<p>where all coefficients have the same denominator 6. Notice though that +<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 +default) it recognizes and filters out coefficients equal to one or +minus one. One can use for example +<code class="docutils literal notranslate"><span class="pre">\PolToCSV{PQ}</span></code> to see the internally stored coefficients.</p> +</li> +<li><p><a class="reference internal" href="#poldiff"><span class="std std-ref">\PolDiff{<polname_1>}{<polname_2>}</span></a> always applies <code class="docutils literal notranslate"><span class="pre">\xintPIrr</span></code> to the +resulting coefficients, which means that fractions are reduced to +lowest terms but ignoring an already separated <em>power of ten</em> part <code class="docutils literal notranslate"><span class="pre">[N]</span></code> +present in the internal representation. This is tentative and may change.</p> +<p>Same remark for <a class="reference internal" href="#polantidiff"><span class="std std-ref">\PolAntiDiff{<polname_1>}{<polname_2>}</span></a>.</p> +</li> +<li><p>Currently, the package stores all coefficients from index <code class="docutils literal notranslate"><span class="pre">0</span></code> to +index equal to the polynomial degree inside a single macro, as a list. +This data structure is obviously very inefficient for polynomials of +high degree and few coefficients (as an example with <code class="docutils literal notranslate"><span class="pre">\poldef</span> +<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> +<span class="pre">f(x)^2;</span></code> will do of the order of 1,000,000 multiplications and +additions involvings only zeroes… which does take time). This +may change in the future.</p></li> +<li><p>As is to be expected internal structures of the package are barely +documented and unstable. Don’t use them.</p></li> +</ul> +</section> +</section> + + + <div class="clearer"></div> + </div> + </div> + </div> + <div class="sphinxsidebar" role="navigation" aria-label="main navigation"> + <div class="sphinxsidebarwrapper"><h3>Contents of this page</h3> +<ul> +<li><a class="reference internal" href="#">polexpr reference</a><ul> +<li><a class="reference internal" href="#syntax-overview-via-examples">Syntax overview via examples</a></li> +<li><a class="reference internal" href="#using-defined-polynomials-in-floating-point-context">Using defined polynomials in floating point context</a></li> +<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> +<li><a class="reference internal" href="#warning-about-unstability-of-the-new-syntax">Warning about unstability of the new syntax</a></li> +<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> +<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> +<li><a class="reference internal" href="#comparison-operators">Comparison 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> +<li><a class="reference internal" href="#pol-nutple-expression"><code class="docutils literal notranslate"><span class="pre">pol(<nutple</span> <span class="pre">expression>)</span></code></a></li> +<li><a class="reference internal" href="#lpol-nutple-expression"><code class="docutils literal notranslate"><span class="pre">lpol(<nutple</span> <span class="pre">expression>)</span></code></a></li> +<li><a class="reference internal" href="#xinteval-pol-expr"><code class="docutils literal notranslate"><span class="pre">\xinteval{<pol.</span> <span class="pre">expr.>}</span></code></a></li> +<li><a class="reference internal" href="#evalp-pol-expr-pol-expr"><code class="docutils literal notranslate"><span class="pre">evalp(<pol.</span> <span class="pre">expr.>,</span> <span class="pre"><pol.</span> <span class="pre">expr>)</span></code></a></li> +<li><a class="reference internal" href="#deg-pol-expr"><code class="docutils literal notranslate"><span class="pre">deg(<pol.</span> <span class="pre">expr.>)</span></code></a></li> +<li><a class="reference internal" href="#coeffs-pol-expr"><code class="docutils literal notranslate"><span class="pre">coeffs(<pol.</span> <span class="pre">expr.>)</span></code></a></li> +<li><a class="reference internal" href="#lcoeffs-pol-expr"><code class="docutils literal notranslate"><span class="pre">lcoeffs(<pol.</span> <span class="pre">expr.>)</span></code></a></li> +<li><a class="reference internal" href="#coeff-pol-expr-num-expr"><code class="docutils literal notranslate"><span class="pre">coeff(<pol.</span> <span class="pre">expr.>,</span> <span class="pre"><num.</span> <span class="pre">expr.>)</span></code></a></li> +<li><a class="reference internal" href="#lc-pol-expr"><code class="docutils literal notranslate"><span class="pre">lc(<pol.</span> <span class="pre">expr.>)</span></code></a></li> +<li><a class="reference internal" href="#monicpart-pol-expr"><code class="docutils literal notranslate"><span class="pre">monicpart(<pol.</span> <span class="pre">expr.>)</span></code></a></li> +<li><a class="reference internal" href="#cont-pol-expr"><code class="docutils literal notranslate"><span class="pre">cont(<pol.</span> <span class="pre">expr.>)</span></code></a></li> +<li><a class="reference internal" href="#primpart-pol-expr"><code class="docutils literal notranslate"><span class="pre">primpart(<pol.</span> <span class="pre">expr.>)</span></code></a></li> +<li><a class="reference internal" href="#quorem-pol-expr-pol-expr"><code class="docutils literal notranslate"><span class="pre">quorem(<pol.</span> <span class="pre">expr.>,</span> <span class="pre"><pol.</span> <span class="pre">expr.>)</span></code></a></li> +<li><a class="reference internal" href="#quo-pol-expr-pol-expr"><code class="docutils literal notranslate"><span class="pre">quo(<pol.</span> <span class="pre">expr.>,</span> <span class="pre"><pol.</span> <span class="pre">expr.>)</span></code></a></li> +<li><a class="reference internal" href="#rem-pol-expr-pol-expr"><code class="docutils literal notranslate"><span class="pre">rem(<pol.</span> <span class="pre">expr.>,</span> <span class="pre"><pol.</span> <span class="pre">expr.>)</span></code></a></li> +<li><a class="reference internal" href="#prem-pol-expr-1-pol-expr-2"><code class="docutils literal notranslate"><span class="pre">prem(<pol.</span> <span class="pre">expr.</span> <span class="pre">1>,</span> <span class="pre"><pol.</span> <span class="pre">expr.</span> <span class="pre">2>)</span></code></a></li> +<li><a class="reference internal" href="#divmod-pol-expr-1-pol-expr-2"><code class="docutils literal notranslate"><span class="pre">divmod(<pol.</span> <span class="pre">expr.</span> <span class="pre">1>,</span> <span class="pre"><pol.</span> <span class="pre">expr.</span> <span class="pre">2>)</span></code></a></li> +<li><a class="reference internal" href="#mod-pol-expr-1-pol-expr-2"><code class="docutils literal notranslate"><span class="pre">mod(<pol.</span> <span class="pre">expr.</span> <span class="pre">1>,</span> <span class="pre"><pol.</span> <span class="pre">expr.</span> <span class="pre">2>)</span></code></a></li> +<li><a class="reference internal" href="#polgcd-pol-expr-1-pol-expr-2"><code class="docutils literal notranslate"><span class="pre">polgcd(<pol.</span> <span class="pre">expr.</span> <span class="pre">1>,</span> <span class="pre"><pol.</span> <span class="pre">expr.</span> <span class="pre">2>,</span> <span class="pre">...)</span></code></a></li> +<li><a class="reference internal" href="#resultant-pol-expr-1-pol-expr-2"><code class="docutils literal notranslate"><span class="pre">resultant(<pol.</span> <span class="pre">expr.</span> <span class="pre">1>,</span> <span class="pre"><pol.</span> <span class="pre">expr.</span> <span class="pre">2>)</span></code></a></li> +<li><a class="reference internal" href="#disc-pol-expr"><code class="docutils literal notranslate"><span class="pre">disc(<pol.</span> <span class="pre">expr.>)</span></code></a></li> +<li><a class="reference internal" href="#polpowmod-pol-expr-1-num-expr-pol-expr-2"><code class="docutils literal notranslate"><span class="pre">polpowmod(<pol.</span> <span class="pre">expr.</span> <span class="pre">1>,</span> <span class="pre"><num.</span> <span class="pre">expr.>,</span> <span class="pre"><pol.</span> <span class="pre">expr.</span> <span class="pre">2>)</span></code></a></li> +<li><a class="reference internal" href="#rdcoeffs-pol-expr"><code class="docutils literal notranslate"><span class="pre">rdcoeffs(<pol.</span> <span class="pre">expr.>)</span></code></a></li> +<li><a class="reference internal" href="#rdzcoeffs-pol-expr"><code class="docutils literal notranslate"><span class="pre">rdzcoeffs(<pol.</span> <span class="pre">expr.>)</span></code></a></li> +<li><a class="reference internal" href="#diff1-pol-expr"><code class="docutils literal notranslate"><span class="pre">diff1(<pol.</span> <span class="pre">expr.>)</span></code></a></li> +<li><a class="reference internal" href="#diff2-pol-expr"><code class="docutils literal notranslate"><span class="pre">diff2(<pol.</span> <span class="pre">expr.>)</span></code></a></li> +<li><a class="reference internal" href="#diffn-pol-expr-p-num-expr-n"><code class="docutils literal notranslate"><span class="pre">diffn(<pol.</span> <span class="pre">expr.</span> <span class="pre">P>,</span> <span class="pre"><num.</span> <span class="pre">expr.</span> <span class="pre">n>)</span></code></a></li> +<li><a class="reference internal" href="#antider-pol-expr-p"><code class="docutils literal notranslate"><span class="pre">antider(<pol.</span> <span class="pre">expr.</span> <span class="pre">P>)</span></code></a></li> +<li><a class="reference internal" href="#intfrom-pol-expr-p-pol-expr-c"><code class="docutils literal notranslate"><span class="pre">intfrom(<pol.</span> <span class="pre">expr.</span> <span class="pre">P>,</span> <span class="pre"><pol.</span> <span class="pre">expr.</span> <span class="pre">c>)</span></code></a></li> +<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(<pol.</span> <span class="pre">expr.</span> <span class="pre">P>,</span> <span class="pre">[<pol.</span> <span class="pre">expr.</span> <span class="pre">a>,</span> <span class="pre"><pol.</span> <span class="pre">expr.</span> <span class="pre">b>])</span></code></a></li> +</ul> +</li> +<li><a class="reference internal" href="#non-expandable-macros">Non-expandable macros</a><ul> +<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> +<li><a class="reference internal" href="#poldef-letter-polname-expr-using-the-letter-as-indeterminate"><code class="docutils literal notranslate"><span class="pre">\PolDef[<letter>]{<polname>}{<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>}</span></code></a></li> +<li><a class="reference internal" href="#polgenfloatvariant"><code class="docutils literal notranslate"><span class="pre">\PolGenFloatVariant{}</span></code></a></li> +<li><a class="reference internal" href="#poltypeset"><code class="docutils literal notranslate"><span class="pre">\PolTypeset{}</span></code></a><ul> +<li><a class="reference internal" href="#poltypesetcmd"><code class="docutils literal notranslate"><span class="pre">\PolTypesetCmd{}</span></code></a><ul> +<li><a class="reference internal" href="#polifcoeffisplusorminusone"><code class="docutils literal notranslate"><span class="pre">\PolIfCoeffIsPlusOrMinusOne{}{}</span></code></a></li> +</ul> +</li> +<li><a class="reference internal" href="#poltypesetone"><code class="docutils literal notranslate"><span class="pre">\PolTypesetOne{}</span></code></a></li> +<li><a class="reference internal" href="#poltypesetmonomialcmd"><code class="docutils literal notranslate"><span class="pre">\PolTypesetMonomialCmd</span></code></a></li> +<li><a class="reference internal" href="#poltypesetcmdprefix"><code class="docutils literal notranslate"><span class="pre">\PolTypesetCmdPrefix{}</span></code></a></li> +</ul> +</li> +<li><a class="reference internal" href="#id13"><code class="docutils literal notranslate"><span class="pre">\PolTypeset*{}</span></code></a></li> +<li><a class="reference internal" href="#pollet"><code class="docutils literal notranslate"><span class="pre">\PolLet{}={}</span></code></a></li> +<li><a class="reference internal" href="#polgloballet"><code class="docutils literal notranslate"><span class="pre">\PolGlobalLet{}={}</span></code></a></li> +<li><a class="reference internal" href="#polassign-toarray"><code class="docutils literal notranslate"><span class="pre">\PolAssign{}\toarray{}</span></code></a></li> +<li><a class="reference internal" href="#polget-fromarray"><code class="docutils literal notranslate"><span class="pre">\PolGet{}\fromarray{}</span></code></a></li> +<li><a class="reference internal" href="#polfromcsv"><code class="docutils literal notranslate"><span class="pre">\PolFromCSV{}{}</span></code></a></li> +<li><a class="reference internal" href="#polmapcoeffs"><code class="docutils literal notranslate"><span class="pre">\PolMapCoeffs{}{}</span></code></a></li> +<li><a class="reference internal" href="#polreducecoeffs"><code class="docutils literal notranslate"><span class="pre">\PolReduceCoeffs{}</span></code></a></li> +<li><a class="reference internal" href="#id20"><code class="docutils literal notranslate"><span class="pre">\PolReduceCoeffs*{}</span></code></a></li> +<li><a class="reference internal" href="#polmakemonic"><code class="docutils literal notranslate"><span class="pre">\PolMakeMonic{}</span></code></a></li> +<li><a class="reference internal" href="#polmakeprimitive"><code class="docutils literal notranslate"><span class="pre">\PolMakePrimitive{}</span></code></a></li> +<li><a class="reference internal" href="#poldiff"><code class="docutils literal notranslate"><span class="pre">\PolDiff{}{}</span></code></a></li> +<li><a class="reference internal" href="#id25"><code class="docutils literal notranslate"><span class="pre">\PolDiff[]{}{}</span></code></a></li> +<li><a class="reference internal" href="#polantidiff"><code class="docutils literal notranslate"><span class="pre">\PolAntiDiff{}{}</span></code></a></li> +<li><a class="reference internal" href="#id28"><code class="docutils literal notranslate"><span class="pre">\PolAntiDiff[]{}{}</span></code></a></li> +<li><a class="reference internal" href="#poldivide"><code class="docutils literal notranslate"><span class="pre">\PolDivide{}{}{}{}</span></code></a></li> +<li><a class="reference internal" href="#polquo"><code class="docutils literal notranslate"><span class="pre">\PolQuo{}{}{}</span></code></a></li> +<li><a class="reference internal" href="#polrem"><code class="docutils literal notranslate"><span class="pre">\PolRem{}{}{}</span></code></a></li> +<li><a class="reference internal" href="#polgcd"><code class="docutils literal notranslate"><span class="pre">\PolGCD{}{}{}</span></code></a></li> +<li><a class="reference internal" href="#root-localization-routines-via-the-sturm-theorem">Root localization routines via the Sturm Theorem</a><ul> +<li><a class="reference internal" href="#poltosturm"><code class="docutils literal notranslate"><span class="pre">\PolToSturm{}{}</span></code></a></li> +<li><a class="reference internal" href="#id35"><code class="docutils literal notranslate"><span class="pre">\PolToSturm*{}{}</span></code></a></li> +<li><a class="reference internal" href="#polsturmisolatezeros"><code class="docutils literal notranslate"><span class="pre">\PolSturmIsolateZeros{}</span></code></a></li> +<li><a class="reference internal" href="#id38"><code class="docutils literal notranslate"><span class="pre">\PolSturmIsolateZeros*{}</span></code></a><ul> +<li><a class="reference internal" href="#polsturmisolatezerosandgetmultiplicities"><code class="docutils literal notranslate"><span class="pre">\PolSturmIsolateZerosAndGetMultiplicities{}</span></code></a></li> +</ul> +</li> +<li><a class="reference internal" href="#id41"><code class="docutils literal notranslate"><span class="pre">\PolSturmIsolateZeros**{}</span></code></a><ul> +<li><a class="reference internal" href="#polsturmisolatezerosgetmultiplicitiesandrationalroots"><code class="docutils literal notranslate"><span class="pre">\PolSturmIsolateZerosGetMultiplicitiesAndRationalRoots</span></code></a></li> +</ul> +</li> +<li><a class="reference internal" href="#polsturmisolatezerosandfindrationalroots"><code class="docutils literal notranslate"><span class="pre">\PolSturmIsolateZerosAndFindRationalRoots{}</span></code></a></li> +<li><a class="reference internal" href="#polrefineinterval"><code class="docutils literal notranslate"><span class="pre">\PolRefineInterval*{}{}</span></code></a></li> +<li><a class="reference internal" href="#id46"><code class="docutils literal notranslate"><span class="pre">\PolRefineInterval[]{}{}</span></code></a></li> +<li><a class="reference internal" href="#polensureintervallength"><code class="docutils literal notranslate"><span class="pre">\PolEnsureIntervalLength{}{}{}</span></code></a></li> +<li><a class="reference internal" href="#polensureintervallengths"><code class="docutils literal notranslate"><span class="pre">\PolEnsureIntervalLengths{}{}</span></code></a></li> +<li><a class="reference internal" href="#polsettosturmchainsignchangesat"><code class="docutils literal notranslate"><span class="pre">\PolSetToSturmChainSignChangesAt{}{}{}</span></code></a></li> +<li><a class="reference internal" href="#polsettonbofzeroswithin"><code class="docutils literal notranslate"><span class="pre">\PolSetToNbOfZerosWithin{}{}{}{}</span></code></a></li> +</ul> +</li> +<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[<varname>]{}</span></code></a><ul> +<li><a class="reference internal" href="#polprintintervalsnorealroots"><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervalsNoRealRoots</span></code></a></li> +<li><a class="reference internal" href="#polprintintervalsbeginenv"><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervalsBeginEnv</span></code></a></li> +<li><a class="reference internal" href="#polprintintervalsendenv"><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervalsEndEnv</span></code></a></li> +<li><a class="reference internal" href="#polprintintervalsrowseparator"><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervalsRowSeparator</span></code></a></li> +<li><a class="reference internal" href="#polprintintervalsknownroot"><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervalsKnownRoot</span></code></a></li> +<li><a class="reference internal" href="#polprintintervalsunknownroot"><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervalsUnknownRoot</span></code></a></li> +<li><a class="reference internal" href="#polprintintervalsprintexactzero"><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervalsPrintExactZero</span></code></a></li> +<li><a class="reference internal" href="#polprintintervalsprintleftendpoint"><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervalsPrintLeftEndPoint</span></code></a></li> +<li><a class="reference internal" href="#polprintintervalsprintrightendpoint"><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervalsPrintRightEndPoint</span></code></a></li> +<li><a class="reference internal" href="#polprintintervals-varname"><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervals*[<varname>]{}</span></code></a><ul> +<li><a class="reference internal" href="#polprintintervalsprintmultiplicity"><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervalsPrintMultiplicity</span></code></a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li><a class="reference internal" href="#expandable-macros">Expandable macros</a><ul> +<li><a class="reference internal" href="#poltoexpr"><code class="docutils literal notranslate"><span class="pre">\PolToExpr{}</span></code></a><ul> +<li><a class="reference internal" href="#poltoexprvar"><code class="docutils literal notranslate"><span class="pre">\PolToExprVar</span></code></a></li> +<li><a class="reference internal" href="#poltoexprinvar"><code class="docutils literal notranslate"><span class="pre">\PolToExprInVar</span></code></a></li> +<li><a class="reference internal" href="#poltoexprtimes"><code class="docutils literal notranslate"><span class="pre">\PolToExprTimes</span></code></a></li> +<li><a class="reference internal" href="#poltoexprcaret"><code class="docutils literal notranslate"><span class="pre">\PolToExprCaret</span></code></a></li> +<li><a class="reference internal" href="#poltoexprcmd"><code class="docutils literal notranslate"><span class="pre">\PolToExprCmd{}</span></code></a></li> +<li><a class="reference internal" href="#poltoexproneterm"><code class="docutils literal notranslate"><span class="pre">\PolToExprOneTerm{}{}</span></code></a></li> +<li><a class="reference internal" href="#poltoexpronetermstylea"><code class="docutils literal notranslate"><span class="pre">\PolToExprOneTermStyleA{}{}</span></code></a></li> +<li><a class="reference internal" href="#poltoexpronetermstyleb"><code class="docutils literal notranslate"><span class="pre">\PolToExprOneTermStyleB{}{}</span></code></a></li> +<li><a class="reference internal" href="#poltoexprtermprefix"><code class="docutils literal notranslate"><span class="pre">\PolToExprTermPrefix{}</span></code></a></li> +</ul> +</li> +<li><a class="reference internal" href="#poltofloatexpr"><code class="docutils literal notranslate"><span class="pre">\PolToFloatExpr{}</span></code></a><ul> +<li><a class="reference internal" href="#poltofloatexproneterm"><code class="docutils literal notranslate"><span class="pre">\PolToFloatExprOneTerm{}{}</span></code></a></li> +<li><a class="reference internal" href="#poltofloatexprcmd"><code class="docutils literal notranslate"><span class="pre">\PolToFloatExprCmd{}</span></code></a></li> +</ul> +</li> +<li><a class="reference internal" href="#id78"><code class="docutils literal notranslate"><span class="pre">\PolToExpr*{}</span></code></a></li> +<li><a class="reference internal" href="#id80"><code class="docutils literal notranslate"><span class="pre">\PolToFloatExpr*{}</span></code></a></li> +<li><a class="reference internal" href="#polnthcoeff"><code class="docutils literal notranslate"><span class="pre">\PolNthCoeff{}{}</span></code></a></li> +<li><a class="reference internal" href="#polleadingcoeff"><code class="docutils literal notranslate"><span class="pre">\PolLeadingCoeff{}</span></code></a></li> +<li><a class="reference internal" href="#poldegree"><code class="docutils literal notranslate"><span class="pre">\PolDegree{}</span></code></a></li> +<li><a class="reference internal" href="#policontent"><code class="docutils literal notranslate"><span class="pre">\PolIContent{}</span></code></a></li> +<li><a class="reference internal" href="#poltolist"><code class="docutils literal notranslate"><span class="pre">\PolToList{}</span></code></a></li> +<li><a class="reference internal" href="#poltocsv"><code class="docutils literal notranslate"><span class="pre">\PolToCSV{}</span></code></a></li> +<li><a class="reference internal" href="#poleval-atexpr"><code class="docutils literal notranslate"><span class="pre">\PolEval{}\AtExpr{}</span></code></a></li> +<li><a class="reference internal" href="#poleval-at"><code class="docutils literal notranslate"><span class="pre">\PolEval{}\At{}</span></code></a></li> +<li><a class="reference internal" href="#polevalreduced-atexpr"><code class="docutils literal notranslate"><span class="pre">\PolEvalReduced{}\AtExpr{}</span></code></a></li> +<li><a class="reference internal" href="#polevalreduced-at"><code class="docutils literal notranslate"><span class="pre">\PolEvalReduced{}\At{}</span></code></a></li> +<li><a class="reference internal" href="#polfloateval-atexpr"><code class="docutils literal notranslate"><span class="pre">\PolFloatEval{}\AtExpr{}</span></code></a></li> +<li><a class="reference internal" href="#polfloateval-at"><code class="docutils literal notranslate"><span class="pre">\PolFloatEval{}\At{}</span></code></a></li> +<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> +<li><a class="reference internal" href="#polsturmchainlength"><code class="docutils literal notranslate"><span class="pre">\PolSturmChainLength{}</span></code></a></li> +<li><a class="reference internal" href="#polsturmifzeroexactlyknown"><code class="docutils literal notranslate"><span class="pre">\PolSturmIfZeroExactlyKnown{}{}{}{}</span></code></a></li> +<li><a class="reference internal" href="#polsturmisolatedzeroleft"><code class="docutils literal notranslate"><span class="pre">\PolSturmIsolatedZeroLeft{}{}</span></code></a></li> +<li><a class="reference internal" href="#polsturmisolatedzeroright"><code class="docutils literal notranslate"><span class="pre">\PolSturmIsolatedZeroRight{}{}</span></code></a></li> +<li><a class="reference internal" href="#polsturmisolatedzeromultiplicity"><code class="docutils literal notranslate"><span class="pre">\PolSturmIsolatedZeroMultiplicity{}{}</span></code></a></li> +<li><a class="reference internal" href="#polsturmnbofisolatedzeros"><code class="docutils literal notranslate"><span class="pre">\PolSturmNbOfIsolatedZeros{}</span></code></a></li> +<li><a class="reference internal" href="#polsturmnbofrootsof-lessthanorequalto"><code class="docutils literal notranslate"><span class="pre">\PolSturmNbOfRootsOf{}\LessThanOrEqualTo{}</span></code></a></li> +<li><a class="reference internal" href="#polsturmnbofrootsof-lessthanorequaltoexpr"><code class="docutils literal notranslate"><span class="pre">\PolSturmNbOfRootsOf{}\LessThanOrEqualToExpr{}</span></code></a></li> +<li><a class="reference internal" href="#polsturmnbwithmultofrootsof-lessthanorequalto"><code class="docutils literal notranslate"><span class="pre">\PolSturmNbWithMultOfRootsOf{}\LessThanOrEqualTo{}</span></code></a></li> +<li><a class="reference internal" href="#polsturmnbwithmultofrootsof-lessthanorequaltoexpr"><code class="docutils literal notranslate"><span class="pre">\PolSturmNbWithMultOfRootsOf{}\LessThanOrEqualToExpr{}</span></code></a></li> +<li><a class="reference internal" href="#polsturmnbofrationalroots"><code class="docutils literal notranslate"><span class="pre">\PolSturmNbOfRationalRoots{}</span></code></a></li> +<li><a class="reference internal" href="#polsturmnbofrationalrootswithmultiplicities"><code class="docutils literal notranslate"><span class="pre">\PolSturmNbOfRationalRootsWithMultiplicities{}</span></code></a></li> +<li><a class="reference internal" href="#polsturmrationalroot"><code class="docutils literal notranslate"><span class="pre">\PolSturmRationalRoot{}{}</span></code></a></li> +<li><a class="reference internal" href="#polsturmrationalrootindex"><code class="docutils literal notranslate"><span class="pre">\PolSturmRationalRootIndex{}{}</span></code></a></li> +<li><a class="reference internal" href="#polsturmrationalrootmultiplicity"><code class="docutils literal notranslate"><span class="pre">\PolSturmRationalRootMultiplicity{}{}</span></code></a></li> +<li><a class="reference internal" href="#polintervalwidth"><code class="docutils literal notranslate"><span class="pre">\PolIntervalWidth{}{}</span></code></a></li> +</ul> +</li> +<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> +<li><a class="reference internal" href="#polprintintervalsthevar"><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervalsTheVar</span></code></a></li> +<li><a class="reference internal" href="#polprintintervalstheindex"><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervalsTheIndex</span></code></a></li> +<li><a class="reference internal" href="#polprintintervalsthesturmname"><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervalsTheSturmName</span></code></a></li> +<li><a class="reference internal" href="#polprintintervalstheleftendpoint"><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervalsTheLeftEndPoint</span></code></a></li> +<li><a class="reference internal" href="#polprintintervalstherightendpoint"><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervalsTheRightEndPoint</span></code></a></li> +<li><a class="reference internal" href="#polprintintervalsthemultiplicity"><code class="docutils literal notranslate"><span class="pre">\PolPrintIntervalsTheMultiplicity</span></code></a></li> +</ul> +</li> +</ul> +</li> +<li><a class="reference internal" href="#tex-booleans-with-names-enacting-their-defaults">TeX Booleans (with names enacting their defaults)</a><ul> +<li><a class="reference internal" href="#xintverbosefalse"><code class="docutils literal notranslate"><span class="pre">\xintverbosefalse</span></code></a></li> +<li><a class="reference internal" href="#polnewpolverbosefalse"><code class="docutils literal notranslate"><span class="pre">\polnewpolverbosefalse</span></code></a></li> +<li><a class="reference internal" href="#poltypesetallfalse"><code class="docutils literal notranslate"><span class="pre">\poltypesetallfalse</span></code></a></li> +<li><a class="reference internal" href="#poltoexprallfalse"><code class="docutils literal notranslate"><span class="pre">\poltoexprallfalse</span></code></a></li> +</ul> +</li> +<li><a class="reference internal" href="#utilities">Utilities</a><ul> +<li><a class="reference internal" href="#poldectostring"><code class="docutils literal notranslate"><span class="pre">\PolDecToString{}</span></code></a></li> +<li><a class="reference internal" href="#polexprsetup-key-val"><code class="docutils literal notranslate"><span class="pre">\polexprsetup{key=val,...}</span></code></a></li> +</ul> +</li> +<li><a class="reference internal" href="#technicalities">Technicalities</a></li> +</ul> +</li> +</ul> + + <div role="note" aria-label="source link"> + <h3>This Page</h3> + <ul class="this-page-menu"> + <li><a href="polexpr-ref.rst.txt" + rel="nofollow">Show Source</a></li> + </ul> + </div> + <div> + <h4>Previous topic</h4> + <p class="topless"><a href="polexpr.html" + title="previous chapter">Introduction to polexpr</a></p> + </div> + <div> + <h4>Next topic</h4> + <p class="topless"><a href="polexpr-changes.html" + title="next chapter">CHANGES</a></p> + </div> + </div> + </div> + <div class="clearer"></div> + </div> + <div class="related" role="navigation" aria-label="related navigation"> + <h3>Navigation</h3> + <ul> + <li class="right" style="margin-right: 10px"> + <a href="polexpr-changes.html" title="CHANGES" + >next</a></li> + <li class="right" > + <a href="polexpr.html" title="Introduction to polexpr" + >previous</a> |</li> + <li class="nav-item nav-item-0"><a href="polexpr.html">polexpr 0.8.7 documentation</a> »</li> + <li class="nav-item nav-item-this"><a href="">polexpr reference</a></li> + </ul> + </div> + <div class="footer" role="contentinfo"> + © Copyright 2022, Jean-François Burnol. + Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 5.0.0+/f58771c09. + </div> + </body> +</html>
\ No newline at end of file |