1 Introduction

As for applications of the quantum theory, implementation of a quantum algorithm to solve Deutsch’s problem [1,2,3] on a nuclear magnetic resonance quantum computer is reported firstly [4]. An implementation of the Deutsch-Jozsa algorithm on an ion-trap quantum computer is also reported [5]. There are several attempts to use single-photon two-qubit states for quantum computing. Oliveira et al. implements Deutsch’s algorithm with polarization and transverse spatial modes of the electromagnetic field as qubits [6]. Single-photon Bell states are prepared and measured [7]. Also the decoherence-free implementation of Deutsch’s algorithm is reported by using such a single-photon and by using two logical qubits [8]. More recently, a one-way based experimental implementation of Deutsch’s algorithm is reported [9].

In 1993, the Bernstein-Vazirani algorithm was reported [10, 11]. It can be considered as an extended Deutsch-Jozsa algorithm. In 1994, Simon’s algorithm was reported [12]. Implementation of a quantum algorithm to solve the Bernstein-Vazirani parity problem without entanglement on an ensemble quantum computer is reported [13]. Fiber-optics implementation of the Deutsch-Jozsa and Bernstein-Vazirani quantum algorithms with three qubits is discussed [14]. Quantum learning robust against noise is studied [15]. A quantum algorithm for approximating the influences of Boolean functions and its applications are recently reported [16]. Quantum computation with coherent spin states and the close Hadamard problem are also discussed [17]. Transport implementation of the Bernstein-Vazirani algorithm with ion qubits is more recently reported [18]. Quantum Gauss-Jordan elimination and simulation of accounting principles on quantum computers are discussed [19]. We mention that the dynamical analysis of Grover’s search algorithm in arbitrarily high-dimensional search spaces is studied [20]. A method of computing many functions simultaneously by using many parallel quantum systems is reported [21].

On the other hand, the earliest quantum algorithm, the Deutsch-Jozsa algorithm, is representative to show that quantum computation is faster than the classical counterpart with a magnitude that grows exponentially with the number of qubits. In 2015, it was discussed that the Deutsch-Jozsa algorithm can be used for quantum key distribution [22]. In 2017, it was discussed that secure quantum key distribution based on Deutsch’s algorithm using an entangled state [23]. Subsequently, a highly speedy secure quantum cryptography based on the Deutsch-Jozsa algorithm is proposed [24].

In this work we present a new method of more speedily calculating a multiplication by using the generalized Bernstein-Vazirani algorithm and many parallel quantum systems. Given the set of real values \(\{a_{1},a_{2},a_{3},\ldots ,a_{N}\}\) and a function \(g:\textbf {R}\rightarrow \{0,1\}\), we shall determine the following values \(\{g(a_{1}),g(a_{2}),g(a_{3}),\ldots , g(a_{N})\}\) simultaneously. The speed of determining the values is shown to outperform the classical case by a factor of \(N\). Next, we consider it as a number in binary representation; M1 = (g(a1),g(a2),g(a3),…,g(a N )). By using \(M\) parallel quantum systems, we have \(M\) numbers in binary representation, simultaneously. The speed of obtaining the \(M\) numbers is shown to outperform the classical case by a factor of \(M\). Finally, we calculate the product; \( M_{1}\times M_{2}\times \cdots \times M_{M}. \) The speed of obtaining the product is shown to outperform the classical case by a factor of N × M.

2 The Generalized Bernstein-Vazirani Algorithm

Let us suppose that we are given the following sequence of real values

$$\begin{array}{@{}rcl@{}} a_{1},a_{2},a_{3},\ldots, a_{N}. \end{array} $$
(1)

Let us now introduce the function

$$\begin{array}{@{}rcl@{}} g:\textbf{R}\rightarrow \{0,1\}. \end{array} $$
(2)

One step is of determining the following values

$$\begin{array}{@{}rcl@{}} g(a_{1}),g(a_{2}),g(a_{3}),\ldots, g(a_{N}). \end{array} $$
(3)

