File

advertisement
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
1
Mujahed Al-Dhaifallah
‫مجاهد آل ضيف هللا‬

Office Hours





Office Hours: SMT, 1:30 – 2:30 PM,
by appointment
Office: Dean Office.
Tel:
7842983
Email:
 muja2007hed@gmail.com
 http://faculty.sau.edu.sa/m.aldhaifallah
EE 3561_Unit_1
(c)Al-Dhaifallah 1435
2
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
Exam 2
Computer Work
Quizzes
HW
Attendance
Final Exams
Total
EE 3561_Unit_1
(c)Al-Dhaifallah 1435
10
10
5
5
5
5
60
100
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
Rules and Regulations
No 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
12
Lecture 1
Introduction 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
13
Analytical Solutions


Analytical methods give exact solutions
Example: Analytical method to evaluate the integral
3 1
x
 0 x dx  3
1

2
0
1 0 1
  
3 3 3
Numerical methods are mathematical procedures to
calculate approximate solution
1 0
1
2
2
 0 x dx  2 (0)  (1)   2
1
2
EE 3561_Unit_1
(c)Al-Dhaifallah 1435
(Trapezoid Method)
14
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
15
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
16
Outlines of the Course






Taylor Theorem
Number
Representation
Solution of nonlinear
Equations
Interpolation
Numerical
Differentiation
Numerical Integration
EE 3561_Unit_1



Solution of linear
Equations
Least Squares curve
fitting
Solution of ordinary
differential equations
(c)Al-Dhaifallah 1435
17
Solution of Nonlinear Equations

Some simple equations can be solved analytically
x2  4 x  3  0
Analytic solution : roots 
4
4 2  4(1)( 3)
2(1)
x  1 and x  3

Many other equations have no analytical solution
x 9  2 x 2  5  0

 No analytic solution
x

xe

EE 3561_Unit_1
(c)Al-Dhaifallah 1435
18
Methods for solving Nonlinear
Equations
o
o
o
Bisection Method
Newton-Raphson Method
Secant Method
EE 3561_Unit_1
(c)Al-Dhaifallah 1435
19
Solution of Systems of
Linear Equations
x1  x2  3
x1  2 x2  5
We can solve it as
x1  3  x2 ,
3  x2  2 x 2  5
 x2  2, x1  3  2  1
What to do if we have
1000 equations in 1000 unknowns?
EE 3561_Unit_1
(c)Al-Dhaifallah 1435
20
Cramer’s Rule is not practical
Cramer' s Rule can be used to solve the system
3
5
x1 
1
1
1
2
 1,
1
2
1
1
x2 
1
1
3
5
2
1
2
But Cramer' s Rule is not practical for large problems.
To solve N equations in N unknowns we need (N  1)(N  1)N!
multiplica tions.
To solve a 30 by 30 system, 2.3 1035 multiplica tions are needed.
A super computer needs more than 10 20 years to compute.
EE 3561_Unit_1
(c)Al-Dhaifallah 1435
21
Methods for solving Systems of Linear
Equations
o
o
Naive Gaussian Elimination
Gaussian Elimination with Scaled
Partial pivoting
EE 3561_Unit_1
(c)Al-Dhaifallah 1435
22
Curve Fitting

Given a set of data
x
0
1
2
y
0.5
10.3
21.3
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.

EE 3561_Unit_1
(c)Al-Dhaifallah 1435
23
Interpolation


Given a set of data
xi
0
1
2
yi
0.5
10.3
15.3
find a polynomial P(x) whose graph
passes through all tabulated points.
yi  P( xi ) if xi is in the table
EE 3561_Unit_1
(c)Al-Dhaifallah 1435
24
Methods for Curve Fitting
o
Least Squares
o
o
o
Linear Regression
Nonlinear least Squares Problems
Interpolation
o
o
Newton polynomial interpolation
Lagrange interpolation
EE 3561_Unit_1
(c)Al-Dhaifallah 1435
25
Integration

Some functions can be integrated analytically
3
3
1 2
9 1
 xdx  2 x  2  2  4
1
1
But many functions have no analytical solutions
a
e
x2
dx  ?
0
EE 3561_Unit_1
(c)Al-Dhaifallah 1435
26
Methods for Numerical Integration
o
o
o
o
Upper and Lower Sums
Trapezoid Method
Romberg Method
Gauss Quadrature
EE 3561_Unit_1
(c)Al-Dhaifallah 1435
27
Solution of Ordinary Differential Equations
A solution t o the differenti al equation
x(t )  3 x (t )  3 x(t )  0
x (0)  1; x(0)  0
is a function x(t) that satisfies the equations
* Analytical solutions are available for
special cases only
EE 3561_Unit_1
(c)Al-Dhaifallah 1435
28
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.
Topics Covered in the Course








