SlideShare una empresa de Scribd logo
1 de 6
Descargar para leer sin conexión
1
Lab notes
In this lab, you will be developing 3 VB codes. You are pretty much on your own to build
these codes. The codes are:
1) Bisection method (detailed notes and algorithm are given below, please read this
before you come to the lab lecture).
2) Direct substitution method (you should have covered this in the class)
3) Newton Raphson method (covered this in the lab). Make sure you use two
subprograms—one for the function and one for its derivative when coding this. Here
is the template to use
Input xold guess, iter (no of iterations), and tol (tolerance level)
For i = 1 to iter
Call myfx(x, fx)
Call mydfx(x,dfx)
xnew = xold – (fx/dfx)
err = abs((xnew-xold)/xold)*100
output xnew, fx, dfx, and error
If (err < tol) Then
Exit for
End if
Next i
**Write your myfx sub here **
**Write your mydfx sub here**
Root finding using the Bisection Method
One of the basic numerical approaches to find the root of a nonlinear equation ( )f x is the
bisection method. The method can be derived from a graphical point of view. Consider a
function ( )f x shown in Figure 1. By definition, the root of the equation ( )f x is nothing but
the value of x when the function ( )f x becomes zero.
As shown in the figure, to employ bisection method the user should provide two initial guess
values XL and XU that bound the root of the function. Note, the root need not be at the
midpoint, but it has to be in-between these two guess values. The method uses these two
guess values to iteratively search for the root in a systematic manner.
03.03.2
2
Figure 1 The root should be bound by the two initial guess values
Before we learn the search algorithm, we will consider the following question: how can one
verify whether a root is present in-between the two arbitrary guess values XL and XU. Figure
2 shows a case where the user has provided two valid guess values. Under this condition, as
shown in the figure, the value of function corresponding to XL, which is f (XL) will be
negative, and the value of function corresponding to XU, which is f (XU), will be positive,
hence the value of the product f (XL) *f (XU) will be negative, therefore ( ) ( ) 0L Uf X f X < .
On the other hand, Figure 3 shows two instances where the user had provided invalid guesses
for XL and XU values, which are not bounding a root. Under this condition, as shown in the
figures, the value of the two functions f(XL) and f(XU), corresponding to XL and XU,
respectively, will be of the same sign (either negative or positive); therefore, the value of the
product f (XL) *f (XU) will always be positive, hence ( ) ( ) 0L Uf X f X > .
Therefore, it can be concluded that the equation 0)( =xf , where )(xf is a real continuous
function, has a root between XL and XU if the product ( ) ( ) 0L Uf X f X < . On the other hand, if
( ) ( ) 0L Uf X f X > then there may not be a root between the two guess values. The validity of
above arguments is the central basis of the bisection method. Note, these arguments also
assume that the function is monotonic and has only one root between XL and XU.
.
f (x)
XL
XU
x
3
f (x)
XL
XU
x
f (xU) is +ve
f (xL) is -ve
Figure 2 If ( ) ( ) 0L Uf X f X < (or negative) then there is a root in between to guess values
the product
f (x)
XL XU
x
f (xU) is -ve
f (xL) is -ve
f (x)
XL XU
x
f (xU) is -ve
f (xL) is -ve
f (x)
XL XU
x
f (xU) is +ve
f (xL) is +ve
f (x)
XL XU
x
f (xU) is +ve
f (xL) is +ve
Figure 3 If ( ) ( ) 0L Uf X f X > (or positive) then there will not be a root in between to guess
values
Logic for Checking the Validity of the Initial Guesses for the Bisection Method
The concepts illustrated in Figures 2 and 3 can be summarized in a computer algorithm to
first identify whether the guess values are bracketing the roots or not. The algorithm can be
written as:
03.03.4
4
1. Read the values of XL and XU from the spreadsheet
2. Compute f(XL) and f(XU) and evaluate the value of their product P = f (XL) *f (XU)
3. If P < 0 then it is a valid guess and the root lies between XL and XU, else stop the
program and prompt the user “invalid guesses, provide another values.”
The Details of the Bisection Procedure
Now that we have verified (using the above algorithm) that a root is present somewhere in
the region between the guess points XL and XU, we will first find a mid-point, XM = (XL +
XU)/2. We will use this midpoint to divide the region into two new intervals: 1) (XL and XM)
and 2) (XM and XU). Now we need to figure out whether the root is between XL and XM or
XM and XU? We know for sure that one of these intervals is a valid interval that can be used
as guess values of the next iteration and the other one should be abandoned. Well, we will
once again employ the logic discussed in steps 2 & 3. We will first find the sign
of ( )* ( )L Mf X f X and if it is negative [or if ( ) ( ) 0L Uf X f X < ] then the root should be in
between XL and XM, otherwise, it has to be between XM and XU. Therefore, with a single test
we can narrow the original range by half. By repeating this process, the width of the interval
can be made smaller and smaller and we can eventually find the root. Figure 4 shows
conceptual diagram of the progression of this search algorithm. As show in the figure,
initially (before iteration-1) we start with XL and XU, which envelops a wide range. With
every iteration, the range will become smaller and smaller and eventually you will land on
the exact root. Note, as the solution converge the difference between the values of XL and
XU will be small and also the value of the function f(x) will be close to zero. You can use
one of them as a criterion to check for convergence.
f (x)
XL
XU
x
XM
XU
(next iteration)
f (x)
XL
XU
x
XM
Iteration-1;here, XM become Xu for
the next iteration
Iteration-2;here XM become XL for
the next iteration
XL
(next iteration)
Figure 4 Progression of bisection algorithm.
Detailed Computer Algorithm
The complete computer algorithm for the bisection method can be summarized as follows:
5
1. Read the values of XL and XU from the spreadsheet
2. Compute f(XL) and f(XU) and evaluate the product Ptest = f (XL) *f (XU). Note we can
use a subprogram to efficiently compute the function values.
3. If Ptest < 0 then we have valid guess values and the root lies between the original
guess values XL and XU, else stop the program and ask them to provide another guess
vales.
4. Iterate n time (where n is the number of iterations given by the user)
5. Estimate XM = (XL + XU)/2
6. Evaluate P = f (XL) *f (XM)
IF (P < 0), Then (note the root must be between XL and XM)
Set XU = XM
ELSE
Set XL = XM
END IF
7. IF ABS[f(XM)] < 0.001 (some small value) you have found the root so exit iteration
8. Iterate and go to step 4
9. Output the latest value of XM as your best estimate of the root
PROBLEMS
1) Find the root of the following non-linear equation and evaluate the value of x using the
Bisection method
[ ]
667
( ) 40 1 exp( 0.15 )f x x
x
=− + − −
Perform five iterations by hand and assume initial guess value of for XL = 12 and XU = 16.
Report the updated new values of XL and XU at the end of each of the iteration.
2) Plot the results of your hand calculations XL, XU and XM values for each iteration and
develop figures similar to Figures 4 and explain the working of the convergence process for
this test problem.
2) Develop VB program for solving the above problem using the Bisection method.
Systematically output the XL and XU values at the end of each of the iteration and verify the
values against the hand calculated results.
Initial guess of 12 and 16
Iter # XL f(XL) XU f(XU) XM f(XM) P
1 12 -2.0943 16 -2.0943 14 1.808683 11.56738
2 14 -2.0943 16 -2.0943 15 -0.22009 -0.39806
3 14 -0.22009 15 -0.22009 14.5 0.774025 1.399966
4 14.5 -0.22009 15 -0.22009 14.75 0.272025 0.210554
5 14.75 -0.22009 15 -0.22009 14.875 0.024748 0.006732
6 14.875 -0.22009 15 -0.22009 14.9375 -0.09797 -0.00242
7 14.875 -0.09797 14.9375 -0.09797 14.90625 -0.03669 -0.00091
8 14.875 -0.03669 14.90625 -0.03669 14.89063 -0.00599 -0.00015
03.03.6
6
9 14.875 -0.00599 14.89063 -0.00599 14.88281 0.009375 0.000232
10 14.88281 -0.00599 14.89063 -0.00599 14.88672 0.001692 1.59E-05
11 14.88672 -0.00599 14.89063 -0.00599 14.88867 -0.00215 -3.6E-06
12 14.88672 -0.00215 14.88867 -0.00215 14.8877 -0.00023

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

