See how quantum states move on the Bloch sphere.
Drag, rotate, and explore them in 3D.
import { init } from "@masabando/easy-three";import { QTool, QState } from "@masabando/quantum-gates";QTool.createAnimation({ init, target: "#bloch", pulseName: "reduced CORPSE/BB1", angle: Math.PI / 2, phi: 0, initState: new QState([1, 0]), speed: 4,})Visualize gate robustness with a fidelity map.
Scan pulse-length and off-resonance errors in one view.
import { QTool } from "@masabando/quantum-gates";QTool.createFidelityMap({ target: "#target", gateName: "reduced CORPSE/BB1", theta: Math.PI, phi: 0, width: 400, height: 400, // [ optional ] // threshold: 0.9999, // error: { // ple: { min: -0.1, max: 0.1, step: 0.005 }, // ore: { min: -0.1, max: 0.1, step: 0.005 } // }, // fillStyle: (val) => `rgb(${val}, ${val}, ${val})`,});Quantum gates can be defined directly as rotations.
You don’t need to write matrices to simulate their behavior.
import { QGate, QState } from "@masabando/quantum-gates";// Not Gate (with global phase)// rotation around X-axis by PIconst gate = new QGate(Math.PI, [1, 0, 0])// Initial State |0>const state = new QState([1, 0])// Bloch Vector (0, 0, 1)console.log(state.xyz);// X|0> = |1>const finalState = gate.apply(state);// Bloch Vector (0, 0, -1)console.log(finalState.xyz);Composite pulses are just sequences of simple rotations.
They can be built directly from individual gates.
import { QGate, QState } from "@masabando/quantum-gates";// Pulse Length Errorconst ple = 0.1; // 10% pulse length error// up spin (0, 0, 1)const initialState = new QState([1, 0]);console.log(initialState.xyz);// ple-affected 180y pulse (-0.31, 0, -0.95)const pulse = new QGate(Math.PI * (1 + ple), [0, 1, 0]);console.log(pulse.apply(initialState).xyz);// composite pulse// 90xconst p1 = new QGate(Math.PI / 2 * (1 + ple), [1, 0, 0])// 180yconst p2 = new QGate(Math.PI * (1 + ple), [0, 1, 0])// 90xconst p3 = new QGate(Math.PI / 2 * (1 + ple), [1, 0, 0])const compositePulse = p3.multiply(p2).multiply(p1);// (0.05, 0.01, -1)console.log(compositePulse.apply(initialState).xyz);Composite quantum gates can be used just like single gates.
You can also evaluate them numerically by computing fidelity.
import { QGate, QTool, CPList } from "@masabando/quantum-gates";// error values for testing// 10% pulse length error and 10% off-resonance errorconst ple = 0.1;const ore = 0.1;// ideal 180x gateconst idealGate = new QGate(Math.PI, [1, 0, 0]);// erroneous simple gateconst plain = QTool.evalGate(CPList["plain"].pulse, Math.PI, 0, ple, ore);// erroneous composite gateconst corpse = QTool.evalGate(CPList["CORPSE"].pulse, Math.PI, 0, ple, ore);// erroneous concatenated composite gateconst cccp = QTool.evalGate(CPList["reduced CORPSE/SK1"].pulse, Math.PI, 0, // fidelities// 0.983console.log(plain.fidelity(idealGate))// 0.987console.log(corpse.fidelity(idealGate))// 0.995console.log(cccp.fidelity(idealGate))