quri_parts.core.utils.differentiation module#

quri_parts.core.utils.differentiation.OperatorGenerator#

Represents a function that generates Operator from given parameters, e.g. generates molecular Hamiltonian from coordinates of atoms.

alias of Callable[[Sequence[float]], Operator]

quri_parts.core.utils.differentiation.OperatorGradientCalculator#

Represents a function that calculates the gradients of an operator at given parameters.

alias of Callable[[Sequence[float], Callable[[Sequence[float]], Operator]], Sequence[Operator]]

quri_parts.core.utils.differentiation.OperatorHessianCalculator#

Represents a function that calculates the hessian of an operator at given parameters.

alias of Callable[[Sequence[float], Callable[[Sequence[float]], Operator]], Sequence[Sequence[Operator]]]

class quri_parts.core.utils.differentiation.DifferentiableObjectProtocol(*args, **kwargs)#

Bases: Protocol

abstract __add__(other: _T) _T#
abstract __sub__(other: _T) _T#
abstract __truediv__(other: int | float | complex) _T#
quri_parts.core.utils.differentiation.forward_difference_gradient_formula(f: Callable[[Sequence[float]], T], params: Sequence[float], step: float = 1e-05) Sequence[T]#

Returns the gradient of a passed function from params with two-point forward-difference formula.

quri_parts.core.utils.differentiation.backward_difference_gradient_formula(f: Callable[[Sequence[float]], T], params: Sequence[float], step: float = 1e-05) Sequence[T]#

Returns the gradient of a passed function from params with two-point backward-difference formula.

quri_parts.core.utils.differentiation.central_difference_gradient_formula(f: Callable[[Sequence[float]], T], params: Sequence[float], step: float = 1e-05) Sequence[T]#

Returns the gradient of a passed function from params with central- difference formula.

quri_parts.core.utils.differentiation.forward_difference_hessian_formula(f: Callable[[Sequence[float]], T], params: Sequence[float], step: float = 1e-05) Sequence[Sequence[T]]#

Returns the hessian of a passed function from params with forward- difference formula.

quri_parts.core.utils.differentiation.backward_difference_hessian_formula(f: Callable[[Sequence[float]], T], params: Sequence[float], step: float = 1e-05) Sequence[Sequence[T]]#

Returns the hessian of a passed function from params with backward- difference formula.

quri_parts.core.utils.differentiation.central_difference_hessian_formula(f: Callable[[Sequence[float]], T], params: Sequence[float], step: float = 1e-05) Sequence[Sequence[T]]#

Returns the hessian of a passed function from params with central- difference formula.

quri_parts.core.utils.differentiation.gradient(f: Callable[[Sequence[float]], T], params: Sequence[float], step: float = 1e-05) Sequence[T]#

Returns the gradient of a passed function from params with central- difference formula.

quri_parts.core.utils.differentiation.hessian(f: Callable[[Sequence[float]], T], params: Sequence[float], step: float = 1e-05) Sequence[Sequence[T]]#

Returns the hessian of a passed function from params with central- difference formula.

quri_parts.core.utils.differentiation.numerical_operator_gradient(params: ~typing.Sequence[float], operator_generator: ~typing.Callable[[~typing.Sequence[float]], ~quri_parts.core.operator.operator.Operator], difference_formula: ~typing.Callable[[~typing.Callable[[~typing.Sequence[float]], ~quri_parts.core.operator.operator.Operator], ~typing.Sequence[float], float], ~typing.Sequence[~quri_parts.core.operator.operator.Operator]] = <function central_difference_gradient_formula>, step: float = 1e-05, atol: float = 1e-08) Sequence[Operator]#

Function that returns the numerical gradient of an Operator with respect to the operator parameters.

Parameters:
  • params – Parameters at which the gradient is calculated.

  • operator_generatorOperatorGenerator.

  • difference_formula – Method to calculate gradients.

  • step – Step size for difference_formula.

  • atol – Absolute tolerance. Terms whose coefficients are smaller than atol will be ignored.

quri_parts.core.utils.differentiation.numerical_operator_hessian(params: ~typing.Sequence[float], operator_generator: ~typing.Callable[[~typing.Sequence[float]], ~quri_parts.core.operator.operator.Operator], difference_formula: ~typing.Callable[[~typing.Callable[[~typing.Sequence[float]], ~quri_parts.core.operator.operator.Operator], ~typing.Sequence[float], float], ~typing.Sequence[~typing.Sequence[~quri_parts.core.operator.operator.Operator]]] = <function central_difference_hessian_formula>, step: float = 1e-05, atol: float = 1e-08) Sequence[Sequence[Operator]]#

Function that returns the numerical hessian of an Operator with respect to the operator parameters.

Parameters:
  • params – Parameters at which the hessian is calculated.

  • operator_generatorOperatorGenerator.

  • difference_formula – Method to calculate hessian.

  • step – Step size for difference_formula.

  • atol – Absolute tolerance. Terms whose coefficients are smaller than atol will be ignored.