"Iterativelt applying the Schmidt decomposition we learned in the last lesson we are able to decompose a quantum state in a Matrix Product State (MPS). It is also known as tensor train.\n",
"The state of each qubit is represented by a tensor, and the links between the qubits represent the quantum correlation (entanglement) between the qubits. here is the general formula:\n",
" print(no + f\"Expectation value of Z should be 1, not {val_z}\" )\n",
" passed = False\n",
" break\n",
"if passed:\n",
" print(yes + f\"Expectation value of Z computed correctly\" )\n",
"\n",
"passed = True\n",
"for ii in range(num_sites):\n",
" val_x = mps.meas_local(xx, ii)\n",
" if not np.isclose(val_x, 0.0):\n",
" print(no + f\"Expectation value of X should be 0, not {val_x}\" )\n",
" passed = False\n",
" break\n",
"if passed:\n",
" print(yes + f\"Expectation value of X computed correctly\" )\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"num_sites = 7\n",
"state = np.zeros(2**num_sites)\n",
"state[[0, -1]] = 1/np.sqrt(2)\n",
"\n",
"mps = EasyMPS.from_statevector(state)\n",
"\n",
"print( f\"Local expectation value of Z: {mps.meas_local(zz, 0)}\" )\n",
"print( f\"Local expectation value of X: {mps.meas_local(xx, 0)}\" )\n",
"print( f\"Expectation value of the parity: {mps.meas_tensor_product([zz for _ in range(num_sites)], np.arange(num_sites))}\")\n",
"print( f\"Expectation value of the XX...XX: {mps.meas_tensor_product([xx for _ in range(num_sites)], np.arange(num_sites))}\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "ed",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}
%% Cell type:markdown id: tags:
# Matrix product states
Iterativelt applying the Schmidt decomposition we learned in the last lesson we are able to decompose a quantum state in a Matrix Product State (MPS). It is also known as tensor train.
The state of each qubit is represented by a tensor, and the links between the qubits represent the quantum correlation (entanglement) between the qubits. here is the general formula: