New answers tagged

1

The first matrix is generally seen in books, as you consider computational basis in the order $|0\rangle$, $|1\rangle$, $|2\rangle$, $|3\rangle$ or in bitstrings $|00\rangle$, $|01\rangle$, $|10\rangle$, $|11\rangle$. So basically, you think as $| q_0, q_1\rangle$. This is called little-endian convention. But in Qiskit, they use the inverse, aka big-endian ...


2

In Qiskit, the bits are reversed order from most textbook definitions. That is to say the zeroth qubit is the farthest to the right in a bitstring or tensor product.


0

Each of those dicts are a QuantumError. You can learn more about the structure of a QuantumError here. That documentation is most likely what you were looking for. Each instruction is an operation being applied on the qubit(s) in qubits. Each value in probabilities corresponds to the respective operation in instructions.


0

This isn't supported in qiskit-terra yet with parametrized circuits. There is an open issue to add support for adding a parameter sweep with trig functions here: https://github.com/Qiskit/qiskit-terra/issues/3908


0

I think these gates only accept float or np.float as a parameter. Try casting to one of these types, for example phase = float(phase) and it should work.


0

$\lambda$ is also a rotation around the $z$ axis. However, there is an ordering issue. There's a sequence of $z$-rotation ($\lambda$), $y$-rotation ($\theta$), $z$-rotation ($\varphi$).


0

The code for finding the expectation value for the $Z \otimes Z \otimes ... \otimes Z = Z^{\otimes n}$ operator after having the counts from Qiskit's get_counts() function. Here expectation_zn is the $\langle \psi | Z^{\otimes n} | \psi \rangle$. expectation_zn = 0 for key in counts: sign = -1 if key.count('1') % 2 == 0: sign = 1 try: ...


4

Your states differ in global phase only, hence they are indistinguishable (or in other words they are equivalent). Therefore you do not need to apply gate $-I$. Note that the global phase is $\pi$ as $-1 = \mathrm{e}^{i\pi}$ However, in case the state is produced by controlled gate, global phase cannot be neglected. In that case you can implement ...


4

You want to implement $$ e^{i3\pi/4}e^{iX\pi/4}. $$ I would rewrite this as $$ e^{i3\pi/4}He^{iZ\pi/4}H. $$ This is the same as $$ -HS^\dagger H $$ in standard gate terminology. If you're only implementing the gate $e^{iAt}$, then you can neglect the global phase and just implement $HS^\dagger H$. Both of these gates are readily implemented in qiskit as sdg ...


4

There is actually a nice way to do this in Qiskit, since it has decompositions for single-qubit unitaries built in. The QuantumCircuit.squ method takes a unitary 2x2 matrix $U$ and a qubit and computes the decomposition $$ U = R_Z(\alpha) R_Y(\beta) R_Z(\gamma) $$ This is a common decomposition, you can find a proof here https://arxiv.org/pdf/quant-ph/...


2

I think this is enough $e^{iAt}= e^{i(1.5I)t} e^{i(0.5X)t}$ for constructing the circuit. From rx and u3: $$R_x(-t) = e^{i(0.5X)t} \qquad R_x(\theta) = u3(\theta, -\pi/2, \pi/2)$$ The $e^{i(1.5I)t}$ is a global phase gate that can be implemented via the following circuit for q[0] qubit. Here is the whole circuit for the $e^{iAt}$: # Rx part circuit.u3(-t, -...


2

Here the subscripts are of the form $1i$, where $i$ is the label of the subsystem (recall that you are using two qubits for this $\left|\psi\right>_0=\left|00\right>_{1}$). So any product of subscripts can be written as $\left|q_0\right>_{10}\left|q_1\right>_{11}=\left|q_0q_1\right>_{1}$ with $q_0,q_1\in\{0,1\}$ in this convention, which makes ...


3

1) In this step, you connect a teleported qubit with entangled qubits between Alice and Bob. This means, Bob now has an "access" to the teleported qubit. 2) Here you get some information about the teleported qubit and "partially colapse" Bob's qubit according to a state of the teleported qubit. 3) In this last step you bring information about the ...


0

You can find some information on another approach to portfolio optimization on quantum computer in this article: Quantum computational finance: quantum algorithm for portfolio optimization. The authors deal with minimizing risk descibed by function $w^T\Sigma w$, where $w$ is vector of asset weights and $\Sigma$ is a covariance matrix. The minimization is ...


2

The objective of the portfolio optimization problem is to trade off expected return ($\mu^T x$) with the risk taken ($x^T \Sigma $x). This could be achieved by introducing a constraint on the risk, e.g. $x^T \Sigma x \leq R$, for an acceptable risk level $R$ and then maximize the return under this constraint. However, this is not a QUBO, i.e., it cannot be ...


1

If that is all you want to do then SciPy is really the way to go. Indeed, qiskit just wraps that functionality when requesting a classical answer. In SciPy you can use scipy.linalg.eig. You can find examples of using this function in the documentation.


0

Error 3202 is a networking error when trying to get the requested page. In this case the results for your job.


1

I'm not sure what had caused the problem but I was able to solve it and most likely know what the problem was. Consider these two lines from my code above: job_exp = execute(qc, backend = backend, shots = 8192) exp_result = job_exp.result() Problem with the above lines is that we are not waiting for the actual quantum device to compute and send over the ...


1

EDIT: I believe this is solved in @IEIrodov's answer below. I'm not sure what's causing the issue, but based on similar issues on the qiskit slack channel, I don't think it's something you're doing. As a workaround, try running: exp_result = job_exp.result() exp_measurement_result = exp_result.get_counts() print(exp_measurement_result) plot_histogram(...


1

There is more information towards the end of the tutorial here but essentially how you do this is you run both circuits on the state_vector simulator and then you can use the function state_fidelity to work out the fidelity between the two states. The code to do this should look something like this from qiskit.quantum_info import state_fidelity # set up ...


1

What I have obtained by running 4 times the same code on "qasm_simulator": {'00': 4656, '01': 1613, '10': 185, '11': 1642} {'00': 4564, '01': 1735, '10': 179, '11': 1618} {'00': 4581, '01': 1646, '10': 184, '11': 1685} {'00': 4602, '01': 1684, '10': 181, '11': 1629} Here we don't have noise, but still, the results are different. So, one can expect some ...


1

As Martin Vesley has mentioned in his answer, there are some error correction techniques that require additional qubits and gates resources, and how we know the resources of nowadays QCs are limited, and that's why those techniques are not so useful today. But in 2017 new error correction techniques were proposed that don't require additional gates/qubits. ...


0

There is the parameter do_swaps when you construct the fourier transform circuit. do_swaps (bool): Boolean flag to specify if swaps should be included to align the qubit order of input and output. The output qubits would be in reversed order without the swaps.


2

The Qiskit backends (quantum devices or simulators) work only when you explicitly invoke them, usually with execute. The code in your snippet does not call qiskit, and runs on a traditional machine.


2

I will provide some general comments concerning noise in quantum computers. Noise in quantum systems is normal phenomena as these systems are probabilistic by nature. Under current state of development, quantum computers unfortunately does not allow to build complex deep circuits. You can of course use additional qubits to introduce error correction which ...


Top 50 recent answers are included