Remove support for np.exp
See original GitHub issueI am really confused of this exponentiation that I expected as exp(-1j X).
>>> np.exp(-1j*cirq.X(q))
cirq.rx(np.pi*0.3183098861837907).on(cirq.GridQubit(0, 0))
In fact, the definition of cirq.rx® is cirq.XPowGate(exponent=r/np.pi, global_shift=-0.5). Because cirq.XPowGate(exponent=t) is [[g·c, -i·g·s], [-i·g·s, g·c]] = g ( I c - i X s) where: c = cos(π·t/2) = cos(r/2) s = sin(π·t/2) = sin(r/2) g = exp(i·π·t/2) = exp(i r/2) since the global_shift = -0.5, exp(i * pi * global_shift * exponent) = exp(i * pi * -0.5 * r/pi) = exp(-i0.5r) = g’ = 1/g, so the final equation is g’g ( I c - i X s) = I cos(r/2) - i X sin(r/2)
However, when I remember the Euler formula like identity equation, exp(-1j r X) = I cos® - i X sin®. Could you help me?
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (2 by maintainers)
Top Results From Across the Web
Overflow Error in Python's numpy.exp function
As fuglede says, the issue here is that np.float64 can't handle a number as large as exp(1234.1) . Try using np.float128 instead:
Read more >Calling np.exp(0) causes many lapack calls to return NaNs on ...
I've encountered this in numpy 1.21.2 with CPUs that support AVX512 and MKL installed. It appears to be fixed in numpy 1.21.4 but...
Read more >numpy.exp — NumPy v1.24 Manual
Calculate the exponential of all elements in the input array. Parameters: xarray_like. Input values. outndarray, None, or tuple of ...
Read more >Python math.exp() Method - W3Schools
The math.exp() method returns E raised to the power of x (E x ). 'E' is the base of the natural system of...
Read more >scipy.optimize.least_squares — SciPy v1.9.3 Manual
Use np.inf with an appropriate sign to disable bounds on all or some variables. ... 2 : display progress during iterations (not supported...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
At Cirq sync we decided to drop this functionality (support for
np.exp
).There is no longer any
exp
methods on gates in Cirq, so this is now fixed as far as I can tell.