Upload
brianne-flowers
View
215
Download
1
Embed Size (px)
Citation preview
EE 3561_Unit_1 (c)Al-Dhaifallah 1435 1
EE 3561 : - Computational Methods in Electrical Engineering
Unit 1: Introduction to Computational Methods and Taylor Series
Lectures 1-3:
Mujahed Al-Dhaifallah (Term 351)
EE 3561_Unit_1 (c)Al-Dhaifallah 1435 2
Mujahed Al-Dhaifallahالله ضيف آل مجاهد
Office Hours Office Hours: SMT, 1:30 – 2:30 PM, by appointment
Office: Dean Office. Tel: 7842983 Email:
http://faculty.sau.edu.sa/m.aldhaifallah
Prerequisites Successful completion of Math 1070,
Math2040, CS1090
EE 3561_Unit_1 (c)Al-Dhaifallah 1435 3
Course Description EE 3561 is a course on
Introduction to computational methods using computer packages, e.g. Matlab, Mathcad or IMSL.
Solution of non-linear equations. Solution of large systems of linear equations. Interpolation. Function approximation. Numerical differentiation and integration. Solution of the initial value problem of ordinary
differential equations. Applications on Electrical Engineering.
EE 3561_Unit_1 (c)Al-Dhaifallah 1435 4
Textbooks “Numerical Methods for Engineers”.
By Steven C. Chapra and Raymond P. Canale
EE 3561_Unit_1 (c)Al-Dhaifallah 1435 5
Attendance Regular lecture attendance is required.
There will be part of the grade on attendance
EE 3561_Unit_1 (c)Al-Dhaifallah 1435 6
Student Evaluation
Exam 1 10Exam 2 10Computer Work 5Quizzes 5HW 5Attendance 5Final Exams 60Total 100
EE 3561_Unit_1 (c)Al-Dhaifallah 1435 7
Quizzes Announced After each HW. From HW material
EE 3561_Unit_1 (c)Al-Dhaifallah 1435 8
Assignment Requirements
Late assignments will not be accepted. assignments are due at the beginning of
lecture. Sloppy or disorganized work will adversely
affect your grade.
EE 3561_Unit_1 (c)Al-Dhaifallah 1435 9
Exams Attendance is mandatory. Make-up exam are not given unless
permission is obtained prior to exam day from the instructor
a valid, documented emergency has arisen
EE 3561_Unit_1 (c)Al-Dhaifallah 1435 10
Academic Dishonesty
cheating fabrication falsification multiple submissions plagiarism complicity
EE 3561_Unit_1 (c)Al-Dhaifallah 1435 11
EE 3561_Unit_1 (c)Al-Dhaifallah 1435 12
Rules and RegulationsNo make up quizzes
DN grade --- (25%) 8 unexcused absences
Homework Assignments are due to the beginning of the lectures.
Absence is not an excuse for not submitting the Homework.
Late submission may not be accepted
EE 3561_Unit_1 (c)Al-Dhaifallah 1435 13
Lecture 1Introduction to
Computational Methods
What are Computational METHODS? Why do we need them? Topics covered in EE3561.
Reading Assignment: pages 3-10 of text book
EE 3561_Unit_1 (c)Al-Dhaifallah 1435 14
Analytical Solutions Analytical methods give exact solutions Example: Analytical method to evaluate the integral
Numerical methods are mathematical procedures to calculate approximate solution
(Trapezoid Method)
3
1
3
0
3
1
3
1
0
31
0
2 x
dxx
2
1)1()0(
2
01 221
0
2
dxx
EE 3561_Unit_1 (c)Al-Dhaifallah 1435 15
Computational Methods
Computational Methods: Algorithms that are used to obtain approximate
solutions of a mathematical problem.
Why do we need them? 1. No analytical solution exists,
2. An analytical solution is difficult to obtain or not practical.
EE 3561_Unit_1 (c)Al-Dhaifallah 1435 16
What do we need
Basic Needs in the Computational Methods: Practical: can be computed in a reasonable amount of time. Accurate:
Good approximate to the true value Information about the approximation
error (Bounds, error order,… )
EE 3561_Unit_1 (c)Al-Dhaifallah 1435 17
Outlines of the Course Taylor Theorem Number
Representation Solution of nonlinear
Equations Interpolation Numerical
Differentiation Numerical Integration
Solution of linear Equations
Least Squares curve fitting
Solution of ordinary differential equations
EE 3561_Unit_1 (c)Al-Dhaifallah 1435 18
Solution of Nonlinear Equations Some simple equations can be solved analytically
Many other equations have no analytical solution
31
)1(2
)3)(1(444 :solution Analytic
034
2
2
xandx
roots
xx
solution analytic No052 29
xex
xx
EE 3561_Unit_1 (c)Al-Dhaifallah 1435 19
Methods for solving Nonlinear Equations
o Bisection Methodo Newton-Raphson Methodo Secant Method
EE 3561_Unit_1 (c)Al-Dhaifallah 1435 20
Solution of Systems ofLinear Equations
unknowns? 1000 in equations 1000
have weif do What to
123,2
523,3
asit solve can We
52
3
12
2221
21
21
xx
xxxx
xx
xx
EE 3561_Unit_1 (c)Al-Dhaifallah 1435 21
Cramer’s Rule is not practical
compute. toyears 10 than more needscomputer super A
needed. are tionsmultiplica102.3 system, 30by 30 a solve To
tions.multiplica
1)N!1)(N(N need weunknowns Nin equations N solve To
problems. largefor practicalnot is Rule sCramer'But
2
21
11
51
31
,1
21
11
25
13
system thesolve toused becan Rule sCramer'
20
35
21
xx
EE 3561_Unit_1 (c)Al-Dhaifallah 1435 22
Methods for solving Systems of Linear Equations
o Naive Gaussian Eliminationo Gaussian Elimination with Scaled
Partial pivoting
EE 3561_Unit_1 (c)Al-Dhaifallah 1435 23
Curve Fitting Given a set of data
Select a curve that best fit the data. One choice is find the curve so that the
sum of the square of the error is minimized.
x 0 1 2
y 0.5 10.3 21.3
EE 3561_Unit_1 (c)Al-Dhaifallah 1435 24
Interpolation Given a set of data
find a polynomial P(x) whose graph passes through all tabulated points.
xi 0 1 2
yi 0.5 10.3 15.3
tablein the is)( iii xifxPy
EE 3561_Unit_1 (c)Al-Dhaifallah 1435 25
Methods for Curve Fitting o Least Squares
o Linear Regressiono Nonlinear least Squares Problems
o Interpolationo Newton polynomial interpolationo Lagrange interpolation
EE 3561_Unit_1 (c)Al-Dhaifallah 1435 26
Integration Some functions can be integrated analytically
?
solutions analytical no have functionsmany But
dxe
xxdx
ax
0
3
1
23
1
2
42
1
2
9
2
1
EE 3561_Unit_1 (c)Al-Dhaifallah 1435 27
Methods for Numerical Integration
o Upper and Lower Sumso Trapezoid Methodo Romberg Methodo Gauss Quadrature
EE 3561_Unit_1 (c)Al-Dhaifallah 1435 28
Solution of Ordinary Differential Equations
only cases special
for available are solutions Analytical *
equations thesatisfies that function a is
0)0(;1)0(
0)(3)(3)(
equation aldifferenti theosolution tA
x(t)
xx
txtxtx
EE 3561_Unit_1 (c)Al-Dhaifallah 1435 29
Summary Computational
Methods: Algorithms that are
used to obtain numerical solution of a mathematical problem.
We need them when No analytical solution
exist or it is difficult to obtain.
Solution of nonlinear Equations Solution of linear Equations Curve fitting
Least Squares Interpolation
Numerical Integration Numerical Differentiation Solution of ordinary differential
equations
Topics Covered in the Course
EE 3561_Unit_1 (c)Al-Dhaifallah 1435 30
Number Representation Normalized Floating Point Representation Significant Digits Accuracy and Precision Rounding and Chopping
Reading assignment: Chapter 2
Lecture 2 Number Representation and
accuracy
EE 3561_Unit_1 (c)Al-Dhaifallah 1435 31
Representing Real Numbers You are familiar with the decimal system
Decimal System Base =10 , Digits(0,1,…9) Standard Representations
21012 10510410210110345.312
part part
fraction integralsign
54.213
EE 3561_Unit_1 (c)Al-Dhaifallah 1435 32
Normalized Floating Point Representation Normalized Floating Point Representation
No integral part, Advantage Efficient in representing very small or very large numbers
integer:,0
exponent mantissa sign
10.0
1
4321
nd
dddd n
EE 3561_Unit_1 (c)Al-Dhaifallah 1435 33
Binary System
Binary System Base=2, Digits{0,1}
exponent mantissasign
21.0 432nbbb
10 11 bb
1010321
2 )625.0()212021()101.0(
EE 3561_Unit_1 (c)Al-Dhaifallah 1435 34
7-Bit Representation(sign: 1 bit, Mantissa 3bits,exponent 3 bits)
EE 3561_Unit_1 (c)Al-Dhaifallah 1435 35
Fact Number that have finite expansion in one numbering
system may have an infinite expansion in another numbering system
You can never represent 0.1 exactly in any computer
210 ...)011000001100110.0()1.0(
EE 3561_Unit_1 (c)Al-Dhaifallah 1435 36
Representation Hypothetical Machine (real computers use ≥ 23 bit
mantissa)
Example:
If a machine has 5 bits representation distributed as follows
Mantissa 2 bits exponent 2 bit sign 1 bit
Possible machine numbers
(0.25=00001) (0.375= 01111) (1.5=00111)
EE 3561_Unit_1 (c)Al-Dhaifallah 1435 37
Representation
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2-1
-0.8
-0.6
-0.4
-0.2
0
0.2
0.4
0.6
0.8
1
Gap near zero
EE 3561_Unit_1 (c)Al-Dhaifallah 1435 38
Remarks
Numbers that can be exactly represented are called machine numbers
Difference between machine numbers is not uniform. So, sum of machine numbers is not necessarily a machine number
0.25 + .375 =0.625 (not a machine number)
EE 3561_Unit_1 (c)Al-Dhaifallah 1435 39
Significant Digits Significant digits are those digits that can be
used with confidence.
0 1 2 3 4
Length of green rectangle = 3.45significant
EE 3561_Unit_1 (c)Al-Dhaifallah 1435 40
Loss of Significance Mathematical operations may lead to
reducing the number of significant digits
0.123466 E+02 6 significant digits
─ 0.123445 E+02 6 significant digits
──────────────
0.000021E+02 2 significant digits
0. 210000E-02Subtracting nearly equal numbers causes loss of significance
EE 3561_Unit_1 (c)Al-Dhaifallah 1435 41
Accuracy and Precision Accuracy is related to closeness to the true value
Precision is related to the closeness to other estimated
values
EE 3561_Unit_1 (c)Al-Dhaifallah 1435 42
Better Precision
Better accuracy
Accuracy is related to closeness to the true value Precision is related to the closeness to other estimated values
Accuracy and Precision
EE 3561_Unit_1 (c)Al-Dhaifallah 1435 43
Rounding and Chopping Rounding: Replace the number by the nearest machine number Chopping: Throw all extra digits
0 1 2
True 1.1681
Rounding (1.2) Chopping (1.1)
EE 3561_Unit_1 (c)Al-Dhaifallah 1435 44
Error DefinitionsTrue Error
can be computed if the true value is known
100* valuetrue
ionapproximat valuetrue
Errorelative Percent RAbsolute
ionapproximat valuetrue
ErrorTrue Absolute
t
tE
EE 3561_Unit_1 (c)Al-Dhaifallah 1435 45
Error DefinitionsEstimated error
Used when the true value is not known
100*estimatecurrent
estimate prevoius estimatecurrent
Errorelative Percent RAbsolute Estimated
estimate prevoius estimatecurrent
ErrorAbsolute Estimated
a
aE
EE 3561_Unit_1 (c)Al-Dhaifallah 1435 46
Notation
We say the estimate is correct to n decimal digits if
We say the estimate is correct to n decimal digits rounded if
n10Error
n 102
1Error
EE 3561_Unit_1 (c)Al-Dhaifallah 1435 47
Summary Number Representation
Number that have finite expansion in one numbering system may
have an infinite expansion in another numbering system.
Normalized Floating Point Representation Efficient in representing very small or very large numbers Difference between machine numbers is not uniform Representation error depends on the number of bits used in the
mantissa.
EE 3561_Unit_1 (c)Al-Dhaifallah 1435 48
Summary Rounding Chopping Error Definitions:
Absolute true error True Percent relative error Estimated absolute error Estimated percent relative error