# infidelity_stf

`Graph.infidelity_stf(sample_times, hamiltonian, target, noise_operators=None, *, name=None)`

Create the total infidelity of a given system with a sampleable Hamiltonian.

See `infidelity_pwc`

for information about the total infidelity
created by this function.

### Parameters

**sample_times**(*np.ndarray**(**1D**,**real**)*) – The times at which the Hamiltonian and noise operators (if present) should be sampled for the integration. Must start with 0, be ordered, and contain at least one element.**hamiltonian**(*Stf*) – The control Hamiltonian $H_{\mathrm c}(t)$. You can provide either a single Hamiltonian or a batch of them.**target**(*Target*) – The object describing the target gate $U_\mathrm{target}$ and (optionally) the filter function projector $P$. If you provide a batch of Hamiltonians, the function uses the same target for all the elements in the batch.**noise_operators**(*list**[**np.ndarray**or**Tensor**or**Stf**] or**None**,**optional*) – The perturbative noise operators $\{N_j(t)\}$. The operators in the list can either be single operators or batches of them. If any of the noise operators or the Hamiltonian are batches, the batch shapes must all be broadcastable. You can omit this list if there are no noises.**name**(*str**or**None**,**optional*) – The name of the node.

### Returns

The total infidelity (operational infidelity plus filter function values) of the given system, with respect to the given target gate, at the last time in sample_times. If you provide a batch of Hamiltonians or noise operators, the function returns a batch of infidelities containing one infidelity for each Hamiltonian and list of noise operators in the input batches.

### Return type

### SEE ALSO

`Graph.infidelity_pwc`

: Corresponding operation for Pwc Hamiltonians.

`Graph.target`

: Define the target operation of the time evolution.

`Graph.time_evolution_operators_stf`

: Unitary time evolution operators for quantum systems with Stf Hamiltonians.

## Examples

Calculate the infidelity of the Pauli $X$ gate for a noiseless qubit.

```
>>> sigma_x = np.array([[0, 1], [1, 0]])
>>> hamiltonian = graph.constant_stf_operator(np.pi * sigma_x / 2)
>>> target = graph.target(sigma_x)
>>> infidelity = graph.infidelity_stf(
... sample_times=np.linspace(0, 0.5, 100),
... hamiltonian=hamiltonian,
... target=target,
... name="infidelity",
... )
>>> result = bo.execute_graph(graph=graph, output_node_names="infidelity")
>>> result["output"]["infidelity"]["value"]
0.5000000000260991
```