state_infidelity
- Graph.state_infidelity(x, y, *, name=None)
Calculate the infidelity of two pure states.
- Parameters:
x (np.ndarray or Tensor) – A pure state, \(|\psi\rangle\), with shape
(..., D)
. Note that the last dimension must be the same as y, and the batch dimension, if any, must be broadcastable with y.y (np.ndarray or Tensor) – A pure state, \(|\phi\rangle\), with shape
(..., D)
. Note that the last dimension must be the same as x, and the batch dimension, if any, must be broadcastable with x.name (str or None, optional) – The name of the node.
- Returns:
The infidelity of two pure states, with shape
(...)
.- Return type:
See also
Graph.density_matrix_infidelity
Infidelity between two density matrices.
Graph.inner_product
Inner product of two vectors.
Graph.unitary_infidelity
Infidelity between a unitary and target operators.
Notes
The infidelity of two pure states \(|\psi\rangle\) and \(|\phi\rangle\) is defined as \(1 - \| \langle \psi | \phi \rangle \|^2\).
For more information about the state fidelity, see fidelity of quantum states on Wikipedia.
Examples
>>> graph.state_infidelity( ... np.array([0, 1]), np.array([[1, 0], [0, 1]]), name="infidelity" ... ) <Tensor: name="infidelity", operation_name="state_infidelity", shape=(2,)> >>> result = bo.execute_graph(graph=graph, output_node_names="infidelity") >>> result["output"]["infidelity"]["value"] array([1., 0.])