Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion Q/Q-Qubit.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,21 @@ Object.assign( Q.Qubit, {
},
fromBlochVector: function( x, y, z ){

// converting back to a Qubit (a, b) only maintains the relative phase between a and b
// for convenience, I will assume a is real.

//basically from a Pauli Rotation
// this neat trick comes from considering the density matrix if a = r and b = s + ti:
// ( r*r rs-rti )
// ( rs+rti s*s+t*t )

// compare that with the density matrix in https://en.wikipedia.org/wiki/Bloch_sphere

const
aReal = ( 0.5 + 0.5 * z ) ** 0.5,
a = new Q.ComplexNumber( aReal, 0 ),
b = new Q.ComplexNumber( x / 2 / aReal, y / 2 / aReal )

return new Q.Qubit( a, b )
}

})
Expand Down