static OperationNamespace.infidelity_pwc(hamiltonian, target_operator, noise_operators=None, *, name=None)

Creates the total infidelity of the given piecewise-constant system.

Use this function to compute the sum of the operational infidelity (which measures how effectively the system achieves a target gate) and filter function values (which measure how robust the system evolution is to various perturbative noise processes). This total infidelity value provides a cost that measures how effectively and robustly a set of controls achieves a target operation.

Note that the total infidelity returned by this function is at least zero, but might be larger than one (for example if the system is highly sensitive to one of the noise processes).

  • hamiltonian (TensorPwc) – The control Hamiltonian \(H_{\mathrm c}(t)\). You can provide either a single Hamiltonian or a batch of them.

  • target_operator (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[TensorPwc], optional) – The perturbative noise operators \(\{N_j(t)\}\). You can omit this list if there are no noises. If you provide a batch of Hamiltonians rather than a single Hamiltonian, don’t provide noise operators.

  • name (str, 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. If you provide a batch of Hamiltonians, the function returns a batch of infidelities contaning one infidelity for each Hamiltonian of the input batch.

Return type



This function currently doesn’t support noise operators when you provide a batch of Hamiltonians (rather than a single Hamiltonian).

The Hessian matrix cannot currently be calculated for a graph which includes an infidelity_pwc node if the hamiltonian has degenerate eigenvalues at any segment.

See also


Corresponding function for sampleable controls.


The total system Hamiltonian is

\[H_{\mathrm c}(t) + \sum_j \beta_j(t) N_j(t),\]

where \(\{\beta_j(t)\}\) are small, dimensionless, stochastic variables.

The total infidelity, as represented by this node, is the sum of the operational infidelity \(\mathcal{I}\) and the filter functions \(\{F_j(0)\}\) of each noise operator evaluated at zero frequency.

The operational infidelity is

\[\mathcal{I} = 1-\left| \frac{\mathrm{Tr} \left(U_\mathrm{target}^\dagger U(t)\right)} {\mathrm{Tr} \left(U_\mathrm{target}^\dagger U_\mathrm{target}\right)} \right|^2,\]

where \(U(t)\) is the unitary time evolution operator due to \(H_{\mathrm c}(t)\).

The filter function for the noise operator \(N_j(t)\) is a measure of robustness, defined at frequency \(f\) as

\[F_j(f) = \frac{1}{\mathrm{Tr}(P)} \mathrm{Tr} \left( P \mathcal{F} \left\{ \tilde N_j^\prime(t) \right\} \left[ \mathcal{F} \left\{ \tilde N^\prime (t) \right\} \right]^\dagger P \right),\]

where \(\mathcal{F}\) is the Fourier transform, \(\tilde N_j(t) \equiv U_c^\dagger(t) N_j(t) U_c(t)\) is the toggling-frame noise operator, and \(\tilde N_j^\prime(t)\equiv \tilde N_j(t)- \frac{\mathrm{Tr}(P\tilde N_j(t)P)}{\mathrm{Tr}(P)} \mathbb{I}\) differs from \(\tilde N_j(t)\) only by a multiple of the identity but is trace-free on the subspace of interest. The filter function value at zero frequency quantifies the sensitivity of the controls to quasi-static noise applied via the corresponding noise operator.