0% found this document useful (0 votes)
93 views13 pages

Chapter 5

This document discusses numerical methods for solving equations, including the Soave-Redlich-Kwong equation of state and various root-finding algorithms in MATLAB. It introduces the bisection method, false position method, and Newton's method for finding roots of functions graphically or numerically. Examples are provided to illustrate implementing the bisection and false position methods in MATLAB and Excel to solve equations.

Uploaded by

Ashley Straub
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
93 views13 pages

Chapter 5

This document discusses numerical methods for solving equations, including the Soave-Redlich-Kwong equation of state and various root-finding algorithms in MATLAB. It introduces the bisection method, false position method, and Newton's method for finding roots of functions graphically or numerically. Examples are provided to illustrate implementing the bisection and false position methods in MATLAB and Excel to solve equations.

Uploaded by

Ashley Straub
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 13

Numerical Methods

CHE 384
“Applied Numerical Methods with MATLAB for Engineers and Scientist, Fourth Edition, Chapra”
Chapter 5

Soave-Redlich-Kwong Equation (P-V-T)

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)

Two examples of functions and fv:


x7 - x + 3
f ( x ) =a4 x 4 + a3 x 3...+ a1x1 + a0
f v [1 0 0 0 0 0 -1]
f v =[a4 a3 0 a1 a0 ] 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

Incremental code search:


Screenshot from ppt

 Download the file from MATLAB folder from Canvas



Example 5.2:

Identify brackets within the interval [3,6] for the function:


F(x) = sin(10x) + cos(3x)

Download the incsearch.m file from CANVAS


The Bisection Method

Write down the equation (iteration equation)


 Xr is the midway point (the bisection)
Use this Iteration equation when you write the code:
 Do this by hand (by excel)
x +x
xr = l u
2
For f(xl)f(xr) > 0
xr -> xl
Screenshot from ppt below

Notice the xr line in the matlab code above:

Example 5.4:
Above two figures are screenshots from ppt

Using this in excel:


 Download the excel file from Canvas
 All the data points are input from the table in the example

Example 5.1:

From the graph from earlier, the root was estimated between 140 and 150 kg.
In matlab:

Save the bisect code from canvas:

False Position Method:

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 iteration equation for false position is:


f ( xu ) ( xl - xu )
xr =
f ( xl ) - f ( xu )

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:

Using the bisect function from earlier

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:

You can get the plot by doing the following in MATLAB:

Solving the problem in Excel:


xl and xr and upper and lower bounds xl(left) and xr(right) and xu is the height

For Bisection:
Input the equation from earlier into f(xl)
4+ x
k= 2
( )(
42 - 2x 28 - x )

For false position:


Input this function into f(xl)

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:

You might also like