eval_poly()

Optionally evaluates polynomial function, or derivative or integral of polynomial when supplied with coefficients and input values

Syntax
eval_poly( coefs, x, type ) where coefs is either in list(...) or one-dimensional makearray(1,...) form

Arguments
Name Description Range Type Required
coefs one-dimensional array of coefficients (-∞, ∞) † integer, real † † yes
x input variable of polynomial function (-∞, ∞) † integer, real, complex † † † yes
type specifies the type of operation (-∞, ∞) † † † † integer yes
† Individual elements of array may have values in this range. † † Individual elements of array may be integer or real valued but not complex. † † † Complex input cannot be used for derivative or integral operations. † † † † Function type = 0 for direct polynomial, < 0 for integral of polynomial, > 0 for derivative of polynomial. See Notes and Equations for details.

Examples

The following variables are used to demonstrate the behavior of this function:
c = list(7)
Carr = list(7,11,13,17)
x = 2
Xarr = list(2,3,5)
y = 2+j*2
Yarr = list(2+j*2,3+j*3,5+j*5)

  1. Direct polynomial evaluation
    Recommended use is for a vector of real coefficients and a scalar input which may be integer, real or complex:
    result = eval_poly( Carr, x, 0 )
    = 7 + 11 * 2 + 13 * 2}} 2 + 17 * 2 3
    = 217
    result = eval_poly( Carr, y, 0 )
    = 7 + 11 * (2+j*2) + 13 * (2+j*2) 2 + 17 * (2+j*2) 3
    = 243 + j*398

Other combinations yield degenerate cases:
result = eval_poly( c, x, 0 ) = 7
result = eval_poly( c, y, 0 ) = 7
result = eval_poly( c, Xarr, 0 ) = 7
result = eval_poly( c, Yarr, 0 ) = 7

An overloaded use is made of the eval_poly() function of type=0 for partial derivative computation when both coefficient and input are in vector form. When both the first and second arguments are vectors, an inner or dot product of the two is generated instead of the algebraic polynomial explained thus far. The dot product is performed as far as possible along the shorter of the two vectors. In this example, it is done until the third element of either vector. This is useful for several specialized operations in ADS.

Thus:
result = eval_poly( Carr, Xarr, 0 )
= d/dx}} 0 ( 7 * x 0 + 11 * x 1 + 13 * x 2 )
= 7

Likewise, given a complex input, the result is the same:
result = eval_poly( Carr, Yarr, 0 ) = 7

  1. Derivative of evaluated polynomial
    Recommended use is for a vector of real coefficients and a scalar input which may be integer or real but not complex:
    result = eval_poly( Carr, x, 1 )
    = 11 + 2 * (13 * 2) + 3 * (17 * 2 2 )
    = 267

Using a scalar coefficient yields degenerate cases which correspond to the direct function responses highlighted above:
result = eval_poly( c, x, 1 )
= d/dx( eval_poly( c, x, 0 ) )
= 0
result = eval_poly( c, Xarr, 1 )
= d/dx( eval_poly( c, Xarr, 0 ) )
= 0

In keeping with the idea of partial derivative behavior signaled by vector on vector operation using this function, when type = 1, the partial derivative of the polynomial is computed with respect to x 1 :
result = eval_poly( Carr, Xarr, 1 )
= d/dx}} 1 ( 7 * x 0 + 11 * x 1 + 13 * x 2 )
= 11

This use model is only restricted to type = 1. Setting type > 1 yields zero output.

  1. Integral of evaluated polynomial
    Recommended use is for a vector of real coefficients and a scalar input which may be integer or real but not complex:
    result = eval_poly( Carr, x, -1 )
    = 7 * 2 + 11/2 * 2 2 + 13/3 * 2 3 + 17/4 * 2 4
    = 138.667

Using a scalar coefficient yields degenerate cases which correspond to the direct function responses highlighted above:
result = eval_poly( c, x, -1 )
= integral x ( eval_poly( c, x, 0 ) )
= c 0 * x
result = eval_poly( c, Xarr, -1 )
= integral x ( eval_poly( c, Xarr, 0 ) )
= c 0 * x 0

See Also

eval_miso_poly()

Notes / Equations
  1. It is recommended that general use of this function be restricted to scalar inputs and coefficient vectors of length greater than 1. Under this condition, the direct polynomial, derivative and integral functions of the polynomial work as expected algebraically. All other variations of argument types exist to support specialized functionalities for various components and designs and may not be of interest to the average user.
  2. The differences between this and the eval_miso_poly() function are as follows:
    • The function eval_miso_poly() can operate on dynamically varying inputs since each is supplied as an independent argument of the function and not as a pre-compiled list as is necessary for eval_poly().
    • The function eval_poly() can perform differentiation and integration operations but eval_miso_poly() cannot.
    • When working with vector input rather than scalar input the eval_miso_poly() function is recommended over eval_poly() if the intention is to use the left long-hand multiplication approach to distributing coefficients. Otherwise any arbitrary composite function should be devised using several simple eval_poly() operations.
 

Privacy Statement  | Terms of Use  | Legal | Contact Us  | © Agilent 2000-2008 

Contents
Additional Resources