- #1
jhosamelly
- 128
- 0
Bisection method for the equation x3−2x−2 = 0 which has a single root
between x=−4 and x = 2.
here's the code I have
I know there's something wrong with my code. Can somebody help me please?
Here are the Bisection Method formulas
xm = (xl+xu)/2
between x=−4 and x = 2.
here's the code I have
Code:
program bisection2
implicit none
real :: fxa, xnew, xu, xl, fxb, fnew
xu=4
xl=2
1 xnew=(xu+xl)/2
fxa=(xnew**3-(2*xnew)-2)
fxb=(xl**3-(2*xl)-2)
fnew=fxa*fxb
if fxnew<0 then
xl=xl
xnew=xu
go to 1
if fxnew>0 then
xnew=xl
xu=xu
go to 1
print *, "fx(a) = ", fxa
print *, "fx(b) = ", fxb
end program bisection2
I know there's something wrong with my code. Can somebody help me please?
Here are the Bisection Method formulas
xm = (xl+xu)/2