55. polynomial — Polynomials — pyFormex 0.9.1 documentation

### Navigation

- index
- modules |
- next |
- previous |
- pyFormex 0.9.1 documentation >
- pyFormex reference manual >

# 55. `polynomial` — Polynomials

This module defines the class Polynomial, representing a polynomial in n variables.

`Classes defined in module polynomial`

class `polynomial.` `Polynomial`(exp, coeff=None)

  A polynomial in ndim dimensions.

  Parameters:

  - exp: (nterms,ndim) int array with the exponents of each of the ndim variables in the nterms terms of the polynomial.
  - coeff: (nterms,) float array with the coefficients of the terms. If not specified, all coeeficients are set to 1.

  Example:

      >>> p = Polynomial([(0,0),(1,0),(1,1),(0,2)],(2,3,-1,-1))
      >>> print(p.atoms())
      ['1', 'x', 'x*y', 'y**2']
      >>> print(p.human())
      2.0 + 3.0*x -1.0*x*y -1.0*y**2
      >>> print(p.evalAtoms([[1,2],[3,0],[2,1]]))
      [[ 1.  1.  2.  4.]
       [ 1.  3.  0.  0.]
       [ 1.  2.  2.  1.]]
      >>> print(p.eval([[1,2],[3,0],[2,1]]))
      [ -1.  11.   5.]

  `degrees`()

    Return the degree of the polynomial in each of the dimensions.

    The degree is the maximal exponent for each of the dimensions.

  `degree`()

    Return the total degree of the polynomial.

    The degree is the sum of the degrees for all dimensions.

  `evalAtoms1`(x)

    Evaluate the monomials at the given points

    x is an (npoints,ndim) array of points where the polynomial is to be evaluated. The result is an (npoints,nterms) array of values.

  `evalAtoms`(x)

    Evaluate the monomials at the given points

    x is an (npoints,ndim) array of points where the polynomial is to be evaluated. The result is an (npoints,nterms) array of values.

  `eval`(x)

    Evaluate the polynomial at the given points

    x is an (npoints,ndim) array of points where the polynomial is to be evaluated. The result is an (npoints,) array of values.

  `atoms`(symbol='xyz')

    Return a human representation of the monomials

  `human`(symbol='xyz')

    Return a human representation

`Functions defined in module polynomial`

`polynomial.` `polynomial`(atoms, x, y=0, z=0)

  Build a matrix of functions of coords.

  - atoms: a list of text strings representing a mathematical function of x, and possibly of y and z.
  - x, y, z: a list of x- (and optionally y-, z-) values at which the atoms will be evaluated. The lists should have the same length.

  Returns a matrix with nvalues rows and natoms colums.

`polynomial.` `monomial`(exp, symbol='xyz')

  Compute the monomials for the given exponents

  - exp: a tuple of integer exponents
  - symbol: a string of at least the same length as exp

  Returns a string representation of a monomial created by raising the symbols to the corresponding exponent.

  Example:

      >>> monomial((2,1))
      'x**2*y'

### Navigation

- index
- modules |
- next |
- previous |
- pyFormex 0.9.1 documentation >
- pyFormex reference manual >