Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails to decompose single qubit unitary #224

Open
emanuel-malvetti opened this issue Jun 2, 2018 · 1 comment
Open

Fails to decompose single qubit unitary #224

emanuel-malvetti opened this issue Jun 2, 2018 · 1 comment

Comments

@emanuel-malvetti
Copy link

The following matrix cannot be decomposed even though it is unitary.

U = np.matrix([[(-0.7108860402090058-0.7033072016973199j),
                    (-9.403468524726843e-05+9.504800300819127e-05j)],
                   [(-9.507314515605492e-05+9.400926537078691e-05j),
                    (-0.7031170805491339-0.7110740841596025j)]])

In fact running np.linalg.norm(U.getH()*U - np.eye(2)) returns 5.462198399343198e-16.

Reducing TOLERANCE in arb1qubit2rzandry.py from 1e-12 to 1e-10 removes the exception, so I assume this is caused by cancellation effects, similar to what happens when solving the quadratic equation: https://en.wikipedia.org/wiki/Loss_of_significance#Instability_of_the_quadratic_equation

Exception: ("Couldn't find parameters for matrix ", [[(-0.7108860402090058-0.7033072016973199j), (-9.403468524726843e-05+9.504800300819127e-05j)], [(-9.507314515605492e-05+9.400926537078691e-05j), (-0.7031170805491339-0.7110740841596025j)]], "This shouldn't happen. Maybe the matrix is not unitary?")
 raised in:
'  File "/Users/isaac/Library/Python/3.5/lib/python/site-packages/projectq/setups/decompositions/arb1qubit2rzandry.py", line 192, in _find_parameters'
'    "not unitary?")'
@thomashaener
Copy link
Contributor

Thanks for pointing this out! I will try to make the current implementation more robust as soon as I find time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants