question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Remove support for np.exp

See original GitHub issue

I 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:closed
  • Created 4 years ago
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
kevinsungcommented, Feb 5, 2020

At Cirq sync we decided to drop this functionality (support for np.exp).

0reactions
dabaconcommented, May 17, 2022

There is no longer any exp methods on gates in Cirq, so this is now fixed as far as I can tell.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found