gemseo.core.mdo_functions.taylor_polynomials module#
Functions computing first- and second-order Taylor polynomials from a function.
- compute_linear_approximation(function, x_vect, name='', f_type=FunctionType.NONE, input_names=())[source]#
Compute a first-order Taylor polynomial of a function.
\(\newcommand{\xref}{\hat{x}}\newcommand{\dim}{d}\) The first-order Taylor polynomial of a (possibly vector-valued) function \(f\) at a point \(\xref\) is defined as
\[\newcommand{\partialder}{\frac{\partial f}{\partial x_i}(\xref)} f(x) \approx f(\xref) + \sum_{i = 1}^{\dim} \partialder \, (x_i - \xref_i).\]- Parameters:
function (MDOFunction) -- The function to be linearized.
x_vect (NumberArray) -- The input vector at which to build the Taylor polynomial.
name (str) --
The name of the linear approximation function. If
None, create a name from the name of the function.By default it is set to "".
f_type (MDOFunction.FunctionType) --
The type of the linear approximation function. If
None, the function will have no type.By default it is set to "".
input_names (Sequence[str]) --
The names of the inputs of the linear approximation function, or a name base. If empty, use the names of the inputs of the function.
By default it is set to ().
- Returns:
The first-order Taylor polynomial of the function at the input vector.
- Raises:
AttributeError -- If the function does not have a Jacobian function.
- Return type:
- compute_quadratic_approximation(function, x_vect, hessian_approx, input_names=())[source]#
Build a quadratic approximation of a function at a given point.
The function must be scalar-valued.
\(\newcommand{\xref}{\hat{x}}\newcommand{\dim}{d}\newcommand{ \hessapprox}{\hat{H}}\) For a given approximation \(\hessapprox\) of the Hessian matrix of a function \(f\) at a point \(\xref\), the quadratic approximation of \(f\) is defined as
\[\newcommand{\partialder}{\frac{\partial f}{\partial x_i}(\xref)} f(x) \approx f(\xref) + \sum_{i = 1}^{\dim} \partialder \, (x_i - \xref_i) + \frac{1}{2} \sum_{i = 1}^{\dim} \sum_{j = 1}^{\dim} \hessapprox_{ij} (x_i - \xref_i) (x_j - \xref_j).\]- Parameters:
function (MDOFunction) -- The function to be approximated.
x_vect (NumberArray) -- The input vector at which to build the quadratic approximation.
hessian_approx (NumberArray) -- The approximation of the Hessian matrix at this input vector.
input_names (Sequence[str]) --
The names of the inputs of the quadratic approximation function, or a base name. If empty, use the ones of the current function.
By default it is set to ().
- Returns:
The second-order Taylor polynomial of the function at the given point.
- Return type: