Ejemplo n.º 1
0
def test_rz_phase_flip_1(simulator, p, angle):
    U = gates.X(target=0) + gates.H(1) + gates.CRz(control=0, target=1, angle=Variable('a')) + gates.H(1)
    H = paulis.Z(1) * paulis.I(0)
    O = ExpectationValue(U, H)
    NM = PhaseFlip(p, 2)
    E = simulate(O, backend=simulator, variables={'a': angle}, samples=1000, noise=NM)
    print(E)
    assert (numpy.isclose(E, ((1.0 - 2 * p) ** 2) * numpy.cos(angle), atol=1.e-1))
Ejemplo n.º 2
0
def test_rz_phase_flip_1(simulator, p, angle):

    U = gates.X(target=0) + gates.H(1) + gates.CRz(
        control=0, target=1, angle=Variable('a')) + gates.H(1)
    H = paulis.Z(1) * paulis.I(0)
    O = ExpectationValue(U, H)
    NM = PhaseFlip(p, 2)
    E = simulate(O,
                 backend=simulator,
                 variables={'a': angle},
                 samples=1,
                 noise=NM)
    print(E)