Qx.Draw.SVG.Bloch (Qx - Quantum Computing Simulator v0.5.0)
View SourceSVG rendering of qubit states on the Bloch sphere.
The Bloch sphere is a geometrical representation of pure qubit states where:
- |0⟩ state is at the north pole (top)
- |1⟩ state is at the south pole (bottom)
- |+⟩ state is on the equator (front)
- |-⟩ state is on the equator (back)
- |i⟩ and |-i⟩ states are on the equator (sides)
This module provides a sophisticated 3D SVG rendering with:
- Wireframe sphere with latitude and longitude lines
- Colored coordinate axes
- State labels at key positions
- State vector visualization
- Angle information (θ and φ)
Internal Module
This module is part of the Qx.Draw refactoring and should be accessed
through the public Qx.Draw API rather than directly.
Summary
Functions
Converts a qubit state to Bloch sphere coordinates.
Renders a qubit state on the Bloch sphere as SVG.
Functions
Converts a qubit state to Bloch sphere coordinates.
Parameters
qubit- Single qubit state tensor (2-element complex vector)
Returns
Tuple of {x, y, z, theta, phi} where:
x, y, zare Cartesian coordinates on the unit spherethetais the polar angle (0 to π)phiis the azimuthal angle (0 to 2π)
Bloch Sphere Mapping
For a qubit state α|0⟩ + β|1⟩:
- θ = 2 * acos(|α|)
- φ = arg(β) - arg(α)
Renders a qubit state on the Bloch sphere as SVG.
Creates a detailed 3D visualization with wireframe, axes, labels, and the state vector.
Parameters
coords- Tuple of {x, y, z, theta, phi} Bloch coordinatestitle- Chart titlesize- Size of the SVG (width and height) in pixels
Returns
SVG string with complete Bloch sphere visualization.
Features
- 3D wireframe with latitude/longitude grid
- Colored coordinate axes (X=red, Y=green, Z=blue)
- State labels (|0⟩, |1⟩, |+⟩, |-⟩, |i⟩, |-i⟩)
- Red state vector arrow
- Angle information footer