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

Quantum symbol expressions won't work with addition #24

Open
Doomsk opened this issue Sep 16, 2024 · 1 comment
Open

Quantum symbol expressions won't work with addition #24

Doomsk opened this issue Sep 16, 2024 · 1 comment
Labels
question Further information is requested

Comments

@Doomsk
Copy link
Member

Doomsk commented Sep 16, 2024

It is possible to evaluate

a = parameter("a")
b = parameter("b")
print(a + b)

however it raises a generic error when doing it with quantum operators

X(1) + Z(1)

It may be helpful if an appropriate error is raised stating that this is not a valid expression.

@Doomsk Doomsk added the question Further information is requested label Sep 16, 2024
@kaosmicadei
Copy link
Contributor

The expression X(1) + Z(1) is valid and can be assigned to a variable.

h = 0.7071 * (X(1) + Z(1))
U = exp(-0.5j * h)

However, X(1) + Z(1) by itself cannot be compiled since there isn't an "addition gate". It needs to be replaced by an equivalent gate first.

replace(U, {0.7071 * (X(1) + Z(1)): H(1)})

Currently, this substitution needs to be performed manually. Future steps of the development would include some automatic analysis of the expressions.

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

No branches or pull requests

2 participants