/usr/share/calc/help/poly is in apcalc-common 2.12.4.4-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | NAME
poly - evaluate a polynomial
SYNOPSIS
poly(a, b, ..., x)
poly(clist, x, y, ...)
TYPES
For first case:
a, b, ... Arithmetic
x Arithmetic
return Depends on argument types
For second case:
clist List of coefficients
x, y, ... Coefficients
return Depends on argument types
Here an arithmetic type is one for which the required + and *
operations are defined, e.g. real or complex numbers or square
matrices of the same size. A coefficient is either of arithmetic
type or a list of coefficients.
DESCRIPTION
If the first argument is not a list, and the necessary operations are
defined:
poly(a_0, a_1, ..., a_n, x)
returns the value of:
a_n + (a_n-1 + ... + (a_1 + a_0 * x) * x ...) * x
If the coefficients a_0, a_1, ..., a_n and x are elements of a
commutative ring, e.g. if the coefficients and x are real or complex
numbers, this is the value of the polynomial:
a_0 * x^n + a_1 * x^(n-1) + ... + a_(n-1) * x + a_n.
For other structures (e.g. if addition is not commutative),
the order of operations may be relevant.
In particular:
poly(a, x) returns the value of a.
poly(a, b, x) returns the value of b + a * x
poly(a, b, c, x) returns the value of c + (b + a * x) * x
If the first argument is a list as if defined by:
clist = list(a_0, a_1, ..., a_n)
and the coefficients a_i and x are are of arithmetic type,
poly(clist, x) returns:
a_0 + (a_1 + (a_2 + ... + a_n * x) * x)
which for a commutative ring, expands to:
a_0 + a_1 * x + ... + a_n * x^n.
If clist is the empty list, the value returned is the number 0.
Note that the order of the coefficients for the list case is the
reverse of that for the non-list case.
If one or more elements of clist is a list and there are more than
one arithmetic arguments x, y, ..., the coefficient corresponding
to such an element is the value of poly for that list and the next
argument in x, y, ... For example:
poly(list(list(a,b,c), list(d,e), f), x, y)
returns:
(a + b * y + c * y^2) + (d + e * y) * x + f * x^2.
Arguments in excess of those required for clist are ignored, e.g.:
poly(list(1,2,3), x, y)
returns the same as poly(list(1,2,3), x). If the number of
arguments is less than greatest depth of lists in clist, the
"missing" arguments are deemed to be zero. E.g.:
poly(list(list(1,2), list(3,4), 5), x)
returns the same as:
poly(list(1, 3, 5), x).
If in the clist case, one or more of x, y, ... is a list, the
arguments to be applied to the polynomial are the successive
non-list values in the list or sublists. For example, if the x_i
are not lists:
poly(clist, list(x_0, x_1), x_2, list(list(x_3, x_4), x_5))
returns the same as:
poly(clist, x_0, x_1, x_2, x_3, x_4, x_5).
EXAMPLE
; print poly(2, 3, 5, 7), poly(list(5, 3, 2), 7), 5 + 3 * 7 + 2 * 7^2
124 124 124
; mat A[2,2] = {1,2,3,4}
; mat I[2,2] = {1,0,0,1}
print poly(2 * I, 3 * I, 5 * I, A)
mat [2,2] (4 elements, 4 nonzero)
[0,0] = 22
[0,1] = 26
[1,0] = 39
[1,1] = 61
; P = list(list(0,0,1), list(0,2), 3); x = 4; y = 5
; print poly(P,x,y), poly(P, list(x,y)), y^2 + 2 * y * x + 3 * x^2
113 113 113
LIMITS
The number of arguments is not to exceed 1024
LINK LIBRARY
BOOL evalpoly(LIST *clist, LISTELEM *x, VALUE *result);
SEE ALSO
list
## Copyright (C) 1999-2006 Landon Curt Noll
##
## Calc is open software; you can redistribute it and/or modify it under
## the terms of the version 2.1 of the GNU Lesser General Public License
## as published by the Free Software Foundation.
##
## Calc is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
## Public License for more details.
##
## A copy of version 2.1 of the GNU Lesser General Public License is
## distributed with calc under the filename COPYING-LGPL. You should have
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##
## @(#) $Revision: 30.1 $
## @(#) $Id: poly,v 30.1 2007/03/16 11:10:42 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/poly,v $
##
## Under source code control: 1995/12/02 02:40:43
## File existed as early as: 1995
##
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|