1math::polynomials(n)           Tcl Math Library           math::polynomials(n)
2
3
4
5______________________________________________________________________________
6

NAME

8       math::polynomials - Polynomial functions
9

SYNOPSIS

11       package require Tcl  ?8.3?
12
13       package require math::polynomials  ?1.0.1?
14
15       ::math::polynomials::polynomial coeffs
16
17       ::math::polynomials::polynCmd coeffs
18
19       ::math::polynomials::evalPolyn polynomial x
20
21       ::math::polynomials::addPolyn polyn1 polyn2
22
23       ::math::polynomials::subPolyn polyn1 polyn2
24
25       ::math::polynomials::multPolyn polyn1 polyn2
26
27       ::math::polynomials::divPolyn polyn1 polyn2
28
29       ::math::polynomials::remainderPolyn polyn1 polyn2
30
31       ::math::polynomials::derivPolyn polyn
32
33       ::math::polynomials::primitivePolyn polyn
34
35       ::math::polynomials::degreePolyn polyn
36
37       ::math::polynomials::coeffPolyn polyn index
38
39       ::math::polynomials::allCoeffsPolyn polyn
40
41______________________________________________________________________________
42

DESCRIPTION

44       This package deals with polynomial functions of one variable:
45
46       ·      the basic arithmetic operations are extended to polynomials
47
48       ·      computing the derivatives and primitives of these functions
49
50       ·      evaluation  through  a  general procedure or via specific proce‐
51              dures)
52

PROCEDURES

54       The package defines the following public procedures:
55
56       ::math::polynomials::polynomial coeffs
57              Return an (encoded) list that defines the polynomial. A  polyno‐
58              mial
59
60
61                 f(x) = a + b.x + c.x**2 + d.x**3
62
63
64              can be defined via:
65
66
67                 set f [::math::polynomials::polynomial [list $a $b $c $d]
68
69
70              list coeffs
71                     Coefficients of the polynomial (in ascending order)
72
73
74       ::math::polynomials::polynCmd coeffs
75              Create  a  new procedure that evaluates the polynomial. The name
76              of the polynomial is automatically generated. Useful if you need
77              to  evualuate  the  polynomial many times, as the procedure con‐
78              sists of a single [expr] command.
79
80              list coeffs
81                     Coefficients of the polynomial (in  ascending  order)  or
82                     the polynomial definition returned by the polynomial com‐
83                     mand.
84
85
86       ::math::polynomials::evalPolyn polynomial x
87              Evaluate the polynomial at x.
88
89              list polynomial
90                     The polynomial's definition (as returned by  the  polyno‐
91                     mial command).  order)
92
93              float x
94                     The coordinate at which to evaluate the polynomial
95
96
97       ::math::polynomials::addPolyn polyn1 polyn2
98              Return a new polynomial which is the sum of the two others.
99
100              list polyn1
101                     The first polynomial operand
102
103              list polyn2
104                     The second polynomial operand
105
106
107       ::math::polynomials::subPolyn polyn1 polyn2
108              Return  a new polynomial which is the difference of the two oth‐
109              ers.
110
111              list polyn1
112                     The first polynomial operand
113
114              list polyn2
115                     The second polynomial operand
116
117
118       ::math::polynomials::multPolyn polyn1 polyn2
119              Return a new polynomial which is the product of the two  others.
120              If  one of the arguments is a scalar value, the other polynomial
121              is simply scaled.
122
123              list polyn1
124                     The first polynomial operand or a scalar
125
126              list polyn2
127                     The second polynomial operand or a scalar
128
129
130       ::math::polynomials::divPolyn polyn1 polyn2
131              Divide the first polynomial by the second polynomial and  return
132              the result. The remainder is dropped
133
134              list polyn1
135                     The first polynomial operand
136
137              list polyn2
138                     The second polynomial operand
139
140
141       ::math::polynomials::remainderPolyn polyn1 polyn2
142              Divide  the first polynomial by the second polynomial and return
143              the remainder.
144
145              list polyn1
146                     The first polynomial operand
147
148              list polyn2
149                     The second polynomial operand
150
151
152       ::math::polynomials::derivPolyn polyn
153              Differentiate the polynomial and return the result.
154
155              list polyn
156                     The polynomial to be differentiated
157
158
159       ::math::polynomials::primitivePolyn polyn
160              Integrate the polynomial and return the result. The  integration
161              constant is set to zero.
162
163              list polyn
164                     The polynomial to be integrated
165
166
167       ::math::polynomials::degreePolyn polyn
168              Return the degree of the polynomial.
169
170              list polyn
171                     The polynomial to be examined
172
173
174       ::math::polynomials::coeffPolyn polyn index
175              Return the coefficient of the term of the index'th degree of the
176              polynomial.
177
178              list polyn
179                     The polynomial to be examined
180
181              int index
182                     The degree of the term
183
184
185       ::math::polynomials::allCoeffsPolyn polyn
186              Return the coefficients of the polynomial (in ascending order).
187
188              list polyn
189                     The polynomial in question
190

REMARKS ON THE IMPLEMENTATION

192       The implementation for evaluating the polynomials at  some  point  uses
193       Horn's  rule,  which  guarantees  numerical  stability and a minimum of
194       arithmetic operations.  To recognise that a  polynomial  definition  is
195       indeed a correct definition, it consists of a list of two elements: the
196       keyword "POLYNOMIAL" and the list of coefficients in descending  order.
197       The latter makes it easier to implement Horner's rule.
198

BUGS, IDEAS, FEEDBACK

200       This  document,  and the package it describes, will undoubtedly contain
201       bugs and other problems.  Please report such in the  category  math  ::
202       polynomials           of          the          Tcllib          Trackers
203       [http://core.tcl.tk/tcllib/reportlist].  Please also report  any  ideas
204       for enhancements you may have for either package and/or documentation.
205
206       When proposing code changes, please provide unified diffs, i.e the out‐
207       put of diff -u.
208
209       Note further that  attachments  are  strongly  preferred  over  inlined
210       patches.  Attachments  can  be  made  by  going to the Edit form of the
211       ticket immediately after its creation, and  then  using  the  left-most
212       button in the secondary navigation bar.
213

KEYWORDS

215       math, polynomial functions
216

CATEGORY

218       Mathematics
219
221       Copyright (c) 2004 Arjen Markus <arjenmarkus@users.sourceforge.net>
222
223
224
225
226tcllib                               1.0.1                math::polynomials(n)
Impressum