1 copyright © 2005 by yshong. 2 engineering applications with computers i (aspect in numerical...

86
1 Copyright © 2005 by yshong

Upload: alyssa-verity

Post on 14-Dec-2015

214 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

1Copyright © 2005 by yshong

Page 2: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

2

Engineering Applications with Engineering Applications with Computers IComputers I

(Aspect in Numerical (Aspect in Numerical Methods)Methods)

YUNG-SHAN HONG, Ph.D., PE.

Office: E723

Tel: 26215656 ext. 3260

Instructor:

Copyright © 2005 by yshong

Page 3: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

3

Objective:

This course covers a variety of numerical methods and their applications in various engineering problems. Emphasis is placed on the solution of solving nonlinear equation, matrix analysis of linear and nonlinear equations, eigen-value problems, curve fitting, numerical integration and differentiations as well as interpolation methods.

Pre-knowledge of Engineering Mathematics and programming skills with computer language (s) are strongly required.

Copyright © 2005 by yshong

Page 4: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

4

Outline and Schedule:

Introduction (2 hrs)

Mathematical modeling and engineering problem solving (2hrs)

Error and definition (2hrs)

Roots of equations (1) - bracketing methods (2hrs)

Roots of equations (2) - open methods (2hr)

Systems of nonlinear equations (2hrs)

Linear algebraic equations - mathematical and numerical method (3hrs)

Eigenvalue problems (3hrs)Copyright © 2005 by yshong

Page 5: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

5

Outline and Schedule:

Least squares regression (2hrs)

Interpolation - Lagrange and Newton approach (2hr)

Interpolation - spline function (2hrs)

Numerical integration - general (2hrs)

Numerical integration - double integral (2hrs)

Numerical solution of ordinary differential equations (2hrs)

Numerical solution of partial differential equations (2hrs)

Copyright © 2005 by yshong

Page 6: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

6

Grading:

Ordinarily expression 20%

Homework (3~4 times) 20%

Mid term exam 30%

Final term exam 30%

Copyright © 2005 by yshong

Page 7: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

7

Textbook:

Chapra, S.C. and Canale, R.P.(2002), “Numerical methods for engineers – with programming and software applications”, Fourth Edition, McGRAW-Hill.

Reference: Gerad, C.F. and Wheatley, P.O.(1999), “Applied numerical analysis”, Sixth Edition, Addison-Wesley.

Schilling, R.J. and Harris, S.L.(1999), “Applied numerical methods for engineers – using Matlab and C”, Brooks/Cole.

林聰悟、林佳慧 (1997), “ 數值方法與程式” , 圖文技術服務。

Copyright © 2005 by yshong

Page 8: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

8

About the authors:

Steve Chapra teaches in the Civil and Environmental Engineering Department at Tufts University.

Dr. Chapra received engineering degrees from Manhattan College and the University of Michigan. Before joining the faculty at Tufts, he worked for the Environmental Protection Agency and the National Oceanic and Atmospheric Administration, and taught at Texas A&M University and the University of Colorado. His general research interests focus on surface water-quality modeling and advanced computer applications in environmental engineering.

Copyright © 2005 by yshong

Page 9: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

9

About the co-authors:

Raymond P. Canale is an emeritus professor at the University of Michigan.

During his over 20-year career at the university, he taught numerous courses in the area of computers, numerical methods, and environmental engineering. He also directed extensive research programs in the area of mathematical and computer modeling of aquatic ecosystems. He has authored or coauthored several books and has published over 100 scientific papers and reports.

Copyright © 2005 by yshong

Page 10: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

10

Why you should study numerical methods ?

Numerical methods are extremely powerful problem-solving tools. They are capable of handling large systems of equations, nonlinearities, and complicated geometries that are not uncommon in engineering practice and often impossible to solve analytically.

During your careers, you may often have occasion to use commercially available prepackaged that involve numerical methods. The intelligent use these programs is often predicated on knowledge of the basic theory underlying the methods.

Copyright © 2005 by yshong

Page 11: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

11

Many problems cannot be approached using prepackaged programs. If you are conversant with numerical methods and are adept at computer programming, you can design your own programs to solve problems without having to buy expensive software.

Numerical methods are an efficient vehicle for learning to use computers. Because numerical methods are for the most part designed for implementation on computers, they are ideal for this purpose. You will also learn to control the errors of approximation that are part of large-scale numerical calculations.

Numerical methods provide a vehicle for you to reinforce your understanding of mathematics. Because one function of numerical methods is to reduce higher mathematics to basic arithmetic operations.

Copyright © 2005 by yshong

Page 12: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

12

Solutions of the problem in engineering:

INTRODUCTION

Analytical solution:

(closed form solution)

Ex. Determine

)(sin xdx

d

)(sin xdx

dat x=0

let x=0 1cos)(sin xxdx

d 900 x(o)

sinx

Ex. Determine AE

PL

P

1

?

Copyright © 2005 by yshong

Page 13: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

13

Numerical solution:(approximation solution)

Ex. Determine )2ln( 2xxedx

d x at x=10

let )2ln()( 2xxexf x

x

f(x)

10

1?

Copyright © 2005 by yshong

Page 14: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

14

Numerical method:

Data + Mathematical theory + computer program

Approximation

Copyright © 2005 by yshong

Page 15: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

15

Types of the problem:

(a) Solution of nonlinear equation (roots of equation)

0594 23 xxx

594)( 23 xxxxflet

x

f(x)

Ex.

Copyright © 2005 by yshong

Page 16: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

16

(b) Matrix analysis (solution of linear algebratic eqs.)

Ex.

2222121

1212111

puaua

puaua

2

1

2

1

2221

1211

p

p

u

u

aa

aa

u1

u2

Ex.

232

1043

yx

yx

Copyright © 2005 by yshong

Page 17: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

17

(c) System of nonlinear eqs.

Ex.

x1

x2

222221121

122121111

)()(

)()(

cxxaxxa

cxxaxxa

2

1

2

1

222121

212111

)()(

)()(

c

c

x

x

xaxa

xaxa

Copyright © 2005 by yshong

Page 18: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

18

(d) Curve fitting

Regression – Least squares regression

Interpolation & Extrapolation

x

y y

x

Regression Interpolation & Extrapolation

Copyright © 2005 by yshong

Page 19: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

19

(e) Integration technique

x

f(x)

a b

I

f(x)

b

a

dxxfI )( p(w)

½ space

Copyright © 2005 by yshong

Page 20: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

20

(f) Ordinary differential equation (ODE)

Because many physical laws are couched in terms of the rate of change of a quantity rather than the magnitude of the quantity itself.

Ex.

tdt

dy3

Difference scheme viewpoint ),(1 ytf

t

yy

t

y

dt

dy ii

Solve y as a function of t

),(1 ytftyy ii

y

t

f(t,y)yi+1yi

yRi+1

ti ti+1

Δt

Copyright © 2005 by yshong

Page 21: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

21

(f) Ordinary differential equation (ODE)

Additional data must be given:

Initial value problem

Boundary value problem

x1

f(x1

) x

?

x1

f(x1

) x

?

x2

f(x2

)

Copyright © 2005 by yshong

Page 22: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

22

(g) Partial differential equation (PDE)

The behavior of a physical quantity is couched in terms of its rate of change with respect to two or more independent variables.

Elliptic – solid mech., flow mech.potential

),(

2

2

2

2

yxpy

u

x

u

0),( yxp Laplace eqs. ( 滲流控制方程式 )

Copyright © 2005 by yshong

Page 23: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

23

(g) Partial differential equation (PDE)

Parabolic – consolidation, heat…

t

u

cz

u

v

1

2

2

Analytical sol.

0

[.......]m

u

2dr

vv H

tcT

Hyperbolic – wave eqs.

2

2

22

2 1

x

u

ct

u

Copyright © 2005 by yshong

Page 24: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

24

Motivation:

Numerical methods are techniques by which mathematical problems are formulated so that they can be solved with arithmetic operations. Although there are many kinds of numerical methods, they have one common characteristic: they invariably involve large numbers of tedious arithmetic calculations.

It is little wonder that with the development of fast, efficient digital computers, the role of numerical methods in engineering problem solving has increased dramatically in recent years.

Copyright © 2005 by yshong

Page 25: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

25

Non-computer methods:

(1) Solutions were derived for some problems using analytical, or exact method.

Ex. 0422 xx

Exact sol.

ix 312

1642

Ex. 082sin/3 257 xxexx x

?Exact sol.

Copyright © 2005 by yshong

Page 26: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

26

(2) Graphical solutions were used to characterize the behavior of systems.

Ex.

01043

0522

2

yx

yx

1

2

x

yx ….y ….

x ….y ….

The results are not very precise. Graphical techniques are often limited to problems that can be described using three or fewer dimensions.

(3) Calculators and slide rules were used to implement numerical method manually.

The method used to simple engineering problems.

Copyright © 2005 by yshong

Page 27: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

27

Numerical method:

Data + Mathematical theory + computer program

Approximation

Complex engineering problems:

Copyright © 2005 by yshong

Page 28: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

28

The engineering problem-solving process :

Problem definition

Mathematical model

Numeric or graphic results

Implementation

DataTheory

Problem-solving tools:Computers, statistics,Numerical methods, graphics, etc.

Societal interfaces:Scheduling, optimization, communication, public interaction, ect.

Copyright © 2005 by yshong

Page 29: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

29

CHAPTER 1

A SIMPLE MATHEMATICAL MODEL

A mathematical model can be broadly defined as a formulation or equation that expresses the essential features of a physical system or process in mathematical terms.

In a very general sense, it can be represented as a functional relationship of the form:

Dependent variable = f (independent variables, parameters, forcing functions)…………..(1.1)

Copyright © 2005 by yshong

Page 30: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

30

Dependent variable = f (independent variables, parameters, forcing functions)…………..(1.1)

Where the dependent variable is a characteristic that usually reflects the behavior or state of the system; the independent variables are usually dimensions, such as time and space, along which the system’s behavior is being determined; the parameters are reflective of the system’s properties or composition; and the forcing functions are external influences acting upon it.

AE

PL

: dependent variable

P: forcing functions

A,E,L: parametersCopyright © 2005 by yshong

Page 31: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

31

The following illustrates a physical problem how to represent by a mathematical model.

According Newton second law,

maF

Where F = net force acting on the body (N or kg-m/sec2)

m = mass of object (kg)

a = its acceleration (m/sec2)

…………………………(1.2)

Copyright © 2005 by yshong

Page 32: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

32

(1.2):

Where a = the dependent variable reflecting the system’s behavior

F = the forcing function (net froce)

m = a parameter represent a property of the system

m

Fa …………………………(1.3)

Note: this simple case there is no independent variable because we are not yet predicting how acceleration varies in time or space.

Copyright © 2005 by yshong

Page 33: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

33

To illustrate a more complex model of this kind, Newton’s second law can be used to determine the terminal velocity of a free-falling body near the earth’s surface. The falling body will be a parachutist. (Fig.1.2)

m

F

dt

dv ……….(1.4)

Fu

Fd

F: net force+: the object will accelerate

-: the object will decelerate

0: the object will remain at a constant level

Copyright © 2005 by yshong

Page 34: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

34

UD FFF ……….(1.5)

FD: the downward pull of gravity

FU: the upward force of air resistance

cvFU

mgFD ……….(1.6)

……….(1.7)

g: the gravitational constant ≈ 9.8 m/s2

c: drag coefficient = f(shape, surface roughness,….)

Copyright © 2005 by yshong

Page 35: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

35

From eqs.(1.4) through (1.7) combined:

m

cvmg

dt

dv

vm

cg

dt

dv

or

……….(1.9)

……….(1.8)

Type of eq. ? ODE

Eq.(1.9) is a differential equation that relates the acceleration of a falling object to the forces acting on it.

If the parachutist is initially at rest (v=0 at t=0), that is a initial value problem. Solve eq.(1.9) for

What type of problem ?

Copyright © 2005 by yshong

Page 36: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

36

)1()( )/( tmcec

gmtv ……….(1.10)

Note : v(t): the dependent variable

t= the independent variable

c,m= parameters

g= the forcing function

The following will illustrate the analytical solution and the numerical solution, respectively.

Copyright © 2005 by yshong

Page 37: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

37

Ex 1.1 analytical solution

Known: mass=68.1 kg, c=12.5 kg/s

Eq.(1.10) then

)1(39.53)( 18355.0 tetv

terminal velocity53.39

exact sol.

t(s)

v(m/s)

Eq.(1.10) is called an analytical, or exact solution because it exactly satisfies the original differential equation. Unfortunately, there are many mathematical models that cannot be solved exactly. In many of these cases, the only alternative is to develop a numerical solution that approximates the exact solution.Copyright © 2005 by yshong

Page 38: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

38

Ex 1.2 numerical solution

tv

t

tt

vv

t

v

dt

dv

ii

ii

0lim

1

1 ……….(1.11)

vm

cg

dt

dv ……….(1.9)

So eq.(1.9):

i

ii

ii vm

cg

tt

vv

1

1

Copyright © 2005 by yshong

Page 39: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

39

)( 11 iiiii ttvm

cgvv

When t=0, v=0, if step size (time step)=2

6.192)0(

1.68

5.128.90)2(

tv

322)6.19(

1.68

5.128.96.19)4(

tv

i=0

i=1

m/s

m/s

v(t=6), v(t=8), …………..Copyright © 2005 by yshong

Page 40: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

40

v (m/s)

t (s)

terminal velocity

exact sol.

numerical sol.

2 4 860

Copyright © 2005 by yshong

Page 41: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

41

Homework :

Problems 1.3, 1.4 and 1.5 (p.22)

Due : One week

Copyright © 2005 by yshong

Page 42: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

42

CHAPTER 2

PROGRAMMING AND SOFTWARE

pp. 25-49

Copyright © 2005 by yshong

Page 43: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

43

CHAPTER 3

APPROXIMATIONS AND ROUND-OFF ERRORS

How much error is present in our calculations and is it tolerable ?

Two major forms of numerical error:

Round-off error

Truncation error

Inherent errorCopyright © 2005 by yshong

Page 44: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

44

The concept of a significant figure.See Fig.3.1 (p.51)

Accuracy and precision

Accuracy refers to how closely a computed or measured value agrees with the true value.

True value = 2.83

Precision refers to how closely individual computed or measured values agree with each other.

Copyright © 2005 by yshong

Page 45: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

45

Fig.3.2

Increasing accuracyIn

crea

sing

pre

cisi

on

(a) (b)

(c) (d)

Copyright © 2005 by yshong

Page 46: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

46

Numerical methods should be sufficiently

accurate or unbiased to meet the

requirements of particular engineering

problem. They also should be precise

enough for adequate engineering design.

Copyright © 2005 by yshong

Page 47: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

47

Error definitions

(1) True error Et (absolute error)

Et = true value - approximation

Ex. Two approaches to measure length of the two objects.

Approach (a) : Object (a) true length=1m, measured error=1cm

Approach (b) : Object (b) true length= 0.1m, measured error=1cm

What is better approach ?

Copyright © 2005 by yshong

Page 48: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

48

(2) Relative error t

%100

valuetrue

errortruet

Ex. Two approaches to measure length of the two objects.

Approach (a) : Object (a) true length=1m, measured error=1cm

Approach (b) : Object (b) true length= 0.1m, measured error=1cm

Approach (a) : t=1%

Approach (b) : t=10%

Copyright © 2005 by yshong

Page 49: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

49

(3) The approximation percent relative error a

%100

%100

)(

)1()(

mi

mi

mi

a

u

uu

ionapproximatcurrent

ionapproximatpreviousionapproximatcurrent

……….(3.5)

m : iteration number

i : point, position

Iterative approach characteristic

value

Cal. number

Copyright © 2005 by yshong

Page 50: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

50

Truncation error (Chapter 4)

Truncation errors are those that result from using an approximation in place of an exact mathematical procedure.

For example, in Chap. 1 we approximated the derivative of velocity of a falling parachutist by a finite-divided-difference eq. of the form.

ii

ii

tt

vv

t

v

dt

dv

1

1 ……….(4.1)

Copyright © 2005 by yshong

Page 51: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

51

A truncation error was introduced into the numerical solution because the difference eq. only approximates the true value of the derivative.

In order to gain insight into the properties of such errors, we now turn to a mathematical formulation that is used widely in numerical methods to express functions in an approximate fashion – the Taylor series.

Copyright © 2005 by yshong

Page 52: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

52

Taylor series

c is between [a, b], nth-order derivatives are existence for f(x), then f(x) at c can be to express following eq. using Taylor series.

dttftxn

xR

xRn

cxcfcxcfcxcfcfxf

x

c

nnn

n

nn

)()(!

1)(

)()!1(

))((.....

!2

))((

!1

))(()()(

)(

1)1(2

Rn(x) = remainder term

Copyright © 2005 by yshong

Page 53: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

53

If c=0, f(x) series expressing to call Maclaurin’s series,

dttftxn

xR

xRn

xfxfxffxf

xnn

n

n

nn

0

)(

1)1(2

)()(!

1)(

)()!1(

)0(.....

!2

)0(

!1

)0()0()(

If (n-1)th-oder approximate, then Rn(x) refers to truncation error

Copyright © 2005 by yshong

Page 54: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

54

Ex. Use fourth-order Maclaurin series expansions to approximate the function

xexf )(

Predict the function’s value at x=1.

Sol: let f(x)=ex, f’(x)=f’’(x)=f’’’(x)=f(4)(x)=ex,

∴ f(0)=1, f’(x)=f’’(x)=f’’’(x)=f(4)(x)=1

∵Maclaurin expansion series:

.....

!4

)0(

!3

)0(

!2

)0(

!1

)0()0()( 4

)4(32

x

fx

fx

fx

ffxf

Copyright © 2005 by yshong

Page 55: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

55

Expressing to fourth-order

4324 24

1

6

1

2

11)( xxxxxf

70833.224

65

24

1

6

1

2

111)1(4 f

But 71828.2)( 1

1

exf

x

∴ truncation error= 2.71828-2.70833= 0.00995

Copyright © 2005 by yshong

Page 56: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

56

In a similar manner, the complete Taylor series expansion:

nn

iii

n

iii

iii

iiiii

Rxxn

xf

xxxf

xxxf

xxxfxfxf

11

)1(

31

)3(2

111

)()!1(

)(

...)(!3

)()(

!2

)())(()()(

………..(4.5)

If we simplify the Taylor series,

))(()()( 11 iiiii xxxfxfxf Refer to first-order approximation

2111 )(

!2

)())(()()( ii

iiiiii xx

xfxxxfxfxf

Refer to second-order approximation

……

xi+1-xi=h refer to step sizeCopyright © 2005 by yshong

Page 57: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

57

Ex. 4.1 Use zero ~ fourth-order Taylor series expansions to approximate the function:

2.125.05.015.01.0)( 234 xxxxxf

from xi=0 with h=1. That is, predict the function’s value at xi+1=1

Sol: true value f(1)=0.2

zero-order: 2.1)0()()( 1 fxfxf ii Truncation error=0.2-1.2=-1

first-order: 95.025.02.11)0()0()1( fff 25.0)0( f∵

Truncation error=0.2-0.95=-0.75

Copyright © 2005 by yshong

Page 58: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

58

second-order: 45.0)1( f Truncation error=0.2-0.45=-0.25

f(x)

x

Zero order

first order

second order

xi=0 xi+1=1

1.2

0.95

0.45

)()( 1 ii xfxf

hxfxfxf iii )()()( 1

21 !2

)()()()( h

xfhxfxfxf i

iii

f(xi+1)

f(xi)

How order Taylor series expansion can be no truncation error ?

Copyright © 2005 by yshong

Page 59: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

59

In general, the nth-order Taylor series expansion will be exact for an nth-order polynomial. For other differentiable and continuous functions, such as exponentials and sinusoids, a finite number of terms will not yield an exact estimate. Each additional term will contribute some improvement, to the approximation. Only if an infinite number of terms are added will the series yield an exact result.

EX. 4.2

Copyright © 2005 by yshong

Page 60: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

60

Round-off error (Chapter 3)

Round-off errors originate from the fact that computers retain only a fixed number of significant figures during a calculation. Number such as p, e, or cannot be expressed by a fixed number of significant figures. Therefore, they cannot represented exactly by the computer.

In addition, because computers use a base-2 representation, they cannot precisely represent certain exact base-10 numbers. The discrepancy introduced by this omission of significant figures is called round-off error.

Copyright © 2005 by yshong

Page 61: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

61

Base-2: 00 01 10 11 100 101 110 111 1000 1001

Base-10: 0 1 2 3 4 5 6 7 8 9

Ex. 3253 is represented base-10:

3253103105102103 0123

Ex. 110.11 is represented base-2:

1021012 )75.6(2121202121

Copyright © 2005 by yshong

Page 62: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

62

But, ex. (0.2)10

8 numbers represented:

...212121212020

...)110011001100.0()2.0(874321

210

199219.0

00390625.00078125.00625.0125.0

21212121

)00110011.0()2.0(8743

210

To get a decimal point at sixth number

Round-off error = 0.2 - 0.199219 = 0.000781

Copyright © 2005 by yshong

Page 63: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

63

ROOTS OF EQUATIONS (Part 2, p.105)

Ex. 0tan xLxL xexf x )(

Such as f(x) cannot be solved analytically. In such instance, the only alternative is an approximate solution technique.

One method to obtain an approximate solution is to plot the function and determine where it crosses the x axis. This point, which represents the x value for which f(x) = 0, is the root.

f(x)

x

root

Copyright © 2005 by yshong

Page 64: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

64

Although graphical method are useful for obtaining rough estimates of roots, they are limited because of their lack of precision.

An alternative approach is to use trial and error. This “technique” consists of guessing a value of x and evaluating whether f(x) is zero.

Such this methods are obviously inefficient and inadequate for the requirements of engineering practice.

Copyright © 2005 by yshong

Page 65: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

65

Ex. )1()( )/( tmcec

gmtv

Such computations can be performed directly because v is expressed explicitly as a function of time.

However, suppose we had to determine the drag coefficient for a parachutist of a given mass to attain a prescribed velocity in a set time period.

Ex. vec

gmcf tmc )1()( )/(

There is no way to rearrange the equation so that c is isolated on one side of the equal sign. In such cases, c is said to be implicit.

Copyright © 2005 by yshong

Page 66: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

66

Approach of Nonlinear equation solution:

Bracketing method (chap. 5) – bisection, false position

Open method (chap. 6) – one-point iteration, Newton-Raphson, secant method

Roots of polynomials (chap. 7) – Müller’s methos, Bairstow’s method

Copyright © 2005 by yshong

Page 67: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

67

Roots within the interval

Assumption a nonlinear equation f(x)=0 is a continue function. Two points are “a” and “b” on x-axis, then f(x) is whether solutions between a and b. According to follow as,

(1) If f(a)*f(b)=0, then f(x) has a solution.

(2) If f(a)*f(b)<0, then f(x) has a solution x=r between “a” and “b” to satisfy f(x)=0.

(3) If f(a)*f(b)>0, then ?

Ref. pp.114~115. fig.5.2 ~ fig.5.4.

Copyright © 2005 by yshong

Page 68: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

68

CHAPTER 5

BRACKETING METHODS

Bi-section method

a

b

f(a)

f(b)

x1

x2

x3

Copyright © 2005 by yshong

Page 69: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

69

False position method (linear interpolation method)

a

b

f(a)

f(b)

x1x2x3

Copyright © 2005 by yshong

Page 70: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

70

CHAPTER 6 OPEN METHODS

For the bracketing methods in the previous chapter, the root is located within an interval prescribed by a lower and an upper bound. Repeated application of these methods always results in closer estimates of the true value of the root. Such methods are said to be convergent because they move closer to the truth as the computation progresses.

In contrast, the open methods described in this chapter are based on formulas that require only a single starting value of x or two starting values that do not necessarily bracket the root. As such, they sometimes diverge or move away from the true root as the computation progresses. However, when the open methods converge, they usually do so much quickly than the bracketing methods.

Copyright © 2005 by yshong

Page 71: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

71

Secant method (ref. chap.6.3)

r0 r2r1 r3

x

y

f(x)

Copyright © 2005 by yshong

Page 72: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

72

Newton-Raphson method (ref. chap.6.2)

x

y f(x)

x0x2 x1

Copyright © 2005 by yshong

Page 73: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

73

Fixed-point iteration (ref. chap.6.1)f(x)=0, x=g(x)

Rewrite, y1=x, y2=g(x)

x

y

y1=x

y2=g(x)

x0 x1 x2

Copyright © 2005 by yshong

Page 74: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

74

CHAPTER 6.5 SYSTEMS OF NONLINEAR EQUATIONS

573

102

2

xyy

xyxEx.

Fixed-point iteration

Newton-Raphson method

Copyright © 2005 by yshong

Page 75: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

75

LINEAR ALGEBRAIC EQUATIONS

nnnnnn

nn

nn

bxaxaxa

bxaxaxa

bxaxaxa

...

.....

...

...

2211

22222121

11212111

Matrix form:

BxA BAx 1

Copyright © 2005 by yshong

Page 76: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

76

Mathematical background (ref. pp.219~230)

Diagonal matrix

Unit matrix

Upper triangular matrix

Lower triangular matrix

Transpose matrix

Symmetrical matrix

Copyright © 2005 by yshong

Page 77: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

77

Mathematical approach:

Numerical approach:

Inverse matrix method

Cramer’s method

Gauss elimination method

Gauss-Jordan elimination method

LU decomposition method

Jacobi’s iteration method

Gauss-Seidel iteration method

Copyright © 2005 by yshong

Page 78: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

78

EIGENVALUE PROBLEMS

(ref. chapter 27)

Engineering analysis:

Steady state (static equilibrium)

Eigenvalue problems (vibration, oscillating system, …)

Propagation problems (wave propagation, transient involve a lot of frequencies)

Copyright © 2005 by yshong

Page 79: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

79

Steady state (static equilibrium)-

Single frequency

Ex.

PKU K: stiffness

U: displacement

P: force

Solve the system of algebraic

The equation is nonhomogeneous

Copyright © 2005 by yshong

Page 80: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

80

Eigenvalue problems (vibration, oscillating system, …)

Solve the system of algebraic

The equation is homogeneous, and the U solution is not unique. (for P=0)

PKU

Copyright © 2005 by yshong

Page 81: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

81

CURVE FITTING, LEAST-SQUARE REGRESSION

(ref. chapter 17)

Copyright © 2005 by yshong

Page 82: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

82

INTERPOLATION

(ref. chapter 18)

Lagrange interpolation polynomial

Newton’s interpolation method

Spline interpolation (Spline function)

Copyright © 2005 by yshong

Page 83: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

83

NUMERICAL INTEGRATION

(ref. pp.569 ~ 612)

Rectangle integration

Trapezoidal integration

Simpson’s integration

Newton-cotes integration

Romberg integration

Double integralCopyright © 2005 by yshong

Page 84: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

84

NUMERICAL DIFFERENTIATION

(ref. chapter 23, pp.632 ~ 666)

Forward difference

Backward difference

Central difference

Difference scheme -

Copyright © 2005 by yshong

Page 85: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

85

………………………………………

Copyright © 2005 by yshong

Page 86: 1 Copyright © 2005 by yshong. 2 Engineering Applications with Computers I (Aspect in Numerical Methods) YUNG-SHAN HONG, Ph.D., PE. Office: E723 Tel: 26215656

86

Thank for your attention

Copyright © 2005 by yshong