mtflib API Reference
This document provides a detailed API reference for the mtflib package.
mtflib Package
The mtflib package provides tools for working with multivariate Taylor series expansions.
mtf
An alias for the MultivariateTaylorFunction class. It is the main entry point for most users.
mtflib.taylor_function Module
This module contains the core MultivariateTaylorFunction class.
MultivariateTaylorFunction Class
The fundamental class for representing a function as a DA vector of its Taylor coefficients.
Class Attributes
Attribute |
Type |
Description |
|---|---|---|
|
|
Global setting for the maximum order of Taylor expansions. |
|
|
Global setting for the maximum number of variables. |
|
|
Global tolerance for floating-point comparisons. |
|
|
If |
Instance Attributes
Attribute |
Type |
Description |
|---|---|---|
|
|
A 2D numpy array of shape |
|
|
A 1D numpy array of shape |
|
|
The number of variables in the Taylor series. |
|
|
An optional name for the function. |
Methods
Method |
Description |
Arguments |
Returns |
|---|---|---|---|
|
Initializes global settings for the mtflib library. |
|
|
|
Calculates max coefficient count for given order/dimension. |
|
|
|
Returns the precomputed Taylor coefficients for elementary functions. |
|
|
|
Returns initialization status of MTF globals. |
|
|
|
Sets the global maximum order for Taylor series. |
|
|
|
Returns the global maximum order for Taylor series. |
|
|
|
Returns the global maximum dimension (number of variables). |
|
|
|
Sets the global error tolerance (etol) for |
|
|
|
Returns the global error tolerance (etol). |
|
|
|
Sets the global flag to enable or disable automatic coefficient cleanup. |
|
|
|
Creates a MultivariateTaylorFunction representing a constant value. |
|
|
|
Creates a MultivariateTaylorFunction representing a single variable. |
|
|
|
Merges a list of MTFs into a single pandas DataFrame for comparison. |
|
|
|
Converts input to MultivariateTaylorFunction or ComplexMultivariateTaylorFunction. |
|
|
|
Serializes the MTF object to a JSON string. |
|
|
|
Creates an MTF object from a JSON string. |
|
|
|
Evaluates the Taylor function at a single point. |
|
|
|
Evaluates the Taylor function at multiple points in a vectorized manner. |
|
|
|
Substitutes a variable with a numerical value. |
|
|
|
Truncates the Taylor series to a specified maximum order. |
|
|
|
Truncates the MTF in place to a specified order. |
|
|
|
Substitutes a variable in the MTF with a numerical value IN-PLACE. |
|
|
|
Checks if an MTF is effectively zero. |
|
|
|
Composes this function with other Taylor functions. |
|
|
|
Returns a pandas DataFrame representation of the Taylor function. |
|
|
|
Extracts the coefficient for a given multi-index exponent. |
|
|
|
Sets the coefficient for a given multi-index exponent. |
|
|
|
Finds the maximum absolute value among all coefficients. |
|
|
|
Finds the minimum absolute value among non-negligible coefficients. |
|
|
|
Converts the MTF to a SymPy expression for pretty printing. |
|
|
|
Returns a copy of the MTF. |
|
|
|
Retrieves the constant (zeroth-order) term of the Taylor series. |
|
|
|
Returns a new MTF representing the polynomial part of the function. |
|
|
|
Converts a NumPy array of numbers into a NumPy array of mtf objects. |
|
|
|
Converts a NumPy array of mtf objects into a NumPy array of their constant values. |
|
|
|
Computes the partial derivative of an MTF. |
|
|
|
Performs definite or indefinite integration of an MTF. |
|
|
mtflib.complex_taylor_function Module
This module provides the ComplexMultivariateTaylorFunction for handling complex coefficients.
ComplexMultivariateTaylorFunction Class
A subclass of MultivariateTaylorFunction for representing Taylor series with complex coefficients. It inherits all methods from MultivariateTaylorFunction and provides the following additional methods.
Methods
Method |
Description |
Arguments |
Returns |
|---|---|---|---|
|
Creates a CMTF representing a constant complex value. |
|
|
|
Creates a CMTF representing a single variable. |
|
|
|
Computes the complex conjugate of the Taylor function. |
|
|
|
Extracts the real part of the Taylor function. |
|
|
|
Extracts the imaginary part of the Taylor function. |
|
|
mtflib.taylor_map Module
This module provides the TaylorMap class for representing vector-valued functions.
TaylorMap Class
Represents a function from R^n to R^m using Taylor series components.
Instance Attributes
Attribute |
Type |
Description |
|---|---|---|
|
|
A NumPy array of |
|
|
The dimension of the output space (m), which is the number of components. |
Methods
Method |
Description |
Arguments |
Returns |
|---|---|---|---|
|
Composes this map with another, calculating |
|
|
|
Retrieves a component function from the map. |
|
|
|
Gets the coefficient of a specific term in a component function. |
|
|
|
Sets the coefficient of a specific term in a component function. |
|
|
|
Adds a new component function to the map. |
|
|
|
Removes a component function from the map by its index. |
|
|
|
Truncates all component functions to a specified order. |
|
|
|
Calculates the trace of the first-order part of the map. |
|
|
|
Returns a new TaylorMap with coefficients scaled for sensitivity analysis. |
|
|
|
Performs partial or full substitution. |
|
|
|
Computes the inverse of the TaylorMap using fixed-point iteration. |
|
|
Elementary Functions
These functions are available as static methods on the MultivariateTaylorFunction class (e.g., mtf.sin(...)).
Function |
Description |
Arguments |
Returns |
|---|---|---|---|
|
Computes the Taylor expansion of |
|
|
|
Computes the Taylor expansion of |
|
|
|
Computes the Taylor expansion of |
|
|
|
Computes the Taylor expansion of |
|
|
|
Computes the Taylor expansion of a Gaussian function, |
|
|
|
Computes the Taylor expansion of |
|
|
|
Computes the Taylor expansion of |
|
|
|
Computes the Taylor expansion of |
|
|
|
Computes the Taylor expansion of |
|
|
|
Computes the Taylor expansion of |
|
|
|
Computes the Taylor expansion of |
|
|
|
Computes the Taylor expansion of |
|
|
|
Computes the Taylor expansion of |
|
|
|
Computes the Taylor expansion of |
|
|
|
Computes the Taylor expansion of |
|
|
Utility Functions
Function |
Description |
Arguments |
Returns |
|---|---|---|---|
|
Loads or precomputes Taylor coefficients for elementary functions. |
|
|