Applied numerical methods lec5
Applied numerical methods lec5Applied numerical methods lec5
Applied numerical methods lec5
 
Solution of non-linear equations
Solution of non-linear equationsSolution of non-linear equations
Solution of non-linear equations
 
Applied numerical methods lec9
Applied numerical methods lec9Applied numerical methods lec9
Applied numerical methods lec9
 
Es272 ch4b
Es272 ch4bEs272 ch4b
Es272 ch4b
 
Secent method
Secent methodSecent method
Secent method
 
Lagrange’s interpolation formula
Lagrange’s interpolation formulaLagrange’s interpolation formula
Lagrange’s interpolation formula
 
Es272 ch3b
Es272 ch3bEs272 ch3b
Es272 ch3b
 
Engr 371 final exam april 1996
Engr 371 final exam april 1996Engr 371 final exam april 1996
Engr 371 final exam april 1996
 
Jan. 8 Synthetic Division
Jan. 8 Synthetic DivisionJan. 8 Synthetic Division
Jan. 8 Synthetic Division
 
3.2.interpolation lagrange
3.2.interpolation lagrange3.2.interpolation lagrange
3.2.interpolation lagrange
 
Algebra 2 Section 4-5
Algebra 2 Section 4-5Algebra 2 Section 4-5
Algebra 2 Section 4-5
 
