Complex Number

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

COMPLEX NUMBERS IN MATLAB

Complex Numbers

 A number represented by 𝒛 = 𝑥 + 𝑖𝑦 is a complex number where 𝑥 and 𝑦


are two real numbers and 𝑖 = −1
 This representation is defined rectangular form
Imaginary Axis

( x, y )
z
 A complex number 𝒛 can be expressed as a vector
r
𝒛 = (𝑥, 𝑦) on a plane.

𝑥 = 𝑅𝑒 𝒛 Real Axis

𝑦 = 𝐼𝑚(𝒛)

1
In matlab, enter the following commands:
>> z=3-5i

>> real (z)


>> imag(z)
>> conj(z)

Complex Numbers in Polar Form

 The Polar Form represents an alternate way to express Complex numbers.

𝑟 = 𝒛 = 𝑎𝑏𝑠 𝒛 = 𝑥2 + 𝑦2 and

𝑦 Imaginary Axis

𝜃 = ∠ 𝒛 = 𝑎𝑟𝑔 𝒛 = tan−1
𝑥 ( x, y )
z
 If we have 𝑟 and 𝜃, then 𝑥 and 𝑦 r

are obtained by:



Real Axis

𝑥 = 𝑟𝑐𝑜𝑠𝜃 = 𝑅𝑒 𝒛
𝑦 = 𝑟𝑠𝑖𝑛𝜃 = 𝐼𝑚 𝒛

2
Euler’s Formula

 Euler's formula, determined by the Swiss Leonhard Euler, establishes a


mathematical relationship between trigonometric functions and the complex
exponential function.

𝑒 𝑖𝜃 = 𝑐𝑜𝑠𝜃 + 𝑖𝑠𝑖𝑛𝜃

 Therefore,

𝒛 = 𝑟𝑐𝑜𝑠𝜃 + 𝑖𝑟𝑠𝑖𝑛𝜃 = 𝑟(𝑐𝑜𝑠𝜃 + 𝑖𝑠𝑖𝑛𝜃)


𝒛 = 𝑟𝑒 𝑖𝜃

 Common engineering notation of the polar form:


𝑟𝑒 𝑖𝜃 ≡ 𝑟∠𝜃

Representation of Complex Numbers in MATLAB

 Complex numbers can be expressed both in rectangular and polar form

• The Rectangular form is described by a simple addition of a real and


imaginary part:
𝒛 = 𝑎 + 𝑖𝑏

 Note: Since i in electronics is often used to describe current, some


times j is used. In MATLAB, they are equivalent

 The Polar form can be described in terms of Euler’s formula;

𝒛 = 𝑟 ∗ exp(𝑖 ∗ 𝑡ℎ𝑒𝑡𝑎)

3
Representation of Complex Numbers in MATLAB

 Example: convert the following complex number to polar form.

𝒛 = 4 + 𝑖3
𝑟= 𝑥 2 + 𝑦 2 = 42 + 32 = 5
3
𝜃 = tan−1 = 36.87 ° 0.6435 𝑟𝑎𝑑
4
𝒛 = 5∠36.87 °

>> z=4+3i;
>> r=abs(z)
r=5
>> theta_rad=angle(z)
heta_rad=0.6435
>> theta_degree=theta_rad*(180/pi)
theta_degree=36.87
>> a=r*exp(i*theta_rad)
a=4.0000 + 3.0000i

Example:

 Example: Convert the following complex number to rectangular form.


𝒛 = 4𝑒 𝑖2

𝑥 = 4𝑐𝑜𝑠2 = −1.6646 𝑦 = 4𝑠𝑖𝑛2 = 3.6372

𝒛 = −1.6646 + 𝑖3.6372

 In MATLAB:
>> z=4*exp(2i)

z =

-1.6646 + 3.6372i

4
Operations on Complex Numbers: SUM

• The addition or subtraction of two complex number is a Vector Sum

𝒛1 = 𝑥1 + 𝑖𝑦1 𝒛2 = 𝑥2 + 𝑖𝑦2
Imaginary Axis

𝒛𝑠𝑢𝑚 = 𝒛1 + 𝒛2 z sum
z2

z1

= 𝑥1 + 𝑖𝑦1 + 𝑥2 + 𝑖𝑦2 z2
Real Axis

= 𝑥1 + 𝑥2 + 𝑖(𝑦1 + 𝑦2 )

Operations on Complex Numbers: Complex Conjugate

 Let 𝒛 = 𝑥 + 𝑖𝑦 = 𝑟𝑒 𝑖𝜃 ,

 We define the complex conjugate of 𝒛, denoted by 𝒛:

𝒛 = 𝑥 − 𝑖𝑦 = 𝑟𝑒 −𝑖𝜃

 Note: The product of 𝒛 and 𝒛 :


