Tangent

class pyADiff.tangent.ADTypeT(value, derivative=0.0)

Tangent ADType.

This class overloads the basic numerical type of python. Instead of only an value it also stores a derivative.

This class implements the numerical operators (+, -, .. ) as expected for a numerical type, but additionaly accumulates the partial derivatives.

Basic mathematical functions (sin, cos, exp, …) are implemented as member functions and also accumulate the partial derivatives.

Parameters:
  • value (float or ADType) – The value of the overloaded numerical type.
  • deriative (float or ADType) – The derivative of the overloaded numerical type.

See also

pyADiff.math_functions
Implementation of basic mathematical functions for the ADType.
derivative

Derivative of the overloaded numerical type.

value

Value of the overloaded numerical type.

pyADiff.tangent.dfdx(f, x_v)

Tangent Differentiation Driver.

This computes the derivative of f with respect to x at the position x_v. The signature of f is assumed to be:

{scalar, list, array} = f({scalar, list, array})

This function converts the inputs x_v to their respective ADTypeT and successively sets their derivative to 1, runs the function f and collects the derivative values from the outputs y = f(x). If x is scalar only one forward run of f is necessary.

Parameters:
  • f (function_type) – The function to differentiate.
  • x_v (scalar, list, array) – The value where to evaluate the derivative.

See also

pyADiff.differentiation.derfor()
Wrapper for the comutation of the derivative via tangent mode.