summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/polexpr/polexpr.html
blob: 962771bdfa78dabe74a093e35454375e1eee7902 (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
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.14: http://docutils.sourceforge.net/" />
<title>Package polexpr documentation</title>
<style type="text/css">
body{font-size: 13pt;}
/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 7952 2016-07-26 18:15:59Z milde $
:Copyright: This stylesheet has been placed in the public domain.

Default cascading style sheet for the HTML output of Docutils.

See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
customize this style sheet.
*/

/* used to remove borders from tables and images */
.borderless, table.borderless td, table.borderless th {
  border: 0 }

table.borderless td, table.borderless th {
  /* Override padding for "table.docutils td" with "! important".
     The right padding separates the table cells. */
  padding: 0 0.5em 0 0 ! important }

.first {
  /* Override more specific margin styles with "! important". */
  margin-top: 0 ! important }

.last, .with-subtitle {
  margin-bottom: 0 ! important }

.hidden {
  display: none }

.subscript {
  vertical-align: sub;
  font-size: smaller }

.superscript {
  vertical-align: super;
  font-size: smaller }

a.toc-backref {
  text-decoration: none ;
  color: black }

blockquote.epigraph {
  margin: 2em 5em ; }

dl.docutils dd {
  margin-bottom: 0.5em }

object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] {
  overflow: hidden;
}

/* Uncomment (and remove this text!) to get bold-faced definition list terms
dl.docutils dt {
  font-weight: bold }
*/

div.abstract {
  margin: 2em 5em }

div.abstract p.topic-title {
  font-weight: bold ;
  text-align: center }

div.admonition, div.attention, div.caution, div.danger, div.error,
div.hint, div.important, div.note, div.tip, div.warning {
  margin: 2em ;
  border: medium outset ;
  padding: 1em }

div.admonition p.admonition-title, div.hint p.admonition-title,
div.important p.admonition-title, div.note p.admonition-title,
div.tip p.admonition-title {
  font-weight: bold ;
  font-family: sans-serif }

div.attention p.admonition-title, div.caution p.admonition-title,
div.danger p.admonition-title, div.error p.admonition-title,
div.warning p.admonition-title, .code .error {
  color: red ;
  font-weight: bold ;
  font-family: sans-serif }

/* Uncomment (and remove this text!) to get reduced vertical space in
   compound paragraphs.
div.compound .compound-first, div.compound .compound-middle {
  margin-bottom: 0.5em }

div.compound .compound-last, div.compound .compound-middle {
  margin-top: 0.5em }
*/

div.dedication {
  margin: 2em 5em ;
  text-align: center ;
  font-style: italic }

div.dedication p.topic-title {
  font-weight: bold ;
  font-style: normal }

div.figure {
  margin-left: 2em ;
  margin-right: 2em }

div.footer, div.header {
  clear: both;
  font-size: smaller }

div.line-block {
  display: block ;
  margin-top: 1em ;
  margin-bottom: 1em }

div.line-block div.line-block {
  margin-top: 0 ;
  margin-bottom: 0 ;
  margin-left: 1.5em }

div.sidebar {
  margin: 0 0 0.5em 1em ;
  border: medium outset ;
  padding: 1em ;
  background-color: #ffffee ;
  width: 40% ;
  float: right ;
  clear: right }

div.sidebar p.rubric {
  font-family: sans-serif ;
  font-size: medium }

div.system-messages {
  margin: 5em }

div.system-messages h1 {
  color: red }

div.system-message {
  border: medium outset ;
  padding: 1em }

div.system-message p.system-message-title {
  color: red ;
  font-weight: bold }

div.topic {
  margin: 2em }

h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
  margin-top: 0.4em }

h1.title {
  text-align: center }

h2.subtitle {
  text-align: center }

hr.docutils {
  width: 75% }

img.align-left, .figure.align-left, object.align-left, table.align-left {
  clear: left ;
  float: left ;
  margin-right: 1em }

img.align-right, .figure.align-right, object.align-right, table.align-right {
  clear: right ;
  float: right ;
  margin-left: 1em }

img.align-center, .figure.align-center, object.align-center {
  display: block;
  margin-left: auto;
  margin-right: auto;
}

table.align-center {
  margin-left: auto;
  margin-right: auto;
}

.align-left {
  text-align: left }

.align-center {
  clear: both ;
  text-align: center }

.align-right {
  text-align: right }

/* reset inner alignment in figures */
div.align-right {
  text-align: inherit }

/* div.align-center * { */
/*   text-align: left } */

.align-top    {
  vertical-align: top }

.align-middle {
  vertical-align: middle }

.align-bottom {
  vertical-align: bottom }

ol.simple, ul.simple {
  margin-bottom: 1em }

ol.arabic {
  list-style: decimal }

ol.loweralpha {
  list-style: lower-alpha }

ol.upperalpha {
  list-style: upper-alpha }

ol.lowerroman {
  list-style: lower-roman }

ol.upperroman {
  list-style: upper-roman }

p.attribution {
  text-align: right ;
  margin-left: 50% }

p.caption {
  font-style: italic }

p.credits {
  font-style: italic ;
  font-size: smaller }

p.label {
  white-space: nowrap }

p.rubric {
  font-weight: bold ;
  font-size: larger ;
  color: maroon ;
  text-align: center }

p.sidebar-title {
  font-family: sans-serif ;
  font-weight: bold ;
  font-size: larger }

p.sidebar-subtitle {
  font-family: sans-serif ;
  font-weight: bold }

p.topic-title {
  font-weight: bold }

pre.address {
  margin-bottom: 0 ;
  margin-top: 0 ;
  font: inherit }

pre.literal-block, pre.doctest-block, pre.math, pre.code {
  margin-left: 2em ;
  margin-right: 2em }

