Complex numbers operations
Addition of complex numbers
Assume that `z_1` and `z_2` are two complex numbers such as,
`z_1= a_1 +b_1.i`
`z_2= a_2 +b_2.i`
Then,
`z_1 +z_2 = (a_1 + a_2) + (b_1 +b_2) * i`
This means that to add two complex numbers, just add their real parts and imaginary parts separately.
Example:
`z_1= 4 + i`
`z_2= -1 - 3*i`
`z_1 +z_2 = (4 -1) + (1 -3) * i = 3 -2*i`
Subtraction of complex numbers
Let `z_1` and `z_2` be two complex numbers such as,
`z_1= a_1 +b_1.i`
`z_2= a_2 +b_2.i`
Then,
`z_1 - z_2 = (a_1 - a_2) + (b_1 - b_2) * i`
So, to subtract two complex numbers, just subtract their real parts and their imaginary parts.
Example:
`z_1= i`
`z_2= -6 - 3*i`
`z_1 - z_2 = (0 -(-6)) + (1 -(-3)) * i = 6 + 4*i`
Multiplication of complex numbers
If `z_1` and `z_2` are two complex numbers such as then,
`z_1= a_1 +b_1.i`
`z_2= a_2 +b_2.i`
then,
`z_1 * z_2 = (a_1 +b_1*i) * (a_2 +b_2*i)`
`z_1 * z_2 = a_1 * a_2 +a_1*b_2*i + b_1*a_2*i + b_1*b_2*i^2`
We know that `i^2 = -1` , so,
`z_1 * z_2 = a_1*a_2-b_1*b_2 + i*(a_1*b_2+b_1*a_2)`
Exemple:
`z_1= 1 + 2*i`
`z_2= 5 - 4*i`
`z_1 * z_2 = (1 +2*i) * (5 -4*i)`
`z_1 * z_2 = 5 -4*i +(2*i)*5-2*i*4*i`
`z_1 * z_2 = 5 -4*i +10*i -8*i^2`
`z_1 * z_2 = 5 -4*i + 10*i + 8`
`z_1 * z_2 = 13 + 6*i`
Division of complex numbers
`z_1` and `z_2` are two complex numbers such as,
`z_1= a_1 +b_1.i`
`z_2= a_2 +b_2.i`
Then,
`\frac{z_1}{z_2} = \frac{a_1 +b_1*i}{a_2 +b_2*i}`
We use the conjugate of `z_2` to get rid of i in the denominator (See more details here Conjugate of a complex number):
`bar z_2 = a_2 -b_2.i`
We use this identity,
`z_2 * bar z_2 = (a_2 +b_2.i) * (a_2 -b_2.i) = a_2^2 + b_2^2`
`\frac{z_1}{z_2} = \frac{(a_1 +b_1.i)*bar z_2}{(a_2 +b_2.i)*bar z_2} = \frac{(a_1 +b_1.i)(a_2 -b_2.i)}{(a_2 +b_2.i)*(a_2 -b_2.i)} = \frac{(a_1*a_2 +b_1*b_2) + (b_1*a_2 - a_1*b_2)*i}{(a_2^2 +b_2^2)}`
Exemple:
`z_1= 3 -i`
`z_2= 2 - 5*i`
`\frac{z_1}{z_2} = \frac{3-i}{2-5*i}`
We multiply the numerator and the denominator by the conjugate of `z_2`:
`bar z_2 = 2+5*i`
`\frac{z_1}{z_2} = \frac{(3-i)*(2+5*i)}{(2-5*i)(2+5*i)} = \frac{6+15*i-2*i+5}{4+25} = \frac{11+13*i}{29} = \11/29+13/29*i`