summaryrefslogtreecommitdiff
path: root/macros/generic/polexpr/polexpr-ref.html
blob: 9f3767c48de8dfd1441b957e1a5021664f888649 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
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 &#8212; 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> &#187;</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">&#64;</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>&lt;polname&gt;<span class="nb">}{</span>&lt;expr. using letter as indeterminate&gt;<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">%  &lt;--- 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">%  &lt;--- 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&#39;<span class="nb">}</span><span class="k">\PolDiff</span><span class="nb">{</span>f&#39;<span class="nb">}{</span>f&#39;&#39;<span class="nb">}</span><span class="k">\PolDiff</span><span class="nb">{</span>f&#39;&#39;<span class="nb">}{</span>f&#39;&#39;&#39;<span class="nb">}</span><span class="c">%</span>
<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&#39;</span><span class="o">(</span><span class="nb">z</span><span class="o">)</span><span class="nb">  </span><span class="o">=</span><span class="nb"> </span><span class="nv">\PolTypeset</span><span class="o">[</span><span class="nb">z</span><span class="o">]</span><span class="nb">{f&#39;}   </span><span class="s">$$</span>
<span class="sb">$$</span><span class="nb">f&#39;&#39;</span><span class="o">(</span><span class="nb">z</span><span class="o">)</span><span class="nb"> </span><span class="o">=</span><span class="nb"> </span><span class="nv">\PolTypeset</span><span class="o">[</span><span class="nb">z</span><span class="o">]</span><span class="nb">{f&#39;&#39;}  </span><span class="s">$$</span>
<span class="sb">$$</span><span class="nb">f&#39;&#39;&#39;</span><span class="o">(</span><span class="nb">z</span><span class="o">)=</span><span class="nb"> </span><span class="nv">\PolTypeset</span><span class="o">[</span><span class="nb">z</span><span class="o">]</span><span class="nb">{f&#39;&#39;&#39;} </span><span class="s">$$</span>
</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{&lt;pol. expr.&gt;}</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">&lt;,</span> <span class="pre">&gt;,</span> <span class="pre">&lt;=,</span> <span class="pre">&gt;=,</span> <span class="pre">==,</span> <span class="pre">!=</span></code></h3>
<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(&lt;nutple</span> <span class="pre">expression&gt;)</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(&lt;nutple</span> <span class="pre">expression&gt;)</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{&lt;pol.</span> <span class="pre">expr.&gt;}</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(&lt;pol.</span> <span class="pre">expr.&gt;,</span> <span class="pre">&lt;pol.</span> <span class="pre">expr&gt;)</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(&lt;pol.</span> <span class="pre">expr.&gt;)</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)&lt;0</span></code> correctly detects the zero polynomial,
and <code class="docutils literal notranslate"><span class="pre">deg(P)&lt;=0</span></code> detects scalars.</p>
</div>
</section>
<section id="coeffs-pol-expr">
<h3><code class="docutils literal notranslate"><span class="pre">coeffs(&lt;pol.</span> <span class="pre">expr.&gt;)</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(&lt;pol.</span> <span class="pre">expr.&gt;)</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(&lt;pol.</span> <span class="pre">expr.&gt;,</span> <span class="pre">&lt;num.</span> <span class="pre">expr.&gt;)</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{&lt;polname&gt;}{&lt;index&gt;}</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(&lt;pol. expr.&gt;)</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(&lt;pol.</span> <span class="pre">expr.&gt;)</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(&lt;pol.</span> <span class="pre">expr.&gt;)</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(&lt;pol.</span> <span class="pre">expr.&gt;)</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(&lt;pol.</span> <span class="pre">expr.&gt;)</span></code></h3>
<blockquote>
<div><p>The quotient (except for the zero polynomial) by
<code class="docutils literal notranslate"><span class="pre">cont(&lt;pol.</span> <span class="pre">expr.&gt;)</span></code>.  This is thus a polynomial with
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(&lt;pol.</span> <span class="pre">expr.&gt;,</span> <span class="pre">&lt;pol.</span> <span class="pre">expr.&gt;)</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(&lt;pol.</span> <span class="pre">expr.&gt;,</span> <span class="pre">&lt;pol.</span> <span class="pre">expr.&gt;)</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(&lt;pol.</span> <span class="pre">expr.&gt;,</span> <span class="pre">&lt;pol.</span> <span class="pre">expr.&gt;)</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(&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">1&gt;,</span> <span class="pre">&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">2&gt;)</span></code></h3>
<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)&gt;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)&gt;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(&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">1&gt;,</span> <span class="pre">&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">2&gt;)</span></code></h3>
<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(&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">1&gt;,</span> <span class="pre">&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">2&gt;)</span></code></h3>
<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(&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">1&gt;,</span> <span class="pre">&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">2&gt;,</span> <span class="pre">...)</span></code></h3>
<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(&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">1&gt;,</span> <span class="pre">&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">2&gt;)</span></code></h3>
<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(&lt;pol.</span> <span class="pre">expr.&gt;)</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(&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">1&gt;,</span> <span class="pre">&lt;num.</span> <span class="pre">expr.&gt;,</span> <span class="pre">&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">2&gt;)</span></code></h3>
<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)&gt;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 &gt; 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(&lt;pol.</span> <span class="pre">expr.&gt;)</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(&lt;pol.</span> <span class="pre">expr.&gt;)</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(&lt;pol.</span> <span class="pre">expr.&gt;)</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(&lt;pol.</span> <span class="pre">expr.&gt;)</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(&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">P&gt;,</span> <span class="pre">&lt;num.</span> <span class="pre">expr.</span> <span class="pre">n&gt;)</span></code></h3>
<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&lt;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(&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">P&gt;)</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(&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">P&gt;,</span> <span class="pre">&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">c&gt;)</span></code></h3>
<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>&gt;&gt;&gt; <span class="nb">&amp;</span>pol
pol mode (i.e. function definitions use <span class="k">\poldef</span>)
&gt;&gt;&gt; P(x):=1+x<span class="nb">^</span>2;
P = x<span class="nb">^</span>2+1
    --&gt; <span class="nb">&amp;</span>GenFloat(P) lets P become usable as function in fp mode
    --&gt; <span class="nb">&amp;</span>ROOTS(P) (resp. <span class="nb">&amp;</span>ROOTS(P,N)) finds all rational roots exactly and
        all irrational roots with at least 10 (resp. N) fractional digits
&gt;&gt;&gt; intfrom(P,1);
@<span class="nb">_</span>1     pol([-4/3, 1, 0, 1/3])
&gt;&gt;&gt; intfrom(1,P);
@<span class="nb">_</span>2     pol([-1, 1, -1])
&gt;&gt;&gt; <span class="nb">&amp;</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(&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">P&gt;,</span> <span class="pre">[&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">a&gt;,</span> <span class="pre">&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">b&gt;])</span></code></h3>
<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{&lt;polname&gt;}</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{&lt;polname&gt;}</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[&lt;letter&gt;]{&lt;polname&gt;}{&lt;expr.</span> <span class="pre">using</span> <span class="pre">the</span> <span class="pre">letter</span> <span class="pre">as</span> <span class="pre">indeterminate&gt;}</span></code></h3>
<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">[&lt;letter&gt;]</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{&lt;polname&gt;}</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{&lt;pol. expr.&gt;}</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{&lt;polname&gt;}</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{&lt;pol.</span> <span class="pre">expr.&gt;}</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{&lt;raw_coeff&gt;}</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{&lt;raw_coeff&gt;}</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{&lt;raw_coeff&gt;}</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{&lt;raw_coeff&gt;}</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{&lt;raw_coeff&gt;}</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{&lt;raw_coeff&gt;}</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*{&lt;pol.</span> <span class="pre">expr.&gt;}</span></code></p>
<blockquote>
<div><p>Typesets in ascending powers. Use <code class="docutils literal notranslate"><span class="pre">[&lt;letter&gt;]</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{&lt;polname_2&gt;}={&lt;polname_1&gt;}</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{&lt;polname_2&gt;}{&lt;polname_1&gt;(x)}</span></code> or (better)
<code class="docutils literal notranslate"><span class="pre">\PolDef{&lt;polname_2&gt;}{&lt;polname_1&gt;}</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{&lt;polname_2&gt;}={&lt;polname_1&gt;}</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{&lt;polname&gt;}\toarray{&lt;\macro&gt;}</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{&lt;polname&gt;}{&lt;index&gt;}</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{&lt;polname&gt;}\fromarray{&lt;\macro&gt;}</span></code></p>
<blockquote>
<div><p>Does the converse operation to
<code class="docutils literal notranslate"><span class="pre">\PolAssign{&lt;polname&gt;}\toarray\macro</span></code>. Each individual
<code class="docutils literal notranslate"><span class="pre">\macro{&lt;value&gt;}</span></code> gets expanded in an <code class="docutils literal notranslate"><span class="pre">\edef</span></code> and then normalized
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{&lt;polname&gt;}{&lt;csv&gt;}</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{&lt;polname&gt;}</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}{&lt;polname&gt;}</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{&lt;polname&gt;}</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*{&lt;polname&gt;}</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{&lt;polname&gt;}</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{&lt;polname&gt;}</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*{&lt;polname&gt;}</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{&lt;polname&gt;}</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{&lt;polname_1&gt;}{&lt;polname_2&gt;}</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]{&lt;polname_1&gt;}{&lt;polname_2&gt;}</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{&lt;polname_2&gt;}={&lt;polname_1&gt;}</span></code>. With negative <code class="docutils literal notranslate"><span class="pre">N</span></code>, switches to
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{&lt;polname_1&gt;}{&lt;polname_2&gt;}</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]{&lt;polname_1&gt;}{&lt;polname_2&gt;}</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{&lt;polname_1&gt;}{&lt;polname_2&gt;}{&lt;polname_Q&gt;}{&lt;polname_R&gt;}</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{&lt;polname_1&gt;}{&lt;polname_2&gt;}{&lt;polname_Q&gt;}</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{&lt;polname_1&gt;}{&lt;polname_2&gt;}{&lt;polname_R&gt;}</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{&lt;polname_1&gt;}{&lt;polname_2&gt;}{&lt;polname_GCD&gt;}</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{&lt;polname&gt;}{&lt;sturmname&gt;}</span></a> and
<a class="reference internal" href="#polsturmisolatezeros"><span class="std std-ref">\PolSturmIsolateZeros{&lt;sturmname&gt;}</span></a> and variants declare
additional polynomial or scalar variables with names based on <code class="docutils literal notranslate"><span class="pre">&lt;sturmname&gt;</span></code> as
prefix, it is advisable to keep the <code class="docutils literal notranslate"><span class="pre">&lt;sturmname&gt;</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{&lt;polname&gt;}{&lt;sturmname&gt;}</span></code></p>
<blockquote>
<div><p>With <code class="docutils literal notranslate"><span class="pre">&lt;polname&gt;</span></code> being for example <code class="docutils literal notranslate"><span class="pre">P</span></code>, and <code class="docutils literal notranslate"><span class="pre">&lt;sturmname&gt;</span></code> being
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{&lt;polname&gt;}</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{&lt;polname&gt;}{&lt;sturmname&gt;}</span></code> and before executing
<code class="docutils literal notranslate"><span class="pre">\PolSturmIsolateZeros{&lt;sturmname&gt;}</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">&lt;polname&gt;</span></code> and <code class="docutils literal notranslate"><span class="pre">&lt;sturmname&gt;</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">&lt;sturmname&gt;</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{&lt;sturmname&gt;}</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*{&lt;polname&gt;}{&lt;sturmname&gt;}</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{&lt;sturmname&gt;}</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{&lt;sturmname&gt;}</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{&lt;polname&gt;}{&lt;sturmname&gt;}</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">&lt;</span> <span class="pre">z</span> <span class="pre">&lt;</span> <span class="pre">b</span></code>, and the end points are guaranteed to not
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*{&lt;sturmname&gt;}{&lt;index&gt;}</span></a> which addresses
this issue.</p>
</div>
<p>Let us suppose <code class="docutils literal notranslate"><span class="pre">&lt;sturmname&gt;</span></code> is <code class="docutils literal notranslate"><span class="pre">S</span></code>.</p>
<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{&lt;sturmname&gt;}{&lt;index&gt;}</span></a> and
<a class="reference internal" href="#polsturmisolatedzeroright"><span class="std std-ref">\PolSturmIsolatedZeroRight{&lt;sturmname&gt;}{&lt;index&gt;}</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{&lt;sturmname&gt;}{&lt;index&gt;}{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">&lt;index&gt;</span></code>-th root is given by
<a class="reference internal" href="#polsturmisolatedzeroleft">\PolSturmIsolatedZeroLeft{&lt;sturmname&gt;}{&lt;index&gt;}</a> if the root is positive, and by
<a class="reference internal" href="#polsturmisolatedzeroright">PolSturmIsolatedZeroRight{&lt;sturmname&gt;}{&lt;index&gt;}</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{&lt;sturmname&gt;}</span></a>.</p>
<p>Furthermore
<a class="reference internal" href="#polsturmnbofrootsoflessthanorequalto"><span class="std std-ref">\PolSturmNbOfRootsOf{&lt;sturmname&gt;}\LessThanOrEqualTo{&lt;value&gt;}</span></a> and
<a class="reference internal" href="#polsturmnbofrootsoflessthanorequaltoexpr"><span class="std std-ref">\PolSturmNbOfRootsOf{&lt;sturmname&gt;}\LessThanOrEqualToExpr{&lt;num. expr.&gt;}</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*{&lt;sturmname&gt;}{&lt;index&gt;}</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*{&lt;sturmname&gt;}</span></code></p>
<blockquote>
<div><p>The macro does the same as <a class="reference internal" href="#polsturmisolatezeros"><span class="std std-ref">\PolSturmIsolateZeros{&lt;sturmname&gt;}</span></a> and
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{&lt;sturmname&gt;}{&lt;index&gt;}</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">&lt;sturmname&gt;</span></code> is <code class="docutils literal notranslate"><span class="pre">S</span></code>, <a class="reference external" href="https://www.ctan.org/pkg/xintexpr">xintexpr</a>
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{&lt;sturmname&gt;}</span></code></p>
<blockquote>
<div><p>This is another name for <a class="reference internal" href="#id38"><span class="std std-ref">\PolSturmIsolateZeros*{&lt;sturmname&gt;}</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**{&lt;sturmname&gt;}</span></code></p>
<blockquote>
<div><p>The macro does the same as <a class="reference internal" href="#id38"><span class="std std-ref">\PolSturmIsolateZeros*{&lt;sturmname&gt;}</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{&lt;sturmname&gt;}</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**{&lt;sturmname&gt;}</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{&lt;sturmname&gt;}</span></code></p>
<blockquote>
<div><p>This works exactly like <a class="reference internal" href="#id41"><span class="std std-ref">\PolSturmIsolateZeros**{&lt;sturmname&gt;}</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{&lt;sturmname&gt;}{&lt;index&gt;}</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*{&lt;sturmname&gt;}{&lt;index&gt;}</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]{&lt;sturmname&gt;}{&lt;index&gt;}</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{&lt;sturmname&gt;}{&lt;index&gt;}{&lt;exponent&gt;}</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&lt;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{&lt;sturmname&gt;}{&lt;exponent&gt;}</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&lt;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}{&lt;sturmname&gt;}{&lt;value&gt;}</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">&lt;sturmname&gt;</span></code>, at location <code class="docutils literal notranslate"><span class="pre">&lt;value&gt;</span></code> (which must be in format as
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}{&lt;sturmname&gt;}{&lt;value_left&gt;}{&lt;value_right&gt;}</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">&lt;=</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{&lt;sturmname&gt;}\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{&lt;sturmname&gt;}\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[&lt;varname&gt;]{}</span></code></h3>
<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolPrintIntervals[&lt;varname&gt;]{&lt;sturmname&gt;}</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">&lt;</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">&amp;&amp;</span><span class="k">\PolPrintIntervalsTheVar</span><span class="nb">_{</span><span class="k">\PolPrintIntervalsTheIndex</span><span class="nb">}</span><span class="c">%</span>
  <span class="nb">&amp;</span>=<span class="nb">&amp;</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">&amp;</span>&lt;<span class="nb">&amp;</span><span class="c">%</span>
  <span class="k">\PolPrintIntervalsTheVar</span><span class="nb">_{</span><span class="k">\PolPrintIntervalsTheIndex</span><span class="nb">}&amp;</span>&lt;<span class="nb">&amp;</span><span class="c">%</span>
  <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*[&lt;varname&gt;]{}</span></code></h4>
