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.


  • 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 Hc(t)H_{\mathrm c}(t)
  • target (Target) – The object describing the target gate UtargetU_\mathrm{target} and (optionally) the filter function projector PP
  • noise_operators (list [ np.ndarray or Tensor or Stf ] or None , optional) – The perturbative noise operators {Nj(t)}\{N_j(t)\}
  • name (str or None , optional) – The name of the node.


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



Graph.infidelity_pwc : Corresponding operation for Pwc Hamiltonians. : Define the target operation of the time evolution.

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


Calculate the infidelity of the Pauli XX

>>> sigma_x = np.array([[0, 1], [1, 0]])
>>> hamiltonian = graph.constant_stf_operator(np.pi * sigma_x / 2)
>>> target =
>>> 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"]

Was this useful?