Interp lagrange
Interp lagrangeInterp lagrange
Interp lagrange
 
Secant Iterative method
Secant Iterative methodSecant Iterative method
Secant Iterative method
 
5 numerical analysis
5 numerical analysis5 numerical analysis
5 numerical analysis
 
Numerical Analysis (Solution of Non-Linear Equations)
Numerical Analysis (Solution of Non-Linear Equations)Numerical Analysis (Solution of Non-Linear Equations)
Numerical Analysis (Solution of Non-Linear Equations)
 
Numerical method (curve fitting)
Numerical method (curve fitting)Numerical method (curve fitting)
Numerical method (curve fitting)
 
Es272 ch4a
Es272 ch4aEs272 ch4a
Es272 ch4a
 
Secant method
Secant methodSecant method
Secant method
 
Es272 ch2
Es272 ch2Es272 ch2
Es272 ch2
 
Numerical method
Numerical methodNumerical method
Numerical method
 

Similar a Nl eqn lab

Non linearequationsmatlab
Non linearequationsmatlabNon linearequationsmatlab
Non linearequationsmatlabsheetslibrary
 
Non linearequationsmatlab
Non linearequationsmatlabNon linearequationsmatlab
Non linearequationsmatlabZunAib Ali
 
Roots of equations
Roots of equationsRoots of equations
Roots of equationsMileacre
 
Equations root
Equations rootEquations root
Equations rootMileacre
 
Numarical values
Numarical valuesNumarical values
Numarical valuesAmanSaeed11
 
Numarical values highlighted
Numarical values highlightedNumarical values highlighted
Numarical values highlightedAmanSaeed11
 
Mit18 330 s12_chapter4
Mit18 330 s12_chapter4Mit18 330 s12_chapter4
Mit18 330 s12_chapter4CAALAAA
 
Presentation on application of numerical method in our life
Presentation on application of numerical method in our lifePresentation on application of numerical method in our life
Presentation on application of numerical method in our lifeManish Kumar Singh
 
A derivative free high ordered hybrid equation solver
A derivative free high ordered hybrid equation solverA derivative free high ordered hybrid equation solver
A derivative free high ordered hybrid equation solverZac Darcy
 
Synchronizing Chaotic Systems - Karl Dutson
Synchronizing Chaotic Systems - Karl DutsonSynchronizing Chaotic Systems - Karl Dutson
Synchronizing Chaotic Systems - Karl DutsonKarl Dutson
 
A Derivative Free High Ordered Hybrid Equation Solver
A Derivative Free High Ordered Hybrid Equation Solver  A Derivative Free High Ordered Hybrid Equation Solver
A Derivative Free High Ordered Hybrid Equation Solver Zac Darcy
 
A DERIVATIVE FREE HIGH ORDERED HYBRID EQUATION SOLVER
A DERIVATIVE FREE HIGH ORDERED HYBRID EQUATION SOLVERA DERIVATIVE FREE HIGH ORDERED HYBRID EQUATION SOLVER
A DERIVATIVE FREE HIGH ORDERED HYBRID EQUATION SOLVERZac Darcy
 
Modelos de Redes Neuronales
Modelos de Redes NeuronalesModelos de Redes Neuronales
Modelos de Redes NeuronalesCarlosNigerDiaz
 
