Chapter 5
Chapter 5
CHE 384
“Applied Numerical Methods with MATLAB for Engineers and Scientist, Fourth Edition, Chapra”
Chapter 5
RT aa
P= -
V - b V ( V + b)
( )
Z 3 - Z 2 + A - B - B 2 Z - AB =0
PV aa P bP
Z= ; A= 2 2 ;B =
RT RT RT
Roots:
One way to find the roots of a function is to plot the function and use the roots command:
Roots(fv)
Solution Methods:
Analytical
Graphical Method
Numerical methods
MATLAB: roots fzero, solve, fsovle
Excel Solve
Polymath (Bad MATLAB)
Graphical Methods:
Graph the equation to find the roots of the equation where f(x) = 0
Example 5.1:
Screenshot from ppt
Bracketing Methods:
How to find roots without graphing:
Use an upper bound and lower bound to find if there’s a root in between,
Where f(x1)f(xu) <0, there’s a root
Incremental search – test values between intervals to see possible sign changes. This
typw of search can cause roots to be missed and requires a very long code
Example 5.4:
Above two figures are screenshots from ppt
Example 5.1:
From the graph from earlier, the root was estimated between 140 and 150 kg.
In matlab:
To use this method, the same bisect code and excel file can be used. The only section that must
be changed is the iteration equation.
The false position method works slower and can be considered bad with certain equations such
as f(x) = x10-1.
The best method to use is Newton’s Method which will be learned later.
Case Study:
To find out how many iterations (steps) you need to have, input this into the command
window.
Use Ead to use an absolute error of +/- 0.005.
Create a function file using the model given in problem:
The answer can be deemed accurate because it is close in value to the answer with 315
iterations instead of 11:
pH for the year 2008 can be solved in MATLAB as below:
Example 5.12:
Obtain the solution by making a plot to decide with method would be used best.
cc,0 + x
k= 2
( )(
ca,0 - 2x cb,0 - x )
Plugging in values given gives:
4+ x
k= 2
( )(
42 - 2x 28 - x )
The plot given from the question is below:
For Bisection:
Input the equation from earlier into f(xl)
4+ x
k= 2
( )(
42 - 2x 28 - x )
xr =xu -
( )( )
f xu xl - xu
( ) ( )
f xl - f xu
The bisect way will always work, false position will work when the slope is unusually large: