{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 1 Real, imaginary, conjugate and modulus"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"# import all python add-ons etc that will be needed later on\n",
"%matplotlib inline\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"from sympy import *\n",
"init_printing() # allows printing of SymPy results in typeset maths format\n",
"plt.rcParams.update({'font.size': 16}) # set font size for plots"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 1 Motivation and concept\n",
"\n",
"Complex numbers arise naturally in mathematics, often when solving quadratic equations such as $x^2+x+1=0$, which has the solutions \n",
"\n",
"$$\\displaystyle x=\\frac{1\\pm\\sqrt{-4}}{2} = \\frac{1}{2} \\pm \\sqrt{-1}$$\n",
"\n",
"Because the negative square root cannot be evaluated, as no ordinary number can be negative when squared, a new number conventionally called $i$ (although engineers call this $j$) was invented with the property $i^2 = -1$ or $i = \\sqrt{-1}$. The solution to the equation becomes $x = 1/2 \\pm i$.\n",
"\n",
"This new number is one of a new class called _complex numbers_. These are not numbers in the elementary sense used in counting or measuring, but constitute new mathematical objects and have an existence of their own. These numbers are called 'complex' only because they contain two parts and can always be written in the form\n",
"\n",
"$$\\displaystyle z=a+ ib \\qquad\\tag{1}$$\n",
"\n",
"where $a$ is called the _real_ (Re) part and $b$ the _imaginary_ (Im) part of the number. The complex number $z = i$, if written in the form of equation 1, has a real part $a = 0$ and an imaginary part $b = 1$. The latter is rather a misnomer as $b$ is just as 'real' as is $a$; it is just a number and perhaps, therefore, the best way to view a complex number is to consider it a number in two dimensions with amounts $a$ and $b$ in each of these dimensions. In that case, a complex number can be represented as a point on a graph rather than being a point on a line, as a normal number may be considered to be. The graph is called an *Argand* diagram, if drawn with the real part $a$ along the conventional x-axis and $b$ along the y-axis; the area defined by $a$ and $b$ is also called the Argand or Gauss plane. The imaginary number $i$ has a real part that is 0 and an imaginary part that is 1, and is represented by the point (0, 1) on the y-axis of an Argand diagram, see figure 1.\n",
"\n",
"![Drawing](chapter2-fig1.png )\n",
"\n",
"Figure 1. The Argand diagram showing two complex numbers in the form $z = a + ib$, $r$ is the modulus of the complex number $z$ and $\\theta$ the argument measured anticlockwise from the real axis.\n",
"_____\n",
"\n",
"The Argand diagram is not like a normal graph in which a function such as $y = x^3$ is plotted, because the value of $y$ on the graph normally shows how large the function is at a given value of $x$. The Argand diagram shows one point in the real and imaginary plane for each complex number so is more like a map that locates a place with latitude or longitude.\n",
"\n",
"Performing algebra with complex numbers is no more difficult than with 'normal' numbers, because the prime rule of algebra still applies:\n",
"\n",
"$\\qquad\\qquad$'*Whatever I do to one side of an equation I do to the other side*'\n",
"\n",
"The normal rules for addition and multiplication apply but with the additional rule that additions and subtractions are kept separate for the real and imaginary parts, as is done for components of vectors. A complex number can be divided in the usual way by a real number. Dividing by a complex number has the additional step that the top and bottom of the expression are first multiplied by the complex conjugate of the denominator. This is explained below. Although $i$ is a complex number, $i^2 = -1$ and is a real number:\n",
"\n",
"\n",
"$$\\displaystyle i=\\sqrt{-1}, \\qquad -i=-\\sqrt{-1}, \\qquad i^2=-1, \\qquad i=\\frac{-1}{i} $$\n",
"\n",
"The series formed from the first few powers of $i$ has a repeating pattern of four terms,\n",
"\n",
"$$\\displaystyle \\begin{align}&i^0 =1, \\quad i^1=i, \\quad i^2=-1, \\quad i^3=-i, \\\\ &i^4=1, \\quad i^5=i , \\quad i^6=-1,\\quad i^7=-i \\cdots\\end{align}$$\n",
"\n",
"## 1.1 Complex conjugate\n",
"\n",
"Complex numbers possess a new property compared to real numbers and this is the complex conjugate. If $z = a + ib$ then the complex conjugate is defined as\n",
"\n",
"$$\\displaystyle z^* = a - ib, \\qquad\\tag{2}$$\n",
"\n",
"where, by convention, an asterisk is added and every $i$ is replaced with $-i$; the result is that $z^*z$ is always a real number;\n",
"\n",
"$$\\displaystyle z^*z=(a+ib)^*(a+ib)=(a-ib)(a+ib)=a^2 +b^2. \\qquad\\tag{3}$$\n",
"\n",
"In geometrical terms, forming the complex conjugate is equivalent to a reflection in the real axis because only the imaginary part is inverted.\n",
"\n",
"In quantum mechanics, the wavefunction is often found to be a complex quantity and, therefore, the complex conjugate is always used to calculate expectation or average values such as $\\displaystyle \\langle x \\rangle = \\int\\psi_i^* x\\psi_f dx$ and probabilities $\\displaystyle p = \\int \\psi^*\\psi dx$ because only a mathematically real quantity is measured in an experiment, not an imaginary one.\n",
"\n",
"The quantity $z + z^*$ is always a real number equal to $2Re(z)$ or $2Re(z^*)$ which is the same. It is worth remembering the rules\n",
"\n",
"$$\\displaystyle (z_1 + z_2)^* = z_1^* + z_2^* \\qquad (z_1z_2)^* = z_1^*z_2^*$$\n",
"\n",
"In some textbooks and some scientific papers, formulae involving complex numbers are written in a form that does not include the complex conjugate but instead has the notation +c.c. at the end of the equation to indicate that the complex conjugate is to be added. This is primarily a method of increasing the readability of formulae. An electric field describing linearly polarized light could be written as\n",
"\n",
"$$E(t,x)= E_0(E^{i(\\omega t - k x)} +c.c.)$$\n",
"\n",
"instead of \n",
"\n",
"$$E(t,x)= E_0(E^{i(\\omega t - k x)} +E^{-i(\\omega t - k x)})$$\n",
"\n",
"similarly\n",
"\n",
"$$\\displaystyle \\chi(t)= E_0\\left( \\frac{e^{i\\omega t}}{\\omega_a^2-\\omega^2+2i\\omega /T} +c.c\\right) \\equiv E_0\\left( \\frac{e^{i\\omega t}}{\\omega_a^2-\\omega^2+2i\\omega /T} +\\frac{e^{-i\\omega t}}{\\omega_a^2-\\omega^2-2i\\omega /T}\\right) $$\n",
"\n",
"![Drawing](chapter2-fig2.png )\n",
"\n",
"Figure 2. The complex number $z$ and its complex conjugate $z^*$.\n",
"______"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 1.2 Adding and subtracting complex numbers\n",
"\n",
"The real and imaginary parts are added separately as shown in Fig.3. This is very much like adding two vectors. Figure 3(Left) also illustrates the _Triangle Inequality_ of complex numbers, i.e. \n",
"\n",
"$$\\displaystyle |z_1+z_2|\\le |z_1| + |z_2|,\\qquad \\text{Triangle inequality}$$\n",
"\n",
"In figure 3 the absolute value of the complex number $z_2$ is $|z_2|$ of length $r$. It can be seen that the green dotted line is less than the sum of one black and one red line, i.e. less than the sum of the magnitudes of the two complex numbers.\n",
"\n",
"## 1.3 Multiplying and dividing complex numbers\n",
"\n",
"Multiplying complex numbers is straightforward using the normal rules of algebra but remembering to use $i^2 = -1$ where necessary, e.g.,\n",
"\n",
"$$\\displaystyle (3+5i)(1-2i)=3-6i+5i-10i^2 =13-i$$\n",
"\n",
"Dividing numbers is a little more difficult. The rule to use is, \n",
"\n",
">Always multiply the top and bottom of the whole expression by the complex conjugate of the denominator.\n",
"\n",
"This is equivalent to multiplying by 1, and makes the denominator a real number. An example makes this clearer.\n",
"\n",
"$$\\displaystyle \\frac{3+5i}{1-2i}=\\left( \\frac{3+5i}{1-2i} \\right)\\frac{(1-2i)^*}{(1-2i)^*}=\\left( \\frac{3+5i}{1-2i} \\right)\\left(\\frac{1+2i}{1+2i}\\right)=\\frac{-7+11i}{5}$$\n",
"\n",
"![Drawing](chapter2-fig3.png )\n",
"\n",
"Figure 3. Left: Adding two complex numbers together to form $z_1+z_2$ green dashed line. Right: Adding and subtracting $z$ and its complex conjugate $z^*$. The red arrow pointing down has the same length and angle as has $z^*$ except that it starts at the end point of the line from the origin to $z$ and ends at $z+z^*$ The arrow going up is the reverse of that going down and leads to $z-z^*$. \n",
"_________\n",
"\n",
"## 1.4 Modulus and Argument\n",
"\n",
"The second new property held by complex numbers is variously called the modulus, magnitude, absolute value, or norm of the complex number. This is calculated in a similar way to that of a vector and is the length of the complex number measured from the origin, Figs 1, 4.\n",
"\n",
"The modulus $r$ of the complex number $z = a + ib$ is \n",
"\n",
"$$\\displaystyle r=+\\sqrt{a^2 +b^2} \\qquad\\tag{4}$$\n",
"It is variously written as\n",
"\n",
"$$\\displaystyle r=|z|=|a+ib|= \\sqrt{z^*z}=|z^*| \\qquad\\tag{5}$$\n",
"\n",
"\n",
"The square of a complex number is the square of the modulus;\n",
"\n",
"$$\\displaystyle |a+ib|^2 =(a+ib)^*(a+ib)=(a-ib)(a+ib)=a^2 +b^2 =z^*z=|z|^2$$\n",
"\n",
"and is always a positive number.\n",
"\n",
"In figures 1 and 4 the line from the origin to the complex number is at an angle $\\theta$ given by\n",
"\n",
"$$ \\tan(\\theta) = \\frac{b}{a},\\qquad \\theta = \\tan^{-1}\\left(\\frac{b}{a}\\right) =\\tan^{-1}\\left( \\frac{Im(z)}{Re(z)} \\right) \\tag{6}$$\n",
"\n",
"measured anticlockwise from the real axis. This angle $\\theta$ is variously called the _argument, amplitude, polar angle_, or _phase_ of the complex number and is measured in radians, a full circle being $2\\pi$ radians. The use of the word 'amplitude' to mean an angle is very confusing, and should probably be avoided.\n",
"\n",
"The location of any complex number is $(a,\\; b)$ in Cartesian type coordinates, or alternatively, in polar type coordinates is $(r,\\; \\theta )$. The complex number is then described as\n",
"\n",
"$$\\displaystyle z = r\\left(\\cos(\\theta) + i \\sin(\\theta)\\right)$$\n",
"\n",
"This interpretation is also illustrated in figure 1 for a point $z = a + ib$ where $r$ is the distance of the point from the origin. The distance along the real axis is $a = r \\cos(\\theta)$ and along the imaginary axis, $b = r \\sin(\\theta)$. Equating the real and imaginary parts gives\n",
"\n",
"$$\\displaystyle z = a + ib = r\\left(\\cos(\\theta) + i \\sin(\\theta)\\right) \\qquad\\tag{7}$$\n",
"\n",
"For example, if the complex number is $z = i$, it has a real part that is $0$ and an imaginary part of $1$, and is represented by a point $(0, 1)$ which is on the imaginary axis. Its modulus is $1$ and its argument (angle/phase) $\\pi/2$. If the number is $z = -1 - i$ then the point is found at $(-1, -1)$ on the Argand diagram. Its argument is $-5\\pi/4$ (225$^\\mathrm{o}$) and its modulus $\\sqrt{(-1 - i)(-1 + i)} = \\sqrt{2}$.\n",
"\n",
"## 1.5 Summary\n",
"\n",
"If $a$ and $b$ are real numbers, then the complex number is \n",
"\n",
"$\\qquad$ $z = a + ib = r\\left(\\cos(\\theta) + i \\sin(\\theta)\\right)$ \n",
"\n",
"$\\qquad$ $a = Re(z)$ is the real part of $z$\n",
"\n",
"$\\qquad$ $b = Im(z)$ is the imaginary part of $z$\n",
"\n",
"$\\qquad$ $r =|z|= \\sqrt{z^*z}=\\sqrt{a^2+b^2}$ is the _modulus_ of $z$, or *absolute value, magnitude* or *norm*.\n",
"\n",
"$\\qquad$ $\\displaystyle \\theta = \\tan^{-1}\\left(\\frac{b}{a}\\right)= \\tan^{-1}\\left( \\frac{Im(z)}{Re(z)} \\right)$ is the argument of $z$, also called the _polar angle_ or *phase*. \n",
"\n",
"$\\qquad$ $z^* = a - ib = r\\left(\\cos(\\theta) - i \\sin(\\theta)\\right)$ is the complex conjugate of $z$.\n",
"\n",
"$\\qquad$ $zz^* = | z |^2 = | z^* |^2$ is the _absolute value squared_ is always a positive real number.\n",
"\n",
"![Drawing](chapter2-fig4.png )\n",
"\n",
"Figure 4. As the angle (argument) $\\theta$ varies anticlockwise from $0\\to 2\\pi$, the complex number changes from $1 \\to i$ to $-1$ to $-i$ according to Euler's theorem, equation 19. A unit circle has radius of $1$.\n",
"______\n",
"\n",
"## 2 Using Python and Sympy\n",
"\n",
"When using a computer language the complex number $a+ib$ is not usually written in the mathematical way. In Python $\\mathtt{1J}$ or $\\mathtt{1j}$ is used instead of $i$, thus $\\mathtt{3*1j}$ is permissible, however, so is $\\mathtt{3j}$ or $\\mathtt{5J}$. The parts of a complex number can be extracted by using the $\\mathtt{re()}$ and $\\mathtt{im()}$ functions. An alternative is to use $\\mathtt{z.real,\\; z.imag}$ or $\\mathtt{z.conjugate()}$ (notice brackets) as shown below. In Sympy $\\mathtt{I}$ is used to represent $i$, so care has to be taken not to use this as a variable or constant."
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"3.00000000000000 5.00000000000000\n",
"3.0 5.0 (3-5j)\n"
]
}
],
"source": [
"z0 = 3 + 5j\n",
"print(re(z0), im(z0) )\n",
"print( z0.real, z0.imag, z0.conjugate() )"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"(38+18j) (-0.03846153846153843+0.8076923076923077j)\n"
]
}
],
"source": [
"z1 = 6 - 4*1J\n",
"print(z0*z1,z0/z1)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In Sympy, however, $\\mathtt{I}$ is used to represent $i$ but care has also to be taken in defining terms, for example"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAABwAAAAYCAYAAADpnJ2CAAABsUlEQVR4nO3WQYhNURzH8c+boZSdyILMggXT5E1ZKCkTmWZjwxSzsaemLEheykvExmIWZKWslJkJSTRZWdjYCCuThZWUyGbEyFic/9NxZ948073Gxq9u555z/ud8/+d3zzndWrPZtJzqqmCOq7jzp8ErKgCexexyAj8tJbispRsxh61RH8ZX9GQxY3iD9VUA65jB66hP4qVkM5zECIbwnvKW9gfgR9Tn0MADaVUN7MN0a0BZYB3PC21TeIYLOBDvv9TO0kN4iA/4Fhk20F2I618AuDcSqQkbFwN24xYmsAXjuCZZdhE3stjV2FwA1qUzOYq7uNQJOIYjuIxtOIYT6MNTHEVvxG6P8kWUPZIrVyKxc9iPgXbAnTiOeziD71nfLG5mca3VTEu7dA0e4T7OR/8ryaHfVplvmlHJ9xk0zVdfIcnr8cBHyZGiDhcbcuBglCMLDMz1tkP/omoBV2EdnmBPmQk7qWVPLcq1fxOWA79Iu60XB9vE7jb/HC5Z+Tc8JV1Jk3gcCXRhA3ZgJTZVCZzCLpyWVjOAz3gXCdwuCysCSffecBUTt1MVvxj/gf8W+BPp+0/y+ErDqAAAAABJRU5ErkJggg==\n",
"text/latex": [
"$\\displaystyle e^{i x}$"
],
"text/plain": [
" ⅈ⋅x\n",
"ℯ "
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"x = symbols('x',real=True) # Tell Sympy that x is not complex\n",
"exp(I*x).expand() # try to expand e^ix as sine and cosine "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"which is not very helpful, instead $x$ has to be defined as well as the $\\mathtt{expand( \\cdots )}$ instruction being told that the expression is complex."
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAJsAAAAVCAYAAABR25wkAAAFkklEQVR4nO2ae2hWZRzHP5uVrQWuZrIwbIFkiuRYKRUVG7jEiOwCQkHeykTpRmm6UFppdlFzdDOKahWJyYaN1mVRmWUiZbaorKzQWmuRUpt0WWWuP77P4T173uec8+4959X2si+M5+W5/M7v+T6/87s8ZwV1dXUMYhCHA4WOvluBXuDqfsgpN2sa4qsUiGeBn4HiGDLOQnpel4hG+Ye4HIfy6zK2s027I8sH5gITgWuA+4DfY8j5CHgJWA4cH1+tvEISHIfy6zK2JcBY4Ot+PKTDrKntv34Z4R7gALAuAVn3AmXATQnIyickxXEgvy5j+x74ErnDTPGPWdOZjXYROB2YDGwE/kxA3gdI13m49x+FWYibqgR0+b8gSY4D+bXJrkZErvL1XQq8hQzpL+BHYAuwwDenHHfO5u8vBzYA+4EeFKYvyUD5OUAB8GLA+BvmGVda/QXmub0oNPixARgF1GTw/FxgEtpPB+K0E+1jumPudOBdoBsZwqcoggx1zM3krFxImmMnv7axVZp2p2mvB5qBccDLwBrgVaAImB2xAT9ORRZfDjyPNjXeyK6OWDsZ+BfYHjC+CDiE8oQhvv7VwEzgCZQa+PG+aY+Esc0FtgGXmXYN8AowgnSjWIm4GgusBx5BB7wSaAWO8c2Nc1ZJc+zk9yhLqG1s84C/gQmoSvFjeKj6fVEF1AF3+frWA6+jjWwOWFcMVABfEJy0foIMeCZKcBuAO1BVvRGY71jzoWkvzEj75DAOeAzlRhcAn1vjp/h+n4s8WDvyhD+Z/lpgE4oKC5HhQfZnlQuOnfy6PNtvwG5f30GUk9nYH6x/Gr4DVlh9rSg/nBSybiR6k6JywWUoNN8J3ICS3VZEzCHH/G4zf1SU4gljPnrBl5NuaAA/+H7PMe0KUoYGOo/b0L7sK4ZszioXHDv59RtbMUoU20gVBy8AxwG7gLXI9Z8UoZQLbchN22gHTghZV2raXyPktwP1KEw/jMLTFehND8IvRHvnvYgL/98zZmyzY6whQt45pn0tYh6koszbjrHdyDBPA4aZvmzPKlccp/HrD6MTkPHt9PU9iN6KBaiUvQWRugWFv0zv4roC+g8SXhF6ldGxGTxjn+/3tcAfEfOLiK686oESq68CmIYuQPdaY20R8jxZHRHzIGVEQR6nE3mOEuRJsj2rXHGcxq/f2Lw36WNr0XPmrwQ4D7gcufhW4AxLgaTh5R6lobP0tWM1CjdlwM24czUPhWg/eyLk1jv6ZiFjawDeiVhvo8u0I9H1QBi6TVsGfOsYP9maB9mdVS44dvLr9yp2cWCjC1U3cxHRJ5L7BLsTETQmZM7FRp/PgDOBr1AuE7ZmDKrq2pJQsh/wqr2pGcz1Xvoqx9hoVEzswR01usj8rHLBsZNf29h6UMz3UG0W2Rhh2qhQFRe96I5pOCLYxvlAI8pfpiDSliKPfX+IXC93CqqCc4V1KHVYhipTG/5q9GnTLqVv7jUEeZhC4Clff7ZnlQuOnfx6YXQo2nwbIsPDJlSdbkf5SQEq2Sei72BvBjwsSTShy8QpwDe+/gqgBYWRGlK5TSPKT6YZXd9zyLwIFSzNOdE4GLtQTvU48lzN6LNgKeL0AKl7x23AA8DtyKM0oquJqeiOcit9L9/jnFXSHDv59TzbeOBo0kPoEnRnUolImm3mLUakuMrspNGE8ooZvr7R6I6uFxFk5zTeN9pVpGMYqtRaUIV1uPEk8hYtKEQuQjf/+4BHrbmLgauQQc5AiX8h8iw19K0E45xVkhwH8lswQP6frRZdXlaSXsD0FzcCD6E3cmtMWfmEpDgO5DebD9FHAmvRBfDdMeUUIVKbGDQ0G0lwHMrvQDG2HnRTvYN4/zxZjr7jLUxAp3xDEhyXE8LvQAmjg8gDDBTPNog8wH/9DK4ClAUeNgAAAABJRU5ErkJggg==\n",
"text/latex": [
"$\\displaystyle i \\sin{\\left(x \\right)} + \\cos{\\left(x \\right)}$"
],
"text/plain": [
"ⅈ⋅sin(x) + cos(x)"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"exp(I*x).expand(complex=True)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAH0AAAAVCAYAAABrJ+ESAAADSElEQVR4nO3aS2gdVRgH8F98tRIRpQvdKEVBjQ9SQxf1ValFEFRsxAeIYtxItz4WCi5uXbhRJKALK5ZU6loRsYoLo1VwIxpFXPhqfGJRofWFiLUuzgQvkzNnMrlncm/I/cNwLt9j5j/fd+Y735m5I51OxxBrC8f1m8AQlbgfx3BH7hPnTPqUQDJ1HE34n1Hon+qSzSfO9WNG7k1wi8DxHfxacHmhBZ/Nxfh+RNdTrE6ouXATzGFXhe4qXIPXEv43CZPwxZL8CKYj9r83o5cNj2C8uP53uKAln4fwKD6P6HqKVe6kz1Xo3ivGZxP+k/gFB0ryw+gsn9YiTGEG2/DWMvzvExL3Ba7GbEs+3yR0PcVqJdb0S7AF3+PVCptThUrwivQSMAiYFZ6+Yy36bCtsH4/oeo5Vzie9CvcW4x7VJG/ASXgpoluHO3E2/sDHwgwf9MnRCyaK8YOIrudYtZ30kwsSR/Fcwm5SIPlGRHcm9pVkB3EP3s7AcRCRSnrPsWq7vN+G0/A6vq2wWY/rhCbvr5JuBtuFmxkVlord2FjYj+cmPCCYEJqvz0ryLLEqJ31e/bar+6jbdiyU9t0Jm2txini52oU3cQh/4hPsxJNCFenUXH8+wnmm0M1GdHtrzrcSGMV5QlNc7gGyxKpc3r+0eAal8ENCdxEuF7rW/Qm7m/G36iYvhmfwALbW2E0LlaYbm4Qtz/PCpOjGXAMObWFceBhjpT1LrMpJ396QYApLaeCOx43CDD3S4Nw/FeNojd10RDYlJH2v5W3Z2sbCev5hSZ4tVm2t6etxl5DsPQm7rdggXq5S2FKMXzWnNvCoauKyxaqtpN+K04UGoqqBI3Si/+LliG5M/EneiKeL33U9xWrEhLDEflqSZ4tVW1u2hdKeegM3gh3C27pDEf3twlp0AF/jN5yL64VKsh9P5KHbCDuKg9Apw2X+bwJ/xoPL9FmHC4Xe4p8u/6yxaiPpY7hSfQO3GWeJr7uE7vp8XIorhJl8GO8Ke9F9mr0Vy4VNuLskO6c4CEEvJ32pPhfjRItLe9ZYjfTxe/pjeFi48YP9IrFKkDVW/fyePomPDBO+FGSN1Uq8e6/CWB+vvdqQNVbDf86sQQyTvgbxH5oLCrbEDeJSAAAAAElFTkSuQmCC\n",
"text/latex": [
"$\\displaystyle - \\frac{7}{5} + \\frac{11 i}{5}$"
],
"text/plain": [
" 7 11⋅ⅈ\n",
"- ─ + ────\n",
" 5 5 "
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"f = (3+5*I)/(1-2*I)\n",
"f.expand( complex = True )"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"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.9.6"
}
},
"nbformat": 4,
"nbformat_minor": 2
}