# Math Review with Matlab:

## Presentation on theme: "Math Review with Matlab:"— Presentation transcript:

Math Review with Matlab:
4/1/2017 Math Review with Matlab: Complex Numbers Complex Number Theory S. Awad, Ph.D. M. Corless, M.S.E.E. E.C.E. Department University of Michigan-Dearborn

Complex Number Theory General Complex Numbers
General Complex Numbers in Matlab Argand Diagrams Exponential Form Polar Form Polar Form in Matlab

Representing Complex Numbers
The conventional representation of a complex number z is the sum of a real part x and an imaginary part y Complex Real Imaginary i is the imaginary unit where: Conventional representation is also referred to as the rectangular form of a complex number

4/1/2017 Functional Notation In different applications, the imaginary unit may be represented as i or j and may be placed before or after the imaginary part In functional notation, it is sometimes convenient to write:

Matlab Complex Numbers
Matlab complex numbers consist of a real portion plus an imaginary portion For example, use Matlab to find the square root of -1 » sqrt(-1) ans = i Real Portion = 0 Imaginary Portion = -1

Entering Complex Numbers
Both the variables i and j in the Matlab workspace are reserved for representing imaginary numbers Placing i or j after a number defines it as imaginary Example: A complex number with real portion = 1 and imaginary portion = 2 can be entered in two ways: » z = 1+2i z = i » z = 1+2j OR

Real and Imag Commands The real and imag functions extract the real and imaginary portion of a complex number respectively Example: » z1= 2+4i z1 = i » z1_re = real(z1) z1_re = 2 » z1_im = imag(z1) z1_imag = 4

Argand Diagram A complex number can be represented as a Point P(x,y) in the xy-plane (Cartesian plane) This representation is called an Argand Diagram The xy-plane is often referred to as the Complex Plane or the z-plane Ordered Pair Notation

Feather Command The feather command draws complex numbers as arrows in the xy plane » z1=1+2j; » z2=3+3j; » z3=3+j; » feather(z1,'r'); » hold on » feather(z2,'b'); » feather(z3,'g'); » feather(z3,'k'); » ylabel('Imaginary'); » xlabel('Real');

Exponential Representation
Sometimes an exponential representation of a complex number is easier to manipulate than the rectangular sum of the real and imaginary part The Complex Exponential Function ez will be used to represent a complex number whose Taylor Series Expansion is: We can assume that ez will be valid for all z

Exponential Series If z = iq, purely imaginary, where q is real, the complex exponential function can be written using a Taylor Series Expansion: Which can be separated into real and imaginary components since i raised to even powers of n will be -1

Derivation of Euler’s Equation
Knowing that the Taylor Series Expansions for sine and cosine functions are: Through substitution, Euler’s Equation is derived:

Exponential Polar Form
Through Euler’s Equation we see that: This representation of a complex number is referred to as the Exponential Polar Form: Sometimes Polar Form is written using the shortened notation:

Plotting Polar Form Graphically depicting Euler’s Equation in the First Quadrant of an Argand Diagram we see: r refers to the radius from z to the origin, commonly called the Magnitude of z q is the Angle of z with respect to the Real Axis measured in degrees or radians

Magnitude Through use of the Pythagorean theorem, the Magnitude (radius) of a complex number always has the relationship: This relationship always holds true regardless of which quadrant of the Argand diagram that the number lies in The Magnitude of a complex number z=x+iy is denoted using Absolute Value notation

Angle The angle, q, of a complex number z denoted by:
Determining the angle of a complex number depends on the quadrant of the Argand diagram Measuring the angle counter-clockwise from the x-axis gives a positive q Measuring the angle clockwise from the x-axis gives a negative q Example: The angle of z=0+j can be represented in multiple ways

Angle of Quadrants I and IV

Angle of Quadrants II and III

Purely Real or Imaginary Numbers
Rectangular Rectangular Polar Polar Short Long Degrees Radians 1 = 1 + i0 = 1Ð0° = 1Ð0 -1 = -1 +i0 = 1Ð180° = 1Ðp j = 0 + i1 = 1Ð90° = 1Ðp/2 -j = 0 - i1 = 1Ð-90° = 1Ð-p/2

Abs and Angle Commands The abs command in Matlab returns the magnitude of a complex number The angle command returns the angle of a complex number in radians Remember that the conversion between radians and degrees is:

Polar Example Use Matlab to find the magnitude and angle of z=1+i

Entering Polar Form » z=2*exp(i*pi/2) z = 0.0000 + 2.0000i
Complex numbers can be directly entered into Matlab using the exponential polar form Example: Create a complex number z with a magnitude of 2 and an angle of p/2 radians » z=2*exp(i*pi/2) z = i

Polar Plotting » z1=3+3i; » compass(z1) » hold on » compass(4,-3)
Matlab’s compass(z) or compass(x,y) command can be used to draw complex numbers on a polar plot Note that z is a complex number in rectangular form » z1=3+3i; » compass(z1) » hold on » compass(4,-3) Angles are displayed in degrees

Plotting Example Example: Plot the following complex numbers by hand. Use Matlab’s compass function to verify your results.

Matlab Verification z(1) = 2; z(2) = 3*exp(i*60*(pi/180));
z(3) = -(8^0.5) + j*(8^0.5); z(4) = 4*exp(-i*pi/2); z(5) = 2.5*exp(-i*150*(pi/180)); z(6) = 2i; compass(z)

Polar Plot

Summary Representing complex numbers in rectangular, exponential, and polar forms Using Euler’s Equation to represent real and imaginary parts of complex numbers Determining magnitude and angles of complex numbers Graphing complex numbers using Argand Diagrams