Comments (5)
Looks like 'mathjs' evaluates to different values when used exp(i*pi/2)
and i
where the first adds some real part to the apart from the imaginary part.
const math = require('mathjs')
console.log(math.evaluate("i"))
console.log(math.evaluate("exp(i * pi / 2)"))
Complex { re: 0, im: 1 }
Complex { re: 6.123233995736766e-17, im: 1 }
from quantum-circuit.
@glanzz thank you for reporting, but I claim this is not a bug.
Error on 16th decimal place simply cannot make that big difference in results.
You have too small number of shots. If I run your example multiple times, I get very different counts each time, which is normal behavior:
{ '0': 50, '1': 50 }
{ '0': 49, '1': 51 }
{ '0': 41, '1': 59 }
{ '0': 60, '1': 40 }
{ '0': 49, '1': 51 }
{ '0': 39, '1': 61 }
{ '0': 59, '1': 41 }
{ '0': 49, '1': 51 }
Try with more shots:
{ '0': 5017, '1': 4983 }
{ '0': 5037, '1': 4963 }
{ '0': 4980, '1': 5020 }
{ '0': 4965, '1': 5035 }
{ '0': 5054, '1': 4946 }
{ '0': 5009, '1': 4991 }
By the way, there is: circuit.measureAllMultishot(numShots)
method which simplifies code:
import QuantumCircuit from 'quantum-circuit';
var ss = new QuantumCircuit();
ss.addGate("h", 0,0) // Apply this so that imaginary part is accounted
ss.addGate("s", 1,0)
ss.addGate("s", 2,0)
var z = new QuantumCircuit();
z.addGate("h", 0,0) // Apply this so that imaginary part is accounted
z.addGate("z", 1, 0)
const shots = 100;
for(let circuit of [ss, z]) {
circuit.run([true]);
results = circuit.measureAllMultishot(shots);
console.log(results)
}
P.S. if you try the same with Qiskit or other framework (also with real quantum computer), you will get similar results.
from quantum-circuit.
I mean, this is a bug (in mathjs), but effect on results is insignificant.
from quantum-circuit.
Ah, now I see what you are suggesting: simple solution to decimal error in this case is to simply change matrix definition from exp(i * pi / 2)
to i
. Will be done in the next update š Thanks.
(but this will not change results in your example code - results are already correct)
from quantum-circuit.
Fixed in v.0.9.223
:
- Matrices of S and Controlled-S are changed from
exp(i * pi / 2)
toi
. - Matrices of Sā and Controlled-Sā are changed from
exp(-i * pi / 2)
to-i
.
Thank you @glanzz
from quantum-circuit.
Related Issues (20)
- problem with cu3 gate HOT 8
- CNOT Gate is Not in Menu HOT 6
- Bloch sphere plot wrong HOT 6
- antlr source code? HOT 3
- Feature Request: Any amount of control Qbits HOT 7
- Add barrier gate
- Wrong result with some elementary computation HOT 11
- Repository of Examples to Illustrate Quantum Programming Concepts HOT 2
- About the signed bitgate parameter
- Please disambiguate unary and binary minus in QASM HOT 1
- Simulation error in Bloch sphere
- Quantum_Classical Export HOT 3
- Interactive measurements: not clear if possible/how to do HOT 11
- ReferenceError with bundler HOT 1
- Quantum Programming Studio website down HOT 4
- Long Identifiers(?) Crash when Importing from QASM HOT 2
- Probabilities can be truncated to 0.00000% in stateAsString(true) HOT 4
- Implementation question HOT 1
- shadow declaration HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
š Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ā¤ļø Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from quantum-circuit.