introduction, foundations - wordpress.com · introduction, foundations ... textbook and course...

19
INTRODUCTION, FOUNDATIONS ELM1222 Numerical Analysis 1 Some of the contents are adopted from Laurene V. Fausett, Applied Numerical Analysis using MATLAB. Prentice Hall Inc., 1999 ELM1222 Numerical Analysis | Dr Muharrem Mercimek

Upload: dokhanh

Post on 10-May-2018

223 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: INTRODUCTION, FOUNDATIONS - WordPress.com · INTRODUCTION, FOUNDATIONS ... Textbook and course Materials Main Text Book: ... 5 TextLU Factorization book Ch6 6 Eigenvalues,

INTRODUCTION, FOUNDATIONS

ELM1222 Numerical Analysis

1

Some of the contents are adopted from

Laurene V. Fausett, Applied Numerical Analysis using MATLAB. Prentice Hall Inc., 1999

ELM1222 Numerical Analysis | Dr Muharrem Mercimek

Page 2: INTRODUCTION, FOUNDATIONS - WordPress.com · INTRODUCTION, FOUNDATIONS ... Textbook and course Materials Main Text Book: ... 5 TextLU Factorization book Ch6 6 Eigenvalues,

Today’s lecture

2

• Information about the course

• What is numerical analysis?

• Applied Problems

• Numerical Techniques

• Analysis

ELM1222 Numerical Analysis | Dr Muharrem Mercimek

Page 3: INTRODUCTION, FOUNDATIONS - WordPress.com · INTRODUCTION, FOUNDATIONS ... Textbook and course Materials Main Text Book: ... 5 TextLU Factorization book Ch6 6 Eigenvalues,

Information about the course

Course Information

Instructor: Dr. Muharrem Mercimek

Office: A-216

Office Hours: Monday 13:00-16:00

Class Location: C-150

Group: 1-2

Course Materials: http://www.yildiz.edu.tr/~mercimek

Email: [email protected], [email protected]

3 ELM1222 Numerical Analysis | Dr Muharrem Mercimek

Page 4: INTRODUCTION, FOUNDATIONS - WordPress.com · INTRODUCTION, FOUNDATIONS ... Textbook and course Materials Main Text Book: ... 5 TextLU Factorization book Ch6 6 Eigenvalues,

Information about the course

Textbook and course Materials

Main Text Book:

Laurene V. Fausett, Applied Numerical Analysis using MATLAB. Prentice Hall Inc.,

1999 OR

Laurene V. Fausett, Applied Numerical Analysis using MATLAB. 2nd Ed. , Pearson Inc.,

2007.

4 ELM1222 Numerical Analysis | Dr Muharrem Mercimek

Page 5: INTRODUCTION, FOUNDATIONS - WordPress.com · INTRODUCTION, FOUNDATIONS ... Textbook and course Materials Main Text Book: ... 5 TextLU Factorization book Ch6 6 Eigenvalues,

Information about the course

Grading

• Assignments: 15%

• Class Attendance: 10%

• Exams: 75%

Assignments

• There will be individual programming assignments and these will be listed on the

schedule page. Due dates will be specified and the students should submit their

material on time.

• Program submissions should be the outcome of each student’s own endeavors.

Collaborative study is encouraged, but any code and document you prepare must be

your own.

• Submissions must include source codes as well as the documentations and data files

when needed.

• When submitting your Assignments via e-mail always zip it, and name it like

ELM1222_YourName_YourNumber_AssignmentNumber.{zip or rar}

• When submitting an assignment always put a subject title relevant to why you are

sending it. You can use the name of your zip file again.

5 ELM1222 Numerical Analysis | Dr Muharrem Mercimek

Page 6: INTRODUCTION, FOUNDATIONS - WordPress.com · INTRODUCTION, FOUNDATIONS ... Textbook and course Materials Main Text Book: ... 5 TextLU Factorization book Ch6 6 Eigenvalues,

6

Week

Subjects

Preparation

