1math::polynomials(n) Tcl Math Library math::polynomials(n)
2
3
4
5______________________________________________________________________________
6
8 math::polynomials - Polynomial functions
9
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
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
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 coeffs list Coefficients of the polynomial (in ascending
68 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 coeffs list Coefficients of the polynomial (in ascending
78 order) or the polynomial definition returned by the poly‐
79 nomial command.
80
81
82 ::math::polynomials::evalPolyn polynomial x
83 Evaluate the polynomial at x.
84
85 polynomial list The polynomial's definition (as returned by
86 the polynomial command). order)
87
88 x float The coordinate at which to evaluate the polynomial
89
90
91 ::math::polynomials::addPolyn polyn1 polyn2
92 Return a new polynomial which is the sum of the two others.
93
94 polyn1 list The first polynomial operand
95
96 polyn2 list The second polynomial operand
97
98
99 ::math::polynomials::subPolyn polyn1 polyn2
100 Return a new polynomial which is the difference of the two oth‐
101 ers.
102
103 polyn1 list The first polynomial operand
104
105 polyn2 list The second polynomial operand
106
107
108 ::math::polynomials::multPolyn polyn1 polyn2
109 Return a new polynomial which is the product of the two others.
110 If one of the arguments is a scalar value, the other polynomial
111 is simply scaled.
112
113 polyn1 list The first polynomial operand or a scalar
114
115 polyn2 list The second polynomial operand or a scalar
116
117
118 ::math::polynomials::divPolyn polyn1 polyn2
119 Divide the first polynomial by the second polynomial and return
120 the result. The remainder is dropped
121
122 polyn1 list The first polynomial operand
123
124 polyn2 list The second polynomial operand
125
126
127 ::math::polynomials::remainderPolyn polyn1 polyn2
128 Divide the first polynomial by the second polynomial and return
129 the remainder.
130
131 polyn1 list The first polynomial operand
132
133 polyn2 list The second polynomial operand
134
135
136 ::math::polynomials::derivPolyn polyn
137 Differentiate the polynomial and return the result.
138
139 polyn list The polynomial to be differentiated
140
141
142 ::math::polynomials::primitivePolyn polyn
143 Integrate the polynomial and return the result. The integration
144 constant is set to zero.
145
146 polyn list The polynomial to be integrated
147
148
149 ::math::polynomials::degreePolyn polyn
150 Return the degree of the polynomial.
151
152 polyn list The polynomial to be examined
153
154
155 ::math::polynomials::coeffPolyn polyn index
156 Return the coefficient of the term of the index'th degree of the
157 polynomial.
158
159 polyn list The polynomial to be examined
160
161 index int The degree of the term
162
163
164 ::math::polynomials::allCoeffsPolyn polyn
165 Return the coefficients of the polynomial (in ascending order).
166
167 polyn list The polynomial in question
168
170 The implementation for evaluating the polynomials at some point uses
171 Horn's rule, which guarantees numerical stability and a minimum of
172 arithmetic operations. To recognise that a polynomial definition is
173 indeed a correct definition, it consists of a list of two elements: the
174 keyword "POLYNOMIAL" and the list of coefficients in descending order.
175 The latter makes it easier to implement Horner's rule.
176
178 math, polynomial functions
179
181 Copyright (c) 2004 Arjen Markus <arjenmarkus@users.sourceforge.net>
182
183
184
185
186math 1.0.1 math::polynomials(n)