FORTRAN 90 Lecturer : Rafel Hekmat Hameed University of Babylon Subject : Fortran 90 College of Engineering Year : Second B.Sc. Mechanical Engineering Dep. S SO OL LU UTTIIO ON N O OF F N NO ON N-L LIIN NE EA AR R E EQ QU UA ATTIIO ON N False Position Method This method attempts to solve an equation of the form f(x)=0. (This is very common in most numerical analysis applications.) Any equation can be written in this form. The algorithm requires a function f(x) and two points a and b for which f(x) is positive for one of the values and negative for the other. We can write this condition as f(a)f(b)<0. If the function f(x) is continuous on the interval [a,b] with f(a)f(b)<0, the algorithm will eventually converge to a solution. The idea for the False position method is to connect the points (a,f(a)) and (b,f(b)) with a straight line. Since linear equations are the simplest equations to solve for find the regulafalsi point (xrfp) which is the solution to the linear equation connecting the endpoints. Look at the sign of f(xrfp): If sign (f(xrfp)) = 0 then end algorithm else If sign(f(xrfp)) = sign(f(a)) then set a = xrfp else set b = xrfp ϭ Regula Falsi (Method of False Position) is a modification of the Bisection Method.. Instead of halving the interval on which there exists a root#_>ADF;;==@ r of f , we use the root of the line joining the points(a1,f(a1)) and (b1,f(b1)) as out approximation to . By similar triangles we have that, and so, If f(c1)=0,, then we have found a solution and may stop looking. If f(a1) and f(c1) have opposite signs, then a root must lie on [a1,c1], and so we may shorten our interval by b1-c1. We set b1=c1 and leave a as is. The points a1 is stationary. If f(a1) and f(c1) have the same sign, then a root must lie on [c1,b1], and so we may shorten our interval by c1-a1, and assign a1=c1. Ϯ program false_position implicit none real::a,b,c,x,f,error=1e-5 f(x)= x**3 - 2 10 read(*,*)a,b If (f (a) * f (b).gt.0) goto 10 20 c=b-(f(b)*(b-a))/(f(b)-f(a)) If (f(c)==0)t hen print*,"the root =",c elseif (f(c)*f(a)<0) then b=c else a=c ; endif if (abs(b-a).lt.error) then print*,"the root=",c else ; goto 20 endif end ϯ