1 2[//000000001]: # (math::polynomials \- Tcl Math Library) 3[//000000002]: # (Generated from file 'polynomials\.man' by tcllib/doctools with format 'markdown') 4[//000000003]: # (Copyright © 2004 Arjen Markus <arjenmarkus@users\.sourceforge\.net>) 5[//000000004]: # (math::polynomials\(n\) 1\.0\.1 tcllib "Tcl Math Library") 6 7<hr> [ <a href="../../../../toc.md">Main Table Of Contents</a> | <a 8href="../../../toc.md">Table Of Contents</a> | <a 9href="../../../../index.md">Keyword Index</a> | <a 10href="../../../../toc0.md">Categories</a> | <a 11href="../../../../toc1.md">Modules</a> | <a 12href="../../../../toc2.md">Applications</a> ] <hr> 13 14# NAME 15 16math::polynomials \- Polynomial functions 17 18# <a name='toc'></a>Table Of Contents 19 20 - [Table Of Contents](#toc) 21 22 - [Synopsis](#synopsis) 23 24 - [Description](#section1) 25 26 - [PROCEDURES](#section2) 27 28 - [REMARKS ON THE IMPLEMENTATION](#section3) 29 30 - [Bugs, Ideas, Feedback](#section4) 31 32 - [Keywords](#keywords) 33 34 - [Category](#category) 35 36 - [Copyright](#copyright) 37 38# <a name='synopsis'></a>SYNOPSIS 39 40package require Tcl ?8\.3? 41package require math::polynomials ?1\.0\.1? 42 43[__::math::polynomials::polynomial__ *coeffs*](#1) 44[__::math::polynomials::polynCmd__ *coeffs*](#2) 45[__::math::polynomials::evalPolyn__ *polynomial* *x*](#3) 46[__::math::polynomials::addPolyn__ *polyn1* *polyn2*](#4) 47[__::math::polynomials::subPolyn__ *polyn1* *polyn2*](#5) 48[__::math::polynomials::multPolyn__ *polyn1* *polyn2*](#6) 49[__::math::polynomials::divPolyn__ *polyn1* *polyn2*](#7) 50[__::math::polynomials::remainderPolyn__ *polyn1* *polyn2*](#8) 51[__::math::polynomials::derivPolyn__ *polyn*](#9) 52[__::math::polynomials::primitivePolyn__ *polyn*](#10) 53[__::math::polynomials::degreePolyn__ *polyn*](#11) 54[__::math::polynomials::coeffPolyn__ *polyn* *index*](#12) 55[__::math::polynomials::allCoeffsPolyn__ *polyn*](#13) 56 57# <a name='description'></a>DESCRIPTION 58 59This package deals with polynomial functions of one variable: 60 61 - the basic arithmetic operations are extended to polynomials 62 63 - computing the derivatives and primitives of these functions 64 65 - evaluation through a general procedure or via specific procedures\) 66 67# <a name='section2'></a>PROCEDURES 68 69The package defines the following public procedures: 70 71 - <a name='1'></a>__::math::polynomials::polynomial__ *coeffs* 72 73 Return an \(encoded\) list that defines the polynomial\. A polynomial 74 75 f(x) = a + b.x + c.x**2 + d.x**3 76 77 can be defined via: 78 79 set f [::math::polynomials::polynomial [list $a $b $c $d] 80 81 * list *coeffs* 82 83 Coefficients of the polynomial \(in ascending order\) 84 85 - <a name='2'></a>__::math::polynomials::polynCmd__ *coeffs* 86 87 Create a new procedure that evaluates the polynomial\. The name of the 88 polynomial is automatically generated\. Useful if you need to evualuate the 89 polynomial many times, as the procedure consists of a single \[expr\] command\. 90 91 * list *coeffs* 92 93 Coefficients of the polynomial \(in ascending order\) or the polynomial 94 definition returned by the *polynomial* command\. 95 96 - <a name='3'></a>__::math::polynomials::evalPolyn__ *polynomial* *x* 97 98 Evaluate the polynomial at x\. 99 100 * list *polynomial* 101 102 The polynomial's definition \(as returned by the polynomial command\)\. 103 order\) 104 105 * float *x* 106 107 The coordinate at which to evaluate the polynomial 108 109 - <a name='4'></a>__::math::polynomials::addPolyn__ *polyn1* *polyn2* 110 111 Return a new polynomial which is the sum of the two others\. 112 113 * list *polyn1* 114 115 The first polynomial operand 116 117 * list *polyn2* 118 119 The second polynomial operand 120 121 - <a name='5'></a>__::math::polynomials::subPolyn__ *polyn1* *polyn2* 122 123 Return a new polynomial which is the difference of the two others\. 124 125 * list *polyn1* 126 127 The first polynomial operand 128 129 * list *polyn2* 130 131 The second polynomial operand 132 133 - <a name='6'></a>__::math::polynomials::multPolyn__ *polyn1* *polyn2* 134 135 Return a new polynomial which is the product of the two others\. If one of 136 the arguments is a scalar value, the other polynomial is simply scaled\. 137 138 * list *polyn1* 139 140 The first polynomial operand or a scalar 141 142 * list *polyn2* 143 144 The second polynomial operand or a scalar 145 146 - <a name='7'></a>__::math::polynomials::divPolyn__ *polyn1* *polyn2* 147 148 Divide the first polynomial by the second polynomial and return the result\. 149 The remainder is dropped 150 151 * list *polyn1* 152 153 The first polynomial operand 154 155 * list *polyn2* 156 157 The second polynomial operand 158 159 - <a name='8'></a>__::math::polynomials::remainderPolyn__ *polyn1* *polyn2* 160 161 Divide the first polynomial by the second polynomial and return the 162 remainder\. 163 164 * list *polyn1* 165 166 The first polynomial operand 167 168 * list *polyn2* 169 170 The second polynomial operand 171 172 - <a name='9'></a>__::math::polynomials::derivPolyn__ *polyn* 173 174 Differentiate the polynomial and return the result\. 175 176 * list *polyn* 177 178 The polynomial to be differentiated 179 180 - <a name='10'></a>__::math::polynomials::primitivePolyn__ *polyn* 181 182 Integrate the polynomial and return the result\. The integration constant is 183 set to zero\. 184 185 * list *polyn* 186 187 The polynomial to be integrated 188 189 - <a name='11'></a>__::math::polynomials::degreePolyn__ *polyn* 190 191 Return the degree of the polynomial\. 192 193 * list *polyn* 194 195 The polynomial to be examined 196 197 - <a name='12'></a>__::math::polynomials::coeffPolyn__ *polyn* *index* 198 199 Return the coefficient of the term of the index'th degree of the polynomial\. 200 201 * list *polyn* 202 203 The polynomial to be examined 204 205 * int *index* 206 207 The degree of the term 208 209 - <a name='13'></a>__::math::polynomials::allCoeffsPolyn__ *polyn* 210 211 Return the coefficients of the polynomial \(in ascending order\)\. 212 213 * list *polyn* 214 215 The polynomial in question 216 217# <a name='section3'></a>REMARKS ON THE IMPLEMENTATION 218 219The implementation for evaluating the polynomials at some point uses Horn's 220rule, which guarantees numerical stability and a minimum of arithmetic 221operations\. To recognise that a polynomial definition is indeed a correct 222definition, it consists of a list of two elements: the keyword "POLYNOMIAL" and 223the list of coefficients in descending order\. The latter makes it easier to 224implement Horner's rule\. 225 226# <a name='section4'></a>Bugs, Ideas, Feedback 227 228This document, and the package it describes, will undoubtedly contain bugs and 229other problems\. Please report such in the category *math :: polynomials* of 230the [Tcllib Trackers](http://core\.tcl\.tk/tcllib/reportlist)\. Please also 231report any ideas for enhancements you may have for either package and/or 232documentation\. 233 234When proposing code changes, please provide *unified diffs*, i\.e the output of 235__diff \-u__\. 236 237Note further that *attachments* are strongly preferred over inlined patches\. 238Attachments can be made by going to the __Edit__ form of the ticket 239immediately after its creation, and then using the left\-most button in the 240secondary navigation bar\. 241 242# <a name='keywords'></a>KEYWORDS 243 244[math](\.\./\.\./\.\./\.\./index\.md\#math), [polynomial 245functions](\.\./\.\./\.\./\.\./index\.md\#polynomial\_functions) 246 247# <a name='category'></a>CATEGORY 248 249Mathematics 250 251# <a name='copyright'></a>COPYRIGHT 252 253Copyright © 2004 Arjen Markus <arjenmarkus@users\.sourceforge\.net> 254