Abstract
Quantum arithmetic in the computational basis constitutes the fundamental component of many circuit-based quantum algorithms. There exist a lot of studies about reversible implementations of algebraic functions, while research on the higher-level transcendental functions is scant. We propose to evaluate the transcendental functions using a novel methodology, which is called quantum function-value binary expansion (qFBE) method. This method transforms the evaluation of transcendental functions to the computation of algebraic functions, and output the binary solution digit-by-digit in a simple recursive way. The quantum circuits for solving the logarithmic, exponential, trigonometric and inverse trigonometric functions are presented based on the qFBE method. The efficiency of the circuits is demonstrated on a quantum virtual computing system installed on the Sunway TaihuLight supercomputer. The qFBE method provides a unified and programmed solution for the evaluation of transcendental functions, and it can be the essential building block for many quantum algorithms.








Similar content being viewed by others
Explore related subjects
Discover the latest articles, news and stories from top researchers in related subjects.References
Feynman, R.P.: Simulating physics with computers. Int. J. Theor. Phys. 21, 467 (1982)
Arute, F., Arya, K., Babbush, R., et al.: Quantum supremacy using a programmable superconducting processor. Nature 574, 505 (2019)
Montanaro, A.: Quantum algorithms: an overview. npj. Quantum inf. 2, 15023 (2016)
Shor, P. W.: Algorithms for quantum computation: Discrete logarithms and factoring. In: Proceedings 35th Annual Symposium on Foundations of Computer Science, pp. 124–134 (1994)
Grover, L., Rudolph, T.: Creating superpositions that correspond to efficiently integrable probability distributions. arXiv:quant-ph/0208112 (2002)
Harrow, A.W., Hassidim, A., Lloyd, S.: Quantum algorithm for linear systems of equations. Phys. Rev. Lett. 103, 150502 (2009)
Mitarai, K., Kitagawa, M., Fujii, K.: Quantum analog-digital conversion. Phys. Rev. A 99, 012301 (2019)
Vedral, V., Barenco, A., Ekert, A.: Quantum networks for elementary arithmetic operations. Phys. Rev. A 54, 147 (1996)
Draper, T.G., Kutin, S.A., Rains, E.M., Svore, K.M.: A logarithmic-depth quantum carry-lookahead adder. Quantum Inf. Comput. 6, 351 (2006)
Takahashi, Y., Tani, S., Kunihiro, N.: Quantum addition circuits and unbounded fan-out. Quantum Inf. Comput. 10, 872 (2010)
Gidney, C.: Halving the cost of quantum addition. Quantum (2018). https://doi.org/10.22331/q-2018-06-18-74
Alvarez-Sanchez, J.J., Alvarez-Bravo, J.V., Nieto, L.M.: A quantum architecture for multiplying signed integers. J. Phys: Conf. Ser. 128, 012013 (2008)
Maynard, C.M., Pius, E.: A quantum multiply-accumulator. Quantum Inf. Process. 13, 1127 (2014)
Munoz-Coreas, E., Thapliyal, H.: T-count optimized design of quantum integer multiplication. arXiv: 1706.05113 (2017)
Rines, R., Chuang, I.: High Performance Quantum Modular Multipliers. arXiv: 1801.01081 (2018)
Cao, Y., Papageorgiou, A., Petras, I., Traub, J., Kais, S.: Quantum algorithm and circuit design solving the poisson equation. New J. Phys. 15, 013021 (2013)
Thapliyal, H., Munoz-Coreas, E., Varun, T.S.S., Humble, T.S.: Quantum circuit designs of integer division optimizing T-count and T-depth. IEEE TETC (2019)
Munoz-Coreas, E., Thapliyal, H.: T-count and qubit optimized quantum circuit design of the non-restoring square root algorithm. ACM JETC 14, 36 (2018)
Bhaskar, M.K., Hadfield, S., Papageorgiou, A., Petras, I.: Quantum algorithms and circuits for scientific computing. Quantum Inf. Comput. 16, 197–236 (2016)
Häner, T., Roetteler, M., Svore, K.M.: Optimizing quantum circuits for arithmetic. arXiv: 1805.12445 (2018)
Wang, S., Wang, Z., Li, W., Fan, L., Wei, Z., Gu, Y.: Quantum fast poisson solver: the algorithm and modular circuit design. Quantum Inf. Process. 19, 170 (2020)
Borwein, J.M., Girgensohn, R.: Addition theorems and binary expansions. Can. J. Math. 47, 262 (1995)
Volder, J.E.: The CORDIC trigonometric computing technique. IRE TEC 3, 330 (1959)
Meher, P.K., Valls, J., Juang, T., Sridharan, K., Maharatna, K.: 50 years of CORDIC: algorithms, architectures, and applications. IEEE TCSI 56, 1893 (2009)
Weisstein, E.W.: Plouffe’s Constants, http://mathworld.wolfram.com/PlouffesConstants.html
Sutikno, T.: An efficient implementation of the non-restoring square root algorithm in gate level. IJCTE 3, 46 (2011)
Freiman, C.V.: Statistical analysis of certain binary division algorithms. Proc. IRE 49, 91 (1961)
Kues, M., Reimer, C., Roztocki, P., et al.: On-chip generation of high-dimensional entangled quantum states and their coherent control. Nature 546, 622 (2017)
Lanyon, B., Barbieri, M., Almeida, M., et al.: Simplifying quantum logic using higher-dimensional Hilbert spaces. Nat. Phys. 5, 134 (2009)
User manual of QRunes, https://github.com/OriginQ/QPanda/tree/master/QRunes
Chen, Z., Zhou, Q., Xue, C., Yang, X., Guo, G.C., Guo, G.P.: 64-qubit quantum circuit simulation. Sci. Bull. 63, 964 (2018)
Acknowledgements
We are very grateful to the National Supercomputing Center in Wuxi for the great computing resource. We would also like to thank the technical team from the Origin Quantum Computing Technology co., LTD in Hefei for the professional services on quantum virtual computation. The present work is financially supported by the National Natural Science Foundation of China (Grant No. 61575180, 61701464, 11475160) and the Pilot National Laboratory for Marine Science and Technology (Qingdao).
Author information
Authors and Affiliations
Corresponding authors
Additional information
Publisher's Note
Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
Electronic supplementary material
Below is the link to the electronic supplementary material.
Appendices
Appendix 1
In this appendix, we perform error analysis of the solution evaluated by the qFBE method. The goal is to determine how many digits of the binary solution are exact, and use it to control the error propagation of the algorithm.
For the logarithmic and inverse trigonometric functions, namely the functions in Group 1, each bit of the solution wi is determined by the fact that which subinterval, D0 or D1, the ai belongs to. All the bits of the solution will be exact when ai are in the corresponding right subinterval. So the solution error should not be sensitive to the accumulation error of the intermediate ai. On the other hand, for the exponential and trigonometric functions, namely the functions in Group 2, the truncation errors of the intermediate ai accumulate gradually to the final iteration. That is, the error from every intermediate ai has directly impact on the solution.
For the arc-cosine, exponential and cosine functions, we derived the theoretical formulas to express the worst case of the error bound, namely the number of exact digits of the binary solution. However, for the logarithmic, arc-cotangent and cotangent functions, we did not find such formulas because their process of truncation error accumulation is more complicated. So in addition to theoretical analysis, we turn to perform numerical tests to simulate error accumulation using the MATLAB software. The variable precision arithmetic (vpa) function is utilized to control the truncation error of each intermediate ai. The numerical results of the solution error for all the six kinds of functions are shown in Table 4. In the table, the number of qubits used to store ai is equal to that of output (namely n = m as shown in Fig. 2), and the number of qubits change from 20 to 50. Three typical inputs are chosen for each function to compute the absolute error of the solution, which are represented as decimal.
1.1 Logarithmic function
In the following analysis, it is assumed that the fractional part of ai occupies q qubits. According to Eq. (11), the highest two bits of ai hold the integer part and the lower m − 2 bits the fractional part, i.e., q = m − 2. In addition, the fact is utilized that when the input x near the dividing point, the accumulated error of ai is most likely to induce the flip of wi. So the largest error can be induced when x = a0 = 2 + 2−q/2+1−2−q. The numerical results in Table 4 show that if the number of qubits used to store ai is equal to that of output, almost all the m bits of the output can be guaranteed to the exact.
1.2 Arc-cosine function
According to Eq. (13), the highest qubit of ai is the sign bit, and the second bit holds the integer part. So the lower m-2 bits represent the fractional part, i.e., q = m-2. As it is in the logarithmic function, when the input x near the dividing point, the accumulated error of ai will induce large error in the solution. The largest error of the solution is induced when the input is x = a0 = 2−q/2(1-2−q/2). And the actual solution obtained by the circuit shown in Fig. 4 is \( \hat{y}(a_{0} ) = 2^{ - 1} - 2^{ - q} \).
The derivative of function y = arccos(x)/π is \( {{ - 1} \mathord{\left/ {\vphantom {{ - 1} {(\pi \sqrt {1 - x^{2} } )}}} \right. \kern-0pt} {(\pi \sqrt {1 - x^{2} } )}} \), which is decreasing in [0,1). So in the interval of [0, a0], y satisfies
When \( \Delta x = a_{0} \), the equation turns to
This is the lower bound of the solution. And the upper bound of error in actual solution satisfies
So an exact solution with n bits is obtained (see Eq. (5)) when n ≤ m/2 + 1 in the worst case. See Fig. 2 for the meaning of m and n. Note that this represents the theoretical upper bound. Numerical results in Table 4 show that generally when n = m, almost all the m bits of the output can be exact.
In addition, the calculation of ai+1 in Eq. (13) can be converted to the following equation to reduce the error slightly,
where the operation complexity remains the same.
1.3 Arc-cotangent function
Numerical method is used to simulate the effect of error accumulation. The simulation results in Table 4 show that when the number of qubits used to store intermediate ai equals to that of output, almost all the m bits of the output can be guaranteed to the exact.
1.4 Exponential function
According to Eq. (16), the highest bit of ai holds the integer part and the lower m-1 bits the fractional part, i.e., q = m-1. Based on the relation of \( \sqrt {1 + 2^{ - q} } < 1 + 2^{ - q - 1} \), the following inequality is obtained when \( \hat{a}_{i} \) is not less than \( \sqrt 2 \),
When the input x equals to \( (0.\mathop {\underline{1 \cdots 1} }\limits_{n} )_{2} \), the accumulation of errors can be induced as follows,
At worst, the high q − 2 bits of the fractional part of an are exact. So the high m − 2 bits of the solution have no error.
1.5 Cosine function
According to Eq. (18), the highest two bits of ai hold the integer part and the low m-2 bits the fractional part, i.e., q = m-2. The maximum of error accumulation occurs at solutions of cos(1/2 ± 1/2n)π. So the case of \( x = (0.0\mathop {\underline{11 \cdots 1} }\limits_{n - 1} )_{2} \) is chosen to evaluate the upper bound of the error. Equation (18) can be expressed as
The derivative of the first iterative function is decreasing and belongs to the interval of \( [{1 \mathord{\left/ {\vphantom {1 4}} \right. \kern-0pt} 4},{{\sqrt 2 } \mathord{\left/ {\vphantom {{\sqrt 2 } 4}} \right. \kern-0pt} 4}] \), while the second one is also decreasing and belongs to the interval of \( [{{ - \sqrt 2 } \mathord{\left/ {\vphantom {{ - \sqrt 2 } 4}} \right. \kern-0pt} 4}, - \infty ) \). The iteration process is as follows,
where εi represents the truncation error of each iteration step. The error of the first step is zero. The next n-2 steps satisfy vi= vi-1, so the first iterative function of Eq. (30) is calculated n-1 times, and the last step calculates the second iterative function. Using the fact that the derivative of \( \sqrt {(1 + x)/2} \) is no larger than \( {{\sqrt 2 } \mathord{\left/ {\vphantom {{\sqrt 2 } 4}} \right. \kern-0pt} 4} \), the accumulation of errors can be expressed as
where δ is the derivative of \( \sqrt {(1 - x)/2} \) and satisfies \( \delta = |y^{\prime}_{n} |\in [{{\sqrt 2 } \mathord{\left/ {\vphantom {{\sqrt 2 } 4}} \right. \kern-0pt} 4}, + \infty ) \).
Now let us evaluate the upper bound of \( \delta \). Based on the relation of cos(x) < 1-x2/4 where x belongs to (0,1), the output of the n-1th iteration satisfies
so the absolute value of derivative of yn is
Substitute Eq. (34) into Eq. (32), and the upper bound is obtained
At worst, the high q − n bits of the fractional part of an have no error, and the high m–n bits of the solution involve no error. For the general case, numerical results in Table 4 show that when n = m, almost all the m bits of the output can be exact.
1.6 Cotangent function
In this case, numerical method is used to simulate the effect of error accumulation. The results in Table 4 show that when the number of qubits used to store intermediate ai equals to that of output, almost all of the m bits of the output can be guaranteed to the exact.
Appendix 2
The qFBE method transforms the evaluation of transcendental functions to computation of algebraic functions. In the circuit representation, the implementation-of-algebraic functions, like addition, subtraction, square and square root, are taken as subroutines. A lot of literature provide variety of quantum circuits for implementing such functions [8,9,10,11,12,13,14,15,16,17,18,19,20,21]. Different choices would be made depending on the conditions. Here we provide some feasible circuit designs for the operations of addition, shift, square root, square and reciprocal. More details about the circuits can be found in the references provided below.
The first quantum circuit for addition operation is designed based on the ripple-carry method [8]. Later several different quantum adders are proposed to improve the performance [9,10,11]. Here the ripple-carry adder is used as the basic module, which is called Plain Adder as shown in Fig. 9.
For the module Adder used in the paper (in Figs. 7, 8), it is almost the same as the Plain Adder except that it discards the highest carry bit, namely the bm+1 bit in Fig. 9. So Adder module is actually a modulo-2 m plain adder. The module Adder+ (in Fig. 8) represents the Hermitian conjugate of module Adder. For the module Adder* (in Figs. 4,5,7,8), it ignores the binary point when do addition. That is, when doing add one operation, Adder* will plus one to the lowest bit of the augend, while Adder will plus one to the 20 bit. The module Subtractor (in Figs. 4,5,7,8) is the inverse of Adder.
The shift operation is to multiply 2 or 1/2. It can be implemented easily using the SWAP operation. The quantum circuits for module Shift_L and Shift_R (in Figs. 3, 4,5,7) are shown in Fig. 10.
For the operations of square root and reciprocal, the quantum circuits provided in Refs. [17, 18, 21] maybe good choices. They are designed based on the classical non-restoring method [26, 27]. The circuit for square operation can be obtained by reversing the circuit for square root. The circuits for the modules of Sqrt (in Figs. 6, 7, 8), Square (in Figs. 3, 4, 8) and Reciprocal (in Fig. 5) are shown in Figs. 11, 12 and 13, respectively. The module Square+ (in Fig. 8) represents the Hermitian conjugate of module Square.
The circuit to implement square root operation [21]. It is designed based on the non-restoring method
The circuit to implement square operation. Square can be seen as the inverse operation of square root, so this circuit is obtained by inversing that in Fig. 11
The circuit to implement reciprocal [21]. It is designed based on the non-restoring method
Rights and permissions
About this article
Cite this article
Wang, S., Wang, Z., Li, W. et al. Quantum circuits design for evaluating transcendental functions based on a function-value binary expansion method. Quantum Inf Process 19, 347 (2020). https://doi.org/10.1007/s11128-020-02855-7
Received:
Accepted:
Published:
DOI: https://doi.org/10.1007/s11128-020-02855-7