# ms_infidelity

ions.ms_infidelity(phases, displacements, target_phases, mean_phonon_numbers=None, *, name=None)

Calculate the final operational infidelity of the Mølmer–Sørensen gate.

This function calculates the operational infidelity with respect to the target phases that you specify in the target_phases array. It can use the tensors returned from ms_phases and ms_displacements to calculate the infidelity tensor.

### Parameters

• phases (np.ndarray ( real ) or Tensor ( real )) – The acquired phases between ion pairs, $\{\Phi_{ln}\}$(N, N) without time samples or (T, N, N) with them, where T is the number of samples and N is the number of ions. For each sample, the phases array must be a strictly lower triangular matrix.
• displacements (np.ndarray ( complex ) or Tensor ( complex )) – The motional displacements in phase-space, $\{\eta_{jkl} \alpha_{jkl}\}$(3, N, N_d) without time samples or (T, 3, N, N_d) with them, where the dimensions indicate, respectively, (time,) axis, collective mode, and ion. Here, N_d is the number of addressed ions.
• target_phases (np.ndarray ( real )) – The target total relative phases between ion pairs, $\{\Psi_{ln}\}$(N, N).
• mean_phonon_numbers (np.ndarray or None , optional) – The mean phonon occupation of motional modes, $\{\bar{n}{jk}\}$. Its shape must be (3, N), where the dimensions indicate, respectively, axis and collective mode. If provided, must contain positive real numbers. If not provided, $\bar{n}{jk} = 0$, meaning no occupation of each mode.
• name (str or None , optional) – The name of the node.

### Returns

A scalar or 1D tensor of infidelities with shape (T,).

### Return type

Tensor(real)

Graph.ions.ms_dephasing_robust_cost : Cost for robust optimization of a Mølmer–Sørensen gate.

Graph.ions.ms_displacements : Displacements for each mode/ion combination.

Graph.ions.ms_phases : Relative phases for all pairs of ions.

## Notes

The infidelity is calculated according to 1

$1 - \mathcal{F}_\mathrm{av} = 1 - \left| \left( \prod_{n=1}^N \prod_{l=n+1}^N \cos ( \Phi_{ln} - \Psi_{ln}) \right) \left( 1 - \sum_{j=1}^3 \sum_{k=1}^N \sum_{l=1}^N \left[ |\eta_{jkl} \alpha_{jkl}|^2 \left(\bar{n}_{jk}+\frac{1}{2} \right) \right] \right) \right|^2 ,$

which assumes that the displacements $\alpha_{jkl}$

See the notes of Graph.ions.ms_phases or Graph.ions.ms_phases_multitone for the relevant definitions.

## Examples

Refer to the How to optimize error-robust Mølmer–Sørensen gates for trapped ions user guide to find how to use this and related nodes.