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
|
[comment {-*- tcl -*- doctools manpage}]
[manpage_begin math::polynomials n 1.0.1]
[keywords math]
[keywords {polynomial functions}]
[copyright {2004 Arjen Markus <arjenmarkus@users.sourceforge.net>}]
[moddesc {Tcl Math Library}]
[titledesc {Polynomial functions}]
[category Mathematics]
[require Tcl [opt 8.3]]
[require math::polynomials [opt 1.0.1]]
[description]
[para]
This package deals with polynomial functions of one variable:
[list_begin itemized]
[item]
the basic arithmetic operations are extended to polynomials
[item]
computing the derivatives and primitives of these functions
[item]
evaluation through a general procedure or via specific procedures)
[list_end]
[section "PROCEDURES"]
The package defines the following public procedures:
[list_begin definitions]
[call [cmd ::math::polynomials::polynomial] [arg coeffs]]
Return an (encoded) list that defines the polynomial. A polynomial
[example {
f(x) = a + b.x + c.x**2 + d.x**3
}]
can be defined via:
[example {
set f [::math::polynomials::polynomial [list $a $b $c $d]
}]
[list_begin arguments]
[arg_def list coeffs] Coefficients of the polynomial (in ascending
order)
[list_end]
[para]
[call [cmd ::math::polynomials::polynCmd] [arg coeffs]]
Create a new procedure that evaluates the polynomial. The name of the
polynomial is automatically generated. Useful if you need to evualuate
the polynomial many times, as the procedure consists of a single
[lb]expr[rb] command.
[list_begin arguments]
[arg_def list coeffs] Coefficients of the polynomial (in ascending
order) or the polynomial definition returned by the [emph polynomial]
command.
[list_end]
[para]
[call [cmd ::math::polynomials::evalPolyn] [arg polynomial] [arg x]]
Evaluate the polynomial at x.
[list_begin arguments]
[arg_def list polynomial] The polynomial's definition (as returned by
the polynomial command).
order)
[arg_def float x] The coordinate at which to evaluate the polynomial
[list_end]
[para]
[call [cmd ::math::polynomials::addPolyn] [arg polyn1] [arg polyn2]]
Return a new polynomial which is the sum of the two others.
[list_begin arguments]
[arg_def list polyn1] The first polynomial operand
[arg_def list polyn2] The second polynomial operand
[list_end]
[para]
[call [cmd ::math::polynomials::subPolyn] [arg polyn1] [arg polyn2]]
Return a new polynomial which is the difference of the two others.
[list_begin arguments]
[arg_def list polyn1] The first polynomial operand
[arg_def list polyn2] The second polynomial operand
[list_end]
[para]
[call [cmd ::math::polynomials::multPolyn] [arg polyn1] [arg polyn2]]
Return a new polynomial which is the product of the two others. If one
of the arguments is a scalar value, the other polynomial is simply
scaled.
[list_begin arguments]
[arg_def list polyn1] The first polynomial operand or a scalar
[arg_def list polyn2] The second polynomial operand or a scalar
[list_end]
[para]
[call [cmd ::math::polynomials::divPolyn] [arg polyn1] [arg polyn2]]
Divide the first polynomial by the second polynomial and return the
result. The remainder is dropped
[list_begin arguments]
[arg_def list polyn1] The first polynomial operand
[arg_def list polyn2] The second polynomial operand
[list_end]
[para]
[call [cmd ::math::polynomials::remainderPolyn] [arg polyn1] [arg polyn2]]
Divide the first polynomial by the second polynomial and return the
remainder.
[list_begin arguments]
[arg_def list polyn1] The first polynomial operand
[arg_def list polyn2] The second polynomial operand
[list_end]
[para]
[call [cmd ::math::polynomials::derivPolyn] [arg polyn]]
Differentiate the polynomial and return the result.
[list_begin arguments]
[arg_def list polyn] The polynomial to be differentiated
[list_end]
[para]
[call [cmd ::math::polynomials::primitivePolyn] [arg polyn]]
Integrate the polynomial and return the result. The integration
constant is set to zero.
[list_begin arguments]
[arg_def list polyn] The polynomial to be integrated
[list_end]
[para]
[call [cmd ::math::polynomials::degreePolyn] [arg polyn]]
Return the degree of the polynomial.
[list_begin arguments]
[arg_def list polyn] The polynomial to be examined
[list_end]
[para]
[call [cmd ::math::polynomials::coeffPolyn] [arg polyn] [arg index]]
Return the coefficient of the term of the index'th degree of the
polynomial.
[list_begin arguments]
[arg_def list polyn] The polynomial to be examined
[arg_def int index] The degree of the term
[list_end]
[para]
[call [cmd ::math::polynomials::allCoeffsPolyn] [arg polyn]]
Return the coefficients of the polynomial (in ascending order).
[list_begin arguments]
[arg_def list polyn] The polynomial in question
[list_end]
[list_end]
[section "REMARKS ON THE IMPLEMENTATION"]
The implementation for evaluating the polynomials at some point uses
Horn's rule, which guarantees numerical stability and a minimum of
arithmetic operations.
To recognise that a polynomial definition is indeed a correct
definition, it consists of a list of two elements: the keyword
"POLYNOMIAL" and the list of coefficients in descending order. The
latter makes it easier to implement Horner's rule.
[vset CATEGORY {math :: polynomials}]
[include ../common-text/feedback.inc]
[manpage_end]
|