EE 3561_Unit_1
Solution of nonlinear Equations
Solution of linear Equations
Curve fitting
Least Squares
Interpolation
Numerical Integration
Numerical Differentiation
Solution of ordinary differential
equations
(c)Al-Dhaifallah 1435
29
Lecture 2
Number Representation and accuracy
 Number Representation
 Normalized Floating Point Representation



Significant Digits
Accuracy and Precision
Rounding and Chopping
 Reading assignment:
EE 3561_Unit_1
Chapter 2
(c)Al-Dhaifallah 1435
30
Representing Real Numbers

You are familiar with the decimal system
312.45  3 10 2  1101  2 100  4 10 1  5 10 2


Decimal System Base =10 , Digits(0,1,…9)
Standard Representations
 3 1 2 . 4 5
sign integral
fraction
part
part
EE 3561_Unit_1
(c)Al-Dhaifallah 1435
31
Normalized Floating Point
Representation

Normalized Floating Point Representation
 0. d1 d 2 d 3 d 4  10n
sign
mantissa
d1  0,
n : integer

No integral part,

Advantage
EE 3561_Unit_1
exponent
Efficient in representing very small or very large numbers
(c)Al-Dhaifallah 1435
32
Binary System

Binary System
Base=2, Digits{0,1}
 0. 1 b2 b3 b4  2 n
sign
mantissa
exponent
b1  0  b1  1
1
2
3
(0.101) 2  (1 2  0  2  1 2 )10  (0.625)10
EE 3561_Unit_1
(c)Al-Dhaifallah 1435
33
7-Bit Representation
(sign: 1 bit, Mantissa 3bits,exponent 3 bits)
EE 3561_Unit_1
(c)Al-Dhaifallah 1435
34
Fact

Number that have finite expansion in one numbering
system may have an infinite expansion in another
numbering system
(0.1)10  (0.000110011001100...)2

You can never represent 0.1 exactly in any computer
EE 3561_Unit_1
(c)Al-Dhaifallah 1435
35
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)
EE 3561_Unit_1
(0.375= 01111) (1.5=00111)
(c)Al-Dhaifallah 1435
36
1
Representation
0.8
Gap near zero
0.6
0.4
0.2
0
-0.2
-0.4
-0.6
-0.8
-1
0
0.2
EE 3561_Unit_1
0.4
0.6
0.8
1 1435 1.2
(c)Al-Dhaifallah
1.4
1.6
1.8
2
37
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
38
Significant Digits

Significant digits are those digits that can be
used with confidence.
0
1
2
3
Length of green rectangle =
4
3.45
significant
EE 3561_Unit_1
(c)Al-Dhaifallah 1435
39
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-02
Subtracting nearly equal numbers causes loss of significance
EE 3561_Unit_1
(c)Al-Dhaifallah 1435
40
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
41
Accuracy and Precision
Better
Precision
Accuracy is
related to
closeness to the
true value
Precision is
related to the
closeness to
other estimated
values
Better
accuracy
EE 3561_Unit_1
(c)Al-Dhaifallah 1435
42
Rounding and Chopping


Rounding: Replace the number by the nearest
machine number
Chopping: Throw all extra digits
True 1.1681
0
1
Rounding
EE 3561_Unit_1
2
(1.2)
(c)Al-Dhaifallah 1435
Chopping (1.1)
43
Error Definitions
True Error
can be computed if the true value is known
Absolute True Error
Et  true value  approximat ion
Absolute Percent R elative Error
true value  approximat ion
t 
* 100
true value
EE 3561_Unit_1
(c)Al-Dhaifallah 1435
44
Error Definitions
Estimated error
Used when the true value is not known
Estimated Absolute Error
Ea  current estimate  prevoius estimate
Estimated Absolute Percent R elative Error
current estimate  prevoius estimate
a 
* 100
current estimate
EE 3561_Unit_1
(c)Al-Dhaifallah 1435
45
Notation
We say the estimate is correct to n decimal
digits if
n
Error  10
We say the estimate is correct to n decimal
digits rounded if
1
Error 
EE 3561_Unit_1
(c)Al-Dhaifallah 1435
2
 10
n
46
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
47
Summary
Rounding
Chopping
 Error Definitions:





Absolute true error
True Percent relative error
Estimated absolute error
Estimated percent relative error
EE 3561_Unit_1
(c)Al-Dhaifallah 1435
48
Download