1 Introduction, Foundations Textbook Ch1

2 Solving Equations of one Variable Textbook Ch2

3 Linear Equation System Solution - Direct Methods Textbook Ch3

4 Linear Equation System Solution - iterative Methods Textbook Ch4

5 LU Factorization Textbook Ch6

6 Eigenvalues, Eigenvectors Textbook Ch7

7 Mid-term 1

8 QR factorization Textbook Ch8

9 Interpolation Textbook Ch9

10 Function Approximation I Textbook Ch10

11 Function Approximation II Textbook Ch10

12 Mid-term 2

13 Numerical Differentiation and Integration I Textbook Ch11

14 Numerical Differentiation and Integration II Textbook Ch11

15 Final Exam

Information about the course

KOM1042 Discrete Mathematics | Dr Muharrem Mercimek

Page 7: INTRODUCTION, FOUNDATIONS - WordPress.com · INTRODUCTION, FOUNDATIONS ... Textbook and course Materials Main Text Book: ... 5 TextLU Factorization book Ch6 6 Eigenvalues,

Information about the course

Programming environment

• MATLAB® 2008 or higher with basic toolboxes, when needed.

Academic Honesty

• Any misconduct in this course is considered a serious offense and strong penalties will

be the results of such behaviors. It is cheating to copy others’ code. Fake program

outputs and documents is also considered as cheating.

7 ELM1222 Numerical Analysis | Dr Muharrem Mercimek

Page 8: INTRODUCTION, FOUNDATIONS - WordPress.com · INTRODUCTION, FOUNDATIONS ... Textbook and course Materials Main Text Book: ... 5 TextLU Factorization book Ch6 6 Eigenvalues,

FOUNDATIONS

8

Some of the contents are adopted from

Laurene V. Fausett, Applied Numerical Analysis using MATLAB. Prentice Hall Inc., 1999

ELM1222 Numerical Analysis | Dr Muharrem Mercimek

Page 9: INTRODUCTION, FOUNDATIONS - WordPress.com · INTRODUCTION, FOUNDATIONS ... Textbook and course Materials Main Text Book: ... 5 TextLU Factorization book Ch6 6 Eigenvalues,

Applied Problems – Nonlinear Functions

• To illustrate the types of problems for which a numerical solution may be

desired.

• There are problems we can solve with algebra or calculus

• On the other hand there closely related problems for which not exact solution

can be found

9 ELM1222 Numerical Analysis | Dr Muharrem Mercimek

• The zeros of 𝑦 = 𝑥2 − 3 can be found exactly by

quadratic formula

• But there is no such method for most non-linear

functions

• It is proven that no formula exist for 5th order

functions-polynomials.

• In Numerical Analysis there are many methods to

approximate the zeros of nonlinear functions

(bisection, newton, etc.)

Page 10: INTRODUCTION, FOUNDATIONS - WordPress.com · INTRODUCTION, FOUNDATIONS ... Textbook and course Materials Main Text Book: ... 5 TextLU Factorization book Ch6 6 Eigenvalues,

Applied Problems – Linear Systems

10 ELM1222 Numerical Analysis | Dr Muharrem Mercimek

• The solution is not straightforward.

• We can apply some numerical techniques.

• Gaussian elimination systematically transforms the system to an equivalent

system. If the Gaussian elimination could be carried out exactly the main

issue would be computational efficiency.

4𝑥1 + 𝑥2 = 6

−𝑥1 + 5𝑥2 = 9

𝐀 =4 1−1 5

𝐱 =𝑥1𝑥2

𝐛 ==69

𝐀𝐱 = 𝐛

Page 11: INTRODUCTION, FOUNDATIONS - WordPress.com · INTRODUCTION, FOUNDATIONS ... Textbook and course Materials Main Text Book: ... 5 TextLU Factorization book Ch6 6 Eigenvalues,

Applied Problems – Numerical Integrations

11 ELM1222 Numerical Analysis | Dr Muharrem Mercimek

