# state_infidelity

Source: https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Graph/state_infidelity

```python
Graph.state_infidelity(x, y, *, name=None)
```

Calculate the infidelity of two pure states.

### Parameters
* **x** (*np.ndarray* *or* [*Tensor*](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Tensor.md#boulderopal.graph.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*](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Tensor.md#boulderopal.graph.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
[Tensor](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Tensor.md#boulderopal.graph.Tensor)

### SEE ALSO
[`Graph.density_matrix_infidelity`](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Graph/density_matrix_infidelity.md#boulderopal.graph.Graph.density_matrix_infidelity)
: Infidelity between two density matrices.

[`Graph.inner_product`](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Graph/inner_product.md#boulderopal.graph.Graph.inner_product)
: Inner product of two vectors.

[`Graph.unitary_infidelity`](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Graph/unitary_infidelity.md#boulderopal.graph.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](https://en.wikipedia.org/wiki/Fidelity_of_quantum_states)
on Wikipedia.

## Examples

```pycon
>>> 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.])
```
