.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/complex_analysis/holomorphic/plot_03_wessel_argand_plane.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code or to run this example in your browser via JupyterLite. .. rst-class:: sphx-glr-example-title .. _sphx_glr_api_gallery_complex_analysis_holomorphic_plot_03_wessel_argand_plane.py: Wessel and Argand's complex plane: multiplication rotates and scales ==================================================================== Caspar Wessel (1797) and Jean-Robert Argand (1806) drew :math:`a + bi` as the point :math:`(a, b)`. Addition is then vector addition, and multiplication by :math:`w = re^{i\varphi}` rotates every point by :math:`\varphi` and scales it by :math:`r`. Multiplying by :math:`i` is a quarter turn, so :math:`i^2 = -1` is a half turn. .. GENERATED FROM PYTHON SOURCE LINES 13-19 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from mathematicskit.complex_analysis import map_grid from mathematicskit.complex_analysis.visualizers import plot_mapped_grid .. GENERATED FROM PYTHON SOURCE LINES 20-22 Powers of i: four quarter turns ------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 22-36 .. code-block:: Python fig, ax = plt.subplots(figsize=(5, 5)) z = 1.0 + 0.0j for k in range(4): ax.annotate("", xy=(z.real, z.imag), xytext=(0, 0), arrowprops={"arrowstyle": "->", "lw": 2}) ax.text(1.12 * z.real - 0.05, 1.12 * z.imag - 0.05, f"$i^{k}$") z *= 1j theta = np.linspace(0, 2 * np.pi, 200) ax.plot(np.cos(theta), np.sin(theta), "k:", lw=0.8) ax.set_xlim(-1.4, 1.4) ax.set_ylim(-1.4, 1.4) ax.set_aspect("equal") ax.set_title("Multiplying by i is a quarter turn") .. image-sg:: /api/gallery/complex_analysis/holomorphic/images/sphx_glr_plot_03_wessel_argand_plane_001.png :alt: Multiplying by i is a quarter turn :srcset: /api/gallery/complex_analysis/holomorphic/images/sphx_glr_plot_03_wessel_argand_plane_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none Text(0.5, 1.0, 'Multiplying by i is a quarter turn') .. GENERATED FROM PYTHON SOURCE LINES 37-39 Multiplication by w = 1 + i: rotate 45 degrees, scale by sqrt 2 ---------------------------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 39-45 .. code-block:: Python w = 1.0 + 1.0j print(f"|w| = {abs(w):.6f}, arg w = {np.degrees(np.angle(w)):.1f} degrees") grid = map_grid(lambda z: w * z, x_range=(0.0, 1.0), y_range=(0.0, 1.0), n_lines=6) plot_mapped_grid(grid) .. image-sg:: /api/gallery/complex_analysis/holomorphic/images/sphx_glr_plot_03_wessel_argand_plane_002.png :alt: plot 03 wessel argand plane :srcset: /api/gallery/complex_analysis/holomorphic/images/sphx_glr_plot_03_wessel_argand_plane_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none |w| = 1.414214, arg w = 45.0 degrees array([, ], dtype=object) .. GENERATED FROM PYTHON SOURCE LINES 46-48 Moduli multiply, arguments add ------------------------------ .. GENERATED FROM PYTHON SOURCE LINES 48-54 .. code-block:: Python z1, z2 = 2.0 * np.exp(0.3j), 1.5 * np.exp(1.1j) print(f"|z1 z2| = {abs(z1 * z2):.6f} vs |z1||z2| = {abs(z1) * abs(z2):.6f}") print(f"arg(z1 z2) = {np.angle(z1 * z2):.6f} vs arg z1 + arg z2 = {np.angle(z1) + np.angle(z2):.6f}") plt.show() .. rst-class:: sphx-glr-script-out .. code-block:: none |z1 z2| = 3.000000 vs |z1||z2| = 3.000000 arg(z1 z2) = 1.400000 vs arg z1 + arg z2 = 1.400000 .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.172 seconds) .. _sphx_glr_download_api_gallery_complex_analysis_holomorphic_plot_03_wessel_argand_plane.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: lite-badge .. image:: images/jupyterlite_badge_logo.svg :target: ../../../../lite/lab/index.html?path=api/gallery/complex_analysis/holomorphic/plot_03_wessel_argand_plane.ipynb :alt: Launch JupyterLite :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_03_wessel_argand_plane.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_03_wessel_argand_plane.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_03_wessel_argand_plane.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_