@tf_export('math.polyval')
def polyval(coeffs, x, name=None):
    "Computes the elementwise value of a polynomial.\n\n  If `x` is a tensor and `coeffs` is a list n + 1 tensors, this function returns\n  the value of the n-th order polynomial\n\n     p(x) = coeffs[n-1] + coeffs[n-2] * x + ...  + coeffs[0] * x**(n-1)\n\n  evaluated using Horner's method, i.e.\n\n     p(x) = coeffs[n-1] + x * (coeffs[n-2] + ... + x * (coeffs[1] +\n            x * coeffs[0]))\n\n  Args:\n    coeffs: A list of `Tensor` representing the coefficients of the polynomial.\n    x: A `Tensor` representing the variable of the polynomial.\n    name: A name for the operation (optional).\n\n  Returns:\n    A `tensor` of the shape as the expression p(x) with usual broadcasting rules\n    for element-wise addition and multiplication applied.\n\n  @compatibility(numpy)\n  Equivalent to numpy.polyval.\n  @end_compatibility\n  "
    with ops.name_scope(name, 'polyval', (nest.flatten(coeffs) + [x])) as name:
        x = ops.convert_to_tensor(x, name='x')
        if (len(coeffs) < 1):
            return array_ops.zeros_like(x, name=name)
        coeffs = [ops.convert_to_tensor(coeff, name=('coeff_%d' % index)) for (index, coeff) in enumerate(coeffs)]
        p = coeffs[0]
        for c in coeffs[1:]:
            p = (c + (p * x))
        return p
Computes the elementwise value of a polynomial.

If `x` is a tensor and `coeffs` is a list n + 1 tensors, this function returns
the value of the n-th order polynomial

   p(x) = coeffs[n-1] + coeffs[n-2] * x + ...  + coeffs[0] * x**(n-1)

evaluated using Horner's method, i.e.

   p(x) = coeffs[n-1] + x * (coeffs[n-2] + ... + x * (coeffs[1] +
          x * coeffs[0]))

Args:
  coeffs: A list of `Tensor` representing the coefficients of the polynomial.
  x: A `Tensor` representing the variable of the polynomial.
  name: A name for the operation (optional).

Returns:
  A `tensor` of the shape as the expression p(x) with usual broadcasting rules
  for element-wise addition and multiplication applied.

@compatibility(numpy)
Equivalent to numpy.polyval.
@end_compatibility
@tf_export('math.polyval')
def polyval(coeffs, x, name=None):
    "Computes the elementwise value of a polynomial.\n\n  If `x` is a tensor and `coeffs` is a list n + 1 tensors, this function returns\n  the value of the n-th order polynomial\n\n     p(x) = coeffs[n-1] + coeffs[n-2] * x + ...  + coeffs[0] * x**(n-1)\n\n  evaluated using Horner's method, i.e.\n\n     p(x) = coeffs[n-1] + x * (coeffs[n-2] + ... + x * (coeffs[1] +\n            x * coeffs[0]))\n\n  Args:\n    coeffs: A list of `Tensor` representing the coefficients of the polynomial.\n    x: A `Tensor` representing the variable of the polynomial.\n    name: A name for the operation (optional).\n\n  Returns:\n    A `tensor` of the shape as the expression p(x) with usual broadcasting rules\n    for element-wise addition and multiplication applied.\n\n  @compatibility(numpy)\n  Equivalent to numpy.polyval.\n  @end_compatibility\n  "
    with ops.name_scope(name, 'polyval', (nest.flatten(coeffs) + [x])) as name:
        x = ops.convert_to_tensor(x, name='x')
        if (len(coeffs) < 1):
            return array_ops.zeros_like(x, name=name)
        coeffs = [ops.convert_to_tensor(coeff, name=('coeff_%d' % index)) for (index, coeff) in enumerate(coeffs)]
        p = coeffs[0]
        for c in coeffs[1:]:
            p = (c + (p * x))
        return p