fundamentals of programming for chemical engineers methods in solving engg problems

11
4/14/2016 1 Fundamentals of Prog ramming for Chemical Engineers- Introducto ry Concepts Leandro T. De Castro Methods in Solving Engineering Problems

Upload: mark-anthony-caro

Post on 01-Mar-2018

217 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Fundamentals of Programming for Chemical Engineers Methods in Solving Engg Problems

7/26/2019 Fundamentals of Programming for Chemical Engineers Methods in Solving Engg Problems

http://slidepdf.com/reader/full/fundamentals-of-programming-for-chemical-engineers-methods-in-solving-engg 1/11

4/14/2016

1

Fundamentals of Programmingfor Chemical Engineers-Introductory Concepts

Leandro T. De Castro

Methods in Solving

Engineering Problems

Page 2: Fundamentals of Programming for Chemical Engineers Methods in Solving Engg Problems

7/26/2019 Fundamentals of Programming for Chemical Engineers Methods in Solving Engg Problems

http://slidepdf.com/reader/full/fundamentals-of-programming-for-chemical-engineers-methods-in-solving-engg 2/11

4/14/2016

2

Definition: Absolute Error and Relative Error

Let p* be an approximation to p

  : =

: =

 

Round-off Errors

To minimize loss of accuracy due to round-offerrors:

a. Reformulate the problem

 b. Reduce the number of error-producingcomputation

c. Use High-order digit arithmetic

Page 3: Fundamentals of Programming for Chemical Engineers Methods in Solving Engg Problems

7/26/2019 Fundamentals of Programming for Chemical Engineers Methods in Solving Engg Problems

http://slidepdf.com/reader/full/fundamentals-of-programming-for-chemical-engineers-methods-in-solving-engg 3/11

4/14/2016

3

Convergence Rate

Suppose that a sequence {Xn} converges to a realnumber X*. We say the convergence is of order l (wherek>=1) provided that for some positive number C, thefollowing inequality will eventually true:

In general, higher values of k give faster convergence.

If a sequence converges at k=1, it is lineartly convergentIf a sequence converges at k=2, it convergesquadratically.

  ≤

Finding the root of f(x)=0

Methods:

Bisection Method

The Regula Falsi MethodThe Secant Method

 Newton’s Method

Page 4: Fundamentals of Programming for Chemical Engineers Methods in Solving Engg Problems

7/26/2019 Fundamentals of Programming for Chemical Engineers Methods in Solving Engg Problems

http://slidepdf.com/reader/full/fundamentals-of-programming-for-chemical-engineers-methods-in-solving-engg 4/11

4/14/2016

4

Bisection Method

- Based on the intermediate value theorem

Assumptions:

1. f(x) is continuous

2. On [a,b], f(a), f(b) have opposite signs

3. Tolerance = tol >0 is prescribed

Bisection Method

 f(b)

 f(a)

root r 

Page 5: Fundamentals of Programming for Chemical Engineers Methods in Solving Engg Problems

7/26/2019 Fundamentals of Programming for Chemical Engineers Methods in Solving Engg Problems

http://slidepdf.com/reader/full/fundamentals-of-programming-for-chemical-engineers-methods-in-solving-engg 5/11

4/14/2016

5

Bisection Method• Method will iteratively construct a sequence x 

n  thatconverges to the root r and will stop when it can beguaranteed that |r -xn| < tol .

• The difficulty though with the error expression, i.e., = is that the roor   of a function is rarelyknown beforehand.

As the limiting criterion to the number of iterations, the

following may be used:1. < 2.    <

3.     < 4.

<

Algorithm for Bisection Method:

1. Choose an interval [a,b]

2. If f(a) and f(b) have opposite signs: start 

3. Iterate:  = + /24. If < : stop

5. Set a=x1 if f(x1) has same sign as f(a), else set b=x1

6. Goto 3

Page 6: Fundamentals of Programming for Chemical Engineers Methods in Solving Engg Problems

7/26/2019 Fundamentals of Programming for Chemical Engineers Methods in Solving Engg Problems

http://slidepdf.com/reader/full/fundamentals-of-programming-for-chemical-engineers-methods-in-solving-engg 6/11

4/14/2016

6

Example: Consider the function

  = 1

a. Show that f(x) has a root on the interval [0,1]

 b. Use the bisection method to approximate this root with an absoluteerror <5e-3

c. How many iterations would it take the bisection method to guarantee

an absolute error < 1e-6

Regula Falsi

Page 7: Fundamentals of Programming for Chemical Engineers Methods in Solving Engg Problems

7/26/2019 Fundamentals of Programming for Chemical Engineers Methods in Solving Engg Problems

http://slidepdf.com/reader/full/fundamentals-of-programming-for-chemical-engineers-methods-in-solving-engg 7/11

4/14/2016

7

Algorithm for Regula Falsi Method:

1. Choose an interval [xa, x b]

2. If f(xa) and f(xb) have opposite signs: start

3. Iterate:  =  

 

4. If error < tol; : stop

5. Set  = if () has same sign as () , else set  =

6. Goto 3

Example: Find the root of

Page 8: Fundamentals of Programming for Chemical Engineers Methods in Solving Engg Problems

7/26/2019 Fundamentals of Programming for Chemical Engineers Methods in Solving Engg Problems

http://slidepdf.com/reader/full/fundamentals-of-programming-for-chemical-engineers-methods-in-solving-engg 8/11

4/14/2016

8

Seca t Method

Page 9: Fundamentals of Programming for Chemical Engineers Methods in Solving Engg Problems

7/26/2019 Fundamentals of Programming for Chemical Engineers Methods in Solving Engg Problems

http://slidepdf.com/reader/full/fundamentals-of-programming-for-chemical-engineers-methods-in-solving-engg 9/11

4/14/2016

9

Algorithm for Secant Method:

1. Choose an interval [xn-1, x b]

2. If f(xn-1) and f(xn) have opposite signs: start

3. Iterate:  =  

 

4. If error   < tol; : stop

5. Goto 3 using the two most recently generated points

Example: Find the root of

Page 10: Fundamentals of Programming for Chemical Engineers Methods in Solving Engg Problems

7/26/2019 Fundamentals of Programming for Chemical Engineers Methods in Solving Engg Problems

http://slidepdf.com/reader/full/fundamentals-of-programming-for-chemical-engineers-methods-in-solving-engg 10/11

4/14/2016

10

Newton’s Method

Page 11: Fundamentals of Programming for Chemical Engineers Methods in Solving Engg Problems

7/26/2019 Fundamentals of Programming for Chemical Engineers Methods in Solving Engg Problems

http://slidepdf.com/reader/full/fundamentals-of-programming-for-chemical-engineers-methods-in-solving-engg 11/11

4/14/2016

11

f(x) is a differentiable function that has a root

x= r which we wish to accurately approximate.

 =

 

 ′