2

I am trying to solve a system of linear equation using HHL algorithm in Qiskit. I have a problem with understanding the purpose of the following function.

state_fidelity()

To understand this I have followed their official documentation. But it is not clear to me yet.

They used this function like the following code.

from qiskit.quantum_info state_fidelity, process_fidelity

backend_sim = BasicAer.get_backend('statevector_simulator')
result = execute(circ, backend_sim).result()
state = result.get_statevector(circ)
print(state)

state_fidelity(basis_state('0110', 4), state)

The last line of this code generates this output.

1.0

Please, help me understand this.

Protik Nag
  • 511
  • 5
  • 20
  • 2
    it computes the quanum state fidelity. See e.g. [this question on quantumcomputing.SE](https://quantumcomputing.stackexchange.com/q/6733/55) – glS Aug 19 '19 at 08:47

1 Answers1

5

State fidelity is the measure of how close two quantum states are to eachother (wikipedia). So what the last line of the code is trying to do is to see how close the resulting state is to the state '0110'. A fidelity of 1.0 means the states are exactly the same, so the variable named state in the code is a state vector that corresponds to the state '0110'.

The exact definitions can be seen from the wikipedia page, or the code for the function.

met927
  • 311
  • 3
  • 9