Skip to content

Commit

Permalink
english tutorials of state
Browse files Browse the repository at this point in the history
  • Loading branch information
KowerKoint committed Dec 20, 2022
1 parent 568366a commit 60a570d
Showing 1 changed file with 45 additions and 2 deletions.
47 changes: 45 additions & 2 deletions doc/en/source/guide/2.0_python_advanced.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -792,8 +793,10 @@
"\n",
"**It is fundamentally different in behavior from the operation of the same name in `QuantumState`, which corresponds to the quantum state**\n",
"\n",
"-- `add_state` of `QuantumState` creates superpositon, but `add_state` of `DensityMatrix` create mixed state\n",
"-- The operation corresponding to `multiply_coef(z)` of `QuantumState` is `multiply_coef(abs(z)**2)` for `DensityMatrix`"
"- `add_state` of `QuantumState` creates superpositon, but `add_state` of `DensityMatrix` create mixed state\n",
"- The operation corresponding to `multiply_coef(z)` of `QuantumState` is `multiply_coef(abs(z)**2)` for `DensityMatrix`\n",
"\n",
"Using `state.make_superposition()` `state.make_mixture()` is recommended since `add_state()` `multiply_coef()` make users confused with those generated by `QuantumState`."
]
},
{
Expand Down Expand Up @@ -885,6 +888,46 @@
"print(obtained)"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"### Creating superposition states and mixture states\n",
"\n",
"You can create superposition states and mixture states by using `make_superposition()` `make_mixture()` in `state` module.\n",
"These states can also be creaated by applying `add_state()` `multiply_coef()` to `QuantumState` `DensityMatrix`, but is deprecated due to low readability."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from qulacs import QuantumState, DensityMatrix\n",
"from qulacs.state import make_superposition, make_mixture\n",
"# from QuantumState |a> and |b>, create a superposition state p|a> + q|b>\n",
"a = QuantumState(2)\n",
"a.set_computational_basis(0b00)\n",
"b = QuantumState(2)\n",
"b.set_computational_basis(0b11)\n",
"p = 1 / 2\n",
"q = 1 / 2\n",
"c = make_superposition(p, a, q, b)\n",
"print(c.get_vector())\n",
"# from QuantumState |a> and DensityMatrix |b><b|, create a mixture state p|a><a| + q|b><b|\n",
"# You can also create a mixture states from two QuantumState or two DensitMatrix\n",
"a = QuantumState(2)\n",
"a.set_computational_basis(0b00)\n",
"b = DensityMatrix(2)\n",
"b.set_computational_basis(0b11)\n",
"p = 1 / 2\n",
"q = 1 / 2\n",
"c = make_mixture(p, a, q, b)\n",
"print(c.get_matrix())"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down

0 comments on commit 60a570d

Please sign in to comment.