Newton raphson halley_householder_simpleexplanation
Newton raphson halley_householder_simpleexplanationNewton raphson halley_householder_simpleexplanation
Newton raphson halley_householder_simpleexplanationmuyuubyou
 
On Application of Power Series Solution of Bessel Problems to the Problems of...
On Application of Power Series Solution of Bessel Problems to the Problems of...On Application of Power Series Solution of Bessel Problems to the Problems of...
On Application of Power Series Solution of Bessel Problems to the Problems of...BRNSS Publication Hub
 
Exercise roots of equations
Exercise roots of equationsExercise roots of equations
Exercise roots of equationsDUBAN CASTRO
 

Similar a Nl eqn lab (20)

Non linearequationsmatlab
Non linearequationsmatlabNon linearequationsmatlab
Non linearequationsmatlab
 
Non linearequationsmatlab
Non linearequationsmatlabNon linearequationsmatlab
Non linearequationsmatlab
 
Roots of equations
Roots of equationsRoots of equations
Roots of equations
 
Equations root
Equations rootEquations root
Equations root
 
Numarical values
Numarical valuesNumarical values
Numarical values
 
Numarical values highlighted
Numarical values highlightedNumarical values highlighted
Numarical values highlighted
 
false-point.pdf
false-point.pdffalse-point.pdf
false-point.pdf
 
Mit18 330 s12_chapter4
Mit18 330 s12_chapter4Mit18 330 s12_chapter4
Mit18 330 s12_chapter4
 
Introduction to R
Introduction to RIntroduction to R
Introduction to R
 
Presentation on application of numerical method in our life
Presentation on application of numerical method in our lifePresentation on application of numerical method in our life
Presentation on application of numerical method in our life
 
A derivative free high ordered hybrid equation solver
A derivative free high ordered hybrid equation solverA derivative free high ordered hybrid equation solver
A derivative free high ordered hybrid equation solver
 
Synchronizing Chaotic Systems - Karl Dutson
Synchronizing Chaotic Systems - Karl DutsonSynchronizing Chaotic Systems - Karl Dutson
Synchronizing Chaotic Systems - Karl Dutson
 
Statistics lab 1
Statistics lab 1Statistics lab 1
Statistics lab 1
 
1249320870000 asgn 1-jm (1)
1249320870000 asgn 1-jm (1)1249320870000 asgn 1-jm (1)
1249320870000 asgn 1-jm (1)
 
A Derivative Free High Ordered Hybrid Equation Solver
A Derivative Free High Ordered Hybrid Equation Solver  A Derivative Free High Ordered Hybrid Equation Solver
A Derivative Free High Ordered Hybrid Equation Solver
 
A DERIVATIVE FREE HIGH ORDERED HYBRID EQUATION SOLVER
A DERIVATIVE FREE HIGH ORDERED HYBRID EQUATION SOLVERA DERIVATIVE FREE HIGH ORDERED HYBRID EQUATION SOLVER
A DERIVATIVE FREE HIGH ORDERED HYBRID EQUATION SOLVER
 
Modelos de Redes Neuronales
Modelos de Redes NeuronalesModelos de Redes Neuronales
Modelos de Redes Neuronales
 
Newton raphson halley_householder_simpleexplanation
Newton raphson halley_householder_simpleexplanationNewton raphson halley_householder_simpleexplanation
Newton raphson halley_householder_simpleexplanation
 
On Application of Power Series Solution of Bessel Problems to the Problems of...
On Application of Power Series Solution of Bessel Problems to the Problems of...On Application of Power Series Solution of Bessel Problems to the Problems of...
On Application of Power Series Solution of Bessel Problems to the Problems of...
 
Exercise roots of equations
Exercise roots of equationsExercise roots of equations
Exercise roots of equations
 

Más de Alvin Setiawan

Penyelesaian pers-biseksi13
Penyelesaian pers-biseksi13Penyelesaian pers-biseksi13
Penyelesaian pers-biseksi13Alvin Setiawan
 
Penyelesaian persamaan-non-linear
Penyelesaian persamaan-non-linearPenyelesaian persamaan-non-linear
Penyelesaian persamaan-non-linearAlvin Setiawan
 
Pengembangan sistem 1 2
Pengembangan sistem 1 2Pengembangan sistem 1 2
Pengembangan sistem 1 2Alvin Setiawan
 