• Fundamental theorem of calculus states that the definite integral of a

function can be from the ant-derivative of the function.

• For many functions it is easier to employ numerical techniques for finding

definite integrals. We can approximate the function to be integrated

1

𝑥3

3

1

𝑑𝑥

Page 12: INTRODUCTION, FOUNDATIONS - WordPress.com · INTRODUCTION, FOUNDATIONS ... Textbook and course Materials Main Text Book: ... 5 TextLU Factorization book Ch6 6 Eigenvalues,

Some Numerical Techniques-

Fixed point Iteration

12 ELM1222 Numerical Analysis | Dr Muharrem Mercimek

• Fixed-point iteration

• To find the square root of a positive

number c

• Rewrite the equation

𝑥2 = 𝑐 as an implicit equation

Fixed point

• form 𝑥 = 𝑔 𝑥 =1

2𝑥 +

𝑐

𝑥

• Starting with initial guess x0

• Evaluate the function up to an iteration

number or until the update is so small

𝑥1 =1

2 (𝑥0 +

𝑐

𝑥0)

𝑥𝑘 =1

2 (𝑥𝑘−1 +

𝑐

𝑥𝑘−1)

Root of 3

Page 13: INTRODUCTION, FOUNDATIONS - WordPress.com · INTRODUCTION, FOUNDATIONS ... Textbook and course Materials Main Text Book: ... 5 TextLU Factorization book Ch6 6 Eigenvalues,

Some Numerical Techniques-

Gaussian Elimination

13 ELM1222 Numerical Analysis | Dr Muharrem Mercimek

4𝑥1 + 𝑥2 = 6

−𝑥1 + 5𝑥2 = 9

𝐀 =4 1−1 5

𝐱 =𝑥1𝑥2

𝐛 ==69

𝐀𝐱 = 𝐛

𝑟1: 𝑟2:

4 1−1 5

| 69

𝑟1

0.25 ∗ 𝑟1 + 𝑟2

4 10 5.25

| 610.5

𝑥2 =10.5

5.25= 2, 𝑥1=

6−2

4= 1

Page 14: INTRODUCTION, FOUNDATIONS - WordPress.com · INTRODUCTION, FOUNDATIONS ... Textbook and course Materials Main Text Book: ... 5 TextLU Factorization book Ch6 6 Eigenvalues,

Some Numerical Techniques-

Trapezoid Rule

• Approximates the definite integral

• Accuracy

• depends on the length of the interval over which the approximation is

imposed (i.e., on the value of h)

• Influenced by the characteristics of the function f

14 ELM1222 Numerical Analysis | Dr Muharrem Mercimek

𝑓(𝑥)𝑏

𝑎

𝑑𝑥

𝑓(𝑥)𝑏

𝑎

𝑑𝑥 ≈ℎ

2(𝑓 𝑎 + 𝑓 𝑏 )

Approximation of 1

𝑥33

1𝑑𝑥

Page 15: INTRODUCTION, FOUNDATIONS - WordPress.com · INTRODUCTION, FOUNDATIONS ... Textbook and course Materials Main Text Book: ... 5 TextLU Factorization book Ch6 6 Eigenvalues,

Analysis-Convergence

• For iterative methods

• Does the process converge?”

• “When do we stop?”

15 ELM1222 Numerical Analysis | Dr Muharrem Mercimek

𝑥 = 𝑔 𝑥 = cos 𝑥

𝑥0 = 0.5

𝑥 = 𝑔 𝑥 = 1 − 𝑥3 𝑥0 = 0.5

Page 16: INTRODUCTION, FOUNDATIONS - WordPress.com · INTRODUCTION, FOUNDATIONS ... Textbook and course Materials Main Text Book: ... 5 TextLU Factorization book Ch6 6 Eigenvalues,

16 ELM1222 Numerical Analysis | Dr Muharrem Mercimek

Analysis-when to stop the iteration

If the numerical technique uses an iterative process, the iterations can be stopped after a while

