dualnum.HyperDual64

class dualnum.HyperDual64

Hyper dual number using 64-bit-floats as fields.

A hyper dual number consists of a + b ε1 + c ε2 + d ε1ε2

Examples

>>> from dualnum import HyperDual64 as HD64
>>> x = HD64(1.0, 0.0, 0.0, 0.0) # constructor
>>> y = HD64.from_re(2.0)        # from real value
>>> x + y
3 + [0]ε1 + [0]ε2 + [0]ε1ε2

Compute partial derivatives of a function.

>>> from dualnum import HyperDual64 as HD64, derive2
>>> x, y = derive2(3.0, 4.0)
>>> # the above is equal to
>>> x = HD64(3.0, 1.0, 0.0, 0.0)
>>> y = HD64(4.0, 0.0, 1.0, 0.0)
>>> fxy = x**2 * y - y**3
>>> fxy.value
-28
>>> fxy.first_derivative
(24.0, -39.0) # df/dx, df/dy
fxy.second_derivative
6.0
__init__()

Methods

__init__()

arccos

Computes the arccosine of a (hyper) dual number.

arccosh

Computes the inverse hyperbolic cosine of a (hyper) dual number.

arcsin

Computes the arcsine of a (hyper) dual number.

arcsinh

Computes the inverse hyperbolic sine of a (hyper) dual number.

arctan

Computes the arctangent of a (hyper) dual number.

arctanh

Computes the inverse hyperbolic tangent of a (hyper) dual number.

cbrt

Cubic root.

cos

Hyperbolic cosine function.

cosh

Computes the hyperbolic cosine of a (hyper) dual number.

exp

Calculate the exponential of (hyper) dual number.

exp2

Calculate 2**x of (hyper) dual number x.

expm1

Calculate exp(x) - 1.

from_re

(Hyper) dual number from real part, setting all other parts to zero.

log

Calculate natural logarithm.

log10

Calculate logarithm with base 10.

log1p

Returns ln(1+n) (natural logarithm) more accurately than if the operations were performed separately.

log2

Calculate logarithm with base 2.

log_base

Calculate logarithm with given base.

mul_add

Fused multiply-add.

powd

Power using self (hyper) dual number as exponent.

powf

Power using 64-bin float as exponent.

powi

Power using 32-bit integer as exponent.

recip

Reciprocal value of self.

sin

Hyperbolic sine function.

sin_cos

Simultaneously computes the sine and cosine of the (hyper) dual number, x.

sinh

Computes the hyperbolic sine of a (hyper) dual number.

sph_j0

Computes the first spherical bessel function.

sph_j1

Computes the second spherical bessel function.

sph_j2

Computes the third spherical bessel function.

sqrt

Sqaure root.

tan

Computes the tangent of a (hyper) dual number (in radians).

tanh

Computes the hyperbolic tangent of a (hyper) dual number.

Attributes

first_derivative

First hyperdual part.

second_derivative

Third hyperdual part.

value

Real part.