Modul pelatihan ly_x_untuk_jurnal-feb-2cols
Modul pelatihan ly_x_untuk_jurnal-feb-2colsModul pelatihan ly_x_untuk_jurnal-feb-2cols
Modul pelatihan ly_x_untuk_jurnal-feb-2colsAlvin Setiawan
 
Metode numerik-rinaldi-munir-libre
Metode numerik-rinaldi-munir-libreMetode numerik-rinaldi-munir-libre
Metode numerik-rinaldi-munir-libreAlvin Setiawan
 
Metode numerik-buku-ajar-unila
Metode numerik-buku-ajar-unilaMetode numerik-buku-ajar-unila
Metode numerik-buku-ajar-unilaAlvin Setiawan
 
Met num3 persnonl-inier_baru
Met num3 persnonl-inier_baruMet num3 persnonl-inier_baru
Met num3 persnonl-inier_baruAlvin Setiawan
 
Met num02 persamaan non linier
Met num02 persamaan non linierMet num02 persamaan non linier
Met num02 persamaan non linierAlvin Setiawan
 
Membuat dokumen dengan latex ver.0.3
Membuat dokumen dengan latex   ver.0.3Membuat dokumen dengan latex   ver.0.3
Membuat dokumen dengan latex ver.0.3Alvin Setiawan
 
Membangun website e-commerce_berbasis_php_dan_my_sql
Membangun website e-commerce_berbasis_php_dan_my_sqlMembangun website e-commerce_berbasis_php_dan_my_sql
Membangun website e-commerce_berbasis_php_dan_my_sqlAlvin Setiawan
 
M8 perancangan terinci
M8 perancangan terinciM8 perancangan terinci
M8 perancangan terinciAlvin Setiawan
 
Lyx tutorial-for-dummies
Lyx tutorial-for-dummiesLyx tutorial-for-dummies
Lyx tutorial-for-dummiesAlvin Setiawan
 

Más de Alvin Setiawan (20)

Penyelesaian pers-biseksi13
Penyelesaian pers-biseksi13Penyelesaian pers-biseksi13
Penyelesaian pers-biseksi13
 
Penyelesaian persamaan-non-linear
Penyelesaian persamaan-non-linearPenyelesaian persamaan-non-linear
Penyelesaian persamaan-non-linear
 
Pengembangan sistem 1 2
Pengembangan sistem 1 2Pengembangan sistem 1 2
Pengembangan sistem 1 2
 
Pedoman ta2008
Pedoman ta2008Pedoman ta2008
Pedoman ta2008
 
Pbw week 01 basics
Pbw week 01   basicsPbw week 01   basics
Pbw week 01 basics
 
Paper
PaperPaper
Paper
 
Modul6
Modul6Modul6
Modul6
 
Modul pelatihan ly_x_untuk_jurnal-feb-2cols
Modul pelatihan ly_x_untuk_jurnal-feb-2colsModul pelatihan ly_x_untuk_jurnal-feb-2cols
Modul pelatihan ly_x_untuk_jurnal-feb-2cols
 
Ml2 f304213
Ml2 f304213Ml2 f304213
Ml2 f304213
 
Micro sim template_2
Micro sim template_2Micro sim template_2
Micro sim template_2
 
Metode numerik-rinaldi-munir-libre
Metode numerik-rinaldi-munir-libreMetode numerik-rinaldi-munir-libre
Metode numerik-rinaldi-munir-libre
 
Metode numerik-buku-ajar-unila
Metode numerik-buku-ajar-unilaMetode numerik-buku-ajar-unila
Metode numerik-buku-ajar-unila
 
Metode regula falsi
Metode regula falsiMetode regula falsi
Metode regula falsi
 
Metode biseksi
Metode biseksiMetode biseksi
Metode biseksi
 
Met num3 persnonl-inier_baru
Met num3 persnonl-inier_baruMet num3 persnonl-inier_baru
Met num3 persnonl-inier_baru
 
Met num02 persamaan non linier
Met num02 persamaan non linierMet num02 persamaan non linier
Met num02 persamaan non linier
 
Membuat dokumen dengan latex ver.0.3
Membuat dokumen dengan latex   ver.0.3Membuat dokumen dengan latex   ver.0.3
Membuat dokumen dengan latex ver.0.3
 
