Skip to content
This repository has been archived by the owner on Dec 7, 2021. It is now read-only.

Z.exp_i().to_matrix() disagrees with documented behavior #1218

Closed
jlapeyre opened this issue Aug 26, 2020 · 0 comments · Fixed by #1224
Closed

Z.exp_i().to_matrix() disagrees with documented behavior #1218

jlapeyre opened this issue Aug 26, 2020 · 0 comments · Fixed by #1224
Assignees

Comments

@jlapeyre
Copy link
Contributor

jlapeyre commented Aug 26, 2020

Z.exp_i().to_matrix() and X.exp_i().to_matrix() give incorrect results.

What is the current behavior?

In [1]: from qiskit.aqua.operators import Z                                                                                                        

In [2]: Z.exp_i().to_matrix()                                                                                                                      
Out[2]: 
array([[1.        +0.j        , 0.        +0.j        ],
       [0.        +0.j        , 0.54030231+0.84147098j]])

What is the expected behavior?

The docs string for exp_i is "Return a CircuitOp equivalent to e^-iH for this operator H", so I expect this matrix:

In [1]: from qiskit.aqua.operators import Z                                                                                                        

In [2]: import scipy                                                                                                                               

In [3]: scipy.linalg.expm(-1j * Z.to_matrix())                                                                                                     
Out[3]: 
array([[0.54030231-0.84147098j, 0.        +0.j        ],
       [0.        +0.j        , 0.54030231+0.84147098j]])

It looks like there are two problems

  • Qiskit Aqua version:
    c8193ac Aug 13
  • Python version:
    3.8.3
  • Operating system:
    linux
@jlapeyre jlapeyre self-assigned this Aug 28, 2020
jlapeyre added a commit to jlapeyre/qiskit-aqua that referenced this issue Aug 30, 2020
The unitary simulator does not account for the global phase in a
circuit. qiskit.quantum_info.Operator does account for global phase
when converting (when possible) a circuit to a unitary matrix.

Closes qiskit-community#1218
jlapeyre added a commit to jlapeyre/qiskit-aqua that referenced this issue Aug 30, 2020
The unitary simulator does not account for the global phase in a
circuit. qiskit.quantum_info.Operator does account for global phase
when converting (when possible) a circuit to a unitary matrix.

Closes qiskit-community#1218
jlapeyre added a commit to jlapeyre/qiskit-aqua that referenced this issue Aug 31, 2020
The unitary simulator does not account for the global phase in a
circuit. qiskit.quantum_info.Operator does account for global phase
when converting (when possible) a circuit to a unitary matrix.

Closes qiskit-community#1218
jlapeyre added a commit to jlapeyre/qiskit-aqua that referenced this issue Aug 31, 2020
The unitary simulator does not account for the global phase in a
circuit. qiskit.quantum_info.Operator does account for global phase
when converting (when possible) a circuit to a unitary matrix.

Closes qiskit-community#1218
Cryoris pushed a commit to Cryoris/qiskit-aqua that referenced this issue Sep 3, 2020
The unitary simulator does not account for the global phase in a
circuit. qiskit.quantum_info.Operator does account for global phase
when converting (when possible) a circuit to a unitary matrix.

Closes qiskit-community#1218
jlapeyre added a commit to jlapeyre/qiskit-aqua that referenced this issue Sep 4, 2020
The unitary simulator does not account for the global phase in a
circuit. qiskit.quantum_info.Operator does account for global phase
when converting (when possible) a circuit to a unitary matrix.