Recall that in the classical case, we need \(N\) queries, that is, \(N\) separate evaluations of the function (2). In our quantum algorithm, we shall require a single query. Suppose now that we introduce another function

$$\begin{array}{@{}rcl@{}} f:\{0,1\}^{N}\rightarrow \{0,1\} \end{array} $$
(4)

which is a function with a \(N\)-bit domain and a 1-bit range. We construct the following function

$$\begin{array}{@{}rcl@{}} f(x) &&=g(a)\cdot x=\sum_{i = 1}^{N} g(a_{i}) x_{i} (\text{mod2})\\ &&=g(a_{1}) x_{1}\oplus g(a_{2}) x_{2} \oplus g(a_{3}) x_{3} \oplus \cdots \oplus g(a_{N}) x_{N}\\ && x_{i}\in \{0,1\}, g(a_{i})\in \{0,1\}, a_{i} \in \textbf{R} \end{array} $$
(5)

where \(a_{i}\) is a real value. Here \(g(a)\) symbolizes

$$\begin{array}{@{}rcl@{}} g(a_{1})g(a_{2})\cdots g(a_{N}). \end{array} $$
(6)

Let us follow the quantum states through the algorithm. The input state is

$$\begin{array}{@{}rcl@{}} |\psi_{0}\rangle=|0\rangle^{\otimes N}|1\rangle \end{array} $$
(7)

where \(|0\rangle ^{\otimes N} =\overbrace {|0\rangle \otimes |0\rangle \otimes ...\otimes |0\rangle }^{N}\). After the componentwise Hadamard transforms on the state (7)

$$\begin{array}{@{}rcl@{}} \overbrace{H|0\rangle\otimes H|0\rangle\otimes ... \otimes H |0\rangle}^{N} \otimes H|1\rangle \end{array} $$
(8)

we have

$$\begin{array}{@{}rcl@{}} |\psi_{1}\rangle=\sum\limits_{x\in\{0,1\}^{N}}\frac{|x\rangle}{\sqrt{2^{N}}} \left[\frac{|0\rangle-|1\rangle}{\sqrt{2}}\right]. \end{array} $$
(9)

Next, the function \(f\) is evaluated using

$$\begin{array}{@{}rcl@{}} U_{f}:|x,y\rangle\rightarrow|x,y\oplus f(x)\rangle \end{array} $$
(10)

giving

$$\begin{array}{@{}rcl@{}} |\psi_{2}\rangle=\pm \sum\limits_{x}\frac{(-1)^{f(x)}|x\rangle}{\sqrt{2^{N}}} \left[\frac{|0\rangle-|1\rangle}{\sqrt{2}}\right]. \end{array} $$
(11)

Here \(y\oplus f(x)\) is the bitwise XOR (exclusive OR) of \(y\) and \(f(x)\). By checking the cases \(x = 0\) and \(x = 1\) separately, we see that for a single qubit

$$\begin{array}{@{}rcl@{}} H|x\rangle=\sum_{z} (-1)^{xz}|z\rangle/\sqrt{2}. \end{array} $$
(12)

Thus

$$\begin{array}{@{}rcl@{}} &&H^{\otimes N}|x_{1},\ldots,x_{N}\rangle\\ &&= \frac{\sum_{z_{1},\ldots,z_{N}} (-1)^{x_{1} z_{1}+\cdots+x_{N} z_{N}}|z_{1},\ldots,z_{N}\rangle}{\sqrt{2^{N}}}. \end{array} $$
(13)

This can be summarized more succinctly in the very useful equation

$$\begin{array}{@{}rcl@{}} H^{\otimes N}|x\rangle= \frac{\sum_{z}(-1)^{x\cdot z}|z\rangle}{\sqrt{2^{N}}} \end{array} $$
(14)

where \(x\cdot z\) is the bitwise inner product of \(x\) and \(z\), modulo 2. Using the (14) and (11), we can now evaluate HN|ψ2〉 = |ψ3

