Ejemplo n.º 1
0
def test_rx_bit_flip_1(simulator, p, angle):
    U = gates.X(target=0) + gates.CRx(control=0, target=1, angle="a")
    H = paulis.Z(1) * paulis.I(0)
    NM = BitFlip(p, 2)
    O = ExpectationValue(U=U, H=H)

    E = simulate(O, backend=simulator, samples=1000, variables={'a': angle}, noise=NM)
    print(E)
    print(p + numpy.cos(angle) - p * numpy.cos(angle))
    assert (numpy.isclose(E, p + numpy.cos(angle) - p * numpy.cos(angle), atol=1.e-1))
Ejemplo n.º 2
0
def test_rx_bit_flip_1(simulator, p, angle):

    qubit = 1
    U = gates.X(target=0) + gates.CRx(control=0, target=1, angle=Variable('a'))
    H = paulis.Z(1) * paulis.I(0)
    NM = BitFlip(p, 2)

    O = ExpectationValue(U=U, H=H)

    E = simulate(O,
                 backend=simulator,
                 samples=1,
                 variables={'a': angle},
                 noise=NM)
    print(E)
    print(p + numpy.cos(angle) - p * numpy.cos(angle))