Closes qiskit-community#1218
jlapeyre added a commit that referenced this issue Sep 12, 2020
…ary matrix (#1224)

* Fix factor of 2 error in converting exp_i to rotation gates

* Make CircuitOp use Operator rather than unitary simulator to get matrix

The unitary simulator does not account for the global phase in a
circuit. qiskit.quantum_info.Operator does account for global phase
when converting (when possible) a circuit to a unitary matrix.

Closes #1218

* Remove note on reversing order of qubits

Using Operator(QuantumCircuit) gives the same qubit ordering
that the previous unitary-simulator-based code did. I removed
the comment entirely because the behavior depends only on
Operator(QuantumCircuit), which is not obscure.
jlapeyre added a commit to jlapeyre/qiskit-aqua that referenced this issue Sep 15, 2020
…ary matrix (qiskit-community#1224)

* Fix factor of 2 error in converting exp_i to rotation gates

* Make CircuitOp use Operator rather than unitary simulator to get matrix

The unitary simulator does not account for the global phase in a
circuit. qiskit.quantum_info.Operator does account for global phase
when converting (when possible) a circuit to a unitary matrix.

Closes qiskit-community#1218

* Remove note on reversing order of qubits

Using Operator(QuantumCircuit) gives the same qubit ordering
that the previous unitary-simulator-based code did. I removed
the comment entirely because the behavior depends only on
Operator(QuantumCircuit), which is not obscure.
pbark pushed a commit to pbark/qiskit-aqua that referenced this issue Sep 16, 2020
…ary matrix (qiskit-community#1224)

* Fix factor of 2 error in converting exp_i to rotation gates

* Make CircuitOp use Operator rather than unitary simulator to get matrix

The unitary simulator does not account for the global phase in a
circuit. qiskit.quantum_info.Operator does account for global phase
when converting (when possible) a circuit to a unitary matrix.

Closes qiskit-community#1218

* Remove note on reversing order of qubits

Using Operator(QuantumCircuit) gives the same qubit ordering
that the previous unitary-simulator-based code did. I removed
the comment entirely because the behavior depends only on
Operator(QuantumCircuit), which is not obscure.
mtreinish pushed a commit to mtreinish/qiskit-core that referenced this issue Nov 20, 2020
…ary matrix (qiskit-community/qiskit-aqua#1224)

* Fix factor of 2 error in converting exp_i to rotation gates

* Make CircuitOp use Operator rather than unitary simulator to get matrix

The unitary simulator does not account for the global phase in a
circuit. qiskit.quantum_info.Operator does account for global phase
when converting (when possible) a circuit to a unitary matrix.

Closes qiskit-community/qiskit-aqua#1218

* Remove note on reversing order of qubits

Using Operator(QuantumCircuit) gives the same qubit ordering
that the previous unitary-simulator-based code did. I removed
the comment entirely because the behavior depends only on
Operator(QuantumCircuit), which is not obscure.
manoelmarques pushed a commit to manoelmarques/qiskit-terra that referenced this issue Dec 2, 2020
…ary matrix (qiskit-community/qiskit-aqua#1224)

* Fix factor of 2 error in converting exp_i to rotation gates

* Make CircuitOp use Operator rather than unitary simulator to get matrix

The unitary simulator does not account for the global phase in a
circuit. qiskit.quantum_info.Operator does account for global phase
when converting (when possible) a circuit to a unitary matrix.

Closes qiskit-community/qiskit-aqua#1218

* Remove note on reversing order of qubits

Using Operator(QuantumCircuit) gives the same qubit ordering
that the previous unitary-simulator-based code did. I removed
the comment entirely because the behavior depends only on
Operator(QuantumCircuit), which is not obscure.
manoelmarques pushed a commit to manoelmarques/qiskit-terra that referenced this issue Dec 7, 2020
…ary matrix (qiskit-community/qiskit-aqua#1224)

* Fix factor of 2 error in converting exp_i to rotation gates

* Make CircuitOp use Operator rather than unitary simulator to get matrix

The unitary simulator does not account for the global phase in a
circuit. qiskit.quantum_info.Operator does account for global phase
when converting (when possible) a circuit to a unitary matrix.

Closes qiskit-community/qiskit-aqua#1218

* Remove note on reversing order of qubits

Using Operator(QuantumCircuit) gives the same qubit ordering
that the previous unitary-simulator-based code did. I removed
the comment entirely because the behavior depends only on
Operator(QuantumCircuit), which is not obscure.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant