1

From what I understood, quantum programming can solve some algorithm exponentially faster.

Thanks to the superposition, unlike a classic bit, which can be either 0 or 1, a qubit can be both 0 and 1.

Does that mean we can apply an algorithm for all bits possibly in one shot?

Example: We have 2 qubits, we apply a Hadamard gate on it to be in superposition. So all possibility will be [00, 01, 10, 11], so [0, 1, 2, 3]

Can we apply an algorithm for all of these solutions ?

For example, apply *10 to the value. So we would get [0, 10, 20, 30]. Then sum it all to get 60. But, getting that in one shot ?

I tried to implement something similar on Qiskit. Creating 2 qubits, applying Hadamard gate on them. But I fail to go further. If I measure my qubits, they will be one of the solutions, but not all of them.

Am I missing something ?

glS
  • 27,510
  • 7
  • 37
  • 125
Globy
  • 13
  • 2

1 Answers1

4

No, you're not missing something. Talking about being able to apply an algorithm for all possible inputs in a single shot is misleading. As you've found, you cannot read out all those answers; you can only get one answer, just as you would with classical.

The trick of quantum computing is asking the right question. This is typically some sort of comparison between the different values you've evaluated. You access it by performing some sort of interference between your multiple parallel evaluations, usually using something like a Hadamard transform or Fourier transform. Working out what that might be for a specific calculation you might want is the major challenge of algorithm design.

For the case that you're asking about, I believe there's a version of Grover's algorithm which you can use to calculate the average value of a function. It's far from single shot, but can provide a mild improvement in run time for large input sizes.

DaftWullie
  • 62,671
  • 4
  • 55
  • 140