$$\begin{array}{@{}rcl@{}} |\psi_{3}\rangle=\pm\sum\limits_{z}\sum\limits_{x} \frac{(-1)^{x\cdot z+f(x)}|z\rangle}{2^{N}} \left[\frac{|0\rangle-|1\rangle}{\sqrt{2}}\right]. \end{array} $$
(15)

Thus

$$\begin{array}{@{}rcl@{}} |\psi_{3}\rangle=\pm\sum\limits_{z}\sum\limits_{x} \frac{(-1)^{x\cdot z+g(a)\cdot x}|z\rangle}{2^{N}} \left[\frac{|0\rangle-|1\rangle}{\sqrt{2}}\right]. \end{array} $$
(16)

Because we have

$$\begin{array}{@{}rcl@{}} \sum\limits_{x} (-1)^{x}= 0 \end{array} $$
(17)

we can see that

$$\begin{array}{@{}rcl@{}} \sum\limits_{x} (-1)^{x\cdot z+g(a)\cdot x}= 2^{N}\delta_{g(a),z}. \end{array} $$
(18)

Therefore, the sum is zero if \(z\neq g(a)\) and is \(2^{N}\) if \(z= g(a)\). Thus

$$\begin{array}{@{}rcl@{}} |\psi_{3}\rangle&=& \pm\sum\limits_{z}\sum\limits_{x} \frac{(-1)^{x\cdot z+g(a)\cdot x}|z\rangle}{2^{N}} \left[\frac{|0\rangle-|1\rangle}{\sqrt{2}}\right]\\ &&=\pm\sum\limits_{z} \frac{2^{N}\delta_{g(a),z}|z\rangle}{2^{N}} \left[\frac{|0\rangle-|1\rangle}{\sqrt{2}}\right]\\ &&=\pm|g(a)\rangle \left[\frac{|0\rangle-|1\rangle}{\sqrt{2}}\right]\\ &&=\pm|g(a_{1})g(a_{2})\cdots g(a_{N})\rangle \left[\frac{|0\rangle-|1\rangle}{\sqrt{2}}\right] \end{array} $$
(19)

from which

$$\begin{array}{@{}rcl@{}} |g(a_{1})g(a_{2})\cdots g(a_{N})\rangle. \end{array} $$
(20)

can be obtained. That is to say, if we measure \(|g(a_{1})g(a_{2})\cdots g(a_{N})\rangle \) then we can retrieve the following values

$$\begin{array}{@{}rcl@{}} g(a_{1}),g(a_{2}),g(a_{3}),\ldots, g(a_{N}) \end{array} $$
(21)

using a single query. All we have to do is of performing one quantum measurement.

The speed of determining \(N\) values improves by a factor of \(N\) as compared to the classical counterpart. Notice that we recover the Bernstein-Vazirani algorithm when \(g:a_{i}\rightarrow a_{i}\).

3 Calculating a Multiplication by using the Generalized Bernstein-Vazirani Algorithm

We present a new method of more speedy calculating a multiplication by using many parallel quantum systems. By using \(M\) parallel quantum systems, we can compute \(M\) functions \(g^{1},g^{2},...,g^{M}\) simultaneously.

Let us suppose that we are given the following another sequence of real values

$$\begin{array}{@{}rcl@{}} b_{1},b_{2},b_{3},\ldots, b_{N}. \end{array} $$
(22)

Let us now introduce the function

$$\begin{array}{@{}rcl@{}} g^{2}:\textbf{R}\rightarrow \{0,1\}. \end{array} $$
(23)

We can determine the following values by using the generalized Bernstein-Vazirani algorithm

$$\begin{array}{@{}rcl@{}} g^{2}(b_{1}),g^{2}(b_{2}),g^{2}(b_{3}),\ldots, g^{2}(b_{N}). \end{array} $$
(24)

By using \(M\) parallel quantum systems, we can retrieve the following values

