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

REMARKS ON THE IMPLEMENTATION

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

BUGS, IDEAS, FEEDBACK

197       This  document,  and the package it describes, will undoubtedly contain
198       bugs and other problems.  Please report such in the  category  math  ::
199       polynomials    of    the    Tcllib    SF    Trackers    [http://source
200       forge.net/tracker/?group_id=12883].  Please also report any  ideas  for
201       enhancements you may have for either package and/or documentation.
202

KEYWORDS

204       math, polynomial functions
205
207       Copyright (c) 2004 Arjen Markus <arjenmarkus@users.sourceforge.net>
208
209
210
211
212math                                 1.0.1                math::polynomials(n)
Impressum