Mathematical functions and numerical integration¶
The escape.core.math module provides methods for common mathematical functions and numerical integration techniques.
- escape.core.math.abs(obj)¶
Returns a functor or parameter which computes an absolute value.
- Parameters:
- obj: float, int, parameter_obj, functor_obj, cplx_functor_obj or variable
Input argument.
- Returns:
object of type functor_obj or parameter_obj depending on the type of obj
- escape.core.math.arg(obj)¶
Returns a functor which computes the arg value.
- Parameters:
- obj: functor_obj, cplx_functor_obj or variable
Input argument.
- Returns:
object of type functor_obj
- escape.core.math.conj(obj)¶
Returns a functor which computes conjugate of obj.
- Parameters:
- obj: functor_obj, cplx_functor_obj or variable
Input argument.
- Returns:
object of type cplx_functor_obj
- escape.core.math.cos(obj)¶
Returns a functor or parameter which computes a cosine value.
- Parameters:
- obj: float, int, parameter_obj, functor_obj, cplx_functor_obj or variable
Input argument.
- Returns:
object of type functor_obj, cplx_functor_obj or parameter_obj depending on the type of obj
- escape.core.math.cosh(obj)¶
Returns a functor or parameter which computes a hyperbolic cosine value.
- Parameters:
- obj: float, int, parameter_obj, functor_obj, cplx_functor_obj or variable
Input argument.
- Returns:
object of type functor_obj, cplx_functor_obj or parameter_obj depending on the type of obj
- escape.core.math.cyl_bessel_j(a, z)¶
Method to create the cylindrical Bessel functor of the first kind or functional parameter.
- Parameters:
- a: parameter_obj or float value
the order of the function
- z: object - functor, variable or parameter
z - the argument of the function
- Returns:
instance of functor_obj or parameter_obj depending on ‘z’ type
- escape.core.math.erf(obj)¶
Returns a functor or parameter which computes an error function value.
- Parameters:
- obj: float, int, parameter_obj, functor_obj or variable
Input argument.
- Returns:
object of type functor_obj or parameter_obj depending on the type of obj
- escape.core.math.exp(obj)¶
Returns a functor or parameter which computes an exponential function value.
- Parameters:
- obj: float, int, parameter_obj, functor_obj, cplx_functor_obj or variable
Input argument.
- Returns:
object of type functor_obj, cplx_functor_obj or parameter_obj depending on the type of obj
- escape.core.math.gamma_p(a, z, bool normalized=True)¶
Method to create lower limit gamma functor or functional parameter.
- Parameters:
- a: parameter_obj or float value
parameter a
- z: object - functor, variable or parameter
z - value, can be functor or parameter
- normalized - boolean
if True the values returned by the generated instance will always lay between [0, 1]
- Returns:
instance of functor_obj or parameter_obj depending on ‘z’ type
- escape.core.math.gamma_q(a, z, bool normalized=True)¶
Method to create upper limit gamma functor or functional parameter.
- Parameters:
- a: parameter_obj or float value
parameter a
- z: object - functor, variable or parameter
z - value, can be functor or parameter
- normalized - boolean
if True the values returned by the generated instance will always lay between [0, 1]
- Returns:
instance of functor_obj or parameter_obj depending on ‘z’ type
- escape.core.math.imag(obj)¶
Returns a functor which computes imaginary part of obj.
- Parameters:
- obj: functor_obj, cplx_functor_obj or variable
Input argument.
- Returns:
object of type functor_obj
- escape.core.math.integral(fun, x, a, b, int numpoints=7, epsabs=None, epsrel=None, maxiter=None)¶
Returns functor which computes a result of definite integral of type
\(I=\int_a^b f(x)dx\),
where \(x\) - is a variable or parameter,
The integration limits ‘a’ and ‘b’ can be parameters, functors or numeric values.
- Parameters:
- fun: functor_obj or parameter_obj with variable or parameter ‘x’
integrated functor or parameter
- x: variable or independent parameter
integration variable
- a: parameter_obj, functor_obj, variable_obj or double value
lower integration limit
- b: parameter_obj, functor_obj, variable_obj or double value
upper integration limit
- numpoints - integer
number of points of Gauss-Kronrod quadratures method. Supported values are [7, 15, 21, 31, 51, 61]
- epsabs: float value or None
absolute tolerance of integration result, used only for adaptive integration. If set to None, Default value of 1e-5 is used
- epsrel: float value or None
relative tolerance of integration result, used only for adaptive integration. If set to None, Default value of 0 is used’
- maxiter: positive integer value or None
maximum number of iterations of adaptive integration. If set to None or zero adaptive integration is not used.
- Returns:
object of type functor_obj (or parameter_obj if initial functor has only one variable)
- escape.core.math.linterp(x, xp, yp)¶
One-dimensional linear interpolation functor.
New in version 0.9.1.
Returns the functor which is the one-dimensional piecewise linear interpolant to a function with given discrete data points (xp, yp), evaluated at values returned by x.
- Parameters:
- x: functor_obj or variable_obj
interpolated functor
- xp: numpy array
sorted array of abscissas
- yp: numpy array
array of interpolated function values
- Returns:
object of type functor_obj
- escape.core.math.log(obj)¶
Returns a functor or parameter which computes a natural logarithm value.
- Parameters:
- obj: float, int, parameter_obj, functor_obj or variable
Input argument.
- Returns:
object of type functor_obj or parameter_obj depending on the type of obj
- escape.core.math.log10(obj)¶
Returns a functor or parameter which computes a decimal logarithm value.
- Parameters:
- obj: float, int, parameter_obj, functor_obj or variable
Input argument.
- Returns:
object of type functor_obj or parameter_obj depending on the type of obj
- escape.core.math.max(obj1, obj2)¶
Returns a functor or parameter which computes the largest value for two arguments.
- Parameters:
- obj1: float, int, parameter_obj, functor_obj or variable
Input argument 1.
- obj2: float, int, parameter_obj, functor_obj or variable
Input argument 2.
- Returns:
object of type functor_obj or parameter_obj depending on types of obj1 and obj2
- escape.core.math.min(obj1, obj2)¶
Returns a functor or parameter which computes the smallest value for two arguments.
- Parameters:
- obj1: float, int, parameter_obj, functor_obj or variable
Input argument 1.
- obj2: float, int, parameter_obj, functor_obj or variable
Input argument 2.
- Returns:
object of type functor_obj or parameter_obj depending on types of obj1 and obj2
- escape.core.math.norm(obj)¶
Returns a functor which computes the norm value.
- Parameters:
- obj: functor_obj, cplx_functor_obj or variable
Input argument.
- Returns:
object of type functor_obj
- escape.core.math.pow(obj1, obj2)¶
Returns a functor or parameter which computes the value of base obj1 raised to the power obj2.
- Parameters:
- obj1: float, int, parameter_obj, functor_obj or variable
Input argument 1.
- obj2: float, int, parameter_obj, functor_obj or variable
Input argument 2.
- Returns:
object of type functor_obj or parameter_obj depending on types of obj1 and obj2
- escape.core.math.real(obj)¶
Returns a functor which computes real part of obj.
- Parameters:
- obj: functor_obj, cplx_functor_obj or variable
Input argument.
- Returns:
object of type functor_obj
- escape.core.math.sin(obj)¶
Returns a functor or parameter which computes a sine value.
- Parameters:
- obj: float, int, parameter_obj, functor_obj, cplx_functor_obj or variable
Input argument.
- Returns:
object of type functor_obj, cplx_functor_obj or parameter_obj depending on the type of obj
- escape.core.math.sinh(obj)¶
Returns a functor or parameter which computes a hyperbolic sine value.
- Parameters:
- obj: float, int, parameter_obj, functor_obj, cplx_functor_obj or variable
Input argument.
- Returns:
object of type functor_obj, cplx_functor_obj or parameter_obj depending on the type of obj
- escape.core.math.sqrt(obj)¶
Returns a functor or parameter which computes a square root value.
- Parameters:
- obj: float, int, parameter_obj, functor_obj, cplx_functor_obj or variable
Input argument.
- Returns:
object of type functor_obj, cplx_functor_obj or parameter_obj depending on the type of obj
- escape.core.math.tan(obj)¶
Returns a functor or parameter which computes a tangent value.
- Parameters:
- obj: float, int, parameter_obj, functor_obj, cplx_functor_obj or variable
Input argument.
- Returns:
object of type functor_obj, cplx_functor_obj or parameter_obj depending on the type of obj
- escape.core.math.tanh(obj)¶
Returns a functor or parameter which computes a hyperbolic tangent value.
- Parameters:
- obj: float, int, parameter_obj, functor_obj, cplx_functor_obj or variable
Input argument.
- Returns:
object of type functor_obj, cplx_functor_obj or parameter_obj depending on the type of obj
- escape.core.math.tgamma(z)¶
Method to create a true gamma functor or functional parameter.
- Parameters:
z: object - functor, variable or parameter
- Returns:
instance of functor_obj or parameter_obj depending on ‘obj’ type