$$\begin{array}{@{}rcl@{}} &&g^{1}(a_{1}),g^{1}(a_{2}),g^{1}(a_{3}),\ldots, g^{1}(a_{N})\\ &&g^{2}(b_{1}),g^{2}(b_{2}),g^{2}(b_{3}),\ldots, g^{2}(b_{N})\\ &&\cdots\\ &&g^{M}(c_{1}),g^{M}(c_{2}),g^{M}(c_{3}),\ldots, g^{M}(c_{N}). \end{array} $$
(25)

In the case, we measure the following quantum state

$$\begin{array}{@{}rcl@{}} |g^{1}(a_{1})g^{1}(a_{2})\cdots g^{1}(a_{N})\rangle\otimes\\ |g^{2}(b_{1})g^{2}(b_{2})\cdots g^{2}(b_{N})\rangle\otimes\\ \cdots \otimes|g^{M}(c_{1})g^{M}(c_{2})\cdots g^{M}(c_{N})\rangle. \end{array} $$
(26)

All we have to do is of performing one quantum measurement.

We consider them as numbers in binary representation

$$\begin{array}{@{}rcl@{}} &&M_{1}=(g^{1}(a_{1}),g^{1}(a_{2}),g^{1}(a_{3}),\ldots, g^{1}(a_{N}))\\ &&M_{2}=(g^{2}(b_{1}),g^{2}(b_{2}),g^{2}(b_{3}),\ldots, g^{2}(b_{N}))\\ &&\cdots\\ &&M_{M}=(g^{M}(c_{1}),g^{M}(c_{2}),g^{M}(c_{3}),\ldots, g^{M}(c_{N})). \end{array} $$
(27)

Therefore, by using \(M\) parallel quantum systems, we have \(M\) numbers in binary representation, simultaneously. The speed of obtaining the \(M\) numbers is shown to outperform the classical case by a factor of \(M\). Finally, we calculate the product; M1 × M2 ×⋯ × M M . The speed of obtaining the product is shown to outperform the classical case by a factor of \(N\times M\).

As an example, if \(N = 2\) and \(M = 3\), we may have

$$\begin{array}{@{}rcl@{}} (g^{1}(a_{1}),g^{1}(a_{2}))=(0,1)= 1 \end{array} $$
(28)
$$\begin{array}{@{}rcl@{}} (g^{2}(b_{1}),g^{2}(b_{2}))=(1,0)= 2 \end{array} $$
(29)
$$\begin{array}{@{}rcl@{}} (g^{3}(c_{1}),g^{3}(c_{2}))=(1,1)= 3 \end{array} $$
(30)

and we have

$$\begin{array}{@{}rcl@{}} &&(g^{1}(a_{1}),g^{1}(a_{2}))\times(g^{2}(b_{1}),g^{2}(b_{2}))\\ &&\times(g^{3}(c_{1}),g^{3}(c_{2}))= 1\times 2\times 3 = 6. \end{array} $$
(31)

An experimental evidence is very interesting and it is a further investigation.

4 Conclusions

In conclusion, we have presented a new method of more speedily calculating a multiplication by using the generalized Bernstein-Vazirani algorithm and many parallel quantum systems. Given the set of real values \(\{a_{1},a_{2},a_{3},\ldots ,a_{N}\}\) and a function \(g:\textbf {R}\rightarrow \{0,1\}\), we shall have determined the following values \(\{g(a_{1}),g(a_{2}),g(a_{3}),\ldots , g(a_{N})\}\) simultaneously. The speed of determining the values has been shown to outperform the classical case by a factor of \(N\). Next, we have considered it as a number in binary representation; M1 = (g(a1),g(a2),g(a3),…,g(a N )). By using \(M\) parallel quantum systems, we have had \(M\) numbers in binary representation, simultaneously. The speed of obtaining the \(M\) numbers has been shown to outperform the classical case by a factor of \(M\). Finally, we have calculated the product; \( M_{1}\times M_{2}\times \cdots \times M_{M}. \) The speed of obtaining the product has been shown to outperform the classical case by a factor of \(N\times M\).