Fall 2008Programming Development Techniques 1 Topic 12 Multiple Representations of Abstract Data – Complex Numbers Section 2.4.1.

Slides:



Advertisements
Similar presentations
TWO STEP EQUATIONS 1. SOLVE FOR X 2. DO THE ADDITION STEP FIRST
Advertisements

Copyright © 2011 Pearson, Inc. P.6 Complex Numbers.
1 Copyright © 2010, Elsevier Inc. All rights Reserved Fig 2.1 Chapter 2.
1 Chapter 40 - Physiology and Pathophysiology of Diuretic Action Copyright © 2013 Elsevier Inc. All rights reserved.
By D. Fisher Geometric Transformations. Reflection, Rotation, or Translation 1.
Factors, Primes & Composite Numbers
Chapters 1 & 2 Theorem & Postulate Review Answers
Business Transaction Management Software for Application Coordination 1 Business Processes and Coordination.
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
0 - 0.
ALGEBRAIC EXPRESSIONS
DIVIDING INTEGERS 1. IF THE SIGNS ARE THE SAME THE ANSWER IS POSITIVE 2. IF THE SIGNS ARE DIFFERENT THE ANSWER IS NEGATIVE.
MULTIPLYING MONOMIALS TIMES POLYNOMIALS (DISTRIBUTIVE PROPERTY)
ADDING INTEGERS 1. POS. + POS. = POS. 2. NEG. + NEG. = NEG. 3. POS. + NEG. OR NEG. + POS. SUBTRACT TAKE SIGN OF BIGGER ABSOLUTE VALUE.
MULTIPLICATION EQUATIONS 1. SOLVE FOR X 3. WHAT EVER YOU DO TO ONE SIDE YOU HAVE TO DO TO THE OTHER 2. DIVIDE BY THE NUMBER IN FRONT OF THE VARIABLE.
SUBTRACTING INTEGERS 1. CHANGE THE SUBTRACTION SIGN TO ADDITION
MULT. INTEGERS 1. IF THE SIGNS ARE THE SAME THE ANSWER IS POSITIVE 2. IF THE SIGNS ARE DIFFERENT THE ANSWER IS NEGATIVE.
Addition Facts
Around the World AdditionSubtraction MultiplicationDivision AdditionSubtraction MultiplicationDivision.
ZMQS ZMQS
HOW TO MULTIPLY FRACTIONS
Copyright 2012, 2008, 2004, 2000 Pearson Education, Inc.
ABC Technology Project
Chapter 15 Complex Numbers
EECS 20 Appendix B1 Complex Numbers Last time we Characterized linear discrete-time systems by their impulse response Formulated zero-input output response.
Slide 6-1 COMPLEX NUMBERS AND POLAR COORDINATES 8.1 Complex Numbers 8.2 Trigonometric Form for Complex Numbers Chapter 8.
Polar Form of Complex Numbers
Warm-up Divide the following using Long Division:
Introduction to Complex Numbers
© 2010 Pearson Education, Inc. All rights reserved
Key Points Two complex numbers can be multiplied by expressing each number in the form z = x + jy, then using distributivity and the rule j2 = -1 (i.e.,
Structure and Interpretation of Computer Programs* Section 2.4 – 2.5 Presenter: Xiang Zhang 05/04/ * Harold A., Gerald J. S., Julie S.. Structure.
Introduction Recall that the imaginary unit i is equal to. A fraction with i in the denominator does not have a rational denominator, since is not a rational.
Pre-Calculus Chapter 6 Additional Topics in Trigonometry.
MAT 205 F08 Chapter 12 Complex Numbers.
Math Review with Matlab:
§ 7.7 Complex Numbers.
© S Haughton more than 3?
Twenty Questions Subject: Twenty Questions
Linking Verb? Action Verb or. Question 1 Define the term: action verb.
Squares and Square Root WALK. Solve each problem REVIEW:
Created by Susan Neal $100 Fractions Addition Fractions Subtraction Fractions Multiplication Fractions Division General $200 $300 $400 $500 $100 $200.
SYSTEMS OF EQUATIONS.
8 2.
Past Tense Probe. Past Tense Probe Past Tense Probe – Practice 1.
Event 4: Mental Math 7th/8th grade Math Meet ‘11.
Addition 1’s to 20.
25 seconds left…...
Test B, 100 Subtraction Facts
11 = This is the fact family. You say: 8+3=11 and 3+8=11
Week 1.
Number bonds to 10,
We will resume in: 25 Minutes.
1 Unit 1 Kinematics Chapter 1 Day
One step equations Add Subtract Multiply Divide Addition X + 5 = -9 X = X = X = X = X = 2.
MA 1165: Special Assignment Completing the Square.
Complex Numbers S. Awad, Ph.D. M. Corless, M.S.E.E. E.C.E. Department University of Michigan-Dearborn Math Review with Matlab: Complex Math.
데이타를 여러방식으로 구현할 때 Multiple Representations 데이터 구현방식마다 꼬리표를 붙이고. 데이터 속내용 감추기 원리를 유지하면서. 예를 들어 complex number data 구현방안들을 생각해 보자 – complex number 만들기 make-from-real-imag:
11.2 Geometric Representations of Complex Numbers.
מבוא מורחב 1 Lecture #13. מבוא מורחב 2 Multiple representations of data.
Fall 2008Programming Development Techniques 1 Topic 13 Multiple Representations of Abstract Data – Tagged Data Section
Fall 2008Programming Development Techniques 1 Topic 5 Data Abstraction Note: This represents a change in order. We are skipping to chapter 2 without finishing.
Fall 2008Programming Development Techniques 1 Topic 14 Multiple Representations of Abstract Data – Data Directed Programming and Additivity Section
IMAGINARY NUMBERS AND DEMOIVRE’S THEOREM Dual 8.3.
Tagged Data Tag: a symbol in a data structure that identifies its type
Complex Numbers Real part Imaginary part
11.2 – Geometric Representation of Complex Numbers
Lecture 12: Message passing The Environment Model
Lecture 11: Multiple representations of abstract data Message passing Overloading Section 2.4, pages ,2.5.2 pages מבוא.
Presentation transcript:

Fall 2008Programming Development Techniques 1 Topic 12 Multiple Representations of Abstract Data – Complex Numbers Section 2.4.1

Fall 2008Programming Development Techniques 2 Multiple representations for abstract data Implementation of complex numbers as an example Illustrates how one representation can be better for one operation, but another representation might be better for another operation (Scheme already has complex numbers, but we'll pretend that it doesn't)

Fall 2008Programming Development Techniques 3 Complex numbers (math view) z = x + i y (rectangular form) = r e iα (polar form) x: real part of z y: imaginary part of z r: magnitude of z a: angle of z x Real y Imaginary r a Z

Fall 2008Programming Development Techniques 4 Complex number arithmetic Addition – addition of coordinates – add real parts and imaginary parts z 1 + z 2 = x 1 + iy 1 + x 2 + iy 2 = (x 1 + x 2 ) + i(y 1 +y 2 ) Multiplication – easier to think of in polar form z 1 * z 2 = r 1 e iα ¹ * r 2 e iα ² =(r 1 * r 2 )e i(α ¹ + α ² )

Fall 2008Programming Development Techniques 5 SO? There are two different representations of complex numbers. Some operations on complex numbers are easier to think of in terms of one operation and others in terms of the other representation. Yet all operations for manipulating complex numbers should be available no matter which representation is chosen. Want to have access to each part: real, imaginary, magnitude, angle no matter which representation is chosen.

Fall 2008Programming Development Techniques 6 Two representations Rectangular make-from-real-imag - constructor real-part – selector imag-part – selector Polar make-from-mag-ang – constructor magnitude – selector angle – selector Two different representations possible for the same number.

Fall 2008Programming Development Techniques 7 Addition ; adds together two complex numbers ; uses the representation of addition of coordinates ; in terms of real and imaginary parts (define (add-complex z1 z2) (make-from-real-imag (+ (real-part z1) (real-part z2)) (+ (imag-part z1) (imag-part z2))))

Fall 2008Programming Development Techniques 8 Subtraction ; subtract one complex number from another ; uses the representation of subtraction of ; coordinates in terms of real and ; imaginary parts (define (sub-complex z1 z2) (make-from-real-imag (- (real-part z1) (real-part z2)) (- (imag-part z1) (imag-part z2))))

Fall 2008Programming Development Techniques 9 Multiplication ; multiplies two complex numbers ; uses the representation as polar form ; in terms of magnitude and angle (define (mul-complex z1 z2) (make-from-mag-ang (* (magnitude z1) (magnitude z2)) (+ (angle z1) (angle z2))))

Fall 2008Programming Development Techniques 10 Division ; divides one complex number from another ; uses the representation as polar form ; in terms of magnitude and angle (define (div-complex z1 z2) (make-from-mag-ang (/ (magnitude z1) (magnitude z2)) (- (angle z1) (angle z2))))

Fall 2008Programming Development Techniques 11 Choose a representation We must implement constructors and selectors in terms of primitive numbers and primitive list structure. Which representation should we use?? Rectangular form (real part, imaginary part – good for addition and subtraction) Polar form (magnitude and angle – good for multiplication and division) Either representation OK as long as we can select out all of the pieces we need – real, imaginary, magnitude, angle

Fall 2008Programming Development Techniques 12 Rectangular Representation ;; lower level implementation ; RECTANGULAR FORM REPRESENTATION ; takes a real and imaginary part and ; creates a complex number represented ; in rectangular form (define (make-from-real-imag x y) (cons x y))

Fall 2008Programming Development Techniques 13 Rectangular Representation (cont) ; given an imaginary number in ; rectangular form ; returns the real part (define (real-part z) (car z)) ; given an imaginary number in ; rectangular form ; returns the imaginary part (define (imag-part z) (cdr z))

Fall 2008Programming Development Techniques 14 Rectangular Representation (cont) ; given an imaginary number in rectangular form ; return the magnitude (using trigonomic rels) (define (magnitude z) (sqrt (+ (square (real-part z)) (square (imag-part z))))) ; given an imaginary number in rectangular form ; return the angle (using trigonomic rels) (define (angle z) (atan (imag-part z) (real-part z)))

Fall 2008Programming Development Techniques 15 Rectangular Representation (cont) ; takes a magnigude and an angle and ; creates a complex number ; represented in rectangular form (define (make-from-mag-ang r a) (make-from-real-mag (* r (cos a)) (* r (sin a))))

Fall 2008Programming Development Techniques 16 Polar representation ;; lower level implementation ; POLAR FORM REPRESENTATION ; takes a magnigude and an angle and ; creates a complex number represented ; in polar form (define (make-from-mag-ang r a) (cons r a))

Fall 2008Programming Development Techniques 17 Polar Representation (cont) ; given an imaginary number in ; polar form ; return the magnitude (define (magnitude z) (car z)) ; given an imaginary number in ; rectangular form ; return the angle (define (angle z) (cdr z))

Fall 2008Programming Development Techniques 18 Polar Representation (cont) ; given an imaginary number in ; polar form ; returns the real part ; (using trignomic rels) (define (real-part z) (* (magnitude z) (cos (angle z)))) ; given an imaginary number in ; polar form ; returns the imaginary part ; (using trigonomic rels) (define (imag-part z) (* (magnitude z) (sin (angle z))))

Fall 2008Programming Development Techniques 19 Polar Representation (cont) ; takes a real and imaginary part and ; creates a complex number represented ; in polar form (harder) (define (make-from-real-imag x y) (make-from-mag-ang (sqrt (+ (square x) (square y))) (atan y x)))

Fall 2008Programming Development Techniques 20 Which Representation? Note – either representation will work fine. Notice that some of the selectors/constructors are easier with one representation over the other But, no matter which is used, our basic operations will still work.