# What is fidelity in quantum computing?

As I studied quantum computing, I saw term 'Fidelity' in many papers that related to quantum algorithm. So, I really wonder about following two things.

What is the real meaning of 'Fidelity' (As I searched, it is reliablity of thing)?

• Here you can find a very good explanation. Aug 9, 2022 at 7:36

Fidelity can refer to either state fidelity or gate/unitary fidelity depending on the use case. In both cases, it is a number that answers the question "how similar is A to B?" on a scale from 0 (as different as possible) to 1 (the same thing). As user1271772 wrote, you can define the state fidelity between two states $$\rho$$ and $$\sigma$$ as

$$F = \Big|\text{tr}\big(\sqrt{\sqrt{\rho}\sigma \sqrt{\rho}}\big)\Big|^2,$$

which simplifies to

$$F_{pure} = \big|\langle \psi_{\rho} | \psi_{\sigma} \rangle \big|^2$$

for pure states (wikipedia).

You can define the gate fidelity between two $$d \times d$$ unitaries $$U$$ and $$V$$ as

$$F = \frac{1}{d^2} \Big|\text{tr}( U^\dagger V )\Big|^2.$$

This second fidelity is used to measure the quality of a quantum logic gate, and is used in e.g. quantum optimal control as part of the objective function. You can think of the gate fidelity as a sort of average of the state fidelities over the output states of $$U$$ and $$V$$ acting on the standard basis, although it also takes into account the phases of these output states to make sure they are consistent with each other.

As a measure of reliability, you can compute the fidelity between an expected logical operation (such as an $$X$$ gate) and the actual operation that was performed. For example, if you want to perform a logical $$X$$ operation

$$X = \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix}$$

$$X' = \begin{pmatrix} 0.141 & 0.99 \\ 0.99 & -0.141 \end{pmatrix},$$
your $$X$$ gate fidelity would be $$\frac{1}{d^2}|\text{tr}(X'^\dagger X)|^2 = 0.9801$$.
Repeating what you'll find in the second paragraph of that article, a quantum state $$\rho$$ has the following fidelity with respect to another quantum state $$\sigma$$:
$$F = \left(\textrm{tr}\sqrt{\sqrt{\rho} \sigma \sqrt{\rho}}\right)^2.\tag{1}$$