Git Product home page Git Product logo

Comments (7)

awcross1 avatar awcross1 commented on August 24, 2024

This is due to numerical error in the argument of acos in yzy_to_zyz. For example, math.sin(math.pi/2) * math.cos(math.pi/4) / math.sin(math.pi/4) = 1.0000000000000002 > 1. One solution is to round the argument.

from qiskit-terra.

1ucian0 avatar 1ucian0 commented on August 24, 2024

One option is to round, but that might add errors after several computations. I suggest to move to symbolic computation instead of flouting point math to avoid this issue:

> import sympy
> sympy.sin(sympy.pi/2) * sympy.cos(sympy.pi/4) / sympy.sin(sympy.pi/4)
< 1

Comments?

from qiskit-terra.

dcmckayibm avatar dcmckayibm commented on August 24, 2024

I think @awcross1 was giving an example where it fails, but it general the inputs are not symbolic they are floats.

from qiskit-terra.

1ucian0 avatar 1ucian0 commented on August 24, 2024

The particular case in yzy_to_zyz, can be solved symbolically. There are several other points in the mapper where math is used, that can be easily be replaced with sympy.

I'm not sure what you mean. In situations where user code has floats, that error is introduced by the user and we can represent exactly that error without adding more, using Decimal in the parser.

My point is, when possible, we should operate with symbols to avoid adding error.

from qiskit-terra.

awcross1 avatar awcross1 commented on August 24, 2024

Thanks Luciano, I think it is worth investigating using symbols.

from qiskit-terra.

awcross1 avatar awcross1 commented on August 24, 2024

Here is a self-contained test case from @dcmckayibm that triggers the error

from qiskit import QuantumProgram
import numpy as np

coupling_map_test = {0:[0]}
qp = QuantumProgram()
qr = qp.create_quantum_register('q', 1)
cr = qp.create_classical_register('c', 1)
qc = qp.create_circuit('qc1', qregisters=[qr], cregisters=[cr])
qc.u2(np.pi/2, 0, qr[0])
qc.u3(np.pi/2, np.pi/2, 0.0, qr[0])
qp.compile('qc1', coupling_map=coupling_map_test)

from qiskit-terra.

diego-plan9 avatar diego-plan9 commented on August 24, 2024

Closing the issue, as it was fixed by #151 - thanks Luciano!

from qiskit-terra.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.