QuTech-Delft / qx-simulator

QX Simulator
Other
16 stars 12 forks source link

Symbolic computation in the simulator #126

Open pablolh opened 1 year ago

pablolh commented 1 year ago

As I just ran into the problem where I do a bell pair and measure a qubit and end up with the following pure state (artificially increased the precision):

Final quantum state
00       0.999999999999999777955395074969 + 0.000000000000000000000000000000*i    (p = 0.999999999999999555910790149937)

This would be a nice feature to have symbolic computation into QX-simulator, so as to avoid rounding issues and get a meaningful output to the user.

This should handle square roots and fractions on top of the usual multiplication and substraction, as well as some simplification methods. Example of expected output for a non-measured bell pair:

00     1/sqrt(2) + 0*i
11     1/sqrt(2) + 0*i

An example of library which could help do this would be SymbolicC++

This functionality would coexist with the current normal computation and would be toggled by a flag. It will probably be much slower than normal floating-point based computation, but much nicer to interpret the output.

On the side, we can look into how to mitigate approximation errors for floating-point computation, which involves diving into the exciting world of floats.

pablolh commented 1 year ago

Some resource to read on float errors: https://en.wikipedia.org/wiki/Floating-point_error_mitigation

arcturusannamalai commented 4 weeks ago

IMHO this goes into domain on - computer algebra system (CAS) - its a slippery slope to add to a library; what could be done is perhaps if you had a Mathematic or similar CAS you can pump in the expressions and get results back.