Vous êtes sur la page 1sur 11

# 4/14/2016

Fundamentals of Programming
for Chemical EngineersIntroductory Concepts
Leandro T. De Castro

Methods in Solving
Engineering Problems

4/14/2016

## Definition: Absolute Error and Relative Error

Let p* be an approximation to p

: =

: =

Round-off Errors
To minimize loss of accuracy due to round-off
errors:
a. Reformulate the problem
b. Reduce the number of error-producing
computation
c. Use High-order digit arithmetic

4/14/2016

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

In general, higher values of k give faster convergence.
If a sequence converges at k=1, it is lineartly convergent
If a sequence converges at k=2, it converges

## Finding the root of f(x)=0

Methods:
Bisection Method
The Regula Falsi Method
The Secant Method
Newtons Method

4/14/2016

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)

root r
f(a)

4/14/2016

Bisection Method
Method will iteratively construct a sequence xn that
converges to the root r and will stop when it can be
guaranteed that |r-xn| < tol.
The difficulty though with the error expression, i.e.,
=
is that the roor of a function is rarely
known beforehand.
As the limiting criterion to the number of iterations, the
following may be used:
1.
<
2.
<
3.

<

4.

<

1.
2.
3.
4.
5.
6.

## Choose an interval [a,b]

If f(a) and f(b) have opposite signs: start
Iterate: = +
/2
If
<
: stop
Set a=x1 if f(x1) has same sign as f(a), else set b=x1
Goto 3

4/14/2016

=

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

b. Use the bisection method to approximate this root with an absolute
error <5e-3
c. How many iterations would it take the bisection method to guarantee
an absolute error < 1e-6

Regula Falsi

4/14/2016

## Algorithm for Regula Falsi Method:

1. Choose an interval [xa, xb]
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 (
6. Goto 3

) , else set

4/14/2016

Secant Method

4/14/2016

## Algorithm for Secant Method:

1. Choose an interval [xn-1, xb]
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

4/14/2016

Newtons Method

10

4/14/2016

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

x= r which we wish to accurately approximate.

11