OrthogonalUniVariatePolynomial

class OrthogonalUniVariatePolynomial(*args)

Base class for orthogonal univariate polynomials.

Warning

Orthogonal univariate polynomials are not intended to be created manually. They should be constructed with the subclasses of OrthogonalUniVariatePolynomialFamily (like e.g. HermiteFactory). Constructor parameters are therefore intentionally not documented.

Examples

>>> import openturns as ot

Create a univariate polynomial from a list of coefficients:

>>> for i in range(3):
...     print(ot.OrthogonalUniVariatePolynomialFamily().build(i))
1
X
-0.707107 + 0.707107 * X^2

Methods

__call__(self, x)

Call self as a function.

derivate(self)

Build the first-order derivative polynomial.

draw(self, xMin, xMax, pointNumber)

Draw the function.

getClassName(self)

Accessor to the object’s name.

getCoefficients(self)

Accessor to the polynomials’s coefficients.

getDegree(self)

Accessor to the polynomials’s degree.

getId(self)

Accessor to the object’s id.

getName(self)

Accessor to the object’s name.

getRecurrenceCoefficients(self)

Accessor to the recurrence coefficients.

getRoots(self)

Compute the roots of the polynomial.

getShadowedId(self)

Accessor to the object’s shadowed id.

getVisibility(self)

Accessor to the object’s visibility state.

gradient(self, x)

Compute the gradient at point x.

hasName(self)

Test if the object is named.

hasVisibleName(self)

Test if the object has a distinguishable name.

hessian(self, x)

Compute the hessian at point x.

incrementDegree(self[, degree])

Multiply the polynomial by x^k.

setCoefficients(self, coefficients)

Accessor to the polynomials’s coefficients.

setName(self, name)

Accessor to the object’s name.

setShadowedId(self, id)

Accessor to the object’s shadowed id.

setVisibility(self, visible)

Accessor to the object’s visibility state.

__init__(self, \*args)

Initialize self. See help(type(self)) for accurate signature.

derivate(self)

Build the first-order derivative polynomial.

Returns
derivated_polynomialUnivariate

The first-order derivated polynomial.

Examples

>>> import openturns as ot
>>> P = ot.UniVariatePolynomial([1.0, 2.0, 3.0])
>>> print(P.derivate())
2 + 6 * X
draw(self, xMin, xMax, pointNumber)

Draw the function.

Parameters
x_minfloat, optional

The starting value that is used for meshing the x-axis.

x_maxfloat, optional, x_{\max} > x_{\min}

The ending value that is used for meshing the x-axis.

n_pointsint, optional

The number of points that is used for meshing the x-axis.

Examples

>>> import openturns as ot
>>> from openturns.viewer import View
>>> f = ot.UniVariatePolynomial([1.0, 2.0, -3.0, 5.0])
>>> View(f.draw(-10.0, 10.0, 100)).show()
getClassName(self)

Accessor to the object’s name.

Returns
class_namestr

The object class name (object.__class__.__name__).

getCoefficients(self)

Accessor to the polynomials’s coefficients.

Returns
coefficientsPoint

Polynomial coefficients in increasing polynomial order.

See also

setCoefficients

Examples

>>> import openturns as ot
>>> P = ot.UniVariatePolynomial([1.0, 2.0, 3.0])
>>> print(P.getCoefficients())
[1,2,3]
getDegree(self)

Accessor to the polynomials’s degree.

Returns
degreeint

Polynomial’s degree.

Examples

>>> import openturns as ot
>>> P = ot.UniVariatePolynomial([1.0, 2.0, 3.0])
>>> print(P.getDegree())
2
getId(self)

Accessor to the object’s id.

Returns
idint

Internal unique identifier.

getName(self)

Accessor to the object’s name.

Returns
namestr

The name of the object.

getRecurrenceCoefficients(self)

Accessor to the recurrence coefficients.

Returns
recurrence_coefficientslist of Point

The list of recurrence coefficients that defined the orthogonal univariate polynomial from the very first univariate orthogonal polynomial P_0.

Notes

Any sequence of orthogonal polynomials has a recurrence formula relating any three consecutive polynomials as follows:

P_{i + 1} = (a_i x + b_i) P_i + c_i P_{i - 1}, \quad i > 1

Examples

>>> import openturns as ot
>>> polynomial = ot.OrthogonalUniVariatePolynomialFamily().build(2)
>>> print(polynomial.getRecurrenceCoefficients())
[[1,0,0],[0.707107,0,-0.707107]]
getRoots(self)

Compute the roots of the polynomial.

Returns
rootslist of complex values

Polynomial’s roots.

Examples

>>> import openturns as ot
>>> P = ot.UniVariatePolynomial([1.0, 2.0, 3.0])
>>> print(P.getRoots())
[(-0.333333,0.471405),(-0.333333,-0.471405)]
getShadowedId(self)

Accessor to the object’s shadowed id.

Returns
idint

Internal unique identifier.

getVisibility(self)

Accessor to the object’s visibility state.

Returns
visiblebool

Visibility flag.

gradient(self, x)

Compute the gradient at point x.

Returns
gradientfloat

The value of the function’s first-order derivative at point x.

Examples

>>> import openturns as ot
>>> P = ot.UniVariatePolynomial([1.0, 2.0, 3.0])
>>> print(P.gradient(1.0))
8.0
hasName(self)

Test if the object is named.

Returns
hasNamebool

True if the name is not empty.

hasVisibleName(self)

Test if the object has a distinguishable name.

Returns
hasVisibleNamebool

True if the name is not empty and not the default one.

hessian(self, x)

Compute the hessian at point x.

Parameters
xfloat

Input value.

Returns
hessianfloat

The value of the function’s second-order derivative at point x.

incrementDegree(self, degree=1)

Multiply the polynomial by x^k.

Parameters
degreeint, optional

The incremented degree k. Default uses k = 1.

Returns
incremented_degree_polynomialUniVariatePolynomial

Polynomial with incremented degree.

Examples

>>> import openturns as ot
>>> P = ot.UniVariatePolynomial([1.0, 2.0, 3.0])
>>> print(P.incrementDegree())
X + 2 * X^2 + 3 * X^3
>>> print(P.incrementDegree(2))
X^2 + 2 * X^3 + 3 * X^4
setCoefficients(self, coefficients)

Accessor to the polynomials’s coefficients.

Parameters
coefficientssequence of float

Polynomial coefficients in increasing polynomial order.

See also

getCoefficients

Examples

>>> import openturns as ot
>>> P = ot.UniVariatePolynomial([1.0, 2.0, 3.0])
>>> P.setCoefficients([4.0, 2.0, 1.0])
>>> print(P)
4 + 2 * X + X^2
setName(self, name)

Accessor to the object’s name.

Parameters
namestr

The name of the object.

setShadowedId(self, id)

Accessor to the object’s shadowed id.

Parameters
idint

Internal unique identifier.

setVisibility(self, visible)

Accessor to the object’s visibility state.

Parameters
visiblebool

Visibility flag.