{ "cells": [ { "cell_type": "markdown", "id": "efe9d3bf", "metadata": {}, "source": [ "[Home](Home.ipynb)\n", "\n", "# Complex Numbers\n", "\n", "The invention called the complex plane lets us dial in any place on the unit circle, by raising $e$ to a power. \n", "\n", "Setting $\\theta$ equal to $\\pi$ in the equation below, leaves us half way around the circle, at (x, y) = (-1, 0).\n", "\n", "$$\n", "e^{ \\pm i\\theta } = \\cos \\theta \\pm i\\sin \\theta\n", "$$\n", "\n", "$$\n", "e^{ i\\pi} = -1\n", "$$" ] }, { "cell_type": "code", "execution_count": 1, "id": "090870a7", "metadata": {}, "outputs": [], "source": [ "from cmath import *" ] }, { "cell_type": "code", "execution_count": 2, "id": "9ef350df", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "2.718281828459045" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "e" ] }, { "cell_type": "code", "execution_count": 3, "id": "312ab91f", "metadata": {}, "outputs": [], "source": [ "import cmath" ] }, { "cell_type": "code", "execution_count": 4, "id": "167be3b5", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "['__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'acos', 'acosh', 'asin', 'asinh', 'atan', 'atanh', 'cos', 'cosh', 'e', 'exp', 'inf', 'infj', 'isclose', 'isfinite', 'isinf', 'isnan', 'log', 'log10', 'nan', 'nanj', 'phase', 'pi', 'polar', 'rect', 'sin', 'sinh', 'sqrt', 'tan', 'tanh', 'tau']\n" ] } ], "source": [ "print(dir(cmath))" ] }, { "cell_type": "code", "execution_count": 5, "id": "2bc03177", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Help on built-in function log in module cmath:\n", "\n", "log(x, y_obj=None, /)\n", " The logarithm of z to the given base.\n", " \n", " If the base not specified, returns the natural logarithm (base e) of z.\n", "\n" ] } ], "source": [ "help(log)" ] }, { "cell_type": "code", "execution_count": 6, "id": "96fcb23a", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "1.5707963267948966j" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "log(0+1j)" ] }, { "cell_type": "code", "execution_count": 7, "id": "458cb096", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "3.141592653589793j" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "log(-1)" ] }, { "cell_type": "code", "execution_count": 9, "id": "6b53ffcc", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(1.0, 3.141592653589793)" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "polar(-1+0j)" ] }, { "cell_type": "code", "execution_count": 10, "id": "9be05fea", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(1.0, -1.5707963267948966)" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "polar(-1j)" ] }, { "cell_type": "code", "execution_count": 11, "id": "4e72f24c", "metadata": {}, "outputs": [], "source": [ "r, theta = polar(-1j)" ] }, { "cell_type": "code", "execution_count": 16, "id": "7a0c28f6", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(6.123233995736766e-17+0j)" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "cos(theta)# + sin(theta)*j" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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.7.9" } }, "nbformat": 4, "nbformat_minor": 5 }