 # What is "np.eps" for in error channel simulation?

In the simulation of Pauli error or Depolarizing error (here is an example for BitFlip Channel in Pennylane), if the parameter p represents the probability of PauliX-error, its corresponding Kraus Operator is not \sqrt{p}X, but \sqrt{p+\varepsilon}X, like this:

K0 = np.sqrt(1 - p + np.eps) * np.eye(2)
K1 = np.sqrt(p + np.eps) * np.array([[0, 1], [1, 0]]


My questions are:

1. Why use this \varepsilon for the simulation of the quantum error channel ? (I mean that \varepsilon may lead to an imperfect error channel. )
2. And what is the specific setting for \varepsilon? (This question is equally important for me )

Love you guys Hi @qhc!

This is added for numerical reasons to prevent errors down the line in case you specify a probability p being 1 or 0.

eps comes from your math module so if you write the following code you can see how much it is:

import pennylane.math as np
print(np.eps)
print(np.sqrt(0+np.eps)* np.eye(2))


Let us know if you have any further questions! 