Finding out that many familiar programmers do not remember complex numbers or remember them very badly, I decided to make a small cheat sheet using formulas.
')
And students can learn something new;) // Anyone interested interested under cat. So, this complex numbers are numbers that can be written as
x + i y
Where x, y are real numbers (that is, numbers that are familiar to everyone), and i is a number for which equality is fulfilled
i 2 = - 1
By the way, -i squared also gives -1. So the statement that if the discriminant is negative, then there is no root is a lie. Or rather, it is performed on a set of real numbers.
Ie we can write:
z = x + y i
x is called the real part, y is the imaginary.
This is an algebraic form of a complex number.
There is also a trigonometric form for recording a complex number z:
z = r ( c o s ϕ + i s i n ϕ )
With the introduction, perhaps, everything.
We turn to the most interesting - operations on complex numbers! To begin, consider addition.
We have two such complex numbers:
z1=1+2i,z2=3+5i
How to fold them? Very simple: add up the real and imaginary parts. We get the number:
z3=4+7i
It's simple, isn't it? Subtraction is the same as adding. You just need to subtract from the real part of 1 number the real part of 2 numbers, and then do the same with the imaginary part. Get the number
z3=−2−3i
Multiplication is done like this:
z3.x=z1.x∗z2.x−z1.y∗z2.y
z3.y=z1.x∗z2.y+z1.y∗z2.x
Let me remind you, x is the real part, y is imaginary. The division is done like this:
z3.x=(z1.x∗z2.x+z1.y∗z2.y)/(z2.x∗z2.x+z2.y∗z2.y)
z 3. y = ( z 1. y ∗ z 2. x - z 1 x ∗ z 2. y ) / ( z 2. x ∗ z 2. x + z 2. y ∗ z 2. y )
By the way, support for complex numbers is in the standard Python library:
z1=1+2j z2=3+5j z3=z1+z2 print(z3) #4+7i
Instead of i, j is used. By the way, this is because Python adopted the convention of electrical engineers who have letter i stands for electric current. Ask your questions, if any, in the comments. I hope you learned something new.
UPD: In the comments asked to talk about the practical application. So complex numbers have found wide practical application in aviation. (wing lift) and electricity. As you can see, a very necessary thing;)