a) If absolute difference of the exact solution and the approximation at 𝑘. iteration is in within a specified tolerance

𝑥∗ − 𝑥𝑘 < 𝑡𝑜𝑙1

(normally x* is not known when using a numerical technique)

b) If absolute difference from one iteration to the other is in within a specified tolerance

𝑥𝑘 − 𝑥𝑘−1 < 𝑡𝑜𝑙2

c) It the iteration number reaches to a maximum iteration number

𝑖𝑡𝑒𝑟 < 𝑖𝑡𝑒𝑟𝑎𝑡𝑖𝑜𝑛_𝑛𝑢𝑚𝑏𝑒𝑟

Page 17: INTRODUCTION, FOUNDATIONS - WordPress.com · INTRODUCTION, FOUNDATIONS ... Textbook and course Materials Main Text Book: ... 5 TextLU Factorization book Ch6 6 Eigenvalues,

Analysis-is the result good?

17 ELM1222 Numerical Analysis | Dr Muharrem Mercimek

a) Complexity of the approximation

Let the approximation error be

𝑒𝑟𝑟𝑜𝑟 = 𝑥∗ − 𝑥𝑘

𝑜𝑟

𝑒𝑟𝑟𝑜𝑟 = (𝑥∗ − 𝑥𝑘)

For some numerical techniques we have to limit the number of terms towards approximation. e.g:

Taylor expansion is

𝑓 𝑥 + ℎ = 𝑓 𝑥 + ℎ. 𝑓′ 𝑥 +ℎ2

2!𝑓′ 𝑥 +

ℎ3

3!𝑓′ 𝑥 + ⋯+

ℎ𝑛

𝑛!𝑓(𝑛) 𝑥

Where 𝑓(𝑛)( ) denotes the nth derivative of 𝑓( )

𝑓 𝑥 is a function of x

𝑓 𝑥 + ℎ is a function of x+h (h is a small value)

Taylor expansion puts the relationship between 𝑓 𝑥 and 𝑓 𝑥 + ℎ

For approximation of 𝑓 𝑥 + ℎ = 𝑒𝑥+ℎ around 𝑥 = 0 with a small h

𝑓 ℎ = 1 + ℎ +ℎ2

2!+ℎ3

3!+⋯+

ℎ𝑛

𝑛! infinite number of terms but instead we can involve with a number of

terms and omit the others

𝑓 ℎ = 1 + ℎ +ℎ2

2!+ℎ3

3!+ 𝒪 ℎ4 here we omit the sum of the remaining terms denoted with 𝒪 ℎ4

𝒪(∙) describes the error with limiting number of terms in use.

Page 18: INTRODUCTION, FOUNDATIONS - WordPress.com · INTRODUCTION, FOUNDATIONS ... Textbook and course Materials Main Text Book: ... 5 TextLU Factorization book Ch6 6 Eigenvalues,

Analysis- is the result good?

b) Floating Point Representation error

• On a computer we can represent integer numbers easily

255 is always 255.

• When it comes to the real numbers they have to be represented

approximately.

The value of pi as an example can only be approximated differently when

represented with different number of digits.

This brings an error in the approximation because numbers used are different.

18 ELM1222 Numerical Analysis | Dr Muharrem Mercimek

Page 19: INTRODUCTION, FOUNDATIONS - WordPress.com · INTRODUCTION, FOUNDATIONS ... Textbook and course Materials Main Text Book: ... 5 TextLU Factorization book Ch6 6 Eigenvalues,

kucg.korea.ac.kr

Analysis - Round-off error

c) Round off Errors

• During calculations/computing sometimes we round the number

Rounding to 3 most significant digits after the decimal point

0,9900+0.0044+0.0042

the calculations when rounding:

(0,9900+0.0044)+0.0042 =0.994+0.004=0.998

Or

0,9900+(0.0044+0.0042)=0.990+0.009=0.999

• In a numerical analysis these two number will lead to different

calculations/computing

19 ELM1222 Numerical Analysis | Dr Muharrem Mercimek