Professional Documents
Culture Documents
ES 84 Project
ES 84 Project
ES 84 Project
College of Engineering
_________________________________________________________
Numerical Methods ES 84
CEN -A
_________________________________________________________
Second Semester
School Year 2015-2016
Mondays and Thursdays 9:00-11:30 am
_________________________________________________________
Laboratory 1
Bisection
_________________________________________________________
Jovan S. Bucol
2013-0091
Engr. Rebecca Ruth R. Salas
ES 84 Lecturer
INTRODUCTION
The bisection method, which is alternatively called binary
chopping, interval halving or Bolzanos Method, is one type of incremental
search method in which the interval is always divided in half. If a function
changes sign over an interval, the function value at the midpoint is
evaluated. The location of the root is then determined as lying at the
midpoint of the subinterval within which the sign change occurs. The process
is repeated to obtain refined estimates.
ENGINEERING PROBLEM POSED
10N
the figure below. Determine the positive unknown value x by which the
resultant of the two forces equals 10N.
3N
A
(x + 3)N
MATHEMATICAL MODELING
10N
3N
(x +
3)N
100 = 9 + x2 + 6x + 9
X2 + 6x 82 = 0
ANALYTICAL SOLUTION
Using quadratic formula, we can solve for x:
x=
b b24 ac
2a
x=
6 (6)24(1)(82)
2(1)
(eq. 2)
x=3+ 91
x=6.539392014
NUMERICAL SOLUTION
Using Bisection Method
Let f (x) = x2 + 6x 82
Assume an interval between x = 6 and x = 7
Iteration (1):
Xu = 7, Xl = 6, Xr =
6 +7
2
=6.5
Iteration (2):
Set Xl = Xr = 6.5, Xu = 7, Xr =
Iteration (3):
6.5+ 6
2
6.75
= 6.6250
100=3.70
|6. 756.5
6. 75 |
100=1. 89
|6. 62506.75
6.6250 |
6.75+6.5
2
Iteration (4):
Set Xu = Xr = 6.6250, Xl = 6.5, Xr =
6.6250+ 6.5
2
= 6.5625
|6. 56256.6250
|100=0.95
6.5625
Iteration (5):
Set Xu = Xr = 6.5625, Xl = 6.5, Xr =
6. 5625+6.5
2
= 6.5313
6.53136.5625
=
100=0. 48
6.5313
Iteration (6):
Set Xl = Xr = 6.5313, Xu = 6.5625, Xr =
6.5625+ 6.5313
2
= 6.5469
|6.54696.5313
|100=0. 24
6.5469
Therefore, X
SOURCE CODE
6.5469
package bisec;
import static java.lang.Math.abs;
import javax.swing.JOptionPane;
public class Bisec {
public static void main(String[] args) {
String Xup = JOptionPane.showInputDialog (null,"f(x)=x^2+6x-82\n\nEnter
The Upper Subinterval X:" , "Chapter 5:Bisection Method" ,
JOptionPane.PLAIN_MESSAGE);
String Xlow = JOptionPane.showInputDialog (null, "f(x)=x^2+6x-82\n\nEnter
The Lower Subinterval X:" , "Chapter 5:Bisection Method",
JOptionPane.PLAIN_MESSAGE);
double Xu = Double.parseDouble(Xup);
double Xl = Double.parseDouble(Xlow);
double Xr = getXr(Xu,Xl);
String X = String.format("Xu: %.4f %nXl: %.4f %nXr: %4f", Xu, Xl, Xr);
double result = f(Xl, Xr);
String f = null;
if (result>0){Xl=Xr; f = String.format("%nf(Xl)f(Xr) = %.5f>0", result);}
else if (result<0) {Xu=Xr; f = String.format("%nf(Xl)f(Xr) = %.5f<0", result);}
JOptionPane.showMessageDialog (null, X+f , "Iteration 1:",
JOptionPane.INFORMATION_MESSAGE);
double Ea=100;
for(int Iteration=2; Ea>0.3; Iteration++){
String iteration = String.format("Iteration" +Iteration+":");
double Xrnew = getXr(Xu,Xl);
X = String.format("Xu: %.4f %nXl: %.4f%nXr: %.4f", Xu, Xl, Xrnew);
Ea = error(Xrnew, Xr);
String Aerror = String.format("%nApproximation error: %.2f",Ea)+"%";
result = f(Xl, Xrnew);
if (result>0){Xl=Xrnew; f = String.format("%nf(Xl)f(Xr) = %.5f>0", result);}
else
if (result<0){Xu=Xrnew; f = String.format("%nf(Xl)f(Xr) = %.5f<0", result);}
Xr = Xrnew;
SCREENSHOTS
CONCLUSION
Before proceeding with the proper procedures using the Bisection
Method, we should first analyze the problem. After analyzing the problem, we
have to come up with our function. For this instance, this simple problem
involving vector forces can be solved directly using the Pythagorean
Theorem. The root from the analytical solution can be the basis for our
numerical solution. Although Bisection Method is a longer process compared
to other process, it still provides a neat error analysis which makes it suitable
for engineering applications. Therefore, Bisection Method is an effective way
of solving engineering problems.