<p>Syntax: <code class="docutils literal notranslate"><span class="pre">\PolPrintIntervals*[&lt;varname&gt;]{&lt;sturmname&gt;}</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&#64;&#64;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{&lt;pol.</span> <span class="pre">expr.&gt;}</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{&lt;raw_coeff&gt;}</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{&lt;raw_coeff&gt;}{&lt;exponent&gt;}</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{&lt;raw_coeff&gt;}{&lt;exponent&gt;}</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{&lt;raw_coeff&gt;}{&lt;exponent&gt;}</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{&lt;raw_coeff&gt;}</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{&lt;raw_coeff&gt;}</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{&lt;pol.</span> <span class="pre">expr.&gt;}</span></code></p>
<blockquote>
<div><p>Similar to <a class="reference internal" href="#poltoexpr"><span class="std std-ref">\PolToExpr{&lt;pol. expr.&gt;}</span></a> but using
<a class="reference internal" href="#poltofloatexprcmd"><span class="std std-ref">\PolToFloatExprCmd{&lt;raw_coeff&gt;}</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{&lt;polname&gt;}</span></a>:
<a class="reference internal" href="#poltofloatexprcmd"><span class="std std-ref">\PolToFloatExprCmd{&lt;raw_coeff&gt;}</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{&lt;raw_coeff&gt;}{&lt;exponent&gt;}</span></code></p>
<blockquote>
<div><p>Similar to <a class="reference internal" href="#poltoexproneterm"><span class="std std-ref">\PolToExprOneTerm{&lt;raw_coeff&gt;}{&lt;exponent&gt;}</span></a>. But does not treat
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{&lt;raw_coeff&gt;}</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*{&lt;pol.</span> <span class="pre">expr.&gt;}</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{&lt;pol. expr.&gt;}</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*{&lt;pol.</span> <span class="pre">expr.&gt;}</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{&lt;polname&gt;}{&lt;index&gt;}</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&lt;-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{&lt;polname&gt;}</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{&lt;polname&gt;}</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{&lt;polname&gt;}</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{&lt;polname&gt;}</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{&lt;polname&gt;}</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{&lt;polname&gt;}{&lt;csv&gt;}</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{&lt;polname&gt;}\AtExpr{&lt;num.</span> <span class="pre">expr.&gt;}</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{&lt;polname&gt;}\At{&lt;value&gt;}</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{&lt;polname&gt;}\AtExpr{&lt;num.</span> <span class="pre">expr.&gt;}</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{&lt;polname&gt;}\At{&lt;value&gt;}</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{&lt;polname&gt;}\AtExpr{&lt;num.</span> <span class="pre">expr.&gt;}</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{&lt;polname&gt;}\At{&lt;value&gt;}</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{&lt;sturmname&gt;}</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{&lt;polname&gt;}{&lt;sturmname&gt;}</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{&lt;sturmname&gt;}{&lt;index&gt;}{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{&lt;sturmname&gt;}{&lt;index&gt;}</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{&lt;sturmname&gt;}</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{&lt;sturmname&gt;}{&lt;index&gt;}</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{&lt;sturmname&gt;}{&lt;index&gt;}</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{&lt;sturmname&gt;}</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{&lt;sturmname&gt;}{&lt;index&gt;}</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*{&lt;sturmname&gt;}</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{&lt;sturmname&gt;}</span></code></p>
<blockquote>
<div><p>Expands to the number of real roots of the polynomial
<code class="docutils literal notranslate"><span class="pre">&lt;sturmname&gt;_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{&lt;polname&gt;}{&lt;sturmname&gt;}</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{&lt;sturmname&gt;}\LessThanOrEqualTo{&lt;value&gt;}</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{&lt;sturmname&gt;}</span></a> must have been executed
beforehand.</p>
<p>And the argument is a <code class="docutils literal notranslate"><span class="pre">&lt;sturmname&gt;</span></code>, not a <code class="docutils literal notranslate"><span class="pre">&lt;polname&gt;</span></code> (this is
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{&lt;sturmname&gt;}\LessThanOrEqualToExpr{&lt;num.</span> <span class="pre">expr.&gt;}</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{&lt;sturmname&gt;}</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{&lt;sturmname&gt;}\LessThanOrEqualTo{&lt;value&gt;}</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*{&lt;sturmname&gt;}</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{&lt;sturmname&gt;}\LessThanOrEqualToExpr{&lt;num.</span> <span class="pre">expr.&gt;}</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*{&lt;sturmname&gt;}</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{&lt;sturmname&gt;}</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**{&lt;sturmname&gt;}</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{&lt;sturmname&gt;}</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**{&lt;sturmname&gt;}</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{&lt;sturmname&gt;}{&lt;k&gt;}</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**{&lt;sturmname&gt;}</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{&lt;sturmname&gt;}{&lt;k&gt;}</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{&lt;sturmname&gt;}{&lt;k&gt;}</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>&lt;sturmname&gt;<span class="nb">}{</span><span class="k">\PolSturmRationalRootIndex</span><span class="nb">{</span>&lt;sturmname&gt;<span class="nb">}{</span>&lt;k&gt;<span class="nb">}}</span>
</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**{&lt;sturmname&gt;}</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{&lt;sturmname&gt;}{&lt;k&gt;}</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**{&lt;sturmname&gt;}</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{&lt;sturmname&gt;}{&lt;index&gt;}</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]{&lt;sturmname&gt;}</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">&lt;sturmname&gt;</span></code> to
<a class="reference internal" href="#polprintintervals"><span class="std std-ref">\PolPrintIntervals[varname]{&lt;sturmname&gt;}</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{&lt;polname&gt;}</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{&lt;pol. expr.&gt;}</span></a> and
<a class="reference internal" href="#poltofloatexpr"><span class="std std-ref">\PolToFloatExpr{&lt;pol. expr.&gt;}</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**{&lt;sturmname&gt;}</span></a>
should append to <code class="docutils literal notranslate"><span class="pre">&lt;sturmname&gt;</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**{&lt;sturmname&gt;}</span></a>
should append to <code class="docutils literal notranslate"><span class="pre">&lt;sturmname&gt;</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">&#64;</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">&#64;</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">&#64;</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">&quot;;&quot;</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{&lt;polname_1&gt;}{&lt;polname_2&gt;}</span></a> always applies <code class="docutils literal notranslate"><span class="pre">\xintPIrr</span></code> to the
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{&lt;polname_1&gt;}{&lt;polname_2&gt;}</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">&lt;,</span> <span class="pre">&gt;,</span> <span class="pre">&lt;=,</span> <span class="pre">&gt;=,</span> <span class="pre">==,</span> <span class="pre">!=</span></code></a></li>
<li><a class="reference internal" href="#pol-nutple-expression"><code class="docutils literal notranslate"><span class="pre">pol(&lt;nutple</span> <span class="pre">expression&gt;)</span></code></a></li>
<li><a class="reference internal" href="#lpol-nutple-expression"><code class="docutils literal notranslate"><span class="pre">lpol(&lt;nutple</span> <span class="pre">expression&gt;)</span></code></a></li>
<li><a class="reference internal" href="#xinteval-pol-expr"><code class="docutils literal notranslate"><span class="pre">\xinteval{&lt;pol.</span> <span class="pre">expr.&gt;}</span></code></a></li>
<li><a class="reference internal" href="#evalp-pol-expr-pol-expr"><code class="docutils literal notranslate"><span class="pre">evalp(&lt;pol.</span> <span class="pre">expr.&gt;,</span> <span class="pre">&lt;pol.</span> <span class="pre">expr&gt;)</span></code></a></li>
<li><a class="reference internal" href="#deg-pol-expr"><code class="docutils literal notranslate"><span class="pre">deg(&lt;pol.</span> <span class="pre">expr.&gt;)</span></code></a></li>
<li><a class="reference internal" href="#coeffs-pol-expr"><code class="docutils literal notranslate"><span class="pre">coeffs(&lt;pol.</span> <span class="pre">expr.&gt;)</span></code></a></li>
<li><a class="reference internal" href="#lcoeffs-pol-expr"><code class="docutils literal notranslate"><span class="pre">lcoeffs(&lt;pol.</span> <span class="pre">expr.&gt;)</span></code></a></li>
<li><a class="reference internal" href="#coeff-pol-expr-num-expr"><code class="docutils literal notranslate"><span class="pre">coeff(&lt;pol.</span> <span class="pre">expr.&gt;,</span> <span class="pre">&lt;num.</span> <span class="pre">expr.&gt;)</span></code></a></li>
<li><a class="reference internal" href="#lc-pol-expr"><code class="docutils literal notranslate"><span class="pre">lc(&lt;pol.</span> <span class="pre">expr.&gt;)</span></code></a></li>
<li><a class="reference internal" href="#monicpart-pol-expr"><code class="docutils literal notranslate"><span class="pre">monicpart(&lt;pol.</span> <span class="pre">expr.&gt;)</span></code></a></li>
<li><a class="reference internal" href="#cont-pol-expr"><code class="docutils literal notranslate"><span class="pre">cont(&lt;pol.</span> <span class="pre">expr.&gt;)</span></code></a></li>
<li><a class="reference internal" href="#primpart-pol-expr"><code class="docutils literal notranslate"><span class="pre">primpart(&lt;pol.</span> <span class="pre">expr.&gt;)</span></code></a></li>
<li><a class="reference internal" href="#quorem-pol-expr-pol-expr"><code class="docutils literal notranslate"><span class="pre">quorem(&lt;pol.</span> <span class="pre">expr.&gt;,</span> <span class="pre">&lt;pol.</span> <span class="pre">expr.&gt;)</span></code></a></li>
<li><a class="reference internal" href="#quo-pol-expr-pol-expr"><code class="docutils literal notranslate"><span class="pre">quo(&lt;pol.</span> <span class="pre">expr.&gt;,</span> <span class="pre">&lt;pol.</span> <span class="pre">expr.&gt;)</span></code></a></li>
<li><a class="reference internal" href="#rem-pol-expr-pol-expr"><code class="docutils literal notranslate"><span class="pre">rem(&lt;pol.</span> <span class="pre">expr.&gt;,</span> <span class="pre">&lt;pol.</span> <span class="pre">expr.&gt;)</span></code></a></li>
<li><a class="reference internal" href="#prem-pol-expr-1-pol-expr-2"><code class="docutils literal notranslate"><span class="pre">prem(&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">1&gt;,</span> <span class="pre">&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">2&gt;)</span></code></a></li>
<li><a class="reference internal" href="#divmod-pol-expr-1-pol-expr-2"><code class="docutils literal notranslate"><span class="pre">divmod(&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">1&gt;,</span> <span class="pre">&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">2&gt;)</span></code></a></li>
<li><a class="reference internal" href="#mod-pol-expr-1-pol-expr-2"><code class="docutils literal notranslate"><span class="pre">mod(&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">1&gt;,</span> <span class="pre">&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">2&gt;)</span></code></a></li>
<li><a class="reference internal" href="#polgcd-pol-expr-1-pol-expr-2"><code class="docutils literal notranslate"><span class="pre">polgcd(&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">1&gt;,</span> <span class="pre">&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">2&gt;,</span> <span class="pre">...)</span></code></a></li>
<li><a class="reference internal" href="#resultant-pol-expr-1-pol-expr-2"><code class="docutils literal notranslate"><span class="pre">resultant(&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">1&gt;,</span> <span class="pre">&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">2&gt;)</span></code></a></li>
<li><a class="reference internal" href="#disc-pol-expr"><code class="docutils literal notranslate"><span class="pre">disc(&lt;pol.</span> <span class="pre">expr.&gt;)</span></code></a></li>
<li><a class="reference internal" href="#polpowmod-pol-expr-1-num-expr-pol-expr-2"><code class="docutils literal notranslate"><span class="pre">polpowmod(&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">1&gt;,</span> <span class="pre">&lt;num.</span> <span class="pre">expr.&gt;,</span> <span class="pre">&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">2&gt;)</span></code></a></li>
<li><a class="reference internal" href="#rdcoeffs-pol-expr"><code class="docutils literal notranslate"><span class="pre">rdcoeffs(&lt;pol.</span> <span class="pre">expr.&gt;)</span></code></a></li>
<li><a class="reference internal" href="#rdzcoeffs-pol-expr"><code class="docutils literal notranslate"><span class="pre">rdzcoeffs(&lt;pol.</span> <span class="pre">expr.&gt;)</span></code></a></li>
<li><a class="reference internal" href="#diff1-pol-expr"><code class="docutils literal notranslate"><span class="pre">diff1(&lt;pol.</span> <span class="pre">expr.&gt;)</span></code></a></li>
<li><a class="reference internal" href="#diff2-pol-expr"><code class="docutils literal notranslate"><span class="pre">diff2(&lt;pol.</span> <span class="pre">expr.&gt;)</span></code></a></li>
<li><a class="reference internal" href="#diffn-pol-expr-p-num-expr-n"><code class="docutils literal notranslate"><span class="pre">diffn(&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">P&gt;,</span> <span class="pre">&lt;num.</span> <span class="pre">expr.</span> <span class="pre">n&gt;)</span></code></a></li>
<li><a class="reference internal" href="#antider-pol-expr-p"><code class="docutils literal notranslate"><span class="pre">antider(&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">P&gt;)</span></code></a></li>
<li><a class="reference internal" href="#intfrom-pol-expr-p-pol-expr-c"><code class="docutils literal notranslate"><span class="pre">intfrom(&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">P&gt;,</span> <span class="pre">&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">c&gt;)</span></code></a></li>
<li><a class="reference internal" href="#integral-pol-expr-p-pol-expr-a-pol-expr-b"><code class="docutils literal notranslate"><span class="pre">integral(&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">P&gt;,</span> <span class="pre">[&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">a&gt;,</span> <span class="pre">&lt;pol.</span> <span class="pre">expr.</span> <span class="pre">b&gt;])</span></code></a></li>
</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[&lt;letter&gt;]{&lt;polname&gt;}{&lt;expr.</span> <span class="pre">using</span> <span class="pre">the</span> <span class="pre">letter</span> <span class="pre">as</span> <span class="pre">indeterminate&gt;}</span></code></a></li>
<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[&lt;varname&gt;]{}</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*[&lt;varname&gt;]{}</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> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">polexpr reference</a></li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
        &#169; Copyright 2022, Jean-François Burnol.
      Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 5.0.0+/f58771c09.
    </div>
  </body>
</html>