Membangun website e-commerce_berbasis_php_dan_my_sql
Membangun website e-commerce_berbasis_php_dan_my_sqlMembangun website e-commerce_berbasis_php_dan_my_sql
Membangun website e-commerce_berbasis_php_dan_my_sql
 
M8 perancangan terinci
M8 perancangan terinciM8 perancangan terinci
M8 perancangan terinci
 
Lyx tutorial-for-dummies
Lyx tutorial-for-dummiesLyx tutorial-for-dummies
Lyx tutorial-for-dummies
 

Nl eqn lab

  • 1. 1 Lab notes In this lab, you will be developing 3 VB codes. You are pretty much on your own to build these codes. The codes are: 1) Bisection method (detailed notes and algorithm are given below, please read this before you come to the lab lecture). 2) Direct substitution method (you should have covered this in the class) 3) Newton Raphson method (covered this in the lab). Make sure you use two subprograms—one for the function and one for its derivative when coding this. Here is the template to use Input xold guess, iter (no of iterations), and tol (tolerance level) For i = 1 to iter Call myfx(x, fx) Call mydfx(x,dfx) xnew = xold – (fx/dfx) err = abs((xnew-xold)/xold)*100 output xnew, fx, dfx, and error If (err < tol) Then Exit for End if Next i **Write your myfx sub here ** **Write your mydfx sub here** Root finding using the Bisection Method One of the basic numerical approaches to find the root of a nonlinear equation ( )f x is the bisection method. The method can be derived from a graphical point of view. Consider a function ( )f x shown in Figure 1. By definition, the root of the equation ( )f x is nothing but the value of x when the function ( )f x becomes zero. As shown in the figure, to employ bisection method the user should provide two initial guess values XL and XU that bound the root of the function. Note, the root need not be at the midpoint, but it has to be in-between these two guess values. The method uses these two guess values to iteratively search for the root in a systematic manner.
  • 2. 03.03.2 2 Figure 1 The root should be bound by the two initial guess values Before we learn the search algorithm, we will consider the following question: how can one verify whether a root is present in-between the two arbitrary guess values XL and XU. Figure 2 shows a case where the user has provided two valid guess values. Under this condition, as shown in the figure, the value of function corresponding to XL, which is f (XL) will be negative, and the value of function corresponding to XU, which is f (XU), will be positive, hence the value of the product f (XL) *f (XU) will be negative, therefore ( ) ( ) 0L Uf X f X < . On the other hand, Figure 3 shows two instances where the user had provided invalid guesses for XL and XU values, which are not bounding a root. Under this condition, as shown in the figures, the value of the two functions f(XL) and f(XU), corresponding to XL and XU, respectively, will be of the same sign (either negative or positive); therefore, the value of the product f (XL) *f (XU) will always be positive, hence ( ) ( ) 0L Uf X f X > . Therefore, it can be concluded that the equation 0)( =xf , where )(xf is a real continuous function, has a root between XL and XU if the product ( ) ( ) 0L Uf X f X < . On the other hand, if ( ) ( ) 0L Uf X f X > then there may not be a root between the two guess values. The validity of above arguments is the central basis of the bisection method. Note, these arguments also assume that the function is monotonic and has only one root between XL and XU. . f (x) XL XU x
  • 3. 3 f (x) XL XU x f (xU) is +ve f (xL) is -ve Figure 2 If ( ) ( ) 0L Uf X f X < (or negative) then there is a root in between to guess values the product f (x) XL XU x f (xU) is -ve f (xL) is -ve f (x) XL XU x f (xU) is -ve f (xL) is -ve f (x) XL XU x f (xU) is +ve f (xL) is +ve f (x) XL XU x f (xU) is +ve f (xL) is +ve Figure 3 If ( ) ( ) 0L Uf X f X > (or positive) then there will not be a root in between to guess values Logic for Checking the Validity of the Initial Guesses for the Bisection Method The concepts illustrated in Figures 2 and 3 can be summarized in a computer algorithm to first identify whether the guess values are bracketing the roots or not. The algorithm can be written as:
  • 4. 03.03.4 4 1. Read the values of XL and XU from the spreadsheet 2. Compute f(XL) and f(XU) and evaluate the value of their product P = f (XL) *f (XU) 3. If P < 0 then it is a valid guess and the root lies between XL and XU, else stop the program and prompt the user “invalid guesses, provide another values.” The Details of the Bisection Procedure Now that we have verified (using the above algorithm) that a root is present somewhere in the region between the guess points XL and XU, we will first find a mid-point, XM = (XL + XU)/2. We will use this midpoint to divide the region into two new intervals: 1) (XL and XM) and 2) (XM and XU). Now we need to figure out whether the root is between XL and XM or XM and XU? We know for sure that one of these intervals is a valid interval that can be used as guess values of the next iteration and the other one should be abandoned. Well, we will once again employ the logic discussed in steps 2 & 3. We will first find the sign of ( )* ( )L Mf X f X and if it is negative [or if ( ) ( ) 0L Uf X f X < ] then the root should be in between XL and XM, otherwise, it has to be between XM and XU. Therefore, with a single test we can narrow the original range by half. By repeating this process, the width of the interval can be made smaller and smaller and we can eventually find the root. Figure 4 shows conceptual diagram of the progression of this search algorithm. As show in the figure, initially (before iteration-1) we start with XL and XU, which envelops a wide range. With every iteration, the range will become smaller and smaller and eventually you will land on the exact root. Note, as the solution converge the difference between the values of XL and XU will be small and also the value of the function f(x) will be close to zero. You can use one of them as a criterion to check for convergence. f (x) XL XU x XM XU (next iteration) f (x) XL XU x XM Iteration-1;here, XM become Xu for the next iteration Iteration-2;here XM become XL for the next iteration XL (next iteration) Figure 4 Progression of bisection algorithm. Detailed Computer Algorithm The complete computer algorithm for the bisection method can be summarized as follows:
  • 5. 5 1. Read the values of XL and XU from the spreadsheet 2. Compute f(XL) and f(XU) and evaluate the product Ptest = f (XL) *f (XU). Note we can use a subprogram to efficiently compute the function values. 3. If Ptest < 0 then we have valid guess values and the root lies between the original guess values XL and XU, else stop the program and ask them to provide another guess vales. 4. Iterate n time (where n is the number of iterations given by the user) 5. Estimate XM = (XL + XU)/2 6. Evaluate P = f (XL) *f (XM) IF (P < 0), Then (note the root must be between XL and XM) Set XU = XM ELSE Set XL = XM END IF 7. IF ABS[f(XM)] < 0.001 (some small value) you have found the root so exit iteration 8. Iterate and go to step 4 9. Output the latest value of XM as your best estimate of the root PROBLEMS 1) Find the root of the following non-linear equation and evaluate the value of x using the Bisection method [ ] 667 ( ) 40 1 exp( 0.15 )f x x x =− + − − Perform five iterations by hand and assume initial guess value of for XL = 12 and XU = 16. Report the updated new values of XL and XU at the end of each of the iteration. 2) Plot the results of your hand calculations XL, XU and XM values for each iteration and develop figures similar to Figures 4 and explain the working of the convergence process for this test problem. 2) Develop VB program for solving the above problem using the Bisection method. Systematically output the XL and XU values at the end of each of the iteration and verify the values against the hand calculated results. Initial guess of 12 and 16 Iter # XL f(XL) XU f(XU) XM f(XM) P 1 12 -2.0943 16 -2.0943 14 1.808683 11.56738 2 14 -2.0943 16 -2.0943 15 -0.22009 -0.39806 3 14 -0.22009 15 -0.22009 14.5 0.774025 1.399966 4 14.5 -0.22009 15 -0.22009 14.75 0.272025 0.210554 5 14.75 -0.22009 15 -0.22009 14.875 0.024748 0.006732 6 14.875 -0.22009 15 -0.22009 14.9375 -0.09797 -0.00242 7 14.875 -0.09797 14.9375 -0.09797 14.90625 -0.03669 -0.00091 8 14.875 -0.03669 14.90625 -0.03669 14.89063 -0.00599 -0.00015
  • 6. 03.03.6 6 9 14.875 -0.00599 14.89063 -0.00599 14.88281 0.009375 0.000232 10 14.88281 -0.00599 14.89063 -0.00599 14.88672 0.001692 1.59E-05 11 14.88672 -0.00599 14.89063 -0.00599 14.88867 -0.00215 -3.6E-06 12 14.88672 -0.00215 14.88867 -0.00215 14.8877 -0.00023