 # How 14.6 and 85.4 probabilities are calculated?

Can you please, please explain to me how these 2 probabilities are calculated?
I’m trying to go through the whole book, I’ve understand everything up to this point.
And here I’m completely puzzled. I’ve tried so many ways of calculating these numbers. ;-(
If you could provide me with the arithmetical expression that shows how to get these numbers.

The probabilities are measured in the Hermitian observable’s eigenstates.

Before the probabilities are extracted on a simulator, the simulator applies the “diagonalizing gates”

``````op = qml.Hermitian(H, wires=0)
op.diagonalizing_gates()
``````

to rotate into the eigenbasis.

The diagonalizing gates / eigenvectors are determined by calling `np.linalg.eigh` on the matrix `H`.

That code example would be equivalent to:

``````dev = qml.device("default.qubit", wires=2)

H = 1 / np.sqrt(2) * np.array([[1, 1], [1, -1]])
op = qml.Hermitian(H, wires=0)

@qml.qnode(dev)
def circuit():
qml.PauliZ(wires=0)
qml.PauliX(wires=1)
op.diagonalizing_gates()
return qml.probs(wires=0)

``````

Huge thanks for your willingness to help me with this.
But I’m still trying to understand how these probabilities of 2 states are being calculated purely from mathematical perspective.
Can you please provide me with a simple arithmetical expressions?
like:
0 prob: 1/ sqrt(2) / 2 * blabla * matrix(…) …
1 prob: 1 - above.

this is what I’m trying to find out

First it might be helpful to print out the diagonalizing gates for this particular hermitian.

If you do the following

``````H = 1 / np.sqrt(2) * np.array([[1, 1], [1, -1]])
op = qml.Hermitian(H, wires=0)
op.diagonalizing_gates()
``````

you will see that a qubit unitary is printed out:

``````[QubitUnitary(array([[ 0.38268343, -0.92387953],
[-0.92387953, -0.38268343]]), wires=)]
``````

So if we look at the full circuit we have:

• A PauliZ gate which acts on the ‘0’ state, so it does nothing.
• A PauliX gate which acts on wire ‘1’, but since we’re not measuring that wire then we can ignore it.
• A Unitary which diagonalizes the circuit according to Hermitian H
• A measurement of the probabilities on wire ‘0’

So finally all we’re doing is measuring the probabilities of a qubit when you apply this qubit unitary to it.

``````[QubitUnitary(array([[ 0.38268343, -0.92387953],
[-0.92387953, -0.38268343]]), wires=)]
``````

I hope this is more clear! Please let me know if it’s still confusing and I’ll try to rephrase.