<jupyter_start><jupyter_text>... continue [here](https://livebook.manning.com/book/learn-quantum-computing-with-python-and-q-sharp/chapter-2/v-4/point-7622-337-337-0)<jupyter_code>%run ../globals.ipynb<jupyter_output><empty_output><jupyter_text>Unitary operators and the Hadamard Operator<jupyter_code>import numpy as np
ket0 = np.array(
    [[1], [0]]
)
ket0
ket1 = np.array(
    [[0], [1]]
)
ket1
ket_plus = (ket0 + ket1) / np.sqrt(2)
ket_plus<jupyter_output><empty_output><jupyter_text>Definition of Hadamard Operator<jupyter_code>H = np.array([[1, 1], [1, -1]]) / np.sqrt(2)
make_pretty(H, show_brackets=True, )
make_pretty(H @ ket0)
make_pretty(H @ ket1)
PP %(H @ ket1)
X = np.array([[0, 1], [1, 0]])
PP % (X @ ket0)
(X @ ket0 == ket1).all()
PP % (X @ H @ ket0)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1934673366834171, 'fraction_numerical': 0.05025125628140704, 'mean_word_length': 5.275590551181103, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 1, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '498713', 'license': 'MIT', 'n_tokens_mistral': 379, 'n_tokens_neox': 352, 'n_words': 59, 'path': 'ch2/3. Unitary operators and the Hadamard Operator.ipynb', 'repo_name': 'tzaffi/qc', 'size': '796'}