pre.code .ln { color: grey; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
pre.code .literal.string, code .literal.string { color: #0C5404 }
pre.code .name.builtin, code .name.builtin { color: #352B84 }
pre.code .deleted, code .deleted { background-color: #DEB0A1}
pre.code .inserted, code .inserted { background-color: #A3D289}

span.classifier {
  font-family: sans-serif ;
  font-style: oblique }

span.classifier-delimiter {
  font-family: sans-serif ;
  font-weight: bold }

span.interpreted {
  font-family: sans-serif }

span.option {
  white-space: nowrap }

span.pre {
  white-space: pre }

span.problematic {
  color: red }

span.section-subtitle {
  /* font-size relative to parent (h1..h6 element) */
  font-size: 80% }

table.citation {
  border-left: solid 1px gray;
  margin-left: 1px }

table.docinfo {
  margin: 2em 4em }

table.docutils {
  margin-top: 0.5em ;
  margin-bottom: 0.5em }

table.footnote {
  border-left: solid 1px black;
  margin-left: 1px }

table.docutils td, table.docutils th,
table.docinfo td, table.docinfo th {
  padding-left: 0.5em ;
  padding-right: 0.5em ;
  vertical-align: top }

table.docutils th.field-name, table.docinfo th.docinfo-name {
  font-weight: bold ;
  text-align: left ;
  white-space: nowrap ;
  padding-left: 0 }

/* "booktabs" style (no vertical lines) */
table.docutils.booktabs {
  border: 0px;
  border-top: 2px solid;
  border-bottom: 2px solid;
  border-collapse: collapse;
}
table.docutils.booktabs * {
  border: 0px;
}
table.docutils.booktabs th {
  border-bottom: thin solid;
  text-align: left;
}

h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
  font-size: 100% }

ul.auto-toc {
  list-style-type: none }

</style>
</head>
<body>
<div class="document" id="package-polexpr-documentation">
<h1 class="title">Package polexpr documentation</h1>
<h2 class="subtitle" id="id1">0.3.1 (2018/01/18)</h2>

<!-- comment: -*- fill-column: 72; mode: rst; -*- -->
<div class="contents topic" id="contents">
<p class="topic-title first">Contents</p>
<ul class="simple">
<li><a class="reference internal" href="#first-examples" id="id15">First Examples</a></li>
<li><a class="reference internal" href="#non-expandable-macros" id="id16">Non-expandable macros</a><ul>
<li><a class="reference internal" href="#poldef-polname-letter-expression-in-letter" id="id17"><tt class="docutils literal">\poldef <span class="pre">polname(letter):=</span> expression in letter;</tt></a></li>
<li><a class="reference internal" href="#poldef-letter-polname-expression-in-letter" id="id18"><tt class="docutils literal"><span class="pre">\PolDef[letter]{polname}{expression</span> in letter}</tt></a></li>
<li><a class="reference internal" href="#pollet-polname-2-polname-1" id="id19"><tt class="docutils literal"><span class="pre">\PolLet{polname_2}={polname_1}</span></tt></a></li>
<li><a class="reference internal" href="#polassign-polname-toarray-macro" id="id20"><tt class="docutils literal"><span class="pre">\PolAssign{polname}\toarray\macro</span></tt></a></li>
<li><a class="reference internal" href="#polget-polname-fromarray-macro" id="id21"><tt class="docutils literal"><span class="pre">\PolGet{polname}\fromarray\macro</span></tt></a></li>
<li><a class="reference internal" href="#polfromcsv-polname-csv" id="id22"><tt class="docutils literal"><span class="pre">\PolFromCSV{polname}{&lt;csv&gt;}</span></tt></a></li>
<li><a class="reference internal" href="#poltypeset-polname" id="id23"><tt class="docutils literal">\PolTypeset{polname}</tt></a><ul>
<li><a class="reference internal" href="#poltypesetcmd-raw-coeff" id="id24"><tt class="docutils literal">\PolTypesetCmd{raw_coeff}</tt></a></li>
<li><a class="reference internal" href="#poltypesetcmdprefix-raw-coeff" id="id25"><tt class="docutils literal">\PolTypesetCmdPrefix{raw_coeff}</tt></a></li>
<li><a class="reference internal" href="#poltypesetmonomialcmd" id="id26"><tt class="docutils literal">\PolTypesetMonomialCmd</tt></a></li>
</ul>
</li>
<li><a class="reference internal" href="#id5" id="id27"><tt class="docutils literal"><span class="pre">\PolTypeset*{polname}</span></tt></a></li>
<li><a class="reference internal" href="#poldiff-polname-1-polname-2" id="id28"><tt class="docutils literal"><span class="pre">\PolDiff{polname_1}{polname_2}</span></tt></a></li>
<li><a class="reference internal" href="#poldiff-n-polname-1-polname-2" id="id29"><tt class="docutils literal"><span class="pre">\PolDiff[N]{polname_1}{polname_2}</span></tt></a></li>
<li><a class="reference internal" href="#polantidiff-polname-1-polname-2" id="id30"><tt class="docutils literal"><span class="pre">\PolAntiDiff{polname_1}{polname_2}</span></tt></a></li>
<li><a class="reference internal" href="#polantidiff-n-polname-1-polname-2" id="id31"><tt class="docutils literal"><span class="pre">\PolAntiDiff[N]{polname_1}{polname_2}</span></tt></a></li>
<li><a class="reference internal" href="#poldivide-polname-1-polname-2-polname-q-polname-r" id="id32"><tt class="docutils literal"><span class="pre">\PolDivide{polname_1}{polname_2}{polname_Q}{polname_R}</span></tt></a></li>
<li><a class="reference internal" href="#polgcd-polname-1-polname-2-polname-gcd" id="id33"><tt class="docutils literal"><span class="pre">\PolGCD{polname_1}{polname_2}{polname_GCD}</span></tt></a></li>
<li><a class="reference internal" href="#polmapcoeffs-macro-polname" id="id34"><tt class="docutils literal"><span class="pre">\PolMapCoeffs{\macro}{polname}</span></tt></a></li>
<li><a class="reference internal" href="#polreducecoeffs-polname" id="id35"><tt class="docutils literal">\PolReduceCoeffs{polname}</tt></a></li>
</ul>
</li>
<li><a class="reference internal" href="#expandable-macros" id="id36">Expandable macros</a><ul>
<li><a class="reference internal" href="#poleval-polname-at-numerical-expression" id="id37"><tt class="docutils literal"><span class="pre">\PolEval{polname}\At{numerical</span> expression}</tt></a></li>
<li><a class="reference internal" href="#polevalreduced-polname-at-numerical-expression" id="id38"><tt class="docutils literal"><span class="pre">\PolEvalReduced{polname}\At{numerical</span> expression}</tt></a></li>
<li><a class="reference internal" href="#polfloateval-polname-at-numerical-expression" id="id39"><tt class="docutils literal"><span class="pre">\PolFloatEval{polname}\At{numerical</span> expression}</tt></a></li>
<li><a class="reference internal" href="#polnthcoeff-polname-number" id="id40"><tt class="docutils literal"><span class="pre">\PolNthCoeff{polname}{number}</span></tt></a></li>
<li><a class="reference internal" href="#poldegree-polname" id="id41"><tt class="docutils literal">\PolDegree{polname}</tt></a></li>
<li><a class="reference internal" href="#poltoexpr-polname" id="id42"><tt class="docutils literal">\PolToExpr{polname}</tt></a><ul>
<li><a class="reference internal" href="#poltoexproneterm-raw-coeff-number" id="id43"><tt class="docutils literal"><span class="pre">\PolToExprOneTerm{raw_coeff}{number}</span></tt></a></li>
<li><a class="reference internal" href="#poltoexpronetermstyleb-raw-coeff-number" id="id44"><tt class="docutils literal"><span class="pre">\PolToExprOneTermStyleB{raw_coeff}{number}</span></tt></a></li>
<li><a class="reference internal" href="#poltoexprcmd-raw-coeff" id="id45"><tt class="docutils literal">\PolToExprCmd{raw_coeff}</tt></a></li>
<li><a class="reference internal" href="#poltoexprtermprefix-raw-coeff" id="id46"><tt class="docutils literal">\PolToExprTermPrefix{raw_coeff}</tt></a></li>
<li><a class="reference internal" href="#poltoexprvar" id="id47"><tt class="docutils literal">\PolToExprVar</tt></a></li>
<li><a class="reference internal" href="#poltoexprtimes" id="id48"><tt class="docutils literal">\PolToExprTimes</tt></a></li>
</ul>
</li>
<li><a class="reference internal" href="#id12" id="id49"><tt class="docutils literal"><span class="pre">\PolToExpr*{polname}</span></tt></a></li>
<li><a class="reference internal" href="#poltofloatexpr-polname" id="id50"><tt class="docutils literal">\PolToFloatExpr{polname}</tt></a><ul>
<li><a class="reference internal" href="#poltofloatexproneterm-raw-coeff-number" id="id51"><tt class="docutils literal"><span class="pre">\PolToFloatExprOneTerm{raw_coeff}{number}</span></tt></a></li>
<li><a class="reference internal" href="#poltofloatexprcmd-raw-coeff" id="id52"><tt class="docutils literal">\PolToFloatExprCmd{raw_coeff}</tt></a></li>
</ul>
</li>
<li><a class="reference internal" href="#id13" id="id53"><tt class="docutils literal"><span class="pre">\PolToFloatExpr*{polname}</span></tt></a></li>
<li><a class="reference internal" href="#poltolist-polname" id="id54"><tt class="docutils literal">\PolToList{polname}</tt></a></li>
<li><a class="reference internal" href="#poltocsv-polname" id="id55"><tt class="docutils literal">\PolToCSV{polname}</tt></a></li>
</ul>
</li>
<li><a class="reference internal" href="#booleans-with-default-setting-as-indicated" id="id56">Booleans (with default setting as indicated)</a><ul>
<li><a class="reference internal" href="#xintverbosefalse" id="id57"><tt class="docutils literal">\xintverbosefalse</tt></a></li>
<li><a class="reference internal" href="#poltypesetallfalse" id="id58"><tt class="docutils literal">\poltypesetallfalse</tt></a></li>
<li><a class="reference internal" href="#poltoexprallfalse" id="id59"><tt class="docutils literal">\poltoexprallfalse</tt></a></li>
</ul>
</li>
<li><a class="reference internal" href="#technicalities" id="id60">Technicalities</a></li>
<li><a class="reference internal" href="#releases" id="id61">RELEASES</a></li>
<li><a class="reference internal" href="#acknowledgments" id="id62">Acknowledgments</a></li>
</ul>
</div>
<div class="section" id="first-examples">
<h1><a class="toc-backref" href="#id15">First Examples</a></h1>
<p>The syntax is:</p>
<pre class="literal-block">
\poldef polname(x):= expression in variable x;
</pre>
<p>where in place of <tt class="docutils literal">x</tt> an arbitrary <em>dummy variable</em> is authorized
(i.e. per default any of <tt class="docutils literal"><span class="pre">[a-z|A-Z]</span></tt>; more letters can be declared
under Unicode engines.) One can also issue:</p>
<pre class="literal-block">
\PolDef{polname}{expression in variable x}
</pre>
<p>which admits an optional first argument to modify the variable letter
from its default <tt class="docutils literal">x</tt>.</p>
<dl class="docutils">
<dt><tt class="docutils literal">\poldef <span class="pre">f(x):=</span> <span class="pre">1-x+x^2;</span></tt></dt>
<dd>defines polynomial <tt class="docutils literal">f</tt>. Polynomial names must start with a
letter and may contain letters, digits, and underscores. The
variable must be a single letter. The colon character is optional.
The semi-colon at end of expression is mandatory.</dd>
<dt><tt class="docutils literal"><span class="pre">\PolDef{f}{1-x+x^2}</span></tt></dt>
<dd>does the same as <tt class="docutils literal">\poldef <span class="pre">f(x):=</span> <span class="pre">1-x+x^2;</span></tt> To use another letter
than <tt class="docutils literal">x</tt> in the expression, one must pass it as an extra optional
argument to <tt class="docutils literal">\PolDef</tt>. Useful if the semi-colon has been assigned
some non-standard catcode by some package.</dd>
<dt><tt class="docutils literal"><span class="pre">\PolLet{g}={f}</span></tt></dt>
<dd>saves a copy of <tt class="docutils literal">f</tt> under name <tt class="docutils literal">g</tt>. Also usable without <tt class="docutils literal">=</tt>.</dd>
<dt><tt class="docutils literal">\poldef <span class="pre">f(z):=</span> <span class="pre">f(z)^2;</span></tt></dt>
<dd>redefines <tt class="docutils literal">f</tt> in terms of itself.</dd>
<dt><tt class="docutils literal">\poldef <span class="pre">f(T):=</span> <span class="pre">f(f(T));</span></tt></dt>
<dd>again redefines <tt class="docutils literal">f</tt> in terms of its (new) self.</dd>
<dt><tt class="docutils literal">\poldef <span class="pre">k(z):=</span> <span class="pre">f(z)-g(g(z)^2)^2;</span></tt></dt>
<dd>should now define the zero polynomial... Let's check:
<tt class="docutils literal">\[ k(z) = <span class="pre">\PolTypeset[z]{k}</span> \]</tt></dd>
<dt><tt class="docutils literal"><span class="pre">\PolDiff{f}{df_dx}</span></tt></dt>
<dd>sets <tt class="docutils literal">df_dx</tt> to the derivative of <tt class="docutils literal">f</tt>.</dd>
<dt><tt class="docutils literal"><span class="pre">\PolDiff{df_dx}{f_xx}</span></tt></dt>
<dd>obtains second derivative.</dd>
<dt><tt class="docutils literal"><span class="pre">\PolDiff[3]{f}{d3f_dx3}</span></tt></dt>
<dd>computes directly the third derivative. Its name does not have to be
chosen so complicated <tt class="docutils literal">:)</tt>, but the right quote <tt class="docutils literal">'</tt> is not
allowed in polynomial names (currently).</dd>
</dl>
<pre class="literal-block">
$f(z)   = \PolTypeset[z]{f}    $\newline
$f'(z)  = \PolTypeset[z]{df_dx}$\newline
$f''(z) = \PolTypeset[z]{f_xx}$\newline
$f'''(z)= \PolTypeset[z]{d3f_dx3}$\par
</pre>
<div class="admonition important">
<p class="first admonition-title">Important</p>
<p>The package does not currently know rational functions: <tt class="docutils literal">/</tt> in
a parsed polynomial expression does the Euclidean quotient:</p>
<pre class="literal-block">
(1-x^2)/(1-x)
</pre>
<p>does give <tt class="docutils literal">1+x</tt> but</p>
<pre class="literal-block">
(1/(1-x))*(1-x^2)
</pre>
<p>evaluates to zero. This will work as expected:</p>
<pre class="last literal-block">
\poldef k(x):= (x-1)(x-2)(x-3)(x-4)/(x^2-5x+4);
</pre>
</div>
<div class="admonition attention" id="warningtacit">
<p class="first admonition-title">Attention!</p>
<p><tt class="docutils literal">1/2 x^2</tt> skips the space and is treated like <tt class="docutils literal"><span class="pre">1/(2*x^2)</span></tt> because
of the tacit multiplication rules of xintexpr. But this means it
gives zero! Thus one must use <tt class="docutils literal">(1/2)x^2</tt> or <tt class="docutils literal">1/2*x^2</tt> or
<tt class="docutils literal"><span class="pre">(1/2)*x^2</span></tt> for disambiguation: <tt class="docutils literal">x - 1/2*x^2 + <span class="pre">1/3*x^3...</span></tt>. It is
even simpler to move the denominator to the right: <tt class="docutils literal">x - x^2/2 +
x^3/3 - ...</tt>.</p>
<p class="last">It is worth noting that <tt class="docutils literal"><span class="pre">1/2(x-1)(x-2)</span></tt> suffers the same issue:
<a class="reference external" href="http://www.ctan.org/pkg/xint">xint</a> tacit multiplication always &quot;ties more&quot;, hence this gets
interpreted as <tt class="docutils literal"><span class="pre">1/(2*(x-1)*(x-2))</span></tt> which gives zero by polynomial
division. Thus, use one of <tt class="docutils literal"><span class="pre">(1/2)(x-1)(x-2)</span></tt>, <tt class="docutils literal"><span class="pre">1/2*(x-1)(x-2)</span></tt> or
<tt class="docutils literal"><span class="pre">(x-1)(x-2)/2</span></tt>.</p>
</div>
<p>After:</p>
<pre class="literal-block">
\poldef f_1(x):= 25(x-1)(x^2-2)(x-3)(x-4)(x-5);%
\poldef f_2(x):= 37(x-1)(x^2-2)(x-6)(x-7)(x-8);%
</pre>
<p>the macro call <tt class="docutils literal"><span class="pre">\PolGCD{f_1}{f_2}{k}</span></tt> sets <tt class="docutils literal">k</tt> to the (unitary) GCD of
<tt class="docutils literal">f_1</tt> and <tt class="docutils literal">f_2</tt> (hence to the expansion of <tt class="docutils literal"><span class="pre">(x-1)(x^2-2)</span></tt>.)</p>
<dl class="docutils">
<dt><tt class="docutils literal">\PolToExpr{k}</tt></dt>
<dd>will (expandably) give in this case <tt class="docutils literal"><span class="pre">x^3-x^2-2*x+2</span></tt>. This is
useful for console or file output (the syntax is Maple- and
PSTricks-compatible; the letter used in output can be
(non-expandably) changed via a redefinition of <a class="reference internal" href="#poltoexprvar">\PolToExprVar</a>.)</dd>
<dt><tt class="docutils literal"><span class="pre">\PolToExpr*{k}</span></tt></dt>
<dd>gives ascending powers: <tt class="docutils literal"><span class="pre">2-2*x-x^2+x^3</span></tt>.</dd>
</dl>
</div>
<div class="section" id="non-expandable-macros">
<h1><a class="toc-backref" href="#id16">Non-expandable macros</a></h1>
<div class="section" id="poldef-polname-letter-expression-in-letter">
<span id="poldef"></span><h2><a class="toc-backref" href="#id17"><tt class="docutils literal">\poldef <span class="pre">polname(letter):=</span> expression in letter;</tt></a></h2>
<blockquote>
<p>This evaluates the <em>polynomial expression</em> and stores the coefficients
in a private structure accessible later via other package macros,
under the user-chosen <tt class="docutils literal">polname</tt>. Of course the <em>expression</em> can
use other previously defined polynomials. Names must start with a
letter and are constituted of letters, digits and underscore
characters. The whole <a class="reference external" href="http://www.ctan.org/pkg/xint">xintexpr</a> syntax is authorized:</p>
<pre class="literal-block">
\poldef sin(z) := add((-1)^i z^(2i+1)/(2i+1)!, i = 0..10);
</pre>
<p>With fractional coefficients, beware the <a class="reference internal" href="#warningtacit">tacit multiplication issue</a>.</p>
<p>As a side effect the function <tt class="docutils literal">polname()</tt> is recognized as a
genuine <tt class="docutils literal"><span class="pre">\xintexpr...\relax</span></tt> function for (exact) numerical
evaluation (or within an <tt class="docutils literal">\xintdefvar</tt> assignment.) It computes
values not according to the original expression but via the Horner
scheme corresponding to the polynomial coefficients.</p>
<p>Also, a function with the same name is created for use within
<tt class="docutils literal">\xintfloatexpr</tt> (or <tt class="docutils literal">\xintdeffloatvar</tt>.) This is indispensible
for numerical algorithms as exact computations very quickly lead to
very big fractions. Addition and multiplication steps of the Horner
scheme will be executed as floating-point operations. The
coefficients have already been rounded at time of definition,
according to the then prevailing <tt class="docutils literal">\xinttheDigits</tt> value.</p>
<div class="admonition important">
<p class="first admonition-title">Important</p>
<p>Package macros (such as derivatives or Euclidean division)
operate with the &quot;exact&quot; polynomials; &quot;floating point&quot;
polynomials are always obtained in a second step.</p>
<p>To modifiy &quot;in-place&quot; the original coefficients of a polynomial
and round them to float precision:</p>
<pre class="literal-block">
\PolMapCoeffs{\xintFloat}{polname}
% or \xintFloat[P] for precision P digits
</pre>
<p class="last">See <a class="reference internal" href="#polmapcoeffs-macro-polname">\PolMapCoeffs{\macro}{polname}</a>.</p>
</div>
<p>The original expression is lost after parsing, and in particular
the package provides no way to typeset it. This has to be done
manually, if needed.</p>
</blockquote>
</div>
<div class="section" id="poldef-letter-polname-expression-in-letter">
<span id="id2"></span><h2><a class="toc-backref" href="#id18"><tt class="docutils literal"><span class="pre">\PolDef[letter]{polname}{expression</span> in letter}</tt></a></h2>
<blockquote>
Does the same in an undelimited macro format (thus avoiding
potential problems with the catcode of the semi-colon in presence of
some packages.) In absence of the <tt class="docutils literal">[letter]</tt> optional argument,
the variable is assumed to be <tt class="docutils literal">x</tt>.</blockquote>
</div>
<div class="section" id="pollet-polname-2-polname-1">
<h2><a class="toc-backref" href="#id19"><tt class="docutils literal"><span class="pre">\PolLet{polname_2}={polname_1}</span></tt></a></h2>
<blockquote>
Makes a copy of the already defined polynomial <tt class="docutils literal">polname_1</tt> to a
new one <tt class="docutils literal">polname_2</tt>. Same effect as
<tt class="docutils literal"><span class="pre">\PolDef{polname_2}{polname_1(x)}</span></tt> but with less overhead. The
<tt class="docutils literal">=</tt> is optional.</blockquote>
</div>
<div class="section" id="polassign-polname-toarray-macro">
<h2><a class="toc-backref" href="#id20"><tt class="docutils literal"><span class="pre">\PolAssign{polname}\toarray\macro</span></tt></a></h2>
<blockquote>
<p>Defines a one-argument expandable macro <tt class="docutils literal"><span class="pre">\macro{#1}</span></tt> which expands
to the (raw) #1th polynomial coefficient.</p>
<ul class="simple">
<li>Attention, coefficients here are indexed starting at 1.</li>
<li>With #1=-1, -2, ..., <tt class="docutils literal"><span class="pre">\macro{#1}</span></tt> returns leading coefficients.</li>
<li>With #1=0, returns the number of coefficients, i.e. <tt class="docutils literal">1 + deg f</tt>
for non-zero polynomials.</li>
<li>Out-of-range #1's return <tt class="docutils literal">0/1[0]</tt>.</li>
</ul>
<p>See also <a class="reference internal" href="#polnthcoeff-polname-number">\PolNthCoeff{polname}{number}</a>. The main difference is that
with <tt class="docutils literal">\PolAssign</tt>, <tt class="docutils literal">\macro</tt> is made a prefix to <tt class="docutils literal">1 + deg f</tt>
already defined (hidden to user) macros holding individually the
coefficients but <a class="reference internal" href="#polnthcoeff-polname-number">\PolNthCoeff{polname}{number}</a> does each time the job
to expandably recover the <tt class="docutils literal">Nth</tt> coefficient, and due to
expandability can not store it in a macro for future usage (of course,
it can be an argument in an <tt class="docutils literal">\edef</tt>.) The other difference
is the shift by one in indexing, mentioned above (negative
indices act the same in both.)</p>
</blockquote>
</div>
<div class="section" id="polget-polname-fromarray-macro">
<h2><a class="toc-backref" href="#id21"><tt class="docutils literal"><span class="pre">\PolGet{polname}\fromarray\macro</span></tt></a></h2>
<blockquote>
<p>Does the converse operation to <tt class="docutils literal"><span class="pre">\PolAssign{polname}\toarray\macro</span></tt>. No
error checks on validity of coefficients as numbers. Each
<tt class="docutils literal">\macro{number}</tt> is expanded in an <tt class="docutils literal">\edef</tt> before being assigned
to a coefficient. Leading zero coefficients are removed from the
polynomial.</p>
<p>(contrived) Example:</p>
<pre class="literal-block">
\xintAssignArray{1}{-2}{5}{-3}\to\foo
\PolGet{f}\fromarray\foo
</pre>
<p>This will define <tt class="docutils literal">f</tt> as would have <tt class="docutils literal">\poldef <span class="pre">f(x):=1-2x+5x^2-3x^3;</span></tt>.
However the coefficients are still in their original form (i.e.
they were not subjected to <tt class="docutils literal">\xintRaw</tt> or similar xintfrac macro.)</p>
</blockquote>
</div>
<div class="section" id="polfromcsv-polname-csv">
<h2><a class="toc-backref" href="#id22"><tt class="docutils literal"><span class="pre">\PolFromCSV{polname}{&lt;csv&gt;}</span></tt></a></h2>
<blockquote>
<p>Defines a polynomial directly from the comma separated list of
values (or a macro expanding to such a list) of its coefficients,
the constant term being the first item. No validity checks. Spaces
from the list argument are trimmed. List items are each expanded in
an <tt class="docutils literal">\edef</tt>, but currently left in their original form like e.g.
<tt class="docutils literal">1.5e3</tt> which is not converted to <tt class="docutils literal">15/1[2]</tt> <em>raw</em> xintfrac
format (this may change).</p>
<p>Leading zero coefficients are removed:</p>
<pre class="literal-block">
\PolFromCSV{f}{0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
</pre>
<p>defines the zero polynomial, which has only one (zero) coefficient.</p>
<p>See also expandable macro <a class="reference internal" href="#poltocsv-polname">\PolToCSV</a>.</p>
</blockquote>
</div>
<div class="section" id="poltypeset-polname">
<h2><a class="toc-backref" href="#id23"><tt class="docutils literal">\PolTypeset{polname}</tt></a></h2>
<blockquote>
<p>Typesets in descending powers in math mode. It uses letter <tt class="docutils literal">x</tt> but
this can be changed via an optional argument:</p>
<pre class="literal-block">
\PolTypeset[z]{polname}
</pre>
<p>By default zero coefficients are skipped (issue <tt class="docutils literal">\poltypesetalltrue</tt>
to get all of them in output).</p>
<p>These commands (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>
</blockquote>
<div class="section" id="poltypesetcmd-raw-coeff">
<h3><a class="toc-backref" href="#id24"><tt class="docutils literal">\PolTypesetCmd{raw_coeff}</tt></a></h3>
<blockquote>
<p>Basically will use <tt class="docutils literal">\xintSignedFrac</tt> from <a class="reference external" href="http://www.ctan.org/pkg/xint">xintfrac</a>, but checks if
the coefficient is <tt class="docutils literal">1</tt> or <tt class="docutils literal"><span class="pre">-1</span></tt> and then skips printing the
<tt class="docutils literal">1</tt>, except for the constant term...</p>
<p>One can do things such as for example: <a class="footnote-reference" href="#id4" id="id3">[1]</a></p>
<pre class="literal-block">
\renewcommand\PolTypesetCmd[1]{\num{\xintPFloat[5]{#1}}}
\renewcommand\PolTypesetCmd[1]{\num{\xintRound{4}{#1}}}
</pre>
<p>where e.g. we used the <tt class="docutils literal">\num</tt> macro of <tt class="docutils literal">siunitx</tt> as it
understands floating point notation.</p>
<table class="docutils footnote" frame="void" id="id4" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label"><a class="fn-backref" href="#id3">[1]</a></td><td>the difference in the syntaxes of <tt class="docutils literal">\xintPFloat</tt> and
<tt class="docutils literal">\xintRound</tt> is explained from the fact that
<tt class="docutils literal">\xintPFloat</tt> by default uses the prevailing precision
hence the extra argument like here <tt class="docutils literal">5</tt> is an optional one.</td></tr>
</tbody>
</table>
</blockquote>
</div>
<div class="section" id="poltypesetcmdprefix-raw-coeff">
<h3><a class="toc-backref" href="#id25"><tt class="docutils literal">\PolTypesetCmdPrefix{raw_coeff}</tt></a></h3>
<blockquote>
Expands to a <tt class="docutils literal">+</tt> if the <tt class="docutils literal">raw_coeff</tt> is zero or positive, and to
nothing if <tt class="docutils literal">raw_coeff</tt> is negative, as in latter case the
<tt class="docutils literal">\xintSignedFrac</tt> used by <a class="reference internal" href="#poltypesetcmd-raw-coeff">\PolTypesetCmd{raw_coeff}</a> will put
the <tt class="docutils literal">-</tt> 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.</blockquote>
</div>
<div class="section" id="poltypesetmonomialcmd">
<h3><a class="toc-backref" href="#id26"><tt class="docutils literal">\PolTypesetMonomialCmd</tt></a></h3>
<blockquote>
This decides how a monomial (in variable <tt class="docutils literal">\PolVar</tt> and with
exponent <tt class="docutils literal">\PolIndex</tt>) is to be printed. The default does nothing
for the constant term, <tt class="docutils literal">\PolVar</tt> for the first degree and
<tt class="docutils literal"><span class="pre">\PolVar^{\PolIndex}</span></tt> for higher degrees monomials. Beware that
<tt class="docutils literal">\PolIndex</tt> expands to digit tokens and needs termination in
<tt class="docutils literal">\ifnum</tt> tests.</blockquote>
</div>
</div>
<div class="section" id="id5">
<h2><a class="toc-backref" href="#id27"><tt class="docutils literal"><span class="pre">\PolTypeset*{polname}</span></tt></a></h2>
<blockquote>
Typesets in ascending powers. Use e.g. <tt class="docutils literal">[h]</tt> optional argument
(after the <tt class="docutils literal">*</tt>) to use letter <tt class="docutils literal">h</tt> rather than <tt class="docutils literal">x</tt>.</blockquote>
</div>
<div class="section" id="poldiff-polname-1-polname-2">
<h2><a class="toc-backref" href="#id28"><tt class="docutils literal"><span class="pre">\PolDiff{polname_1}{polname_2}</span></tt></a></h2>
<blockquote>
<p>This sets <tt class="docutils literal">polname_2</tt> to the first derivative of <tt class="docutils literal">polname_1</tt>. It
is allowed to issue <tt class="docutils literal"><span class="pre">\PolDiff{f}{f}</span></tt>, effectively replacing <tt class="docutils literal">f</tt>
by <tt class="docutils literal">f'</tt>.</p>
<p>Coefficients of the result <tt class="docutils literal">polname_2</tt> are irreducible fractions
(see <a class="reference internal" href="#technicalities">Technicalities</a> for the whole story.)</p>
</blockquote>
</div>
<div class="section" id="poldiff-n-polname-1-polname-2">
<h2><a class="toc-backref" href="#id29"><tt class="docutils literal"><span class="pre">\PolDiff[N]{polname_1}{polname_2}</span></tt></a></h2>
<blockquote>
This sets <tt class="docutils literal">polname_2</tt> to the <tt class="docutils literal">N</tt>-th derivative of <tt class="docutils literal">polname_1</tt>.
Identical arguments is allowed. With <tt class="docutils literal">N=0</tt>, same effect as
<tt class="docutils literal"><span class="pre">\PolLet{polname_2}={polname_1}</span></tt>. With negative <tt class="docutils literal">N</tt>, switches to
using <tt class="docutils literal">\PolAntiDiff</tt>.</blockquote>
</div>
<div class="section" id="polantidiff-polname-1-polname-2">
<h2><a class="toc-backref" href="#id30"><tt class="docutils literal"><span class="pre">\PolAntiDiff{polname_1}{polname_2}</span></tt></a></h2>
<blockquote>
<p>This sets <tt class="docutils literal">polname_2</tt> to the primitive of <tt class="docutils literal">polname_1</tt> vanishing
at zero.</p>
<p>Coefficients of the result <tt class="docutils literal">polname_2</tt> are irreducible fractions
(see <a class="reference internal" href="#technicalities">Technicalities</a> for the whole story.)</p>
</blockquote>
</div>
<div class="section" id="polantidiff-n-polname-1-polname-2">
<h2><a class="toc-backref" href="#id31"><tt class="docutils literal"><span class="pre">\PolAntiDiff[N]{polname_1}{polname_2}</span></tt></a></h2>
<blockquote>
This sets <tt class="docutils literal">polname_2</tt> to the result of <tt class="docutils literal">N</tt> successive integrations on
<tt class="docutils literal">polname_1</tt>. With negative <tt class="docutils literal">N</tt>, it switches to using <tt class="docutils literal">\PolDiff</tt>.</blockquote>
</div>
<div class="section" id="poldivide-polname-1-polname-2-polname-q-polname-r">
<h2><a class="toc-backref" href="#id32"><tt class="docutils literal"><span class="pre">\PolDivide{polname_1}{polname_2}{polname_Q}{polname_R}</span></tt></a></h2>
<blockquote>
This sets <tt class="docutils literal">polname_Q</tt> and <tt class="docutils literal">polname_R</tt> to be the quotient and
remainder in the Euclidean division of <tt class="docutils literal">polname_1</tt> by
<tt class="docutils literal">polname_2</tt>.</blockquote>
</div>
<div class="section" id="polgcd-polname-1-polname-2-polname-gcd">
<h2><a class="toc-backref" href="#id33"><tt class="docutils literal"><span class="pre">\PolGCD{polname_1}{polname_2}{polname_GCD}</span></tt></a></h2>
<blockquote>
This sets <tt class="docutils literal">polname_GCD</tt> to be the G.C.D. It is a unitary
polynomial except if both <tt class="docutils literal">polname_1</tt> and <tt class="docutils literal">polname_2</tt> vanish,
then <tt class="docutils literal">polname_GCD</tt> is the zero polynomial.</blockquote>
</div>
<div class="section" id="polmapcoeffs-macro-polname">
<h2><a class="toc-backref" href="#id34"><tt class="docutils literal"><span class="pre">\PolMapCoeffs{\macro}{polname}</span></tt></a></h2>
<blockquote>
<p>It modifies ('in-place': original coefficients get lost) each
coefficient of the defined polynomial via the <em>expandable</em> macro
<tt class="docutils literal">\macro</tt>. The degree is adjusted as necessary if some leading
coefficients vanish after the operation. In replacement text of
<tt class="docutils literal">\macro</tt>, <tt class="docutils literal">\index</tt> expands to the coefficient index (which is
defined to be zero for the constant term).</p>
<p>Notice that <tt class="docutils literal">\macro</tt> will have to handle inputs of the shape
<tt class="docutils literal">A/B[N]</tt> (<a class="reference external" href="http://www.ctan.org/pkg/xint">xintfrac</a> internal notation). This means that it probably
will have to be expressed in terms of macros from xintfrac package.</p>
<p>Example:</p>
<pre class="literal-block">
\def\foo#1{\xintMul{#1}{\the\numexpr\index*\index\relax}}
</pre>
<p>(or with <tt class="docutils literal"><span class="pre">\xintSqr{\index}</span></tt>) to replace <tt class="docutils literal">n</tt>-th coefficient
<tt class="docutils literal">f_n</tt> by <tt class="docutils literal">f_n*n^2</tt>.</p>
</blockquote>
</div>
<div class="section" id="polreducecoeffs-polname">
<h2><a class="toc-backref" href="#id35"><tt class="docutils literal">\PolReduceCoeffs{polname}</tt></a></h2>
<blockquote>
About the same as <tt class="docutils literal"><span class="pre">\PolMapCoeffs{\xintIrr}{polname}</span></tt> (but
maintaining a <tt class="docutils literal">[0]</tt> postfix for speedier <a class="reference external" href="http://www.ctan.org/pkg/xint">xintfrac</a> parsing when
polynomial function is used for computations.) This is a
one-argument macro, working 'in-place'.</blockquote>
</div>
</div>
<div class="section" id="expandable-macros">
<h1><a class="toc-backref" href="#id36">Expandable macros</a></h1>
<p>All these macros expand completely in two steps except <tt class="docutils literal">\PolToExpr</tt>
and <tt class="docutils literal">\PolToFloatExpr</tt> (and their auxiliaries) which need a
<tt class="docutils literal">\write</tt>, <tt class="docutils literal">\edef</tt> or a <tt class="docutils literal"><span class="pre">\csname...\endcsname</span></tt> context.</p>
<div class="section" id="poleval-polname-at-numerical-expression">
<h2><a class="toc-backref" href="#id37"><tt class="docutils literal"><span class="pre">\PolEval{polname}\At{numerical</span> expression}</tt></a></h2>
<blockquote>
<p>It boils down to <tt class="docutils literal">\xinttheexpr polname(numerical <span class="pre">expression)\relax</span></tt>.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p>The <tt class="docutils literal">0.2</tt> version stupidly tried to be clever and as a result
of a misguided optimization choked if <tt class="docutils literal">value</tt> was not a number
but a numerical expression (a sum e.g.), but the more powerful
behaviour has been reinstored at <tt class="docutils literal">0.3</tt> release.</p>
<p class="last">The <tt class="docutils literal">0.1</tt> and <tt class="docutils literal">0.2</tt> version did a <tt class="docutils literal">reduce</tt> which however is
costly on big fractions and irrelevant if the output is served as
argument of <tt class="docutils literal">\xintRound</tt> or <tt class="docutils literal">\xintFloat</tt>. Thus <tt class="docutils literal">reduce</tt> was
removed, and former meaning is now available as
<a class="reference internal" href="#polevalreduced-polname-at-numerical-expression">\PolEvalReduced{polname}\At{numerical expression}</a></p>
</div>
</blockquote>
</div>
<div class="section" id="polevalreduced-polname-at-numerical-expression">
<h2><a class="toc-backref" href="#id38"><tt class="docutils literal"><span class="pre">\PolEvalReduced{polname}\At{numerical</span> expression}</tt></a></h2>
<blockquote>
Boils down to <tt class="docutils literal">\xinttheexpr reduce(polname(numerical <span class="pre">expression))\relax</span></tt>.</blockquote>
</div>
<div class="section" id="polfloateval-polname-at-numerical-expression">
<h2><a class="toc-backref" href="#id39"><tt class="docutils literal"><span class="pre">\PolFloatEval{polname}\At{numerical</span> expression}</tt></a></h2>
<blockquote>
<p>Boils down to <tt class="docutils literal">\xintthefloatexpr polname(numerical <span class="pre">expression)\relax</span></tt>.</p>
<p>This is done via a Horner Scheme (see <a class="reference internal" href="#poldef">\poldef</a>), with
already rounded coefficients. <a class="footnote-reference" href="#id8" id="id6">[2]</a> To use the <em>exact coefficients</em>
(and <em>exact</em> additions and multiplications), just insert it in the
float expression as in this example: <a class="footnote-reference" href="#id9" id="id7">[3]</a></p>
<pre class="literal-block">
\xintthefloatexpr 3.27*\xintexpr f(2.53)\relax^2\relax
</pre>
<p>The <tt class="docutils literal">f(2.53)</tt> is exactly computed then rounded at the time of
getting raised to the power <tt class="docutils literal">2</tt>. Moving the <tt class="docutils literal">^2</tt> inside, that
operation would also be treated exactly.</p>
<table class="docutils footnote" frame="void" id="id8" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label"><a class="fn-backref" href="#id6">[2]</a></td><td>Anyway each floating point operation starts by rounding its
operands to the floating point precision.</td></tr>
</tbody>
</table>
<table class="docutils footnote" frame="void" id="id9" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label"><a class="fn-backref" href="#id7">[3]</a></td><td>The <tt class="docutils literal">\xintexpr</tt> could be <tt class="docutils literal">\xinttheexpr</tt> but that would be
less efficient. Cf. <a class="reference external" href="http://www.ctan.org/pkg/xint">xintexpr</a> documentation about nested
expressions.</td></tr>
</tbody>
</table>
</blockquote>
</div>
<div class="section" id="polnthcoeff-polname-number">
<h2><a class="toc-backref" href="#id40"><tt class="docutils literal"><span class="pre">\PolNthCoeff{polname}{number}</span></tt></a></h2>
<blockquote>
It expands to the raw <tt class="docutils literal">N</tt>-th coefficient (<tt class="docutils literal">0/1[0]</tt> if the index
number is out of range). With <tt class="docutils literal"><span class="pre">N=-1</span></tt>, <tt class="docutils literal"><span class="pre">-2</span></tt>, ... expands to the
leading coefficients.</blockquote>
</div>
<div class="section" id="poldegree-polname">
<h2><a class="toc-backref" href="#id41"><tt class="docutils literal">\PolDegree{polname}</tt></a></h2>
<blockquote>
It expands to the degree. This is <tt class="docutils literal"><span class="pre">-1</span></tt> if zero polynomial but this
may change in future. Should it then expand to <tt class="docutils literal"><span class="pre">-\infty</span></tt> ?</blockquote>
</div>
<div class="section" id="poltoexpr-polname">
<h2><a class="toc-backref" href="#id42"><tt class="docutils literal">\PolToExpr{polname}</tt></a></h2>
<blockquote>
<p>Expands <a class="footnote-reference" href="#id11" id="id10">[4]</a> to <tt class="docutils literal"><span class="pre">coeff_N*x^N+...</span></tt> (descending powers.)</p>
<table class="docutils footnote" frame="void" id="id11" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label"><a class="fn-backref" href="#id10">[4]</a></td><td>in a <tt class="docutils literal">\write</tt>, <tt class="docutils literal">\edef</tt>, or <tt class="docutils literal"><span class="pre">\csname...\endcsname</span></tt>, but
not under <tt class="docutils literal"><span class="pre">\romannumeral-`0</span></tt>.</td></tr>
</tbody>
</table>
<p>By default zero coefficients are skipped (issue <tt class="docutils literal">\poltoexpralltrue</tt> to
get all of them in output).</p>
<p>By default, no <tt class="docutils literal">+</tt> sign before negative coefficients, for
compliance with Maple input format (but see
<a class="reference internal" href="#poltoexprtermprefix-raw-coeff">\PolToExprTermPrefix{raw_coeff}</a>.) Also, like the default
behaviour of <a class="reference internal" href="#poltypeset-polname">\PolTypeset{polname}</a>, does not print (for the non
constant terms) coefficients equal to plus or minus one. The degree
one monomial is output as <tt class="docutils literal">x</tt>, not <tt class="docutils literal">x^1</tt>. Complete customization is
possible, see next macros.</p>
<p>Of course <tt class="docutils literal">\PolToExpr{f}</tt> can be inserted in a <tt class="docutils literal">\poldef</tt>, as the
latter expands token by token, hence will force complete expansion
of <tt class="docutils literal">\PolToExpr{f}</tt>, but a simple <tt class="docutils literal">f(x)</tt> is more efficient for
the identical result.</p>
</blockquote>
<div class="section" id="poltoexproneterm-raw-coeff-number">
<h3><a class="toc-backref" href="#id43"><tt class="docutils literal"><span class="pre">\PolToExprOneTerm{raw_coeff}{number}</span></tt></a></h3>
<blockquote>
<p>This two argument expandable command takes care of the monomial and
its coefficient. The default definition is done in order for
coefficients of absolute value <tt class="docutils literal">1</tt> not be printed explicitely
(except of course for the constant term). Also by default, the
monomial of degree one is <tt class="docutils literal">x</tt> not <tt class="docutils literal">x^1</tt>, and <tt class="docutils literal">x^0</tt> is skipped.</p>
<p>For compatibility with Maple input requirements, by default a <tt class="docutils literal">*</tt>
always precedes the <tt class="docutils literal">x^number</tt>, except if the coefficient is a one
or a minus one. See <a class="reference internal" href="#poltoexprtimes">\PolToExprTimes</a>.</p>
</blockquote>
</div>
<div class="section" id="poltoexpronetermstyleb-raw-coeff-number">
<h3><a class="toc-backref" href="#id44"><tt class="docutils literal"><span class="pre">\PolToExprOneTermStyleB{raw_coeff}{number}</span></tt></a></h3>
<blockquote>
<p>For output in this style:</p>
<pre class="literal-block">
2*x^11/3+3*x^8/7-x^5−x^4/4−x^3−x^2/2−2*x+1
</pre>
<p>issue <tt class="docutils literal">\let\PolToExprOneTerm\PolToExprOneTermStyleB</tt> before using
<tt class="docutils literal">\PolToExpr</tt>. Note that then <tt class="docutils literal">\PolToExprCmd</tt> isn't used at all.</p>
<p>To suppress the <tt class="docutils literal">*</tt>'s, cf. <a class="reference internal" href="#poltoexprtimes">\PolToExprTimes</a>.</p>
</blockquote>
</div>
<div class="section" id="poltoexprcmd-raw-coeff">
<h3><a class="toc-backref" href="#id45"><tt class="docutils literal">\PolToExprCmd{raw_coeff}</tt></a></h3>
<blockquote>
It is the one-argument macro used by the package definition of
<tt class="docutils literal">\PolToExprOneTerm</tt> for the coefficients themselves (when not
equal to plus or minus one), and it defaults to
<tt class="docutils literal"><span class="pre">\xintPRaw{\xintRawWithZeros{#1}}</span></tt>. One will have to redefine it
to <tt class="docutils literal"><span class="pre">\xintIrr{#1}</span></tt> or to <tt class="docutils literal"><span class="pre">\xintPRaw{\xintIrr{#1}}</span></tt> to obtain in the
output forcefully reduced coefficients.</blockquote>
</div>
<div class="section" id="poltoexprtermprefix-raw-coeff">
<h3><a class="toc-backref" href="#id46"><tt class="docutils literal">\PolToExprTermPrefix{raw_coeff}</tt></a></h3>
<blockquote>
Defined identically as <a class="reference internal" href="#poltypesetcmdprefix-raw-coeff">\PolTypesetCmdPrefix{raw_coeff}</a>. It
prefixes with a plus sign for non-negative coefficients, because
they don't carry one by themselves.</blockquote>
</div>
<div class="section" id="poltoexprvar">
<h3><a class="toc-backref" href="#id47"><tt class="docutils literal">\PolToExprVar</tt></a></h3>
<blockquote>
This expands to the variable to use in output (it does not have to
be a single letter, may be an expandable macro.) Initial definition
is <tt class="docutils literal">x</tt>.</blockquote>
</div>
<div class="section" id="poltoexprtimes">
<h3><a class="toc-backref" href="#id48"><tt class="docutils literal">\PolToExprTimes</tt></a></h3>
<blockquote>
This expands to the symbol used for multiplication of an
<tt class="docutils literal"><span class="pre">x^{number}</span></tt> by the corresponding coefficient. The default is
<tt class="docutils literal">*</tt>. Redefine the macro to expand to nothing to get rid of it (but
this will give output incompatible with some professional computer
algebra software).</blockquote>
</div>
</div>
<div class="section" id="id12">
<h2><a class="toc-backref" href="#id49"><tt class="docutils literal"><span class="pre">\PolToExpr*{polname}</span></tt></a></h2>
<blockquote>
Expands to <tt class="docutils literal"><span class="pre">coeff_0+coeff_1*x+coeff_2*x^2+...</span></tt> (ascending powers).
Customizable like <a class="reference internal" href="#poltoexpr-polname">\PolToExpr{polname}</a> via the same macros.</blockquote>
</div>
<div class="section" id="poltofloatexpr-polname">
<h2><a class="toc-backref" href="#id50"><tt class="docutils literal">\PolToFloatExpr{polname}</tt></a></h2>
<blockquote>
<p>Similar to <a class="reference internal" href="#poltoexpr-polname">\PolToExpr{polname}</a> but uses <a class="reference external" href="\PolToFloatExprCmd{raw_coeff}">\PolToFloatExprCmd</a>
which by default rounds and converts the coefficients to floating
point format.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p>The polynomial function for usage in <tt class="docutils literal">\xintfloatexpr</tt> is
already prepared with the rounded coefficients, but the latter
are not easily recoverable (and especially not expandably) from
this. Thus <tt class="docutils literal">\PolToFloatExprCmd</tt> operates from the <em>exact</em>
coefficients anew. This means though that if the prevailing float
precision was changed with <tt class="docutils literal"><span class="pre">\xintDigits:=P;</span></tt> syntax, the output
will obey this precision <tt class="docutils literal">P</tt>, but the polynomial function was
defined earlier and operates on floating point numbers with
coefficients which were rounded at time of definition.</p>
<p class="last">This may change in future, if the pre-rounded coefficients are
stored in a more easily accessible data structure.</p>
</div>
</blockquote>
<div class="section" id="poltofloatexproneterm-raw-coeff-number">
<h3><a class="toc-backref" href="#id51"><tt class="docutils literal"><span class="pre">\PolToFloatExprOneTerm{raw_coeff}{number}</span></tt></a></h3>
<blockquote>
Similar to <a class="reference external" href="\PolToExprOneTerm{raw_coeff}{number}">\PolToExprOneTerm</a>. But does not treat
especially coefficients equal to plus or minus one.</blockquote>
</div>
<div class="section" id="poltofloatexprcmd-raw-coeff">
<h3><a class="toc-backref" href="#id52"><tt class="docutils literal">\PolToFloatExprCmd{raw_coeff}</tt></a></h3>
<blockquote>
<p>It is the one-argument macro used by <tt class="docutils literal">\PolToFloatExprOneTerm</tt>.
Its package definition is <tt class="docutils literal"><span class="pre">\xintFloat{#1}</span></tt>.</p>
<div class="admonition caution">
<p class="first admonition-title">Caution!</p>
<p>Currently (<a class="reference external" href="http://www.ctan.org/pkg/xint">xint</a> <tt class="docutils literal">1.2p</tt>) <tt class="docutils literal">\xintFloat{0}</tt> outputs <tt class="docutils literal">0.e0</tt>
which is perfectly acceptable input for Python, but not for
Maple. Thus, one should better leave the <a class="reference internal" href="#poltoexprallfalse">\poltoexprallfalse</a>
toggle to its default <tt class="docutils literal">\iffalse</tt> state, if one intends to use
the output in a Maple worksheet.</p>
<p>But even then the zero polynomial will cause a problem. Workaround:</p>
<pre class="literal-block">
\renewcommand\PolToFloatExprCmd[1]{\xintiiifZero{#1}{0.0}{\xintFloat{#1}}}
</pre>
<p class="last">Usage of <tt class="docutils literal">\xintiiifZero</tt> and not <tt class="docutils literal">\xintifZero</tt> is only for
optimization (I can't help it) because <tt class="docutils literal">#1</tt> is known to be
in <tt class="docutils literal">xintfrac</tt> raw format.</p>
</div>
</blockquote>
</div>
</div>
<div class="section" id="id13">
<h2><a class="toc-backref" href="#id53"><tt class="docutils literal"><span class="pre">\PolToFloatExpr*{polname}</span></tt></a></h2>
<blockquote>
Typesets in ascending powers.</blockquote>
</div>
<div class="section" id="poltolist-polname">
<h2><a class="toc-backref" href="#id54"><tt class="docutils literal">\PolToList{polname}</tt></a></h2>
<blockquote>
Expands to <tt class="docutils literal"><span class="pre">{coeff_0}{coeff_1}...{coeff_N}</span></tt> with <tt class="docutils literal">N</tt> = degree
(except zero polynomial which does give <tt class="docutils literal">{0/1[0]}</tt> and not an
empty output.)</blockquote>
</div>
<div class="section" id="poltocsv-polname">
<h2><a class="toc-backref" href="#id55"><tt class="docutils literal">\PolToCSV{polname}</tt></a></h2>
<blockquote>
Expands to <tt class="docutils literal">coeff_0, coeff_1, coeff_2, <span class="pre">.....,</span> coeff_N</tt>. Converse
to <a class="reference internal" href="#polfromcsv-polname-csv">\PolFromCSV</a>.</blockquote>
</div>
</div>
<div class="section" id="booleans-with-default-setting-as-indicated">
<h1><a class="toc-backref" href="#id56">Booleans (with default setting as indicated)</a></h1>
<div class="section" id="xintverbosefalse">
<h2><a class="toc-backref" href="#id57"><tt class="docutils literal">\xintverbosefalse</tt></a></h2>
<blockquote>
<p>This is actually an <a class="reference external" href="http://www.ctan.org/pkg/xint">xintexpr</a> configuration. Setting it to
<tt class="docutils literal">true</tt> triggers the writing of information to the log when new
polynomials are defined.</p>
<div class="admonition caution">
<p class="first admonition-title">Caution!</p>
<p class="last">The macro meanings as written to the log are to be considered
unstable and undocumented internal structures.</p>
</div>
</blockquote>
</div>
<div class="section" id="poltypesetallfalse">
<h2><a class="toc-backref" href="#id58"><tt class="docutils literal">\poltypesetallfalse</tt></a></h2>
<blockquote>
If <tt class="docutils literal">true</tt>, <a class="reference internal" href="#poltypeset-polname">\PolTypeset{polname}</a> will also typeset the vanishing
coefficients.</blockquote>
</div>
<div class="section" id="poltoexprallfalse">
<h2><a class="toc-backref" href="#id59"><tt class="docutils literal">\poltoexprallfalse</tt></a></h2>
<blockquote>
If <tt class="docutils literal">true</tt>, <a class="reference internal" href="#poltoexpr-polname">\PolToExpr{polname}</a> and <a class="reference internal" href="#poltofloatexpr-polname">\PolToFloatExpr{polname}</a> will
also include the vanishing coefficients in their outputs.</blockquote>
</div>
</div>
<div class="section" id="technicalities">
<h1><a class="toc-backref" href="#id60">Technicalities</a></h1>
<ul>
<li><p class="first">The catcode of the semi-colon is reset temporarily by <a class="reference internal" href="#poldef">\poldef</a> macro in case some other package (for example the French
babel module) may have made it active. This will fail though if the
whole thing was already part of a macro argument, in such cases one
can use <a class="reference internal" href="#id2">\PolDef{f}{P(x)}</a>
rather. The colon in <tt class="docutils literal">:=</tt> may be active with no consequences.</p>
</li>
<li><p class="first">During execution of polynomial operations by <tt class="docutils literal">\poldef</tt> (but not
during the initial purely numerical parsing of the expression), the
<a class="reference external" href="http://www.ctan.org/pkg/xint">xintfrac</a> macro <tt class="docutils literal">\xintAdd</tt> is temporarily patched to always express
<tt class="docutils literal">a/b + c/d</tt> with <tt class="docutils literal"><span class="pre">l.c.m.(b,d)</span></tt> as denominator. Indeed the current
(xint 1.2p) <tt class="docutils literal">\xintAdd</tt> uses <tt class="docutils literal"><span class="pre">(ad+bc)/bd</span></tt> formula except if <tt class="docutils literal">b</tt>
divides <tt class="docutils literal">d</tt> or <tt class="docutils literal">d</tt> divides <tt class="docutils literal">b</tt>, which quickly leads in real life
to big denominators.</p>
<p>It is probable that this convention will be backported as default
behaviour of xintfrac's <tt class="docutils literal">\xintAdd</tt> in a future xint release. When this
change is merged, there will be an impact on coefficients computed by
<tt class="docutils literal">\poldef</tt> because the change will apply even to the pure numerical
evaluations arising during the initial stage of the parsing. Of course
the coefficients are still the same rational numbers, only
representation as fractions may change.</p>
</li>
<li><p class="first">As a consequence of previous rule, user-chosen common denominators
survive addition and multiplications:</p>
<pre class="literal-block">
\poldef P(x):= 1/2 + 2/2*x + 3/2*x^3 + 4/2*x^4;
\poldef Q(x):= 1/3 + (2/3)x + (3/3)x^3 + (4/3)x^4;
\poldef PQ(x):= P(x)Q(x);
</pre>
<p>gives the polynomial:</p>
<pre class="literal-block">
1/6+4/6*x^1+4/6*x^2+6/6*x^3+20/6*x^4+16/6*x^5+9/6*x^6+24/6*x^7+16/6*x^8
</pre>
<p>where all coefficients have the same denominator 6 (which in this
example is the <tt class="docutils literal">l.c.m</tt> of the denominators of the reduced coefficients.)</p>
</li>
<li><p class="first"><a class="reference internal" href="#poldiff-polname-1-polname-2">\PolDiff{polname_1}{polname_2}</a> always applies <tt class="docutils literal">\xintIrr</tt> to the
resulting coefficients, except that the <em>power of ten</em> part <tt class="docutils literal">[N]</tt>
(for example an input in scientific notation such as <tt class="docutils literal">1.23e5</tt> gives
<tt class="docutils literal">123/1[3]</tt> internally in xintfrac) is not taken into account in the
reduction of the fraction. This is tentative and may change.</p>
<p>Same remark for <a class="reference internal" href="#polantidiff-polname-1-polname-2">\PolAntiDiff{polname_1}{polname_2}</a>.</p>
</li>
<li><p class="first">If <tt class="docutils literal">f</tt> was created from comma separated values by macro
<a class="reference internal" href="#polfromcsv-polname-csv">\PolFromCSV{polname}{&lt;csv&gt;}</a>, then the coefficients will be in
the output of <a class="reference internal" href="#poltolist-polname">\PolToList{polname}</a> and <a class="reference internal" href="#poltocsv-polname">\PolToCSV{polname}</a> in
the same format as originally in input: a <tt class="docutils literal">1.3e2</tt> will again be a
<tt class="docutils literal">1.3e2</tt>.</p>
<p>In contrast when such coefficients are used in a <tt class="docutils literal">\poldef</tt> (or
<tt class="docutils literal">\PolDef</tt>) expression, they get transformed during the parsing to
the xintfrac <em>raw</em> format.
This <em>raw</em> format speeds up expansion of xintfrac macros for numerical
evaluations.</p>
</li>
<li><p class="first">Currently, the package stores all coefficients from index <tt class="docutils literal">0</tt> 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 <tt class="docutils literal">\poldef
<span class="pre">f(x):=x^1000</span> + x^500;</tt> the subsequent definition <tt class="docutils literal">\poldef <span class="pre">g(x):=</span>
<span class="pre">f(x)^2;</span></tt> 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 class="first">Tests have been made with Newton's iteration (for which computing
exactly the derivative is precisely what this package is made for) or
Regula Falsi method for locating roots: using exact computations leads
quickly to gigantic fractions (but dichotomy method much less so). It
is thus recommended to use <tt class="docutils literal">\xintdeffloatvar</tt> or
<tt class="docutils literal">\xintthefloatexpr</tt> contexts for any kind of numerical mathematics.
Of course, exact computations are invaluable for number theory or
combinatorics...</p>
</li>
<li><p class="first">As is to be expected internal structures of the package are barely
documented and unstable. Don't use them.</p>
</li>
</ul>
</div>
<div class="section" id="releases">
<h1><a class="toc-backref" href="#id61">RELEASES</a></h1>
<ul>
<li><p class="first">0.1 (2018/01/11)</p>
<p>Initial release (files README, polexpr.sty).</p>
</li>
<li><p class="first">0.2 (2018/01/14)</p>
<p>Documentation moved to polexpr.{txt,html}.</p>
</li>
<li><p class="first">0.3 (2018/01/17)</p>
<p>Make polynomials known to <tt class="docutils literal">\xintfloatexpr</tt> and improve
documentation.</p>
</li>
<li><p class="first">0.3.1 (2018/01/18)</p>
<p>Fix two typos in documentation.</p>
</li>
</ul>
<p>Files of 0.3.1 release:</p>
<ul class="simple">
<li>README.md,</li>
<li>polexpr.sty (package file),</li>
<li>polexpr.txt (documentation),</li>
<li>polexpr.html (conversion via <a class="reference external" href="http://docutils.sourceforge.net/docs/index.html">DocUtils</a> rst2html.py)</li>
</ul>
<p>See README.md for the License and the change log (there were
some breaking changes from 0.2 to 0.3).</p>
</div>
<div class="section" id="acknowledgments">
<h1><a class="toc-backref" href="#id62">Acknowledgments</a></h1>
<p>Thanks to Jürgen Gilg whose question about <a class="reference external" href="http://www.ctan.org/pkg/xint">xint</a> usage for
differentiating polynomials was the initial trigger leading to this
package, and to Jürgen Gilg and Thomas Söll for testing it on some
concrete problems.</p>
</div>
</div>
</body>
</html>