<jupyter_start><jupyter_text>$$\text{This is the cutdown companion Jupyter notebook of Appendix A - Readying Mathematical Concepts, of the book titled:}$$$$\text{ "Quantum Chemistry and Computing for the Curious: Illustrated with Python and Qiskit® code" and with ISBN-13: 978-1803243900.}$$ The following MIT license only applies to the code, and not to the text and images. The authors are not granting a license to replicate or reuse the text and images in the companion Jupyter notebook. MIT LicenseCopyright (c) 2022 PacktPermission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in allcopies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THESOFTWARE.  Appendix A – Readying Mathematical Concepts  Installing NumPy, SimPy, and Qiskit and importing various modulesInstall NumPy with the following command:<jupyter_code># pip install numpy<jupyter_output><empty_output><jupyter_text>Install SimPy with the following command:<jupyter_code>pip install simpy<jupyter_output><empty_output><jupyter_text>Install Qiskit with the following command:<jupyter_code>pip install qiskit<jupyter_output><empty_output><jupyter_text>Importing NumPy and a function which returns a LaTeX representation of a complex arrayImporting numPy<jupyter_code>import numpy as np<jupyter_output><empty_output><jupyter_text>Importing array_to_latex function which returns a Latex representation of a complex array with dimension 1 or 2.<jupyter_code>from qiskit.visualization import array_to_latex<jupyter_output><empty_output><jupyter_text>Mathematical definitions  Complex numbers Vector space<jupyter_code>x = np.array([[1j],
             [2]])
array_to_latex(x, prefix='x = ')
α = 1j
print('α =', α)
y = α*x
array_to_latex(y, prefix=' y = α*x =')<jupyter_output>α = 1j<jupyter_text>Linear operators  Matrices  Eigenvalues and eigenvectors  Vector and matrix transpose, conjugate, and conjugate transpose<jupyter_code>array_to_latex(x.transpose(), prefix='x^T = ')
array_to_latex(x.conjugate(), prefix='x^* = ')
array_to_latex(x.conjugate().transpose(), prefix='x^\dagger = (x^*)^T = ')<jupyter_output><empty_output><jupyter_text>Dirac’s notation  Inner product of two vectors<jupyter_code>array_to_latex(x, prefix=' x = ')
array_to_latex(y, prefix=' y = ')
print("np.vdot(x, y) = ", np.vdot(x, y))<jupyter_output>np.vdot(x, y) =  5j<jupyter_text>Norm of a vector<jupyter_code>print("Norm of vector x: {:.3f}".format(np.linalg.norm(x)))<jupyter_output>Norm of vector x: 2.236<jupyter_text>Hilbert space  Matrix multiplication with a vector<jupyter_code>A = np.array([[1, 2],
              [3, 1j]])
array_to_latex(A, prefix='A = ')
a = np.array([[1],
             [1]])
array_to_latex(a, prefix='a = ')
array_to_latex(A@a, prefix='A@a = ')<jupyter_output><empty_output><jupyter_text>Matrix addition<jupyter_code>A = np.array([[1, 0],
              [0, 1j]])
array_to_latex(A, prefix='A = ')
B = np.array([[0, 1],
              [1j, 0]])
array_to_latex(B, prefix='B = ')
array_to_latex(A+B, prefix='A+B = ')<jupyter_output><empty_output><jupyter_text>Matrix multiplication<jupyter_code>A = np.array([[1, 0],
              [0, 1j]])
array_to_latex(A, prefix='A = ')
B = np.array([[1, 1, 1j],
              [1, -1, 0]])
array_to_latex(B, prefix='B = ')
array_to_latex(A@B, prefix='A@B = ')<jupyter_output><empty_output><jupyter_text>Matrix inverse<jupyter_code>from numpy.linalg import inv
A = np.array([[1., 2.], [3., 4.]])
array_to_latex(A, prefix='A =')
array_to_latex(inv(A), prefix='A^{-1} = ')<jupyter_output><empty_output><jupyter_text>Tensor product  Kronecker product or tensor product of matrices or vectors<jupyter_code>A = np.array([[1,2],
              [3, 4]])
array_to_latex(A, prefix='A =')
B = np.array([[0, 5],
              [6, 7]])
array_to_latex(B, prefix='B =')
C = np.kron(A,B)
array_to_latex(C, prefix='A \otimes B =')<jupyter_output><empty_output><jupyter_text>Outer product<jupyter_code>array_to_latex(x, prefix=' x = ')
array_to_latex(y, prefix=' y = ')
array_to_latex(np.outer(x, y), prefix='np.outer(x, y) = ')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12014637121366131, 'fraction_numerical': 0.01382394795690181, 'mean_word_length': 5.910112359550562, 'pattern_counts': {'":': 0, '<': 58, '<?xml version=': 0, '>': 58, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '15', 'dir': 'jupyter-structured-clean-dedup', 'id': '646846', 'license': 'MIT', 'n_tokens_mistral': 1747, 'n_tokens_neox': 1672, 'n_words': 474, 'path': 'Appendix_A_Readying_mathematical_concepts.ipynb', 'repo_name': 'AlainChance/Quantum-Chemistry-and-Computing-for-the-Curious', 'size': '4919'}