𝒛𝒛 = 𝑥 2 + 𝑦 2 = 𝒛 2 = 𝑟2
• Note(2):
𝒛 = 𝑟𝑒 −𝑖𝜃 = 𝑟(cos −𝜃 + isin −𝜃 = r(cos𝜃 − isin𝜃)

𝑒 𝑖𝜃 +𝑒 −𝑖𝜃 𝑒 𝑖𝜃 −𝑒 −𝑖𝜃
𝑐𝑜𝑠𝜃 = ; sin𝜃 =
2 2𝑖

10

5
Operations on Complex Numbers: Multiplication

 Multiplication in Rectangular Form:

𝒛1 = 𝑥1 + 𝑖𝑦1 ; 𝒛2 = 𝑥2 + 𝑖𝑦2
𝒛𝑝𝑟𝑜𝑑 = 𝑥1𝑥2 − 𝑦1 𝑦2 + 𝑖(𝑥1 𝑦2 + 𝑥2 𝑦1 )

 The operation require calculations that can be costly or cumbersome. If


we move the representation to Polar Form:

𝒛1 = 𝑟1 𝑒 𝑖𝜃1 ; 𝒛2 = 𝑟2 𝑒 𝑖𝜃2 ; 𝒛𝑝𝑟𝑜𝑑 = 𝒛1 𝒛2

= 𝑟1 𝑒 𝑖𝜃1 𝑟2 𝑒 𝑖𝜃2 = 𝑟1 𝑟2 𝑒 𝑖(𝜃1 +𝜃2)

𝒛𝑝𝑟𝑜𝑑 = 𝑥1 𝑥2 − 𝑦1 𝑦2 + 𝑖(𝑥1 𝑦2 + 𝑥2 𝑦1 )

11

Operations on Complex Numbers: Division

 Division in rectangular form:

𝑧1 𝑥1 + 𝑖𝑦1 𝑧1 𝑧2 𝑥1 𝑥2 + 𝑦1𝑦2 + 𝑖(𝑥2 𝑦1 − 𝑥1 𝑦2 )


= = =
𝑧2 𝑥2 + 𝑖𝑦2 𝑧2 𝑧2 𝑥22 + 𝑦22

• Again, this operation is not suited to the rectangular form, where it can be costly
or cumbersome. If we move to the polar representation
𝒛1 = 𝑟1 𝑒 𝑖𝜃1 ; 𝒛2 = 𝑟2 𝑒 𝑖𝜃2 ;

𝑧1 𝑟 𝑒 𝑖𝜃1 𝑟
𝒛𝑑𝑖𝑣 = = 𝑟1 𝑒 𝑖𝜃2 = 𝑟1 𝑒 𝑖(𝜃1 −𝜃2 )
𝑧2 2 2

12

6
Application of Complex numbers (2)

 Determine the roots of 𝑠 4 + 1 = 0. In MATLAB: >>roots([1 0 0 0 1])

𝑠 4 = −1 = 1𝑒 𝑖(𝜋+2𝜋𝑛)
𝜋 2𝜋
𝑠 = 𝑒 𝑖( 4 +𝑛 4 )

𝜋
𝑠1 = 𝑒 𝑖 4 = 0.7071 + 𝑖0.7071
3𝜋
𝑠2 = 𝑒 𝑖 4 = −0.7071 + 𝑖0.7071
5𝜋
𝑠3 = 𝑒 𝑖 4 = −0.7071 − 𝑖0.7071
7𝜋
𝑠4 = 𝑒 𝑖 4 = 0.7071 − 𝑖0.7071

13

Using DeMoivre's Theorem with the power being a


rational exponent (and therefore meaning a root), we can
develop a method for finding complex roots. This leads
to the following formula:

    2 k     2 k  
z k  n r  cos    i sin  
  n   n 
w here k  0 , 1, 2 ,  , n  1

14

7
Find the 4th root of z  81 cos80  i sin80 

Find the three cube roots of z = -2+2i

15

1. Find the 4th root of 81 r  4 81  3


2. Divide theta by 4 to get 80
  20
the first angle. 4

3. Divide a full circle (360) by 360


 90 between answers
4 to find out how far apart 4
the answers are.

4. List the 4 answers. z1  3  cos 20  i sin 20 

• The only thing that changes z2  3  cos  20  90   i sin  20  90    3  cos110  i sin110 


is the angle. z3  3  cos 110  90   i sin 110  90    3  cos 200  i sin 200 
• The number of answers z4  3  cos  200  90   i sin  200  90    3  cos 290  i sin 290 
equals the number of roots.

16

8
Find the 4th root of z  81 cos80  i sin80 

17

 
1
8 cos135  isin135
1
2  2i 3
 o o 3

1  3  135  360k 
1

8 2  cos
135 360k
 isin 
   3 3 
For k = 0, 1, and 2, the roots are:


2 cos 45o  i sin 45o 

2 cos 165 o  i sin 165 o 
 2 cos 285 o
 i sin 285 
o

18

9
Find the three cube roots of z = -2+2i

ENSC180 – Introduction to Engineering Analysis Tools 19

Reference:
ENSC 180 – Introduction to Engineering Analysis Tools
School of Engineering Science
Simon Fraser University
Burnaby, BC, Canada
http://www.sfu.ca/outlines.html?2019/spring/ensc/180/d100

20

10
Mathematical Functions
Elementary Functions
cos(x) Cosine abs(x) Absolute value
sin(x) Sine ceil(x) Round towards + Inf
tan(x) Tangent floor(x) Round towards - Inf
acos(x) Arc cosine round(x) Round
asin(x) Arc sine rem(x) Remainder after division
atan(x) Arc tangent angle(x) Phase
exp(x) Exponential conj(x) Complex Conjugate
sqrt(x) Square root imag (x) imaginary
Natural
log(x) real (x) Real number
Logarithm
Common
log10(x) primes (x) Prime Number
Logarithm
21

11

You might also like