Numerical Calculation Part 1: Equations &Roots (Bisection's Method) Dr.Entesar Ganash Bisection's Method A general idea: This is another numerical method , which could be used to solve a general equation f(x)=0. The method depends on the intermediate value theorem for continuous functions. If a function f(x) is continuous on the interval [a, b] and sign of f(a) ≠ sign of f(b), then: there is a value c ∈ [a..b] such that: f(c) = 0 i.e., there is a root c in the interval [a, b] f(x) In [a,b] x From: http://www.mathcs.emory.edu/~cheung/Courses/170/Syllabus/07/bisection.html •It is a successive approximation method that makes an interval, which has a root of the function f(x) narrow. • It will bisect the interval in two parts and test which one has a function root. • It will continue bisect the interval until the resulting interval becomes really small. Then the root is approximately equal to any value in the final interval. • The efficient thing of Bisection's method is number of bisections, which is needed for getting a good accuracy can be calculated before beginning as will be seen below. A Structure Plan: A structure plan to execute Bisection's method: 1. Estimate a required accuracy (Epsilon). 2. try to find two initial values of x ( and ) such that that means both functions have different signs. So, at least one root must lie some where between them. 3. Calculate maximum bisection N from inequality 4. Repeat N times (a) & (b) steps a) Find the mid point, call it It is given by b) Test whether . .then let 5. Print root N log( xL xR / Eps) log( 2) , which is the estimated root of the interval [ , also Find . if this condition is right otherwise let and then end a program . , ]. Example Write a program using Bisection’s method to solve this equation starting with two guesses repetitions. Solving PROGRAM BISECTION IMPLICIT NONE Integer::k,N ! a counter & a maximum bisection Real :: eps ,XL,XR !required accuracy (epsilon)& two initial guesses Real :: xm ! a mid point Eps=1E-6 xL=1.0 ; xR=2.0 N=log(ABS(XL-XR)/eps)/log(2.0)+1 !N must exceed formula value DO K=1,N XM=(XL+XR)/2.0 If(F(XL)*F(XM) <0.0)THEN XR=XM Else XL=XM END IF END DO Write(*,*)'Number of bisection:‘ N Write(*,*)'The root is approximately =',XM Contains !-------------------------!Function Subprogram f is to solve f(x)=0 !-------------------------REAL FUNCTION f(x) Implicit none Real::f,x f=x**3+x-3 End FUNCTION f !-------------------------END PROGRAM BISECTION continue Solving 1 The result: Exercise Write a program compute the position( x & y co-ordinate) and the velocity (magnitude &direction) of projectile, given t, the time since launch, u, the launch velocity, a, the initial angle of launch(in degrees) and g, the acceleration due gravity. The horizontal & vertical displacement are given by the formulae x ut cos a, y ut sin a gt 2 / 2 The velocity has magnitude V such that V Vx2 Vy2 Where its horizontal & vertical components Vx u cos a, V y u sin a gt And V makes an angle with the ground such that tan Vy Vx References •Hahn, B.D., 1994, Fortran 90 For Scientists and Engineers, Elsevier. •http://www.mathcs.emory.edu/~cheung/Courses/170/Syllabus/07/bisection.html •http://mat.iitm.ac.in/home/sryedida/public_html/caimna/transcendental/bracketing %20methods/bisection/bisection.html •Univ.,
© Copyright 2026 Paperzz