underworld.function.math module
This module provides math functions. All functions take functions (or convertibles) as arguments. These functions effectively wrap to the c++ standard template library equivalent. For example, the ‘exp’ class generates a function with uses std::exp(double).
All functions operate on and return ‘double’ type data (or ‘float’ from python).
Classes
Computes the absolute value of its argument function. |
|
Computes the principal value of the arc cosine of x, expressed in radians. |
|
Computes the inverse hyperbolic cosine of its argument function. |
|
Computes the principal value of the arc sine of x, expressed in radians. |
|
Computes the inverse hyperbolic sine of its argument function. |
|
Computes the principal value of the arc tangent of x, expressed in radians. |
|
Computes the inverse hyperbolic tangent of its argument function. |
|
Computes the cosine of its argument function (measured in radians). |
|
Computes the hyperbolic cosine of its argument function. |
|
Dot product function. |
|
Computes the error function of its argument function. |
|
Computes the complementary error function of its argument function. |
|
Computes the exponent of its argument function. |
|
Computes the natural logarithm of its argument function. |
|
Computes the base 10 logarithm of its argument function. |
|
Computes the base 2 logarithm of its argument function. |
|
Power function. |
|
Computes the sine of its argument function (measured in radians). |
|
Computes the hyperbolic sine of its argument function. |
|
Computes the square root of its argument function. |
|
Computes the tangent of its argument function (measured in radians). |
|
Computes the hyperbolic tangent of its argument function. |
- class underworld.function.math.abs(fn=None, *args, **kwargs)[source]
Bases:
FunctionComputes the absolute value of its argument function.
- Parameters:
fn (underworld.function.Function (or convertible).) – Optionally provided for function composition.
Example
>>> import math as sysmath >>> import numpy as np >>> func = abs() >>> np.allclose( func.evaluate(-0.1234), sysmath.fabs(0.1234) ) True
- class underworld.function.math.acos(fn=None, *args, **kwargs)[source]
Bases:
FunctionComputes the principal value of the arc cosine of x, expressed in radians.
- Parameters:
fn (underworld.function.Function (or convertible).) – Optionally provided for function composition.
Example
>>> import math as sysmath >>> import numpy as np >>> func = acos() >>> np.allclose( func.evaluate(0.1234), sysmath.acos(0.1234) ) True
- class underworld.function.math.acosh(fn=None, *args, **kwargs)[source]
Bases:
FunctionComputes the inverse hyperbolic cosine of its argument function.
- Parameters:
fn (underworld.function.Function (or convertible).) – Optionally provided for function composition.
Example
>>> import math as sysmath >>> import numpy as np >>> func = acosh() >>> np.allclose( func.evaluate(5.1234), sysmath.acosh(5.1234) ) True
- class underworld.function.math.asin(fn=None, *args, **kwargs)[source]
Bases:
FunctionComputes the principal value of the arc sine of x, expressed in radians.
- Parameters:
fn (underworld.function.Function (or convertible).) – Optionally provided for function composition.
Example
>>> import math as sysmath >>> import numpy as np >>> func = asin() >>> np.allclose( func.evaluate(0.1234), sysmath.asin(0.1234) ) True
- class underworld.function.math.asinh(fn=None, *args, **kwargs)[source]
Bases:
FunctionComputes the inverse hyperbolic sine of its argument function.
- Parameters:
fn (underworld.function.Function (or convertible).) – Optionally provided for function composition.
Example
>>> import math as sysmath >>> import numpy as np >>> func = asinh() >>> np.allclose( func.evaluate(5.1234), sysmath.asinh(5.1234) ) True
- class underworld.function.math.atan(fn=None, *args, **kwargs)[source]
Bases:
FunctionComputes the principal value of the arc tangent of x, expressed in radians.
- Parameters:
fn (underworld.function.Function (or convertible).) – Optionally provided for function composition.
Example
>>> import math as sysmath >>> import numpy as np >>> func = atan() >>> np.allclose( func.evaluate(0.1234), sysmath.atan(0.1234) ) True
- class underworld.function.math.atanh(fn=None, *args, **kwargs)[source]
Bases:
FunctionComputes the inverse hyperbolic tangent of its argument function.
- Parameters:
fn (underworld.function.Function (or convertible).) – Optionally provided for function composition.
Example
>>> import math as sysmath >>> import numpy as np >>> func = atanh() >>> np.allclose( func.evaluate(0.1234), sysmath.atanh(0.1234) ) True
- class underworld.function.math.cos(fn=None, *args, **kwargs)[source]
Bases:
FunctionComputes the cosine of its argument function (measured in radians).
- Parameters:
fn (underworld.function.Function (or convertible).) – Optionally provided for function composition.
Example
>>> import math as sysmath >>> import numpy as np >>> func = cos() >>> np.allclose( func.evaluate(0.1234), sysmath.cos(0.1234) ) True
- class underworld.function.math.cosh(fn=None, *args, **kwargs)[source]
Bases:
FunctionComputes the hyperbolic cosine of its argument function.
- Parameters:
fn (underworld.function.Function (or convertible).) – Optionally provided for function composition.
Example
>>> import math as sysmath >>> import numpy as np >>> func = cosh() >>> np.allclose( func.evaluate(0.1234), sysmath.cosh(0.1234) ) True
- class underworld.function.math.dot(fn1, fn2, **kwargs)[source]
Bases:
FunctionDot product function. Returns fn1.fn2. Argument functions must return values of identical size.
- Parameters:
fn1 (underworld.function.Function (or convertible).) – Argument function 1.
fn2 (underworld.function.Function (or convertible).) – Argument function 2.
Example
>>> import math as sysmath >>> import numpy as np >>> input1 = (2.,3.,4.) >>> input2 = (5.,6.,7.) >>> func = dot( input1, input2 )
The function is constant, so evaluate anywhere:
>>> np.allclose( func.evaluate(0.), np.dot(input1,input2) ) True
- class underworld.function.math.erf(fn=None, *args, **kwargs)[source]
Bases:
FunctionComputes the error function of its argument function.
- Parameters:
fn (underworld.function.Function (or convertible).) – Optionally provided for function composition.
Example
>>> import math as sysmath >>> import numpy as np >>> func = erf() >>> np.allclose( func.evaluate(0.1234), sysmath.erf(0.1234) ) True
- class underworld.function.math.erfc(fn=None, *args, **kwargs)[source]
Bases:
FunctionComputes the complementary error function of its argument function.
- Parameters:
fn (underworld.function.Function (or convertible).) – Optionally provided for function composition.
Example
>>> import math as sysmath >>> import numpy as np >>> func = erfc() >>> np.allclose( func.evaluate(0.1234), sysmath.erfc(0.1234) ) True
- class underworld.function.math.exp(fn=None, *args, **kwargs)[source]
Bases:
FunctionComputes the exponent of its argument function.
- Parameters:
fn (underworld.function.Function (or convertible).) – Optionally provided for function composition.
Example
>>> import math as sysmath >>> import numpy as np >>> func = exp() >>> np.allclose( func.evaluate(0.1234), sysmath.exp(0.1234) ) True
- class underworld.function.math.log(fn=None, *args, **kwargs)[source]
Bases:
FunctionComputes the natural logarithm of its argument function.
- Parameters:
fn (underworld.function.Function (or convertible).) – Optionally provided for function composition.
Example
>>> import math as sysmath >>> import numpy as np >>> func = log() >>> np.allclose( func.evaluate(0.1234), sysmath.log(0.1234) ) True
- class underworld.function.math.log10(fn=None, *args, **kwargs)[source]
Bases:
FunctionComputes the base 10 logarithm of its argument function.
- Parameters:
fn (underworld.function.Function (or convertible).) – Optionally provided for function composition.
Example
>>> import math as sysmath >>> import numpy as np >>> func = log10() >>> np.allclose( func.evaluate(0.1234), sysmath.log10(0.1234) ) True
- class underworld.function.math.log2(fn=None, *args, **kwargs)[source]
Bases:
FunctionComputes the base 2 logarithm of its argument function.
- Parameters:
fn (underworld.function.Function (or convertible).) – Optionally provided for function composition.
Example
>>> import math as sysmath >>> import numpy as np >>> func = log2() >>> np.allclose( func.evaluate(0.1234), sysmath.log(0.1234,2) ) True
- class underworld.function.math.pow(fn1, fn2, **kwargs)[source]
Bases:
FunctionPower function. Raises fn1 to the power of fn2.
- Parameters:
fn1 (underworld.function.Function (or convertible).) – The base function.
fn2 (underworld.function.Function (or convertible).) – The power function.
Example
>>> import math as sysmath >>> import numpy as np >>> func = pow(_uw.function.input(),3.) >>> np.allclose( func.evaluate(2.), sysmath.pow(2.,3.) ) True
- class underworld.function.math.sin(fn=None, *args, **kwargs)[source]
Bases:
FunctionComputes the sine of its argument function (measured in radians).
- Parameters:
fn (underworld.function.Function (or convertible).) – Optionally provided for function composition.
Example
>>> import math as sysmath >>> import numpy as np >>> func = sin() >>> np.allclose( func.evaluate(0.1234), sysmath.sin(0.1234) ) True
- class underworld.function.math.sinh(fn=None, *args, **kwargs)[source]
Bases:
FunctionComputes the hyperbolic sine of its argument function.
- Parameters:
fn (underworld.function.Function (or convertible).) – Optionally provided for function composition.
Example
>>> import math as sysmath >>> import numpy as np >>> func = sinh() >>> np.allclose( func.evaluate(0.1234), sysmath.sinh(0.1234) ) True
- class underworld.function.math.sqrt(fn=None, *args, **kwargs)[source]
Bases:
FunctionComputes the square root of its argument function.
- Parameters:
fn (underworld.function.Function (or convertible).) – Optionally provided for function composition.
Example
>>> import math as sysmath >>> import numpy as np >>> func = sqrt() >>> np.allclose( func.evaluate(0.1234), sysmath.sqrt(0.1234) ) True
- class underworld.function.math.tan(fn=None, *args, **kwargs)[source]
Bases:
FunctionComputes the tangent of its argument function (measured in radians).
- Parameters:
fn (underworld.function.Function (or convertible).) – Optionally provided for function composition.
Example
>>> import math as sysmath >>> import numpy as np >>> func = tan() >>> np.allclose( func.evaluate(0.1234), sysmath.tan(0.1234) ) True
- class underworld.function.math.tanh(fn=None, *args, **kwargs)[source]
Bases:
FunctionComputes the hyperbolic tangent of its argument function.
- Parameters:
fn (underworld.function.Function (or convertible).) – Optionally provided for function composition.
Example
>>> import math as sysmath >>> import numpy as np >>> func = tanh() >>> np.allclose( func.evaluate(0.1234), sysmath.tanh(0.1234) ) True